on xenial help sign in
Add a handle to the full-screen Drawer
a4366c2Dalton Durst
qml/Panel/Handle.qml → qml/Components/Handle.qmlrenamed+1
@@ -29,6 +29,7 @@ Rectangle {
29 height: childrenRect.height
29 height: childrenRect.height
30 anchors.centerIn: parent
30 anchors.centerIn: parent
31 spacing: units.gu(0.5)
31 spacing: units.gu(0.5)
32+ rotation: (parent.width >= parent.height) ? 0 : 90
32 Repeater {
33 Repeater {
33 model: 3
34 model: 3
34 delegate: Rectangle {
35 delegate: Rectangle {
qml/Launcher/Drawer.qml+46−3
@@ -32,7 +32,7 @@ FocusScope {
32
32
33 signal applicationSelected(string appId)
33 signal applicationSelected(string appId)
34
34
35− property bool firstOpen: true
35+ property bool handleVisible: false
36 property bool draggingHorizontally: false
36 property bool draggingHorizontally: false
37 property int dragDistance: 0
37 property int dragDistance: 0
38
38
@@ -73,6 +73,44 @@ FocusScope {
73 color: "#111111"
73 color: "#111111"
74 opacity: 0.99
74 opacity: 0.99
75
75
76+ MouseArea {
77+ id: drawerHandle
78+ anchors {
79+ right: parent.right
80+ top: parent.top
81+ bottom: parent.bottom
82+ }
83+ width: root.handleVisible ? units.gu(2) : 0
84+ property int oldX: 0
85+
86+ onPressed: {
87+ handle.active = true;
88+ oldX = mouseX;
89+ }
90+ onMouseXChanged: {
91+ var diff = oldX - mouseX;
92+ root.draggingHorizontally |= diff > units.gu(2);
93+ if (!root.draggingHorizontally) {
94+ return;
95+ }
96+ root.dragDistance += diff;
97+ oldX = mouseX
98+ }
99+ onReleased: reset()
100+ onCanceled: reset()
101+
102+ function reset() {
103+ root.draggingHorizontally = false;
104+ handle.active = false;
105+ }
106+
107+ Handle {
108+ id: handle
109+ anchors.fill: parent
110+ active: parent.pressed
111+ }
112+ }
113+
76 AppDrawerModel {
114 AppDrawerModel {
77 id: appDrawerModel
115 id: appDrawerModel
78 }
116 }
@@ -86,8 +124,13 @@ FocusScope {
86
124
87 Item {
125 Item {
88 id: contentContainer
126 id: contentContainer
89− anchors.fill: parent
127+ anchors {
128+ left: parent.left
129+ right: drawerHandle.left
130+ top: parent.top
131+ bottom: parent.bottom
90− anchors.leftMargin: root.panelWidth
132+ leftMargin: root.panelWidth
133+ }
91
134
92 Item {
135 Item {
93 id: searchFieldContainer
136 id: searchFieldContainer
qml/Launcher/Launcher.qml+8−8
@@ -167,7 +167,7 @@ FocusScope {
167 switchToNextState("visible")
167 switchToNextState("visible")
168 }
168 }
169
169
170− function openDrawer(focusInputField) {
170+ function toggleDrawer(focusInputField, onlyOpen) {
171 if (!drawerEnabled) {
171 if (!drawerEnabled) {
172 return;
172 return;
173 }
173 }
@@ -179,7 +179,7 @@ FocusScope {
179 if (focusInputField) {
179 if (focusInputField) {
180 drawer.focusInput();
180 drawer.focusInput();
181 }
181 }
182− if (state === "drawer") {
182+ if (state === "drawer" && !onlyOpen) {
183 switchToNextState("visible");
183 switchToNextState("visible");
184 } else {
184 } else {
185 switchToNextState("drawer");
185 switchToNextState("drawer");
@@ -357,14 +357,14 @@ FocusScope {
357 // See drawer.onDraggingHorizontallyChanged below
357 // See drawer.onDraggingHorizontallyChanged below
358 drawer.searchTextField.focus = hadFocus;
358 drawer.searchTextField.focus = hadFocus;
359 drawer.searchTextField.select(oldSelectionStart, oldSelectionEnd);
359 drawer.searchTextField.select(oldSelectionStart, oldSelectionEnd);
360− resetOldFocus();
361 } else if (fullyClosed) {
360 } else if (fullyClosed) {
362 drawer.searchTextField.text = "";
361 drawer.searchTextField.text = "";
363− resetOldFocus();
364 }
362 }
363+ resetOldFocus();
365 }
364 }
366 }
365 }
367− width: Math.min(root.width, units.gu(90)) * .9
366+ width: Math.min(root.width, units.gu(81))
367+ handleVisible: (width < units.gu(81))
368 panelWidth: panel.width
368 panelWidth: panel.width
369 visible: x > -width
369 visible: x > -width
370 property var fullyOpen: x === 0
370 property var fullyOpen: x === 0
@@ -414,7 +414,7 @@ FocusScope {
414 if (drawer.x < -units.gu(10)) {
414 if (drawer.x < -units.gu(10)) {
415 root.hide();
415 root.hide();
416 } else {
416 } else {
417− root.openDrawer();
417+ root.toggleDrawer(false, true);
418 }
418 }
419 }
419 }
420 }
420 }
@@ -497,7 +497,7 @@ FocusScope {
497 }
497 }
498 onPassed: {
498 onPassed: {
499 if (root.drawerEnabled) {
499 if (root.drawerEnabled) {
500− root.openDrawer()
500+ root.toggleDrawer()
501 }
501 }
502 }
502 }
503
503
@@ -573,7 +573,7 @@ FocusScope {
573 if (!dragging) {
573 if (!dragging) {
574 if (distance > panel.width / 2) {
574 if (distance > panel.width / 2) {
575 if (root.drawerEnabled && distance > panel.width * 3 && dragDirection() !== "left") {
575 if (root.drawerEnabled && distance > panel.width * 3 && dragDirection() !== "left") {
576− root.openDrawer(false)
576+ root.toggleDrawer(false)
577 } else {
577 } else {
578 root.switchToNextState("visible");
578 root.switchToNextState("visible");
579 }
579 }
qml/Shell.qml+9−9
@@ -235,7 +235,7 @@ StyledItem {
235 onHomeKeyActivated: {
235 onHomeKeyActivated: {
236 // Ignore when greeter is active, to avoid pocket presses
236 // Ignore when greeter is active, to avoid pocket presses
237 if (!greeter.active) {
237 if (!greeter.active) {
238− launcher.openDrawer(false);
238+ launcher.toggleDrawer(false);
239 }
239 }
240 }
240 }
241 onTouchBegun: { cursor.opacity = 0; }
241 onTouchBegun: { cursor.opacity = 0; }
@@ -344,7 +344,7 @@ StyledItem {
344 if (status !== TouchGestureArea.Recognized) {
344 if (status !== TouchGestureArea.Recognized) {
345 if (status === TouchGestureArea.WaitingForTouch) {
345 if (status === TouchGestureArea.WaitingForTouch) {
346 if (wasPressed && !dragging) {
346 if (wasPressed && !dragging) {
347− launcher.openDrawer(true);
347+ launcher.toggleDrawer(true);
348 }
348 }
349 }
349 }
350 wasPressed = false;
350 wasPressed = false;
@@ -375,7 +375,7 @@ StyledItem {
375 onLoaded: {
375 onLoaded: {
376 item.objectName = "greeter"
376 item.objectName = "greeter"
377 }
377 }
378− property bool openDrawerAfterUnlock: false
378+ property bool toggleDrawerAfterUnlock: false
379 Connections {
379 Connections {
380 target: greeter
380 target: greeter
381 onActiveChanged: {
381 onActiveChanged: {
@@ -383,9 +383,9 @@ StyledItem {
383 return
383 return
384
384
385 // Show drawer in case showHome() requests it
385 // Show drawer in case showHome() requests it
386− if (greeterLoader.openDrawerAfterUnlock) {
386+ if (greeterLoader.toggleDrawerAfterUnlock) {
387− launcher.openDrawer(false);
387+ launcher.toggleDrawer(false);
388− greeterLoader.openDrawerAfterUnlock = false;
388+ greeterLoader.toggleDrawerAfterUnlock = false;
389 }
389 }
390 // Show the launcher when there are no running apps
390 // Show the launcher when there are no running apps
391 else if (topLevelSurfaceList.count < 1) {
391 else if (topLevelSurfaceList.count < 1) {
@@ -499,9 +499,9 @@ StyledItem {
499 SessionBroadcast.requestHomeShown(AccountsService.user);
499 SessionBroadcast.requestHomeShown(AccountsService.user);
500 } else {
500 } else {
501 if (!greeter.active) {
501 if (!greeter.active) {
502− launcher.openDrawer(false);
502+ launcher.toggleDrawer(false);
503 } else {
503 } else {
504− greeterLoader.openDrawerAfterUnlock = true;
504+ greeterLoader.toggleDrawerAfterUnlock = true;
505 }
505 }
506 }
506 }
507 }
507 }
@@ -609,7 +609,7 @@ StyledItem {
609 GlobalShortcut {
609 GlobalShortcut {
610 shortcut: Qt.MetaModifier | Qt.Key_A
610 shortcut: Qt.MetaModifier | Qt.Key_A
611 onTriggered: {
611 onTriggered: {
612− launcher.openDrawer(true);
612+ launcher.toggleDrawer(true);
613 }
613 }
614 }
614 }
615 GlobalShortcut {
615 GlobalShortcut {
tests/qmltests/Launcher/tst_Drawer.qml+6−6
@@ -235,7 +235,7 @@ StyledItem {
235 function test_search() {
235 function test_search() {
236 compare(launcher.lastSelectedApplication, "");
236 compare(launcher.lastSelectedApplication, "");
237
237
238− launcher.openDrawer(true)
238+ launcher.toggleDrawer(true)
239 typeString("cam");
239 typeString("cam");
240 keyClick(Qt.Key_Enter);
240 keyClick(Qt.Key_Enter);
241
241
@@ -279,7 +279,7 @@ StyledItem {
279 keyClick(Qt.Key_Escape);
279 keyClick(Qt.Key_Escape);
280 waitForRendering(launcher);
280 waitForRendering(launcher);
281 waitUntilTransitionsEnd(launcher);
281 waitUntilTransitionsEnd(launcher);
282− launcher.openDrawer(true);
282+ launcher.toggleDrawer(true);
283 waitForRendering(launcher);
283 waitForRendering(launcher);
284 waitUntilTransitionsEnd(launcher);
284 waitUntilTransitionsEnd(launcher);
285
285
@@ -290,7 +290,7 @@ StyledItem {
290 }
290 }
291
291
292 function test_kbdNavigation() {
292 function test_kbdNavigation() {
293− launcher.openDrawer(true);
293+ launcher.toggleDrawer(true);
294 waitForRendering(launcher);
294 waitForRendering(launcher);
295 waitUntilTransitionsEnd(launcher);
295 waitUntilTransitionsEnd(launcher);
296 compare(launcher.lastSelectedApplication, "");
296 compare(launcher.lastSelectedApplication, "");
@@ -331,7 +331,7 @@ StyledItem {
331 // once https://codereview.qt-project.org/#/c/184942/ is accepted
331 // once https://codereview.qt-project.org/#/c/184942/ is accepted
332 skip();
332 skip();
333
333
334− launcher.openDrawer(true);
334+ launcher.toggleDrawer(true);
335 waitForRendering(launcher);
335 waitForRendering(launcher);
336 waitUntilTransitionsEnd(launcher);
336 waitUntilTransitionsEnd(launcher);
337
337
@@ -353,7 +353,7 @@ StyledItem {
353 keyClick(Qt.Key_Down);
353 keyClick(Qt.Key_Down);
354 tryCompare(panel, "highlightIndex", 0);
354 tryCompare(panel, "highlightIndex", 0);
355
355
356− launcher.openDrawer(true);
356+ launcher.toggleDrawer(true);
357 tryCompare(searchField, "focus", true);
357 tryCompare(searchField, "focus", true);
358
358
359 keyClick(Qt.Key_Escape);
359 keyClick(Qt.Key_Escape);
@@ -365,7 +365,7 @@ StyledItem {
365 }
365 }
366
366
367 function test_closeWhileDragging() {
367 function test_closeWhileDragging() {
368− launcher.openDrawer(true);
368+ launcher.toggleDrawer(true);
369 waitForRendering(launcher);
369 waitForRendering(launcher);
370 waitUntilTransitionsEnd(launcher);
370 waitUntilTransitionsEnd(launcher);
371
371
tests/qmltests/tst_Shell.qml+1−1
@@ -3130,7 +3130,7 @@ Rectangle {
3130 if (data.lockLauncher) {
3130 if (data.lockLauncher) {
3131 panel.applicationMenus.show();
3131 panel.applicationMenus.show();
3132 tryCompare(panel.applicationMenus, "fullyOpened", true);
3132 tryCompare(panel.applicationMenus, "fullyOpened", true);
3133− launcher.openDrawer();
3133+ launcher.toggleDrawer();
3134 } else {
3134 } else {
3135 tryCompare(launcher, "shown", false);
3135 tryCompare(launcher, "shown", false);
3136 panel.applicationMenus.show();
3136 panel.applicationMenus.show();