@@ -31,12 +31,82 @@ FocusScope {
31 readonly property bool moving: appList && appList.moving
31 readonly property bool moving: appList && appList.moving
32 readonly property Item searchTextField: searchField
32 readonly property Item searchTextField: searchField
33 readonly property real delegateWidth: units.gu(10)
33 readonly property real delegateWidth: units.gu(10)
35+ property var fullyOpen: x === 0
36+ property var fullyClosed: x === -width
35 signal applicationSelected(string appId)
38 signal applicationSelected(string appId)
40+ // Request that the Drawer is opened fully, if it was partially closed then
44+ // Request that the Drawer (and maybe its parent) is hidden, normally if
45+ // the Drawer has been dragged away.
48+ property bool allowSlidingAnimation: false
37 property bool draggingHorizontally: false
49 property bool draggingHorizontally: false
38 property int dragDistance: 0
50 property int dragDistance: 0
52+ property var hadFocus: false
53+ property var oldSelectionStart: null
54+ property var oldSelectionEnd: null
57+ onRightMarginChanged: {
58+ if (fullyOpen && hadFocus) {
59+ // See onDraggingHorizontallyChanged below
60+ searchField.focus = hadFocus;
61+ searchField.select(oldSelectionStart, oldSelectionEnd);
63+ } else if (fullyClosed || fullyOpen) {
64+ searchField.text = "";
70+ Behavior on anchors.rightMargin {
71+ enabled: allowSlidingAnimation && !draggingHorizontally
74+ easing.type: Easing.OutCubic
78+ onDraggingHorizontallyChanged: {
79+ if (draggingHorizontally) {
80+ // Remove (and put back using anchors.onRightMarginChanged) the
81+ // focus for the searchfield in order to hide the copy/paste
82+ // popover when we move the drawer
83+ hadFocus = searchField.focus;
84+ oldSelectionStart = searchField.selectionStart;
85+ oldSelectionEnd = searchField.selectionEnd;
86+ searchField.focus = false;
88+ if (x < -units.gu(10)) {
96+ Keys.onEscapePressed: {
100+ onDragDistanceChanged: {
101+ anchors.rightMargin = Math.max(-drawer.width, anchors.rightMargin + dragDistance);
104+ function resetOldFocus() {
106+ oldSelectionStart = null;
107+ oldSelectionEnd = null;
40 function focusInput() {
110 function focusInput() {
41 searchField.selectAll();
111 searchField.selectAll();
42 searchField.focus = true;
112 searchField.focus = true;
@@ -96,6 +166,7 @@ FocusScope {
97 MouseArea {
167 MouseArea {
98 id: drawerHandle
168 id: drawerHandle
169+ objectName: "drawerHandle"
99 anchors {
170 anchors {
100 right: parent.right
171 right: parent.right
101 top: parent.top
172 top: parent.top