17
17
import Ubuntu.Components 1.3
18
18
import Ubuntu.Components.Popups 1.3
19
import Ubuntu.Components.Styles 1.3 as Style
21
Style.ActionBarStyle {
22
23
implicitWidth: actionsContainer.implicitWidth
23
24
implicitHeight: units.gu(5)
25
// FIXME: Add color and label configuration properties or make
26
// the action delegates configurable.
26
overflowIconName: "contextual-menu"
28
// Unused with the standard action icon buttons, but may be used with a custom delegate.
32
The default action delegate if the styled item does
33
not provide a delegate.
35
defaultDelegate: AbstractButton {
36
style: IconButtonStyle { }
37
objectName: action.objectName + "_button"
38
height: parent ? parent.height : undefined
42
defaultNumberOfSlots: 3
29
45
id: actionsContainer
40
56
return visibleActionList;
58
property var barActions: overflowAction.visible
59
? visibleActions.slice(0, numberOfSlots.used).concat(overflowAction)
60
: visibleActions.slice(0, numberOfSlots.used)
61
property var overflowActions: visibleActions.slice(numberOfSlots.used,
62
numberOfSlots.requested)
45
66
property int requested: actionsContainer.visibleActions.length
46
67
property int available: styledItem.numberOfSlots
47
property int overflow: actionsOverflowButton.visible ? 1 : 0
68
property int overflow: overflowAction.visible ? 1 : 0
48
69
// when numberOfSlots < 1, show the overflow button, but set used
49
70
// to 0 so that all actions will appear in the overflow panel.
50
71
property int used: Math.min(Math.max(0, available - overflow), requested)
59
81
objectName: "actions_repeater"
60
model: numberOfSlots.used
62
style: IconButtonStyle { }
64
objectName: action.objectName + "_action_button"
65
height: actionsContainer.height
66
action: actionsContainer.visibleActions[index]
82
model: actionsContainer.barActions
83
delegate: styledItem.delegate
71
style: IconButtonStyle { }
72
id: actionsOverflowButton
73
objectName: "actions_overflow_button"
74
height: actionsContainer.height
88
iconSource: actionBarStyle.overflowIconSource
89
iconName: actionBarStyle.overflowIconName
90
text: actionBarStyle.overflowText
91
objectName: "overflow_action"
75
92
visible: numberOfSlots.requested > numberOfSlots.available
77
// Ensure resetting of X when this button is not visible to avoid
78
// miscalculation of actionsContainer.width. Fixes bug #1408481.
79
onVisibleChanged: if (!visible) x = 0
80
iconName: "contextual-menu"
81
onTriggered: PopupUtils.open(actionsOverflowPopoverComponent, actionsOverflowButton)
84
id: actionsOverflowPopoverComponent
87
id: actionsOverflowPopover
88
objectName: "actions_overflow_panel"
90
// Ensure the popover closes when actions change and
91
// the list item below may be destroyed before its
92
// onClicked is executed. See bug
93
// https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1326963
97
actionsOverflowPopover.hide();
94
var overflowButton = actionsRepeater.itemAt(actionsRepeater.count - 1);
95
PopupUtils.open(actionsOverflowPopoverComponent, overflowButton);
100
id: actionsOverflowPopoverComponent
102
id: actionsOverflowPopover
103
objectName: "actions_overflow_panel"
105
// Ensure the popover closes when actions change and
106
// the list item below may be destroyed before its
107
// onClicked is executed. See bug
108
// https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1326963
112
actionsOverflowPopover.hide();
101
actions: actionsContainer.visibleActions.slice(numberOfSlots.used,
102
numberOfSlots.requested)
115
actions: actionsContainer.overflowActions