on xenial help sign in
Merge pull request #112 from ubports/xenial_-_edge_-_drawer-search-cuts
9eb391fRodney
qml/Launcher/Drawer.qml−6
@@ -35,12 +35,6 @@ FocusScope {
35 property bool draggingHorizontally: false
35 property bool draggingHorizontally: false
36 property int dragDistance: 0
36 property int dragDistance: 0
37
37
38− onFocusChanged: {
39− if (focus) {
40− searchField.selectAll();
41− }
42− }
43−
44 function focusInput() {
38 function focusInput() {
45 searchField.selectAll();
39 searchField.selectAll();
46 searchField.focus = true;
40 searchField.focus = true;
qml/Launcher/Launcher.qml+32−10
@@ -176,7 +176,6 @@ FocusScope {
176 superPressTimer.stop();
176 superPressTimer.stop();
177 superLongPressTimer.stop();
177 superLongPressTimer.stop();
178 root.focus = true;
178 root.focus = true;
179− drawer.focus = true;
180 if (focusInputField) {
179 if (focusInputField) {
181 drawer.focusInput();
180 drawer.focusInput();
182 }
181 }
@@ -350,19 +349,26 @@ FocusScope {
350 bottom: parent.bottom
349 bottom: parent.bottom
351 right: parent.left
350 right: parent.left
352 onRightMarginChanged: {
351 onRightMarginChanged: {
353− // Remove (and put back) the focus for the searchfield in
352+ if (fullyOpen && hadFocus) {
354− // order to hide the copy/paste popover when we move the drawer
353+ // See drawer.onDraggingHorizontallyChanged below
355− var hadFocus = drawer.searchTextField.focus;
356− var oldSelectionStart = drawer.searchTextField.selectionStart;
357− var oldSelectionEnd = drawer.searchTextField.selectionEnd;
358− drawer.searchTextField.focus = false;
359− drawer.searchTextField.focus = hadFocus;
354+ drawer.searchTextField.focus = hadFocus;
360− drawer.searchTextField.select(oldSelectionStart, oldSelectionEnd);
355+ drawer.searchTextField.select(oldSelectionStart, oldSelectionEnd);
356+ resetOldFocus();
357+ } else if (fullyClosed) {
358+ drawer.searchTextField.text = "";
359+ resetOldFocus();
360+ }
361 }
361 }
362 }
362 }
363 width: Math.min(root.width, units.gu(81))
363 width: Math.min(root.width, units.gu(81))
364 panelWidth: panel.width
364 panelWidth: panel.width
365 visible: x > -width
365 visible: x > -width
366+ property var fullyOpen: x === 0
367+ property var fullyClosed: x === -width
368+
369+ property var hadFocus: false
370+ property var oldSelectionStart: null
371+ property var oldSelectionEnd: null
366
372
367 Behavior on anchors.rightMargin {
373 Behavior on anchors.rightMargin {
368 enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate && !drawer.draggingHorizontally
374 enabled: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate && !drawer.draggingHorizontally
@@ -378,6 +384,12 @@ FocusScope {
378 root.focus = false;
384 root.focus = false;
379 }
385 }
380
386
387+ function resetOldFocus() {
388+ hadFocus = false;
389+ oldSelectionStart = null;
390+ oldSelectionEnd = null;
391+ }
392+
381 Keys.onEscapePressed: {
393 Keys.onEscapePressed: {
382 root.hide()
394 root.hide()
383 }
395 }
@@ -386,7 +398,15 @@ FocusScope {
386 anchors.rightMargin = Math.max(-drawer.width, anchors.rightMargin + dragDistance);
398 anchors.rightMargin = Math.max(-drawer.width, anchors.rightMargin + dragDistance);
387 }
399 }
388 onDraggingHorizontallyChanged: {
400 onDraggingHorizontallyChanged: {
389− if (!draggingHorizontally) {
401+ if (draggingHorizontally) {
402+ // Remove (and put back using anchors.onRightMarginChanged) the
403+ // focus for the searchfield in order to hide the copy/paste
404+ // popover when we move the drawer
405+ hadFocus = drawer.searchTextField.focus;
406+ oldSelectionStart = drawer.searchTextField.selectionStart;
407+ oldSelectionEnd = drawer.searchTextField.selectionEnd;
408+ drawer.searchTextField.focus = false;
409+ } else {
390 if (drawer.x < -units.gu(10)) {
410 if (drawer.x < -units.gu(10)) {
391 root.hide();
411 root.hide();
392 } else {
412 } else {
@@ -572,6 +592,7 @@ FocusScope {
572 PropertyChanges {
592 PropertyChanges {
573 target: drawer
593 target: drawer
574 anchors.rightMargin: 0
594 anchors.rightMargin: 0
595+ focus: false
575 }
596 }
576 },
597 },
577 State {
598 State {
@@ -591,6 +612,7 @@ FocusScope {
591 PropertyChanges {
612 PropertyChanges {
592 target: drawer
613 target: drawer
593 anchors.rightMargin: -drawer.width + root.x // so we never go past panelWidth, even when teased by tutorial
614 anchors.rightMargin: -drawer.width + root.x // so we never go past panelWidth, even when teased by tutorial
615+ focus: true
594 }
616 }
595 },
617 },
596 State {
618 State {