Changeset View
Changeset View
Standalone View
Standalone View
src/controls/private/ActionButton.qml
Show All 36 Lines | 28 | Item { | |||
---|---|---|---|---|---|
37 | } | 37 | } | ||
38 | //smallSpacing for the shadow | 38 | //smallSpacing for the shadow | ||
39 | implicitHeight: button.height + Units.smallSpacing | 39 | implicitHeight: button.height + Units.smallSpacing | ||
40 | clip: true | 40 | clip: true | ||
41 | 41 | | |||
42 | readonly property Page page: root.parent.page | 42 | readonly property Page page: root.parent.page | ||
43 | //either Action or QAction should work here | 43 | //either Action or QAction should work here | ||
44 | 44 | | |||
45 | function isActionAvailable(action) { return action && (action.visible === undefined || action.visible); } | 45 | function isActionAvailable(action) { return action && (action.hasOwnProperty("visible") ? action.visible === undefined || action.visible : !action.hasOwnProperty("visible")); } | ||
46 | 46 | | |||
47 | readonly property QtObject action: root.page && isActionAvailable(root.page.mainAction) ? root.page.mainAction : null | 47 | readonly property QtObject action: root.page && isActionAvailable(root.page.mainAction) ? root.page.mainAction : null | ||
48 | readonly property QtObject leftAction: root.page && isActionAvailable(root.page.leftAction) ? root.page.leftAction : null | 48 | readonly property QtObject leftAction: root.page && isActionAvailable(root.page.leftAction) ? root.page.leftAction : null | ||
49 | readonly property QtObject rightAction: root.page && isActionAvailable(root.page.rightAction) ? root.page.rightAction : null | 49 | readonly property QtObject rightAction: root.page && isActionAvailable(root.page.rightAction) ? root.page.rightAction : null | ||
50 | 50 | | |||
51 | readonly property bool hasApplicationWindow: typeof applicationWindow !== "undefined" && applicationWindow | 51 | readonly property bool hasApplicationWindow: typeof applicationWindow !== "undefined" && applicationWindow | ||
52 | readonly property bool hasGlobalDrawer: typeof globalDrawer !== "undefined" && globalDrawer | 52 | readonly property bool hasGlobalDrawer: typeof globalDrawer !== "undefined" && globalDrawer | ||
53 | readonly property bool hasContextDrawer: typeof contextDrawer !== "undefined" && contextDrawer | 53 | readonly property bool hasContextDrawer: typeof contextDrawer !== "undefined" && contextDrawer | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 175 | if (!actionUnderMouse) { | |||
176 | return; | 176 | return; | ||
177 | } | 177 | } | ||
178 | 178 | | |||
179 | //if an action has been assigned, trigger it | 179 | //if an action has been assigned, trigger it | ||
180 | if (actionUnderMouse && actionUnderMouse.trigger) { | 180 | if (actionUnderMouse && actionUnderMouse.trigger) { | ||
181 | actionUnderMouse.trigger(); | 181 | actionUnderMouse.trigger(); | ||
182 | } | 182 | } | ||
183 | 183 | | |||
184 | if (actionUnderMouse.children.length > 0) { | 184 | if (actionUnderMouse.hasOwnProperty("children") && actionUnderMouse.children.length > 0) { | ||
185 | var subMenuUnderMouse; | 185 | var subMenuUnderMouse; | ||
186 | switch (actionUnderMouse) { | 186 | switch (actionUnderMouse) { | ||
187 | case leftAction: | 187 | case leftAction: | ||
188 | subMenuUnderMouse = leftActionSubMenu; | 188 | subMenuUnderMouse = leftActionSubMenu; | ||
189 | break; | 189 | break; | ||
190 | case mainAction: | 190 | case mainAction: | ||
191 | subMenuUnderMouse = mainActionSubMenu; | 191 | subMenuUnderMouse = mainActionSubMenu; | ||
192 | break | 192 | break | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 241 | Rectangle { | |||
249 | readonly property bool pressed: root.action && root.action.enabled && ((root.action == mouseArea.actionUnderMouse && mouseArea.pressed) || root.action.checked) | 249 | readonly property bool pressed: root.action && root.action.enabled && ((root.action == mouseArea.actionUnderMouse && mouseArea.pressed) || root.action.checked) | ||
250 | property color baseColor: root.action && root.action.icon && root.action.icon.color && root.action.icon.color != undefined && root.action.icon.color.a > 0 ? root.action.icon.color : Theme.highlightColor | 250 | property color baseColor: root.action && root.action.icon && root.action.icon.color && root.action.icon.color != undefined && root.action.icon.color.a > 0 ? root.action.icon.color : Theme.highlightColor | ||
251 | color: pressed ? Qt.darker(baseColor, 1.3) : baseColor | 251 | color: pressed ? Qt.darker(baseColor, 1.3) : baseColor | ||
252 | 252 | | |||
253 | ActionsMenu { | 253 | ActionsMenu { | ||
254 | id: mainActionSubMenu | 254 | id: mainActionSubMenu | ||
255 | y: -height | 255 | y: -height | ||
256 | x: -width/2 + parent.width/2 | 256 | x: -width/2 + parent.width/2 | ||
257 | actions: root.action ? root.action.children : "" | 257 | actions: root.action && root.action.hasOwnProperty("children") ? root.action.children : "" | ||
258 | submenuComponent: Component { | 258 | submenuComponent: Component { | ||
259 | ActionsMenu {} | 259 | ActionsMenu {} | ||
260 | } | 260 | } | ||
261 | } | 261 | } | ||
262 | Icon { | 262 | Icon { | ||
263 | id: icon | 263 | id: icon | ||
264 | anchors.centerIn: parent | 264 | anchors.centerIn: parent | ||
265 | width: Units.iconSizes.smallMedium | 265 | width: Units.iconSizes.smallMedium | ||
266 | height: width | 266 | height: width | ||
267 | source: root.action && root.action.iconName ? root.action.iconName : "" | 267 | source: root.action && root.action.icon.name ? root.action.icon.name : "" | ||
268 | selected: true | 268 | selected: true | ||
269 | color: root.action && root.action.color && root.action.color.a > 0 ? root.action.color : (selected ? Theme.highlightedTextColor : Theme.textColor) | 269 | color: root.action && root.action.color && root.action.color.a > 0 ? root.action.color : (selected ? Theme.highlightedTextColor : Theme.textColor) | ||
270 | } | 270 | } | ||
271 | Behavior on color { | 271 | Behavior on color { | ||
272 | ColorAnimation { | 272 | ColorAnimation { | ||
273 | duration: Units.longDuration | 273 | duration: Units.longDuration | ||
274 | easing.type: Easing.InOutQuad | 274 | easing.type: Easing.InOutQuad | ||
275 | } | 275 | } | ||
Show All 28 Lines | 303 | ColorAnimation { | |||
304 | duration: Units.longDuration | 304 | duration: Units.longDuration | ||
305 | easing.type: Easing.InOutQuad | 305 | easing.type: Easing.InOutQuad | ||
306 | } | 306 | } | ||
307 | } | 307 | } | ||
308 | ActionsMenu { | 308 | ActionsMenu { | ||
309 | id: leftActionSubMenu | 309 | id: leftActionSubMenu | ||
310 | y: -height | 310 | y: -height | ||
311 | x: -width/2 + parent.width/2 | 311 | x: -width/2 + parent.width/2 | ||
312 | actions: root.leftAction ? root.leftAction.children : "" | 312 | actions: root.leftAction && root.leftAction.hasOwnProperty("children") ? root.leftAction.children : "" | ||
313 | submenuComponent: Component { | 313 | submenuComponent: Component { | ||
314 | ActionsMenu {} | 314 | ActionsMenu {} | ||
315 | } | 315 | } | ||
316 | } | 316 | } | ||
317 | Icon { | 317 | Icon { | ||
318 | source: root.leftAction && root.leftAction.iconName ? root.leftAction.iconName : "" | 318 | source: root.leftAction && root.leftAction.icon.name ? root.leftAction.icon.name : "" | ||
319 | width: Units.iconSizes.smallMedium | 319 | width: Units.iconSizes.smallMedium | ||
320 | height: width | 320 | height: width | ||
321 | selected: leftButtonGraphics.pressed | 321 | selected: leftButtonGraphics.pressed | ||
322 | color: root.action && root.action.color && root.action.color.a > 0 ? root.action.color : (selected ? Theme.highlightedTextColor : Theme.textColor) | 322 | color: root.action && root.action.color && root.action.color.a > 0 ? root.action.color : (selected ? Theme.highlightedTextColor : Theme.textColor) | ||
323 | anchors { | 323 | anchors { | ||
324 | left: parent.left | 324 | left: parent.left | ||
325 | verticalCenter: parent.verticalCenter | 325 | verticalCenter: parent.verticalCenter | ||
326 | margins: Units.smallSpacing * 2 | 326 | margins: Units.smallSpacing * 2 | ||
Show All 23 Lines | 349 | ColorAnimation { | |||
350 | duration: Units.longDuration | 350 | duration: Units.longDuration | ||
351 | easing.type: Easing.InOutQuad | 351 | easing.type: Easing.InOutQuad | ||
352 | } | 352 | } | ||
353 | } | 353 | } | ||
354 | ActionsMenu { | 354 | ActionsMenu { | ||
355 | id: rightActionSubMenu | 355 | id: rightActionSubMenu | ||
356 | y: -height | 356 | y: -height | ||
357 | x: -width/2 + parent.width/2 | 357 | x: -width/2 + parent.width/2 | ||
358 | actions: root.rightAction ? root.rightAction.children : "" | 358 | actions: root.rightAction && root.rightAction.hasOwnProperty("children") ? root.rightAction.children : "" | ||
359 | submenuComponent: Component { | 359 | submenuComponent: Component { | ||
360 | ActionsMenu {} | 360 | ActionsMenu {} | ||
361 | } | 361 | } | ||
362 | } | 362 | } | ||
363 | Icon { | 363 | Icon { | ||
364 | source: root.rightAction && root.rightAction.iconName ? root.rightAction.iconName : "" | 364 | source: root.rightAction && root.rightAction.icon.name ? root.rightAction.icon.name : "" | ||
365 | width: Units.iconSizes.smallMedium | 365 | width: Units.iconSizes.smallMedium | ||
366 | height: width | 366 | height: width | ||
367 | selected: rightButtonGraphics.pressed | 367 | selected: rightButtonGraphics.pressed | ||
368 | color: root.action && root.action.color && root.action.color.a > 0 ? root.action.color : (selected ? Theme.highlightedTextColor : Theme.textColor) | 368 | color: root.action && root.action.color && root.action.color.a > 0 ? root.action.color : (selected ? Theme.highlightedTextColor : Theme.textColor) | ||
369 | anchors { | 369 | anchors { | ||
370 | right: parent.right | 370 | right: parent.right | ||
371 | verticalCenter: parent.verticalCenter | 371 | verticalCenter: parent.verticalCenter | ||
372 | margins: Units.smallSpacing * 2 | 372 | margins: Units.smallSpacing * 2 | ||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |