on xenial help sign in
Improve Launcher ←→ touch menu interaction

Needs to move the label from PanelItemRow to Panel because how clipping works in those items (and fixes some other problems too) If launcher is locked visible:      * Touch menus show shifted to the right to not overlap      * Showing the app drawer closes the touch menus      * Showing the touch menus closes the app drawer If launcher is not locked visible:      * Showing the launcher closes the touch menus      * Showing the touch menus closes the launcher (LP: #1667620, #1671069) Approved by: Lukáš Tinkl, Unity8 CI Bot

commite1dd3c767000938fd1654df80547a9fd1ed83e15 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 21 Mar 2017, 10:55 (10 years ago) parent799e37ca76e6d3
7 files changed+139−59
qml/Panel/Panel.qml+26−2 qml/Panel/PanelBar.qml+1−2 qml/Panel/PanelItemRow.qml+3−23 qml/Panel/PanelMenu.qml+34−23 qml/Shell.qml+9−1 tests/qmltests/Panel/tst_Panel.qml+10−7 tests/qmltests/tst_Shell.qml+56−1
qml/Panel/Panel.qml+26−2
@@ -38,6 +38,7 @@ Item {
3838 property real expandedPanelHeight: units.gu(7)
3939 property real indicatorMenuWidth: width
4040 property real applicationMenuWidth: width
41+ property alias applicationMenuContentX: __applicationMenus.menuContentX
4142
4243 property alias applicationMenus: __applicationMenus
4344 property alias indicators: __indicators
@@ -256,6 +257,7 @@ Item {
256257 PanelMenu {
257258 id: __applicationMenus
258259
260+ x: menuContentX
259261 model: registeredMenuModel.model
260262 width: root.applicationMenuWidth
261263 minimizedPanelHeight: root.minimizedPanelHeight
@@ -264,6 +266,7 @@ Item {
264266 alignment: Qt.AlignLeft
265267 enableHint: !callHint.active && !fullscreenMode
266268 showOnClick: false
269+ adjustDragHandleSizeToContents: false
267270 panelColor: panelAreaBackground.color
268271
269272 onShowTapped: {
@@ -272,8 +275,7 @@ Item {
272275 }
273276 }
274277
275− showRowTitle: !expanded
276− rowTitle: PanelState.title
278+ hideRow: !expanded
277279 rowItemDelegate: ActionItem {
278280 id: actionItem
279281 property int ownIndex: index
@@ -322,6 +324,28 @@ Item {
322324 }
323325 }
324326
327+ Label {
328+ id: rowLabel
329+ objectName: "panelTitle"
330+ anchors {
331+ left: parent.left
332+ leftMargin: units.gu(1)
333+ right: __indicators.left
334+ rightMargin: units.gu(1)
335+ }
336+ height: root.minimizedPanelHeight
337+ verticalAlignment: Text.AlignVCenter
338+ elide: Text.ElideRight
339+ maximumLineCount: 1
340+ fontSize: "medium"
341+ font.weight: Font.Medium
342+ color: Theme.palette.selected.backgroundText
343+ opacity: __applicationMenus.visible && !__applicationMenus.expanded ? 1 : 0
344+ visible: opacity != 0
345+ Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
346+ text: PanelState.title
347+ }
348+
325349 PanelMenu {
326350 id: __indicators
327351 objectName: "indicators"
qml/Panel/PanelBar.qml+1−2
@@ -30,8 +30,7 @@ Item {
3030 property real lateralPosition: -1
3131 property int alignment: Qt.AlignRight
3232
33− property alias showRowTitle: row.showRowTitle
34− property alias rowTitle: row.rowTitle
33+ property alias hideRow: row.hideRow
3534 property alias rowItemDelegate: row.delegate
3635
3736 implicitWidth: flickable.contentWidth
qml/Panel/PanelItemRow.qml+3−23
@@ -20,11 +20,10 @@ import "../Components"
2020
2121Item {
2222 id: root
23− implicitWidth: showRowTitle && !expanded ? rowTitle != "" ? rowLabel.width : 0 : row.width
23+ implicitWidth: row.width
2424 implicitHeight: units.gu(3)
2525
26− property bool showRowTitle: false
27− property alias rowTitle: rowLabel.text
26+ property bool hideRow: false
2827 property QtObject model: null
2928 property real overFlowWidth: width
3029 property bool expanded: false
@@ -164,31 +163,12 @@ Item {
164163 d.previousItem = currentItem;
165164 }
166165
167− Label {
168− id: rowLabel
169− objectName: "panelTitle"
170− anchors {
171− left: parent.left
172− leftMargin: units.gu(1)
173− verticalCenter: parent.verticalCenter
174− }
175− width: implicitWidth + units.gu(2)
176− elide: Text.ElideRight
177− maximumLineCount: 1
178− fontSize: "medium"
179− font.weight: Font.Medium
180− color: Theme.palette.selected.backgroundText
181− opacity: showRowTitle ? 1 : 0
182− visible: opacity != 0
183− Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
184− }
185−
186166 ListView {
187167 id: row
188168 objectName: "panelRow"
189169 orientation: ListView.Horizontal
190170 model: root.model
191− opacity: showRowTitle ? 0 : 1
171+ opacity: hideRow ? 0 : 1
192172 // dont set visible on basis of opacity; otherwise width will not be calculated correctly
193173 anchors {
194174 top: parent.top
qml/Panel/PanelMenu.qml+34−23
@@ -32,11 +32,12 @@ Showable {
3232 property real openedHeight: units.gu(71)
3333 property bool enableHint: true
3434 property bool showOnClick: true
35+ property bool adjustDragHandleSizeToContents: true
3536 property color panelColor: theme.palette.normal.background
37+ property real menuContentX: 0
3638
3739 property alias alignment: bar.alignment
38− property alias rowTitle: bar.rowTitle
39− property alias showRowTitle: bar.showRowTitle
40+ property alias hideRow: bar.hideRow
4041 property alias rowItemDelegate: bar.rowItemDelegate
4142 property alias pageDelegate: content.pageDelegate
4243
@@ -45,7 +46,7 @@ Showable {
4546 readonly property bool partiallyOpened: unitProgress > 0 && unitProgress < 1.0
4647 readonly property bool fullyClosed: unitProgress == 0
4748 readonly property alias expanded: bar.expanded
48− readonly property int barWidth: Math.min(bar.width, bar.implicitWidth)
49+ readonly property int barWidth: adjustDragHandleSizeToContents ? Math.min(bar.width, bar.implicitWidth) : bar.width
4950 readonly property alias currentMenuIndex: bar.currentItemIndex
5051
5152 signal showTapped()
@@ -78,33 +79,42 @@ Showable {
7879
7980 shown: false
8081 height: minimizedPanelHeight
81− clip: root.partiallyOpened
8282
8383 onUnitProgressChanged: d.updateState()
8484
85− // eater
86− MouseArea {
87− anchors.fill: content
88− hoverEnabled: true
89− acceptedButtons: Qt.AllButtons
90− onWheel: wheel.accepted = true;
91− enabled: root.state != "initial"
92− visible: content.visible
93− }
94−
95− MenuContent {
96− id: content
97− objectName: "menuContent"
98−
85+ Item {
9986 anchors {
10087 left: parent.left
10188 right: parent.right
10289 top: bar.bottom
90+ bottom: parent.bottom
91+ }
92+ clip: root.partiallyOpened
93+
94+ // eater
95+ MouseArea {
96+ anchors.fill: content
97+ hoverEnabled: true
98+ acceptedButtons: Qt.AllButtons
99+ onWheel: wheel.accepted = true;
100+ enabled: root.state != "initial"
101+ visible: content.visible
102+ }
103+
104+ MenuContent {
105+ id: content
106+ objectName: "menuContent"
107+
108+ anchors {
109+ left: parent.left
110+ right: parent.right
111+ top: parent.top
112+ }
113+ height: openedHeight - bar.height - handle.height
114+ model: root.model
115+ visible: root.unitProgress > 0
116+ currentMenuIndex: bar.currentItemIndex
103117 }
104− height: openedHeight - bar.height - handle.height
105− model: root.model
106− visible: root.unitProgress > 0
107− currentMenuIndex: bar.currentItemIndex
108118 }
109119
110120 Handle {
@@ -218,8 +228,9 @@ Showable {
218228 objectName: "showDragHandle"
219229 anchors.bottom: parent.bottom
220230 anchors.left: alignment == Qt.AlignLeft ? parent.left : undefined
231+ anchors.leftMargin: -root.menuContentX
221232 anchors.right: alignment == Qt.AlignRight ? parent.right : undefined
222− width: root.barWidth // show handle should only cover panel items.
233+ width: root.barWidth + root.menuContentX // show handle should only cover panel items.
223234 height: minimizedPanelHeight
224235 direction: Direction.Downwards
225236 enabled: !root.shown && root.available
qml/Shell.qml+9−1
@@ -502,6 +502,7 @@ StyledItem {
502502 expandedPanelHeight: units.gu(7)
503503 indicatorMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
504504 applicationMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
505+ applicationMenuContentX: launcher.lockedVisible ? launcher.panelWidth : 0
505506
506507 indicators {
507508 hides: [launcher]
@@ -570,7 +571,14 @@ StyledItem {
570571 }
571572 onShownChanged: {
572573 if (shown) {
573− panel.indicators.hide()
574+ panel.indicators.hide();
575+ panel.applicationMenus.hide();
576+ }
577+ }
578+ onDrawerShownChanged: {
579+ if (drawerShown) {
580+ panel.indicators.hide();
581+ panel.applicationMenus.hide();
574582 }
575583 }
576584 onFocusChanged: {
tests/qmltests/Panel/tst_Panel.qml+10−7
@@ -320,12 +320,15 @@ PanelTest {
320320 tryCompare(panel.indicators, "fullyOpened", true);
321321 }
322322
323− function pullDownApplicationsMenu() {
323+ function pullDownApplicationsMenu(xPos) {
324324 var showDragHandle = findChild(panel.applicationMenus, "showDragHandle");
325+ if (xPos === undefined) {
326+ xPos = showDragHandle.width / 2;
327+ }
325328 touchFlick(showDragHandle,
326− showDragHandle.width / 2,
329+ xPos,
327330 showDragHandle.height / 2,
328− showDragHandle.width / 2,
331+ xPos,
329332 showDragHandle.height / 2 + (showDragHandle.autoCompleteDragThreshold * 1.1));
330333 tryCompare(panel.applicationMenus, "fullyOpened", true);
331334 }
@@ -774,7 +777,7 @@ PanelTest {
774777 panel.mode = "staged";
775778 mouseEmulation.checked = false;
776779
777− var appTitle = findChild(panel.applicationMenus, "panelTitle"); verify(appTitle);
780+ var appTitle = findChild(panel, "panelTitle"); verify(appTitle);
778781 var appMenuRow = findChild(panel.applicationMenus, "panelRow"); verify(appMenuRow);
779782 var appMenuBar = findChild(panel, "menuBar"); verify(appMenuBar);
780783
@@ -792,7 +795,7 @@ PanelTest {
792795 panel.mode = "windowed";
793796 mouseEmulation.checked = false;
794797
795− var appTitle = findChild(panel.applicationMenus, "panelTitle"); verify(appTitle);
798+ var appTitle = findChild(panel, "panelTitle"); verify(appTitle);
796799 var appMenuRow = findChild(panel.applicationMenus, "panelRow"); verify(appMenuRow);
797800 var appMenuBar = findChild(panel, "menuBar"); verify(appMenuBar);
798801
@@ -853,7 +856,7 @@ PanelTest {
853856 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
854857
855858 PanelState.title = "Fake Title"
856− pullDownApplicationsMenu();
859+ pullDownApplicationsMenu(0 /*xPos*/);
857860 compare(aboutToShowCalledSpy.count, 1);
858861
859862 keyClick(Qt.Key_Right);
@@ -886,7 +889,7 @@ PanelTest {
886889 var indicatorsBar = findChild(panel.applicationMenus, "indicatorsBar");
887890
888891 PanelState.title = "Fake Title"
889− pullDownApplicationsMenu();
892+ pullDownApplicationsMenu(0 /*xPos*/);
890893
891894 tryCompare(indicatorsBar, "currentItemIndex", 0);
892895
tests/qmltests/tst_Shell.qml+56−1
@@ -2865,7 +2865,7 @@ Rectangle {
28652865 loadShell(data.tag);
28662866
28672867 var panel = findChild(shell, "panel"); verify(panel);
2868− var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2868+ var panelTitle = findChild(panel, "panelTitle"); verify(panelTitle);
28692869 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
28702870
28712871 swipeAwayGreeter();
@@ -3038,6 +3038,61 @@ Rectangle {
30383038 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
30393039 }
30403040
3041+ function test_touchMenuPosition_data() {
3042+ return [
3043+ { tag: "launcher locked", lockLauncher: true },
3044+ { tag: "launcher not locked", lockLauncher: false }
3045+ ];
3046+ }
3047+
3048+ function test_touchMenuPosition(data) {
3049+ loadShell("desktop");
3050+ shell.usageScenario = "desktop";
3051+ waitForRendering(shell);
3052+ swipeAwayGreeter();
3053+
3054+ var panel = findChild(shell, "panel");
3055+ var launcher = testCase.findChild(shell, "launcher");
3056+ launcher.lockedVisible = data.lockLauncher;
3057+ if (data.lockLauncher) {
3058+ compare(panel.applicationMenus.x, launcher.panelWidth);
3059+ } else {
3060+ compare(panel.applicationMenus.x, 0);
3061+ }
3062+ }
3063+
3064+ function test_touchMenuHidesOnLauncherAppDrawer_data() {
3065+ return [
3066+ { tag: "launcher locked", lockLauncher: true },
3067+ { tag: "launcher not locked", lockLauncher: false }
3068+ ];
3069+ }
3070+
3071+ function test_touchMenuHidesOnLauncherAppDrawer(data) {
3072+ loadShell("desktop");
3073+ shell.usageScenario = "desktop";
3074+ waitForRendering(shell);
3075+ swipeAwayGreeter();
3076+
3077+ var panel = findChild(shell, "panel");
3078+ var launcher = testCase.findChild(shell, "launcher");
3079+ launcher.lockedVisible = data.lockLauncher;
3080+
3081+ waitForRendering(panel.applicationMenus);
3082+
3083+ if (data.lockLauncher) {
3084+ panel.applicationMenus.show();
3085+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3086+ launcher.openDrawer();
3087+ } else {
3088+ tryCompare(launcher, "shown", false);
3089+ panel.applicationMenus.show();
3090+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3091+ launcher.switchToNextState("visible");
3092+ }
3093+ tryCompare(panel.applicationMenus, "fullyClosed", true);
3094+ }
3095+
30413096 function test_doubleClickPanelRestoresWindow() {
30423097 loadShell("desktop");
30433098 shell.usageScenario = "desktop";