@@ -25,12 +25,13 @@ Item {
26 objectName: "menuBar"
26 objectName: "menuBar"
28 property alias unityMenuModel: rowRepeater.model
29 property alias unityMenuModel: rowRepeater.model
30− readonly property bool valid: rowRepeater.count > 0
32 property bool enableKeyFilter: false
30 property bool enableKeyFilter: false
31+ property real overflowWidth: width
34+ readonly property bool valid: rowRepeater.count > 0
34 readonly property bool showRequested: d.longAltPressed || d.currentItem != null
35 readonly property bool showRequested: d.longAltPressed || d.currentItem != null
36 implicitWidth: row.width
37 implicitWidth: row.width
@@ -65,168 +66,185 @@ Item {
65 onPressed: d.dismissAll()
66 onPressed: d.dismissAll()
68− Item {
69+ Rectangle {
69− id: clippingItem
70+ anchors.fill: row
70−
71+ color: Qt.rgba(1,0,0,0.4)
78− height: parent.height
82− objectName: "barContext"
83− active: !d.currentItem && enableKeyFilter
91− objectName: root.objectName + "-item" + __ownIndex
93− readonly property int __ownIndex: index
74+ Row {
94− property Item __popup: null;
75+ id: row
95− property bool popupVisible: __popup && __popup.visible
76+ spacing: units.gu(2)
77+ height: parent.height
97− implicitWidth: column.implicitWidth
79+ ActionContext {
98− implicitHeight: row.height
80+ id: menuBarContext
99− enabled: model.sensitive
81+ objectName: "barContext"
82+ active: !d.currentItem && enableKeyFilter
90+ objectName: root.objectName + "-item" + __ownIndex
92+ readonly property int __ownIndex: index
93+ property Item __popup: null;
94+ property bool popupVisible: __popup && __popup.visible
95+ property bool shouldDisplay: x + width + ((index < rowRepeater.count-1) ? units.gu(1) : 0) <
96+ (root.overflowWidth - (overflowButton.visible ? overflowButton.width : 0))
98+ implicitWidth: column.implicitWidth
99+ implicitHeight: row.height
100+ enabled: model.sensitive && shouldDisplay
101+ opacity: shouldDisplay ? 1 : 0
101− function show() {
103+ function show() {
102− if (!__popup) {
104+ if (!__popup) {
103− __popup = menuComponent.createObject(root, { objectName: visualItem.objectName + "-menu" });
105+ __popup = menuComponent.createObject(root, { objectName: visualItem.objectName + "-menu" });
104− // force the current item to be the newly popped up menu
106+ // force the current item to be the newly popped up menu
105− } else {
107+ } else {
106− __popup.show();
108+ __popup.show();
108− d.currentItem = visualItem;
110+ d.currentItem = visualItem;
110− function hide() {
112+ function hide() {
111− if (__popup) {
113+ if (__popup) {
112− __popup.hide();
114+ __popup.hide();
114− if (d.currentItem === visualItem) {
116+ if (d.currentItem === visualItem) {
115− d.currentItem = null;
117+ d.currentItem = null;
119− function dismiss() {
121+ function dismiss() {
120− if (__popup) {
122+ if (__popup) {
121− __popup.destroy();
123+ __popup.destroy();
122− __popup = null;
124+ __popup = null;
124− if (d.currentItem === visualItem) {
126+ if (d.currentItem === visualItem) {
125− d.currentItem = null;
127+ d.currentItem = null;
130− Connections {
132+ Connections {
131− target: d
133+ target: d
132− onDismissAll: visualItem.dismiss()
134+ onDismissAll: visualItem.dismiss()
135− Component {
137+ Component {
136− id: menuComponent
138+ id: menuComponent
137− MenuPopup {
139+ MenuPopup {
138− x: visualItem.x - units.gu(1)
140+ x: visualItem.x - units.gu(1)
139− anchors.top: parent.bottom
141+ anchors.top: parent.bottom
140− unityMenuModel: root.unityMenuModel.submenu(visualItem.__ownIndex)
142+ unityMenuModel: root.unityMenuModel.submenu(visualItem.__ownIndex)
142− Component.onCompleted: reset();
144+ Component.onCompleted: reset();
146− RowLayout {
148+ RowLayout {
147− id: column
149+ id: column
148− spacing: units.gu(1)
150+ spacing: units.gu(1)
149− anchors {
151+ anchors {
150− centerIn: parent
152+ centerIn: parent
154− Layout.preferredWidth: units.gu(2)
156+ Layout.preferredWidth: units.gu(2)
155− Layout.preferredHeight: units.gu(2)
157+ Layout.preferredHeight: units.gu(2)
156− Layout.alignment: Qt.AlignVCenter
158+ Layout.alignment: Qt.AlignVCenter
158− visible: model.icon || false
160+ visible: model.icon || false
159− source: model.icon || ""
161+ source: model.icon || ""
162− ActionItem {
164+ ActionItem {
163− id: actionItem
165+ id: actionItem
164− width: _title.width
166+ width: _title.width
165− height: _title.height
167+ height: _title.height
167− action: Action {
169+ action: Action {
168− // FIXME - SDK Action:text modifies menu text with html underline for mnemonic
170+ // FIXME - SDK Action:text modifies menu text with html underline for mnemonic
169− text: model.label.replace("_", "&").replace("<u>", "&").replace("</u>", "")
171+ text: model.label.replace("_", "&").replace("<u>", "&").replace("</u>", "")
171− onTriggered: {
173+ onTriggered: {
172− visualItem.show();
174+ visualItem.show();
177− id: _title
179+ id: _title
178− text: actionItem.text
180+ text: actionItem.text
179− horizontalAlignment: Text.AlignLeft
181+ horizontalAlignment: Text.AlignLeft
180− color: enabled ? theme.palette.normal.overlayText : theme.palette.disabled.overlayText
182+ color: enabled ? theme.palette.normal.overlayText : theme.palette.disabled.overlayText
184− } // Item ( delegate )
186+ } // Item ( delegate )
185− } // Repeater
187+ } // Repeater
186− } // Row
188+ } // Row
192+ visible: root.implicitWidth > root.width
193+ height: parent.height
195+ anchors.right: parent.right
201+ anchors.centerIn: parent
202+ color: theme.palette.normal.overlayText
203+ name: "toolkit_chevron-down_2gu"
188− MouseArea {
207+ MouseArea {
189− anchors.fill: parent
208+ anchors.fill: parent
190− hoverEnabled: d.currentItem
209+ hoverEnabled: d.currentItem
192− onEntered: {
211+ onEntered: {
193− if (d.currentItem) {
212+ if (d.currentItem) {
194− updateCurrentItemFromPosition(Qt.point(mouseX, mouseY))
213+ updateCurrentItemFromPosition(Qt.point(mouseX, mouseY))
197− onPositionChanged: {
216+ onPositionChanged: {
198− if (d.currentItem) {
217+ if (d.currentItem) {
199− updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
218+ updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
202− onClicked: updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
221+ onClicked: updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
204− function updateCurrentItemFromPosition(point) {
223+ function updateCurrentItemFromPosition(point) {
205− var pos = mapToItem(row, point.x, point.y);
224+ var pos = mapToItem(row, point.x, point.y);
207− if (!d.hoveredItem || !d.currentItem || !d.hoveredItem.contains(Qt.point(pos.x - d.currentItem.x, pos.y - d.currentItem.y))) {
226+ if (!d.hoveredItem || !d.currentItem || !d.hoveredItem.contains(Qt.point(pos.x - d.currentItem.x, pos.y - d.currentItem.y))) {
208− d.hoveredItem = row.childAt(pos.x, pos.y);
227+ d.hoveredItem = row.childAt(pos.x, pos.y);
209− if (!d.hoveredItem || !d.hoveredItem.enabled)
228+ if (!d.hoveredItem || !d.hoveredItem.enabled)
210− return false;
229+ return false;
211− if (d.currentItem != d.hoveredItem) {
230+ if (d.currentItem != d.hoveredItem) {
212− d.currentItem = d.hoveredItem;
231+ d.currentItem = d.hoveredItem;
219− Rectangle {
238+ Rectangle {
220− id: underline
239+ id: underline
221− anchors {
240+ anchors {
222− bottom: row.bottom
241+ bottom: row.bottom
224− x: d.currentItem ? row.x + d.currentItem.x - units.gu(1) : 0
225− width: d.currentItem ? d.currentItem.width + units.gu(2) : 0
227− color: theme.palette.normal.activity
228− visible: d.currentItem
243+ x: d.currentItem ? row.x + d.currentItem.x - units.gu(1) : 0
244+ width: d.currentItem ? d.currentItem.width + units.gu(2) : 0
246+ color: theme.palette.normal.activity
247+ visible: d.currentItem
232 MenuNavigator {
250 MenuNavigator {