Changeset View
Changeset View
Standalone View
Standalone View
src/controls/ActionToolBar.qml
Show All 11 Lines | |||||
12 | * GNU Library General Public License for more details | 12 | * GNU Library General Public License for more details | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.6 | 20 | import QtQuick 2.7 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtQuick.Controls 2.2 as Controls | 22 | import QtQuick.Controls 2.5 as Controls | ||
23 | import org.kde.kirigami 2.5 as Kirigami | 23 | import org.kde.kirigami 2.5 as Kirigami | ||
24 | import "private" | 24 | import "private" | ||
25 | 25 | | |||
26 | /** | 26 | /** | ||
27 | * This is a simple toolbar built out of a list of actions | 27 | * This is a simple toolbar built out of a list of actions | ||
28 | * each action is represented by a ToolButton, those that won't fit | 28 | * each action is represented by a ToolButton, those that won't fit | ||
29 | * the size will go in a menu under a button with the overflow ... icon | 29 | * the size will go in a menu under a button with the overflow ... icon | ||
30 | * | 30 | * | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 110 | Repeater { | |||
111 | model: root.actions | 111 | model: root.actions | ||
112 | delegate: PrivateActionToolButton { | 112 | delegate: PrivateActionToolButton { | ||
113 | id: actionDelegate | 113 | id: actionDelegate | ||
114 | flat: root.flat | 114 | flat: root.flat | ||
115 | opacity: x + width <= parent.width | 115 | opacity: x + width <= parent.width | ||
116 | enabled: opacity | 116 | enabled: opacity | ||
117 | 117 | | |||
118 | display: root.display | 118 | display: root.display | ||
119 | visible: modelData.visible | 119 | visible: !modelData.hasOwnProperty("visible") || modelData.visible | ||
120 | Layout.fillWidth: false | 120 | Layout.fillWidth: false | ||
121 | Layout.alignment: Qt.AlignVCenter | 121 | Layout.alignment: Qt.AlignVCenter | ||
122 | Layout.minimumWidth: implicitWidth | 122 | Layout.minimumWidth: implicitWidth | ||
123 | kirigamiAction: modelData | 123 | action: modelData | ||
124 | onOpacityChanged: updateOverflowSet() | 124 | onOpacityChanged: updateOverflowSet() | ||
125 | function updateOverflowSet() { | 125 | function updateOverflowSet() { | ||
126 | var index = actionsLayout.findIndex(actionsLayout.overflowSet, function(act) { | 126 | var index = actionsLayout.findIndex(actionsLayout.overflowSet, function(act) { | ||
127 | return act === modelData}); | 127 | return act === modelData}); | ||
128 | 128 | | |||
129 | if ((opacity > 0 || !modelData.visible) && index > -1) { | 129 | if ((opacity > 0 || (modelData.hasOwnProperty("visible") || !modelData.visible)) && index > -1) { | ||
130 | actionsLayout.overflowSet.splice(index, 1); | 130 | actionsLayout.overflowSet.splice(index, 1); | ||
131 | } else if (opacity === 0 && modelData.visible && index === -1) { | 131 | } else if (opacity === 0 && (!modelData.hasOwnProperty("visible") || modelData.visible) && index === -1) { | ||
132 | actionsLayout.overflowSet.push(modelData); | 132 | actionsLayout.overflowSet.push(modelData); | ||
133 | } | 133 | } | ||
134 | actionsLayout.overflowSetChanged(); | 134 | actionsLayout.overflowSetChanged(); | ||
135 | } | 135 | } | ||
136 | Connections { | 136 | Connections { | ||
137 | target: modelData | 137 | target: modelData | ||
138 | ignoreUnknownSignals: !modelData.hasOwnProperty("visible") | ||||
138 | onVisibleChanged: actionDelegate.updateOverflowSet(); | 139 | onVisibleChanged: actionDelegate.updateOverflowSet(); | ||
139 | } | 140 | } | ||
140 | Component.onCompleted: { | 141 | Component.onCompleted: { | ||
141 | actionDelegate.updateOverflowSet(); | 142 | actionDelegate.updateOverflowSet(); | ||
142 | } | 143 | } | ||
143 | } | 144 | } | ||
144 | } | 145 | } | ||
145 | } | 146 | } | ||
Show All 24 Lines | 169 | ActionsMenu { | |||
170 | y: root.position == Controls.ToolBar.Footer ? -height : moreButton.height | 171 | y: root.position == Controls.ToolBar.Footer ? -height : moreButton.height | ||
171 | x: -width + moreButton.width | 172 | x: -width + moreButton.width | ||
172 | actions: root.actions | 173 | actions: root.actions | ||
173 | submenuComponent: Component { | 174 | submenuComponent: Component { | ||
174 | ActionsMenu { | 175 | ActionsMenu { | ||
175 | Binding { | 176 | Binding { | ||
176 | target: parentItem | 177 | target: parentItem | ||
177 | property: "visible" | 178 | property: "visible" | ||
178 | value: actionsLayout.findIndex(actionsLayout.overflowSet, function(act) {return act === parentAction}) > -1 && (parentAction.visible === undefined || parentAction.visible) | 179 | value: actionsLayout.findIndex(actionsLayout.overflowSet, function(act) {return act === parentAction}) > -1 && (parentAction.hasOwnProperty("visible") ? parentAction.visible === undefined || parentAction.visible : !parentAction.hasOwnProperty("visible")) | ||
179 | } | 180 | } | ||
180 | } | 181 | } | ||
181 | } | 182 | } | ||
182 | itemDelegate: ActionMenuItem { | 183 | itemDelegate: ActionMenuItem { | ||
183 | visible: actionsLayout.findIndex(actionsLayout.overflowSet, function(act) {return act === ourAction}) > -1 && (ourAction.visible === undefined || ourAction.visible) | 184 | visible: actionsLayout.findIndex(actionsLayout.overflowSet, function(act) {return act === ourAction}) > -1 && ( ourAction.hasOwnProperty("visible") ? ourAction.visible === undefined || ourAction.visible : !ourAction.hasOwnProperty("visible")) | ||
apol: If `ourAction` doesn't have a visible property, won't `ourAction.visible` be undefined? | |||||
camiloh: I think it then gets marked as visible = true | |||||
camiloh: You were right, I have now fixed it. | |||||
184 | } | 185 | } | ||
185 | Instantiator { | 186 | Instantiator { | ||
186 | 187 | | |||
187 | model: root.hiddenActions | 188 | model: root.hiddenActions | ||
188 | delegate: QtObject { | 189 | delegate: QtObject { | ||
189 | readonly property QtObject action: modelData | 190 | readonly property QtObject action: modelData | ||
190 | property QtObject item: null | 191 | property QtObject item: null | ||
191 | 192 | | |||
Show All 29 Lines |
If ourAction doesn't have a visible property, won't ourAction.visible be undefined?