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

Proposed by Albert Astals Cid
Status: Merged
Approved by: Lukáš Tinkl
Approved revision: 2841
Merged at revision: 2889
Proposed branch: lp:~aacid/unity8/select_first_submenu_when_it_appears
Merge into: lp:unity8
Prerequisite: lp:~aacid/unity8/menutool
Diff against target: 289 lines (+94/-28)
6 files modified
qml/ApplicationMenus/MenuBar.qml (+2/-5)
qml/ApplicationMenus/MenuPopup.qml (+11/-5)
tests/mocks/QMenuModel/unitymenumodel.cpp (+23/-4)
tests/mocks/QMenuModel/unitymenumodel.h (+7/-0)
tests/qmltests/ApplicationMenus/tst_MenuBar.qml (+34/-0)
tests/qmltests/ApplicationMenus/tst_MenuPopup.qml (+17/-14)
To merge this branch: bzr merge lp:~aacid/unity8/select_first_submenu_when_it_appears
Reviewer Review Type Date Requested Status
Lukáš Tinkl (community) Approve
Unity8 CI Bot continuous-integration Approve
Michael Zanetti Pending
Review via email: mp+318615@code.launchpad.net

This proposal supersedes a proposal from 2017-02-22.

Commit message

Fix real world submenus (e.g. kate) not getting their first item selected on open

MenuBar.qml: remove unused function
MenuPopup.qml: Select first item when one arrives if there's no currentItem instead of on completion
unitymenumodel.cpp: trick rowCount() to simulate "real world late" menus
tst_MenuPopup.qml: adapt to unitymenumodel.cpp changes (and make the Up test actually press Up and not Down)

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
https://code.launchpad.net/~aacid/qmenumodel/batch_insert_remove_from_menu

 * 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
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

It does improve the situation but there is something odd:

again, using kate as an example, opening the Tools menu, navigate down to a submenu, enter it, navigate down to the third entry, press left, go to another submenu, enter it. Now the highlight will be at the third entry instead of starting at the first again.

also I managed to get into the situation where I lost keyboard focus altogether in the menu by navigating through the main menu entries. While I'm not 100% sure that is introduced by this branch, I haven't seen it in trunk so far.

review: Needs Fixing
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:2835
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3177/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4172
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2456
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2456
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4200
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4037
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4037/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4037
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4037/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4037
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4037/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4037
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4037/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4037
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4037/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4037
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4037/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2839
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3248/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4265
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2535
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2535
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4293
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4126
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4126/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4126
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4126/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4126
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4126/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4126
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4126/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4126
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4126/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4126
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4126/artifact/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)
2840. By Albert Astals Cid

only submenus select first, not first level menus

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2840
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3255/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4279
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2549
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2549
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4307
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4141
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4141/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4141
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4141/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4141
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4141/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4141
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4141/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4141
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4141/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4141
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4141/artifact/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2840
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3257/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4284
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2553
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2553
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4312
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4146
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4146/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4146
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4146/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4146
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4146/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4146
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4146/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4146
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4146/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4146
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4146/artifact/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2840
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3262/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4290
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2557
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2557
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4318
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4152
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4152/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4152
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4152/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4152
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4152/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4152
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4152/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4152
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4152/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4152
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4152/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
2841. By Albert Astals Cid

Merge

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2841
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3347/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4403
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2640
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2640
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4431
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4264
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4264/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4264
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4264/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4264
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4264/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4264
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4264/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4264
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4264/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4264
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4264/artifact/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2841
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3354/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4416
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2648
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2648
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4444
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4277
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4277/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4277
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4277/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4277
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4277/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4277
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4277/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4277
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4277/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4277
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4277/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

This works fine for first level submenus; however, very often I found that on second and subsequent levels, most of the time it's the last item that gets preselected. It seems very random, sometimes it's the first one, sometimes the last one.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

> This works fine for first level submenus; however, very often I found that on
> second and subsequent levels, most of the time it's the last item that gets
> preselected. It seems very random, sometimes it's the first one, sometimes the
> last one.

Are you sure you're using this with https://code.launchpad.net/~aacid/qmenumodel/batch_insert_remove_from_menu ? Because what you describe sounds like what happens if you do not.

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

> > This works fine for first level submenus; however, very often I found that
> on
> > second and subsequent levels, most of the time it's the last item that gets
> > preselected. It seems very random, sometimes it's the first one, sometimes
> the
> > last one.
>
> Are you sure you're using this with
> https://code.launchpad.net/~aacid/qmenumodel/batch_insert_remove_from_menu ?
> Because what you describe sounds like what happens if you do not.

Yup, that might explain it (added the MP to the silo as well)

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Works fine now, thanks!

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

Yes

* Did CI run pass? If not, please explain why.

Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qml/ApplicationMenus/MenuBar.qml'
--- qml/ApplicationMenus/MenuBar.qml 2017-03-08 09:53:21 +0000
+++ qml/ApplicationMenus/MenuBar.qml 2017-03-13 14:11:08 +0000
@@ -44,10 +44,6 @@
44 implicitWidth: row.width44 implicitWidth: row.width
45 height: parent.height45 height: parent.height
4646
47 function select(index) {
48 d.select(index);
49 }
50
51 function dismiss() {47 function dismiss() {
52 d.dismissAll();48 d.dismissAll();
53 }49 }
@@ -137,7 +133,8 @@
137 objectName: visualItem.objectName + "-menu",133 objectName: visualItem.objectName + "-menu",
138 desiredX: Qt.binding(function() { return visualItem.x - units.gu(1); }),134 desiredX: Qt.binding(function() { return visualItem.x - units.gu(1); }),
139 desiredY: Qt.binding(function() { return root.height; }),135 desiredY: Qt.binding(function() { return root.height; }),
140 unityMenuModel: Qt.binding(function() { return root.unityMenuModel.submenu(visualItem.__ownIndex); })136 unityMenuModel: Qt.binding(function() { return root.unityMenuModel.submenu(visualItem.__ownIndex); }),
137 selectFirstOnCountChange: false
141 });138 });
142 __popup.reset();139 __popup.reset();
143 __popup.childActivated.connect(dismiss);140 __popup.childActivated.connect(dismiss);
144141
=== modified file 'qml/ApplicationMenus/MenuPopup.qml'
--- qml/ApplicationMenus/MenuPopup.qml 2017-02-22 09:43:50 +0000
+++ qml/ApplicationMenus/MenuPopup.qml 2017-03-13 14:11:08 +0000
@@ -33,6 +33,8 @@
33 // if they don't fit when growing right33 // if they don't fit when growing right
34 property bool substractWidth: false34 property bool substractWidth: false
3535
36 property bool selectFirstOnCountChange: true
37
36 property real desiredX38 property real desiredX
37 x: {39 x: {
38 var dummy = visible; // force recalc when shown/hidden40 var dummy = visible; // force recalc when shown/hidden
@@ -73,8 +75,8 @@
73 d.currentItem = null;75 d.currentItem = null;
74 }76 }
7577
76 function select(index) {78 function selectFirstIndex() {
77 d.select(index)79 d.selectNext(-1);
78 }80 }
7981
80 function reset() {82 function reset() {
@@ -325,6 +327,7 @@
325 });327 });
326 } else if (popup) {328 } else if (popup) {
327 popup.visible = true;329 popup.visible = true;
330 popup.item.selectFirstIndex();
328 }331 }
329 } else {332 } else {
330 root.unityMenuModel.activate(__ownIndex);333 root.unityMenuModel.activate(__ownIndex);
@@ -358,6 +361,12 @@
358 Repeater {361 Repeater {
359 id: repeater362 id: repeater
360363
364 onCountChanged: {
365 if (root.selectFirstOnCountChange && !d.currentItem && count > 0) {
366 root.selectFirstIndex();
367 }
368 }
369
361 Loader {370 Loader {
362 id: loader371 id: loader
363 objectName: root.objectName + "-item" + __ownIndex372 objectName: root.objectName + "-item" + __ownIndex
@@ -484,9 +493,6 @@
484 target: item493 target: item
485 onChildActivated: childActivated();494 onChildActivated: childActivated();
486 }495 }
487
488 Component.onCompleted: item.select(0);
489 onVisibleChanged: if (visible) { item.select(0); }
490 }496 }
491 }497 }
492 }498 }
493499
=== modified file 'tests/mocks/QMenuModel/unitymenumodel.cpp'
--- tests/mocks/QMenuModel/unitymenumodel.cpp 2017-01-10 14:46:09 +0000
+++ tests/mocks/QMenuModel/unitymenumodel.cpp 2017-03-13 14:11:08 +0000
@@ -18,6 +18,8 @@
1818
19#include "unitymenumodel.h"19#include "unitymenumodel.h"
2020
21#include <QTimer>
22
21enum MenuRoles {23enum MenuRoles {
22 LabelRole = Qt::DisplayRole + 1,24 LabelRole = Qt::DisplayRole + 1,
23 SensitiveRole,25 SensitiveRole,
@@ -35,7 +37,8 @@
35};37};
3638
37UnityMenuModel::UnityMenuModel(QObject *parent)39UnityMenuModel::UnityMenuModel(QObject *parent)
38: QAbstractListModel(parent)40 : QAbstractListModel(parent)
41 , m_rowCountStatus(NoRequestMade)
39{42{
40}43}
4144
@@ -60,7 +63,7 @@
6063
61void UnityMenuModel::insertRow(int row, const QVariant& data)64void UnityMenuModel::insertRow(int row, const QVariant& data)
62{65{
63 row = qMin(row, rowCount());66 row = qMin(row, m_modelData.count());
6467
65 beginInsertRows(QModelIndex(), row, row);68 beginInsertRows(QModelIndex(), row, row);
6669
@@ -71,12 +74,12 @@
7174
72void UnityMenuModel::appendRow(const QVariant& data)75void UnityMenuModel::appendRow(const QVariant& data)
73{76{
74 insertRow(rowCount(), data);77 insertRow(m_modelData.count(), data);
75}78}
7679
77void UnityMenuModel::removeRow(int row)80void UnityMenuModel::removeRow(int row)
78{81{
79 if (row < 0 || rowCount() <= row) {82 if (row < 0 || m_modelData.count() <= row) {
80 return;83 return;
81 }84 }
8285
@@ -133,6 +136,22 @@
133136
134int UnityMenuModel::rowCount(const QModelIndex&) const137int UnityMenuModel::rowCount(const QModelIndex&) const
135{138{
139 // Fake the rowCount to be 0 for a while (100ms)
140 // This emulates menus in real world that don't load immediately
141 if (m_rowCountStatus == TimerRunning)
142 return 0;
143
144 if (m_rowCountStatus == NoRequestMade) {
145 UnityMenuModel *that = const_cast<UnityMenuModel*>(this);
146 that->m_rowCountStatus = TimerRunning;
147 QTimer::singleShot(100, that, [that] {
148 that->beginInsertRows(QModelIndex(), 0, that->m_modelData.count() - 1);
149 that->m_rowCountStatus = TimerFinished;
150 that->endInsertRows();
151 });
152 return 0;
153 }
154
136 return m_modelData.count();155 return m_modelData.count();
137}156}
138157
139158
=== modified file 'tests/mocks/QMenuModel/unitymenumodel.h'
--- tests/mocks/QMenuModel/unitymenumodel.h 2016-09-29 09:15:04 +0000
+++ tests/mocks/QMenuModel/unitymenumodel.h 2017-03-13 14:11:08 +0000
@@ -101,6 +101,13 @@
101 QByteArray m_busName;101 QByteArray m_busName;
102 QVariantMap m_actions;102 QVariantMap m_actions;
103 QByteArray m_menuObjectPath;103 QByteArray m_menuObjectPath;
104
105 enum RowCountStatus {
106 NoRequestMade,
107 TimerRunning,
108 TimerFinished
109 };
110 RowCountStatus m_rowCountStatus;
104};111};
105112
106#endif // MOCK_UNITYMENUMODEL_H113#endif // MOCK_UNITYMENUMODEL_H
107114
=== modified file 'tests/qmltests/ApplicationMenus/tst_MenuBar.qml'
--- tests/qmltests/ApplicationMenus/tst_MenuBar.qml 2017-03-03 10:21:54 +0000
+++ tests/qmltests/ApplicationMenus/tst_MenuBar.qml 2017-03-13 14:11:08 +0000
@@ -271,5 +271,39 @@
271 return false;271 return false;
272 }, true);272 }, true);
273 }273 }
274
275 function test_firstDisabled() {
276 var data = appMenuData.generateTestData(10,5,2,3);
277 data[0].submenu[1].submenu[0].rowData.sensitive = false;
278 menuBackend.modelData = data;
279
280 var menuItem = findChild(menuBar, "menuBar-item0");
281 menuItem.show();
282
283 // waits for item to be created so the keyclick actually works
284 findChild(menuBar, "menuBar-item0-menu-item1-actionItem");
285
286 keyClick(Qt.Key_Down);
287 keyClick(Qt.Key_Down);
288 keyClick(Qt.Key_Right);
289
290 var submenu = findChild(menuBar, "menuBar-item0-menu-item1-menu");
291 var priv = findInvisibleChild(submenu, "d");
292 var subActionItem1 = findChild(submenu, "menuBar-item0-menu-item1-menu-item1-actionItem");
293 compare(priv.currentItem.item, subActionItem1);
294
295 keyClick(Qt.Key_Down);
296 var subActionItem3 = findChild(submenu, "menuBar-item0-menu-item1-menu-item3-actionItem");
297 compare(priv.currentItem.item, subActionItem3);
298
299 // now move mouse over to a different item and back to exercise a different codepath
300 var actionItem0 = findChild(menuBar, "menuBar-item0-menu-item0-actionItem");
301 mouseMove(actionItem0, actionItem0.width/2, actionItem0.height/2);
302
303 var actionItem1 = findChild(menuBar, "menuBar-item0-menu-item1-actionItem");
304 mouseMove(actionItem1, actionItem1.width/2, actionItem1.height/2);
305
306 tryCompareFunction(function() { return priv.currentItem.item == subActionItem1; }, true);
307 }
274 }308 }
275}309}
276310
=== modified file 'tests/qmltests/ApplicationMenus/tst_MenuPopup.qml'
--- tests/qmltests/ApplicationMenus/tst_MenuPopup.qml 2017-01-25 14:10:44 +0000
+++ tests/qmltests/ApplicationMenus/tst_MenuPopup.qml 2017-03-13 14:11:08 +0000
@@ -160,9 +160,6 @@
160 var priv = findInvisibleChild(menu, "d");160 var priv = findInvisibleChild(menu, "d");
161161
162 keyClick(Qt.Key_Down, Qt.NoModifier);162 keyClick(Qt.Key_Down, Qt.NoModifier);
163 compare(priv.currentItem, item0, "CurrentItem should have moved to item 0");
164
165 keyClick(Qt.Key_Down, Qt.NoModifier);
166 compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");163 compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
167164
168 keyClick(Qt.Key_Down, Qt.NoModifier);165 keyClick(Qt.Key_Down, Qt.NoModifier);
@@ -170,6 +167,9 @@
170167
171 keyClick(Qt.Key_Down, Qt.NoModifier);168 keyClick(Qt.Key_Down, Qt.NoModifier);
172 compare(priv.currentItem, item0, "CurrentItem should have moved to item 0");169 compare(priv.currentItem, item0, "CurrentItem should have moved to item 0");
170
171 keyClick(Qt.Key_Down, Qt.NoModifier);
172 compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
173 }173 }
174174
175 function test_keyboardNavigation_UpKeySelectsAndOpensPreviousMenuItemAndRotates() {175 function test_keyboardNavigation_UpKeySelectsAndOpensPreviousMenuItemAndRotates() {
@@ -181,17 +181,17 @@
181181
182 var priv = findInvisibleChild(menu, "d");182 var priv = findInvisibleChild(menu, "d");
183183
184 keyClick(Qt.Key_Down, Qt.NoModifier);184 keyClick(Qt.Key_Up, Qt.NoModifier);
185 compare(priv.currentItem, item0, "CurrentItem should have moved to item 2");185 compare(priv.currentItem, item2, "CurrentItem should have moved to item 2");
186186
187 keyClick(Qt.Key_Down, Qt.NoModifier);187 keyClick(Qt.Key_Up, Qt.NoModifier);
188 compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");188 compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
189189
190 keyClick(Qt.Key_Down, Qt.NoModifier);190 keyClick(Qt.Key_Up, Qt.NoModifier);
191 compare(priv.currentItem, item2, "CurrentItem should have moved to item 0");191 compare(priv.currentItem, item0, "CurrentItem should have moved to item 0");
192192
193 keyClick(Qt.Key_Down, Qt.NoModifier);193 keyClick(Qt.Key_Up, Qt.NoModifier);
194 compare(priv.currentItem, item0, "CurrentItem should have moved to item 2");194 compare(priv.currentItem, item2, "CurrentItem should have moved to item 2");
195 }195 }
196196
197 function test_keyboardNavigation_RightKeyEntersSubMenu() {197 function test_keyboardNavigation_RightKeyEntersSubMenu() {
@@ -217,7 +217,7 @@
217217
218 var menuItem = findChild(menu, "menu-item0"); verify(menuItem);218 var menuItem = findChild(menu, "menu-item0"); verify(menuItem);
219 mouseClick(menuItem, menuItem.width/2, menuItem.height/2);219 mouseClick(menuItem, menuItem.width/2, menuItem.height/2);
220 tryCompareFunction(function() { return menuItem.popup !== null && menuItem.popup.visible }, true);220 tryCompareFunction(function() { return menuItem.popup !== null && findInvisibleChild(menuItem.popup, "d").currentItem !== null }, true);
221221
222 keyClick(Qt.Key_Left, Qt.NoModifier);222 keyClick(Qt.Key_Left, Qt.NoModifier);
223 tryCompareFunction(function() { return menuItem.popup !== null && menuItem.popup.visible }, false);223 tryCompareFunction(function() { return menuItem.popup !== null && menuItem.popup.visible }, false);
@@ -245,13 +245,16 @@
245245
246 menu.unityMenuModel.modelData = differentSizesMenu;246 menu.unityMenuModel.modelData = differentSizesMenu;
247247
248 waitForRendering(menu);248 // Wait for the two items to be there
249 tryCompareFunction(function() { return findChild(menu, "menu-item1") !== null; }, true);
249 var longWidth = menu.width;250 var longWidth = menu.width;
251
252 // Now pop one item and make sure it's smaller
250 differentSizesMenu.pop();253 differentSizesMenu.pop();
251 menu.unityMenuModel.modelData = differentSizesMenu;254 menu.unityMenuModel.modelData = differentSizesMenu;
252255
253 waitForRendering(menu);256 tryCompareFunction(function() { return findChild(menu, "menu-item0") !== null; }, true);
254 verify(menu.width < longWidth);257 tryCompareFunction(function() { return menu.width < longWidth; }, true);
255 }258 }
256259
257 function test_minimumWidth() {260 function test_minimumWidth() {

Subscribers

People subscribed via source and target branches