on xenial help sign in
fixed tests
commit06214dd5ed040bc16c2b6c106e3a147c0ddf4262 authorNick Dedekind <nick.dedekind@canonical.com> dateWed 12 Oct 2016, 18:12 (10 years ago) parent6c3fa96
7 files changed+44−44
qml/ApplicationMenus/MenuBar.qml+29−29 qml/Panel/Panel.qml+5−1 qml/Stage/DecoratedWindow.qml−2 qml/Stage/WindowDecoration.qml+5−7 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/tst_Shell.qml+1−3 tests/qmltests/tst_ShellWithPin.qml+3−1
qml/ApplicationMenus/MenuBar.qml+29−29
@@ -18,6 +18,7 @@ import QtQuick 2.4
1818import QtQuick.Layouts 1.1
1919import Utils 0.1
2020import Ubuntu.Components 1.3
21+import GlobalShortcut 1.0
2122
2223Item {
2324 id: root
@@ -27,9 +28,9 @@ Item {
2728
2829 readonly property bool valid: rowRepeater.count > 0
2930
30− property alias enableKeyFilter: altFilter.enabled
31+ property bool enableKeyFilter: false
3132
32− readonly property bool showRequested: altFilter.longAltPressed || d.currentItem != null
33+ readonly property bool showRequested: d.longAltPressed || d.currentItem != null
3334
3435 implicitWidth: row.width + units.gu(1)
3536 height: parent.height
@@ -38,36 +39,32 @@ Item {
3839 d.dismissAll();
3940 }
4041
41− WindowInputFilter {
42− id: altFilter
43− property bool altPressed: false
44− property bool longAltPressed: false
45− Keys.onPressed: {
46− if (event.key === Qt.Key_Alt && !event.isAutoRepeat) {
47− altPressed = true;
48− longAltPressed = false;
49− menuBarShortcutTimer.start();
50− return;
51− }
52− event.accepted = false;
42+ // Need 2 shortcuts because Alt press gives a different event to Alt release.
43+ GlobalShortcut {
44+ shortcut: Qt.Key_Alt|Qt.AltModifier
45+ active: enableKeyFilter
46+ onTriggered: {
47+ d.altPressed = true;
48+ d.longAltPressed = false;
49+ menuBarShortcutTimer.start();
5350 }
54− Keys.onReleased: {
55− if (event.key === Qt.Key_Alt) {
56− menuBarShortcutTimer.stop();
57− altPressed = false;
58− longAltPressed = false;
59− return;
60− }
61− event.accepted = false
51+ }
52+ GlobalShortcut {
53+ shortcut: Qt.Key_Alt
54+ active: enableKeyFilter
55+ onReleased: {
56+ menuBarShortcutTimer.stop();
57+ d.altPressed = false;
58+ d.longAltPressed = false;
6259 }
60+ }
6361
64− Timer {
65− id: menuBarShortcutTimer
66− interval: 200
67− repeat: false
68− onTriggered: {
69− altFilter.longAltPressed = true;
70− }
62+ Timer {
63+ id: menuBarShortcutTimer
64+ interval: 200
65+ repeat: false
66+ onTriggered: {
67+ d.longAltPressed = true;
7168 }
7269 }
7370
@@ -210,6 +207,9 @@ Item {
210207 property Item hoveredItem: null
211208 property Item prevCurrentItem: null
212209
210+ property bool altPressed: false
211+ property bool longAltPressed: false
212+
213213 signal dismissAll()
214214
215215 onCurrentItemChanged: {
qml/Panel/Panel.qml+5−1
@@ -104,7 +104,7 @@ Item {
104104 fill: panelAreaBackground
105105 bottomMargin: -units.gu(1)
106106 }
107− visible: PanelState.dropShadow && !callHint.visible
107+ visible: PanelState.dropShadow
108108 source: "graphics/rectangular_dropshadow.sci"
109109 }
110110
@@ -231,6 +231,8 @@ Item {
231231
232232 ActiveCallHint {
233233 id: callHint
234+ objectName: "callHint"
235+
234236 x: __applicationMenus.x + __applicationMenus.barWidth
235237 height: parent.height
236238
@@ -371,6 +373,8 @@ Item {
371373
372374 ActiveCallHint {
373375 id: callHint
376+ objectName: "callHint"
377+
374378 anchors.centerIn: parent
375379 height: minimizedPanelHeight
376380
qml/Stage/DecoratedWindow.qml−2
@@ -254,8 +254,6 @@ FocusScope {
254254 property var menus: surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : []
255255 property var menuService: menus.length > 0 ? menus[0] : undefined
256256
257− onMenuServiceChanged: console.log("MENU!", menuService.service, menuService.menuPath, menuService.actionPath)
258−
259257 busName: menuService ? menuService.service : ""
260258 menuObjectPath: menuService && menuService.menuPath ? menuService.menuPath : ""
261259 actions: menuService && menuService.actionPath ? { "unity": menuService.actionPath } : {}
qml/Stage/WindowDecoration.qml+5−7
@@ -57,12 +57,10 @@ MouseArea {
5757 id: priv
5858 property var menuBar: menuBarLoader.item
5959
60− property bool enableMenus: root.enableMenus &&
61− menuBar &&
62− menuBar.valid
63−
64− property bool shouldShowMenus : enableMenus &&
65− (menuBar.showRequested || root.containsMouse)
60+ property bool shouldShowMenus: root.enableMenus &&
61+ menuBar &&
62+ menuBar.valid &&
63+ (menuBar.showRequested || root.containsMouse)
6664 }
6765
6866 Rectangle {
@@ -144,7 +142,7 @@ MouseArea {
144142 MenuBar {
145143 id: menuBar
146144 height: menuBarLoader.height
147− enableKeyFilter: priv.enableMenus
145+ enableKeyFilter: root.active && valid
148146 unityMenuModel: root.menu
149147 }
150148 }
tests/qmltests/CMakeLists.txt+1−1
@@ -86,7 +86,7 @@ add_unity8_qmltest(Panel MenuContent)
8686add_unity8_qmltest(Panel Panel)
8787add_unity8_qmltest(Panel/Indicators IndicatorItem)
8888add_unity8_qmltest(Panel/Indicators IndicatorsLight)
89−add_unity8_qmltest(Panel/Indicators MenuItemFactory)
89+add_unity8_qmltest(Panel/Indicators IndicatorMenuItemFactory)
9090add_unity8_qmltest(Panel/Indicators MessageMenuItemFactory)
9191add_unity8_qmltest(Stage ApplicationWindow)
9292add_unity8_qmltest(Stage DesktopStage)
tests/qmltests/tst_Shell.qml+1−3
@@ -53,9 +53,7 @@ Rectangle {
5353 shellLoader.active = true;
5454 }
5555
56− DesktopMenuData {
57− id: appMenuData
58− }
56+ ApplicationMenuDataLoader {}
5957
6058 property var shell: shellLoader.item ? shellLoader.item : null
6159
tests/qmltests/tst_ShellWithPin.qml+3−1
@@ -463,7 +463,9 @@ Item {
463463
464464 ApplicationManager.requestFocusApplication("unity8-dash");
465465 tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
466− tryCompare(panel.callHint, "visible", true);
466+ var callHint = findChild(panel, "callHint");
467+ tryCompare(callHint, "visible", true);
468+ wait(10000)
467469
468470 // simulate a callHint press, the real thing requires dialer: url support
469471 ApplicationManager.requestFocusApplication("dialer-app");