@@ -64,156 +64,164 @@ Item {
6464 onPressed: d.dismissAll()
6565 }
6666
67− Row {
68− id: row
69− height: parent.height
70− spacing: units.gu(2)
71−
72− ActionContext {
73− id: menuBarContext
74− objectName: "barContext"
75− active: !d.currentItem && enableKeyFilter
76− }
67+ Item {
68+ id: clippingItem
69+
70+ height: root.height
71+ width: root.width
72+ clip: true
73+
74+ Row {
75+ id: row
76+ spacing: units.gu(2)
77+ height: parent.height
78+
79+ ActionContext {
80+ id: menuBarContext
81+ objectName: "barContext"
82+ active: !d.currentItem && enableKeyFilter
83+ }
7784
78− Repeater {
79− id: rowRepeater
85+ Repeater {
86+ id: rowRepeater
8087
81− Item {
82− id: visualItem
83− objectName: root.objectName + "-item" + __ownIndex
88+ Item {
89+ id: visualItem
90+ objectName: root.objectName + "-item" + __ownIndex
8491
85− readonly property int __ownIndex: index
86− property Item __popup: null;
87− property bool popupVisible: __popup && __popup.visible
92+ readonly property int __ownIndex: index
93+ property Item __popup: null;
94+ property bool popupVisible: __popup && __popup.visible
8895
89− implicitWidth: column.implicitWidth
90− implicitHeight: row.height
91− enabled: model.sensitive
96+ implicitWidth: column.implicitWidth
97+ implicitHeight: row.height
98+ enabled: model.sensitive
9299
93− function show() {
94− if (!__popup) {
95− __popup = menuComponent.createObject(root, { objectName: visualItem.objectName + "-menu" });
96− // force the current item to be the newly popped up menu
97− } else {
98− __popup.visible = true;
100+ function show() {
101+ if (!__popup) {
102+ __popup = menuComponent.createObject(root, { objectName: visualItem.objectName + "-menu" });
103+ // force the current item to be the newly popped up menu
104+ } else {
105+ __popup.visible = true;
106+ }
107+ d.currentItem = visualItem;
99108 }
100− d.currentItem = visualItem;
101− }
102− function hide() {
103− if (__popup) {
104− __popup.visible = false;
109+ function hide() {
110+ if (__popup) {
111+ __popup.visible = false;
105112
106− if (d.currentItem === visualItem) {
107− d.currentItem = null;
113+ if (d.currentItem === visualItem) {
114+ d.currentItem = null;
115+ }
108116 }
109117 }
110− }
111− function dismiss() {
112− if (__popup) {
113− __popup.destroy();
114− __popup = null;
118+ function dismiss() {
119+ if (__popup) {
120+ __popup.destroy();
121+ __popup = null;
115122
116− if (d.currentItem === visualItem) {
117− d.currentItem = null;
123+ if (d.currentItem === visualItem) {
124+ d.currentItem = null;
125+ }
118126 }
119127 }
120− }
121128
122− Connections {
123− target: d
124− onDismissAll: visualItem.dismiss()
125− }
129+ Connections {
130+ target: d
131+ onDismissAll: visualItem.dismiss()
132+ }
126133
127− Component {
128− id: menuComponent
129− MenuPopup {
130− x: visualItem.x - units.gu(1)
131− anchors.top: parent.bottom
132− unityMenuModel: root.unityMenuModel.submenu(visualItem.__ownIndex)
134+ Component {
135+ id: menuComponent
136+ MenuPopup {
137+ x: visualItem.x - units.gu(1)
138+ anchors.top: parent.bottom
139+ unityMenuModel: root.unityMenuModel.submenu(visualItem.__ownIndex)
133140
134− Component.onCompleted: reset();
135− onVisibleChanged: if (visible) { reset(); }
141+ Component.onCompleted: reset();
142+ onVisibleChanged: if (visible) { reset(); }
143+ }
136144 }
137− }
138145
139− RowLayout {
140− id: column
141− spacing: units.gu(1)
142− anchors {
143− centerIn: parent
144− }
146+ RowLayout {
147+ id: column
148+ spacing: units.gu(1)
149+ anchors {
150+ centerIn: parent
151+ }
145152
146− Icon {
147− Layout.preferredWidth: units.gu(2)
148− Layout.preferredHeight: units.gu(2)
149− Layout.alignment: Qt.AlignVCenter
153+ Icon {
154+ Layout.preferredWidth: units.gu(2)
155+ Layout.preferredHeight: units.gu(2)
156+ Layout.alignment: Qt.AlignVCenter
150157
151− visible: model.icon || false
152− source: model.icon || ""
153− }
158+ visible: model.icon || false
159+ source: model.icon || ""
160+ }
154161
155− ActionItem {
156− id: actionItem
157− width: _title.width
158− height: _title.height
162+ ActionItem {
163+ id: actionItem
164+ width: _title.width
165+ height: _title.height
159166
160− action: Action {
161− // FIXME - SDK Action:text modifies menu text with html underline for mnemonic
162− text: model.label.replace("_", "&").replace("<u>", "&").replace("</u>", "")
167+ action: Action {
168+ // FIXME - SDK Action:text modifies menu text with html underline for mnemonic
169+ text: model.label.replace("_", "&").replace("<u>", "&").replace("</u>", "")
163170
164− onTriggered: {
165− visualItem.show();
171+ onTriggered: {
172+ visualItem.show();
173+ }
166174 }
167− }
168175
169− Label {
170− id: _title
171− text: actionItem.text
172− horizontalAlignment: Text.AlignLeft
173− color: enabled ? "white" : "#5d5d5d"
176+ Label {
177+ id: _title
178+ text: actionItem.text
179+ horizontalAlignment: Text.AlignLeft
180+ color: enabled ? "white" : "#5d5d5d"
181+ }
174182 }
175183 }
176− }
177− } // Item ( delegate )
178− } // Repeater
179− } // Row
184+ } // Item ( delegate )
185+ } // Repeater
186+ } // Row
180187
181− MouseArea {
182− anchors.fill: parent
183− hoverEnabled: d.currentItem
188+ MouseArea {
189+ anchors.fill: parent
190+ hoverEnabled: d.currentItem
184191
185− onPositionChanged: {
186− if (d.currentItem) {
187− updateCurrentItemFromPosition(mouse)
192+ onPositionChanged: {
193+ if (d.currentItem) {
194+ updateCurrentItemFromPosition(mouse)
195+ }
188196 }
189− }
190− onClicked: updateCurrentItemFromPosition(mouse)
197+ onClicked: updateCurrentItemFromPosition(mouse)
191198
192− function updateCurrentItemFromPosition(point) {
193− var pos = mapToItem(row, point.x, point.y);
199+ function updateCurrentItemFromPosition(point) {
200+ var pos = mapToItem(row, point.x, point.y);
194201
195− if (!d.hoveredItem || !d.currentItem || !d.hoveredItem.contains(Qt.point(pos.x - d.currentItem.x, pos.y - d.currentItem.y))) {
196− d.hoveredItem = row.childAt(pos.x, pos.y);
197− if (!d.hoveredItem || !d.hoveredItem.enabled)
198− return false;
199− if (d.currentItem != d.hoveredItem) {
200− d.currentItem = d.hoveredItem;
202+ if (!d.hoveredItem || !d.currentItem || !d.hoveredItem.contains(Qt.point(pos.x - d.currentItem.x, pos.y - d.currentItem.y))) {
203+ d.hoveredItem = row.childAt(pos.x, pos.y);
204+ if (!d.hoveredItem || !d.hoveredItem.enabled)
205+ return false;
206+ if (d.currentItem != d.hoveredItem) {
207+ d.currentItem = d.hoveredItem;
208+ }
201209 }
210+ return true;
202211 }
203− return true;
204212 }
205− }
206213
207− Rectangle {
208− id: underline
209− anchors {
210− bottom: row.bottom
214+ Rectangle {
215+ id: underline
216+ anchors {
217+ bottom: row.bottom
218+ }
219+ x: d.currentItem ? row.x + d.currentItem.x - units.gu(1) : 0
220+ width: d.currentItem ? d.currentItem.width + units.gu(2) : 0
221+ height: units.dp(4)
222+ color: UbuntuColors.orange
223+ visible: d.currentItem
211224 }
212− x: d.currentItem ? row.x + d.currentItem.x - units.gu(1) : 0
213− width: d.currentItem ? d.currentItem.width + units.gu(2) : 0
214− height: units.dp(4)
215− color: UbuntuColors.orange
216− visible: d.currentItem
217225 }
218226
219227 MenuNavigator {