Merge lp:~aacid/unity8/correctly_sized_menus into lp:unity8

Proposed by Albert Astals Cid
Status: Rejected
Rejected by: Albert Astals Cid
Proposed branch: lp:~aacid/unity8/correctly_sized_menus
Merge into: lp:unity8
Diff against target: 169 lines (+115/-4)
3 files modified
qml/ApplicationMenus/MenuPopup.qml (+41/-4)
tests/qmltests/ApplicationMenuDataLoader.qml (+59/-0)
tests/qmltests/ApplicationMenus/tst_MenuPopup.qml (+15/-0)
To merge this branch: bzr merge lp:~aacid/unity8/correctly_sized_menus
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve
Unity Team Pending
Review via email: mp+314920@code.launchpad.net

Commit message

Make the MenuPopup size be the one of the biggest menu

Don't like this solution much since it involves saving the delegates of the list, but seems to work

Description of the change

See https://code.launchpad.net/~aacid/unity8/correctly_sized_menus_v2/+merge/314927 for an alternative solution

* Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2769
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2917/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3806
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2203
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2203
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3834
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3677
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3677/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3677
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3677/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3677
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3677/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3677
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3677/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3677
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3677/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3677
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3677/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2917/rebuild

review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Unmerged revisions

2769. By Albert Astals Cid

Make the MenuPopup size be the one of the biggest menu

Don't like this solution much since it involves saving the delegates of the list, but seems to work

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/ApplicationMenus/MenuPopup.qml'
2--- qml/ApplicationMenus/MenuPopup.qml 2017-01-09 15:26:05 +0000
3+++ qml/ApplicationMenus/MenuPopup.qml 2017-01-17 14:57:53 +0000
4@@ -154,9 +154,42 @@
5 objectName: "listView"
6 Layout.fillHeight: true
7 Layout.fillWidth: true
8- contentWidth: MathUtils.clamp(contentItem.childrenRect.width,
9- __minimumWidth,
10- __maximumWidth)
11+
12+ property var items: []
13+
14+ // Batch updateContentWidthCalls
15+ Timer {
16+ id: updateContentWidthTimer
17+ interval: 0
18+ onTriggered: listView.realUpdateContentWidth();
19+ }
20+
21+ function newItem(item) {
22+ items.push(item);
23+ updateContentWidthTimer.start();
24+ }
25+
26+ function removeItem(item) {
27+ var index = items.indexOf(item);
28+ if(index != -1) {
29+ items.splice(index, 1);
30+ updateContentWidthTimer.start();
31+ }
32+ }
33+
34+ function updateContentWidth() {
35+ updateContentWidthTimer.start();
36+ }
37+
38+ function realUpdateContentWidth() {
39+ var maxChildrenWidth = 0;
40+
41+ for (var i in items) {
42+ maxChildrenWidth = Math.max(maxChildrenWidth, items[i].implicitWidth);
43+ }
44+
45+ contentWidth = MathUtils.clamp(maxChildrenWidth, __minimumWidth, __maximumWidth)
46+ }
47
48 orientation: Qt.Vertical
49 interactive: contentHeight > height
50@@ -222,7 +255,7 @@
51
52 property int __ownIndex: index
53
54- width: root.width
55+ width: listView.contentWidth
56 enabled: model.isSeparator ? false : model.sensitive
57
58 sourceComponent: {
59@@ -289,6 +322,10 @@
60 objectName: loader.objectName + "-separator"
61 }
62 }
63+
64+ Component.onCompleted: listView.newItem(loader);
65+ Component.onDestruction: listView.removeItem(loader);
66+ onImplicitWidthChanged: listView.updateContentWidth();
67 }
68 } // ListView
69
70
71=== modified file 'tests/qmltests/ApplicationMenuDataLoader.qml'
72--- tests/qmltests/ApplicationMenuDataLoader.qml 2017-01-06 14:07:36 +0000
73+++ tests/qmltests/ApplicationMenuDataLoader.qml 2017-01-17 14:57:53 +0000
74@@ -72,4 +72,63 @@
75 "shortcut": "Alt+F"
76 }
77 }]
78+
79+ property var differentSizesMenu: [{
80+ "rowData": { // 1.1
81+ "label": "Short",
82+ "sensitive": true,
83+ "isSeparator": false,
84+ "icon": "",
85+ "type": "com.canonical.indicator.test",
86+ "ext": {},
87+ "action": "menu0",
88+ "actionState": {},
89+ "isCheck": false,
90+ "isRadio": false,
91+ "isToggled": false,
92+ "shortcut": "Alt+F"
93+ }}, {
94+ "rowData": { // 1.2
95+ "label": "This is Medium",
96+ "sensitive": true,
97+ "isSeparator": false,
98+ "icon": "",
99+ "type": "com.canonical.indicator.test",
100+ "ext": {},
101+ "action": "menu1",
102+ "actionState": {},
103+ "isCheck": false,
104+ "isRadio": false,
105+ "isToggled": false,
106+ }}, {
107+ "rowData": { // row 1.2
108+ "label": "This is Medium v2",
109+ "sensitive": true,
110+ "isSeparator": false,
111+ "icon": "",
112+ "type": "com.canonical.indicator.test",
113+ "ext": {},
114+ "action": "menu2",
115+ "actionState": {},
116+ "isCheck": false,
117+ "isRadio": false,
118+ "isToggled": false,
119+ "shortcut": "Alt+G"
120+ }}, {
121+ "rowData": { // row 1.2
122+ "label": "This is really Looong",
123+ "sensitive": true,
124+ "isSeparator": false,
125+ "icon": "",
126+ "type": "com.canonical.indicator.test",
127+ "ext": {},
128+ "action": "menu2",
129+ "actionState": {},
130+ "isCheck": false,
131+ "isRadio": false,
132+ "isToggled": false,
133+ "shortcut": "Ctrl+Shift+T"
134+ }}
135+ ];
136+
137 }
138
139=== modified file 'tests/qmltests/ApplicationMenus/tst_MenuPopup.qml'
140--- tests/qmltests/ApplicationMenus/tst_MenuPopup.qml 2017-01-09 15:26:05 +0000
141+++ tests/qmltests/ApplicationMenus/tst_MenuPopup.qml 2017-01-17 14:57:53 +0000
142@@ -90,6 +90,7 @@
143 // recurse into submenu
144 var submenu = rows[i]["submenu"];
145 if (submenu) {
146+ waitForRendering(menuItem);
147 mouseClick(menuItem, menuItem.width/2, menuItem.height/2);
148 tryCompare(menuPriv, "currentItem", menuItem);
149
150@@ -203,5 +204,19 @@
151 keyClick(Qt.Key_Left, Qt.NoModifier);
152 tryCompareFunction(function() { return menuItem.popup !== null && menuItem.popup.visible }, false);
153 }
154+
155+ function test_differentSizes() {
156+ menuBackend.modelData = appMenuData.differentSizesMenu;
157+
158+ waitForRendering(page);
159+ var longWidth = page.width;
160+
161+ var menuData = appMenuData.differentSizesMenu;
162+ menuData.pop();
163+ menuBackend.modelData = menuData;
164+
165+ waitForRendering(page);
166+ verify(page.width < longWidth);
167+ }
168 }
169 }

Subscribers

People subscribed via source and target branches