on xenial help sign in
Remove the ListViews from the Drawer
69b5391Dalton Durst
qml/Launcher/Drawer.qml+47−147
@@ -26,7 +26,7 @@ FocusScope {
26 id: root
26 id: root
27
27
28 property int panelWidth: 0
28 property int panelWidth: 0
29− readonly property bool moving: listLoader.item && listLoader.item.moving
29+ readonly property bool moving: singleGroupListView && singleGroupListView.moving
30 readonly property Item searchTextField: searchField
30 readonly property Item searchTextField: searchField
31 readonly property real delegateWidth: units.gu(10)
31 readonly property real delegateWidth: units.gu(10)
32
32
@@ -51,10 +51,6 @@ FocusScope {
51 event.accepted = true;
51 event.accepted = true;
52 }
52 }
53
53
54− Settings {
55− property alias selectedTab: sections.selectedIndex
56− }
57−
58 MouseArea {
54 MouseArea {
59 anchors.fill: parent
55 anchors.fill: parent
60 hoverEnabled: true
56 hoverEnabled: true
@@ -83,60 +79,34 @@ FocusScope {
83 anchors.fill: parent
79 anchors.fill: parent
84 anchors.leftMargin: root.panelWidth
80 anchors.leftMargin: root.panelWidth
85
81
86− TextField {
82+ Item {
87− id: searchField
83+ id: searchFieldContainer
88− objectName: "searchField"
84+ height: units.gu(4)
89 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
85 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
90− placeholderText: i18n.tr("Search…")
91−
92− KeyNavigation.down: sections
93
86
94− onAccepted: {
87+ TextField {
95− if (searchField.displayText != "" && listLoader.item) {
88+ id: searchField
96− // In case there is no currentItem (it might have been filtered away) lets reset it to the first item
89+ objectName: "searchField"
97− if (!listLoader.item.currentItem) {
90+ anchors {
98− listLoader.item.currentIndex = 0;
91+ left: parent.left
99− }
92+ top: parent.top
100− root.applicationSelected(listLoader.item.getFirstAppId());
93+ right: parent.right
94+ bottom: parent.bottom
95+ bottomMargin: units.gu(1)
101 }
96 }
102− }
97+ placeholderText: i18n.tr("Search…")
103− }
98+ z: 100
104
99
105− Item {
106− id: sectionsContainer
107− anchors { left: parent.left; top: searchField.bottom; right: parent.right; }
108− height: sections.height
109− clip: true
110− z: 2
111−
112− Sections {
113− id: sections
114− objectName: "drawerSections"
115− width: parent.width
116−
117− KeyNavigation.up: searchField
118− KeyNavigation.down: headerFocusScope
100+ KeyNavigation.down: singleGroupListView
119− KeyNavigation.backtab: searchField
120− KeyNavigation.tab: headerFocusScope
121−
122− actions: [
123− Action {
124− text: i18n.tr("Apps")
125− },
126− Action {
127− text: i18n.ctr("Apps sorted and grouped alphabetically", "A-Z")
128− // TODO: Disabling this for now as we don't get the right input from u-a-l yet.
129− // },
130− // Action {
131− // text: i18n.ctr("Most used apps", "Most used")
132− }
133− ]
134
101
135− Rectangle {
102+ onAccepted: {
136− anchors.bottom: parent.bottom
103+ if (searchField.displayText != "" && singleGroupListView) {
137− height: units.dp(1)
104+ // In case there is no currentItem (it might have been filtered away) lets reset it to the first item
138− color: 'gray'
105+ if (!appList.currentItem) {
139− width: contentContainer.width
106+ appList.currentIndex = 0;
107+ }
108+ root.applicationSelected(appList.getFirstAppId());
109+ }
140 }
110 }
141 }
111 }
142 }
112 }
@@ -144,10 +114,10 @@ FocusScope {
144 FocusScope {
114 FocusScope {
145 id: headerFocusScope
115 id: headerFocusScope
146 objectName: "headerFocusScope"
116 objectName: "headerFocusScope"
147− KeyNavigation.up: sections
117+ KeyNavigation.up: searchField
148− KeyNavigation.down: listLoader.item
118+ KeyNavigation.down: singleGroupListView
149− KeyNavigation.backtab: sections
119+ KeyNavigation.backtab: searchField
150− KeyNavigation.tab: listLoader.item
120+ KeyNavigation.tab: singleGroupListView
151 activeFocusOnTab: true
121 activeFocusOnTab: true
152
122
153 GSettings {
123 GSettings {
@@ -170,32 +140,9 @@ FocusScope {
170 }
140 }
171 }
141 }
172
142
173− Loader {
174− id: listLoader
175− objectName: "drawerListLoader"
176− anchors { left: parent.left; top: sectionsContainer.bottom; right: parent.right; bottom: parent.bottom }
177−
178− KeyNavigation.up: headerFocusScope
179− KeyNavigation.down: searchField
180− KeyNavigation.backtab: headerFocusScope
181− KeyNavigation.tab: searchField
182−
183− sourceComponent: {
184− switch (sections.selectedIndex) {
185− case 0: return singleGroupComponent;
186− case 1: return aToZComponent;
187− }
188− }
189− Binding {
190− target: listLoader.item || null
191− property: "objectName"
192− value: "drawerItemList"
193− }
194− }
195−
196 MouseArea {
143 MouseArea {
197 id: horizontalDragDetector
144 id: horizontalDragDetector
198− parent: listLoader.item ? listLoader.item : null
145+ parent: singleGroupListView
199 anchors.fill: parent
146 anchors.fill: parent
200 propagateComposedEvents: true
147 propagateComposedEvents: true
201 property int oldX: 0
148 property int oldX: 0
@@ -227,83 +174,37 @@ FocusScope {
227 }
174 }
228 }
175 }
229
176
230− Component {
231− id: singleGroupComponent
232− DrawerListView {
233− id: singleGroupListView
234−
235− model: ListModel {
236− id: singleGroupModel
237− Component.onCompleted: {
238− append({"name": i18n.tr("Apps")});
239− }
240− }
241−
242− delegate: Item {
177+ Item {
243− width: parent.width - units.gu(2)
178+ anchors {
244− anchors.horizontalCenter: parent.horizontalCenter
179+ left: parent.left
245−
180+ right: parent.right
246− readonly property string appId: model.appId
181+ top: searchFieldContainer.bottom
247−
182+ bottom: parent.bottom
248− // NOTE: Cannot use gridView.rows here as it would evaluate to 0 at first and only update later,
249− // which messes up the ListView.
250− height: (Math.ceil(gridView.model.count / gridView.columns) * gridView.delegateHeight) + units.gu(2)
251−
252− DrawerGridView {
253− id: gridView
254− anchors { left: parent.left; top: parent.top; right: parent.right; topMargin: units.gu(1) }
255− height: rows * delegateHeight
256−
257− interactive: false
258− focus: index == aToZListView.currentIndex
259−
260− model: AppDrawerProxyModel {
261− id: categoryModel
262− source: sortProxyModel
263− dynamicSortFilter: false
264− }
265− delegateWidth: root.delegateWidth
266− delegateHeight: units.gu(11)
267− delegate: drawerDelegateComponent
268− }
269− }
270 }
183 }
271− }
184+ z: 1
185+
186+ Flickable {
187+ id: singleGroupListView
188+ clip: true
272
189
273− Component {
190+ contentHeight: appListContainer.height
274− id: aToZComponent
275− DrawerListView {
276− id: aToZListView
277
191
278− model: AppDrawerProxyModel {
192+ anchors.fill: parent
279− source: sortProxyModel
280− sortBy: AppDrawerProxyModel.SortByAToZ
281− group: AppDrawerProxyModel.GroupByAToZ
282− dynamicSortFilter: false
283− }
284
193
285− delegate: UbuntuShape {
194+ Item {
195+ id: appListContainer
286 width: parent.width - units.gu(2)
196 width: parent.width - units.gu(2)
287 anchors.horizontalCenter: parent.horizontalCenter
197 anchors.horizontalCenter: parent.horizontalCenter
288− color: "#20ffffff"
289− aspect: UbuntuShape.Flat
290
198
291 readonly property string appId: model.appId
199 readonly property string appId: model.appId
292
200
293 // NOTE: Cannot use gridView.rows here as it would evaluate to 0 at first and only update later,
201 // NOTE: Cannot use gridView.rows here as it would evaluate to 0 at first and only update later,
294 // which messes up the ListView.
202 // which messes up the ListView.
295− height: (Math.ceil(gridView.model.count / gridView.columns) * gridView.delegateHeight) +
203+ height: (Math.ceil(appList.model.count / appList.columns) * appList.delegateHeight) + units.gu(2)
296− categoryNameLabel.implicitHeight + units.gu(2)
297−
298− Label {
299− id: categoryNameLabel
300− anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
301− text: model.letter
302− }
303
204
304 DrawerGridView {
205 DrawerGridView {
305− id: gridView
206+ id: appList
306− anchors { left: parent.left; top: categoryNameLabel.bottom; right: parent.right; topMargin: units.gu(1) }
207+ anchors { left: parent.left; top: parent.top; right: parent.right; topMargin: units.gu(1) }
307 height: rows * delegateHeight
208 height: rows * delegateHeight
308
209
309 interactive: false
210 interactive: false
@@ -312,7 +213,6 @@ FocusScope {
312 model: AppDrawerProxyModel {
213 model: AppDrawerProxyModel {
313 id: categoryModel
214 id: categoryModel
314 source: sortProxyModel
215 source: sortProxyModel
315− filterLetter: model.letter
316 dynamicSortFilter: false
216 dynamicSortFilter: false
317 }
217 }
318 delegateWidth: root.delegateWidth
218 delegateWidth: root.delegateWidth
qml/Launcher/DrawerGridView.qml+4
@@ -46,4 +46,8 @@ FocusScope {
46 cellWidth: root.delegateWidth + spacing
46 cellWidth: root.delegateWidth + spacing
47 cellHeight: root.delegateHeight
47 cellHeight: root.delegateHeight
48 }
48 }
49+
50+ function getFirstAppId() {
51+ return model.appId(0);
52+ }
49}
53}
qml/Launcher/DrawerListView.qmldeleted−38
@@ -1,38 +0,0 @@
1−/*
2− * Copyright (C) 2016 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−import "../Components"
20−
21−ListView {
22− id: root
23− anchors.fill: parent
24− topMargin: units.gu(1)
25− bottomMargin: units.gu(1)
26− spacing: units.gu(1)
27− clip: true
28− focus: true
29−
30− onActiveFocusChanged: {
31− currentIndex = -1;
32− currentIndex = 0;
33− }
34−
35− function getFirstAppId() {
36− return model.appId(0);
37− }
38−}