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