on xenial help sign in
Remove the ListViews from the Drawer

To simplify the Drawer code, I've removed all of the ListViews. This gets rid of the ability to have separate sorting options, however we can always bring this back later if we wish. Now the only available sorting is A-Z with no groups.

commit69b5391aa5dfa2e419eec0018cd687e8940f34c1 authorDalton Durst <d@ltondur.st> dateMon 1 Apr 2019, 16:28 (8 years ago) parentacc1ca9
3 files changed+51−185
qml/Launcher/Drawer.qml+47−147 qml/Launcher/DrawerGridView.qml+4 qml/Launcher/DrawerListView.qml−38
qml/Launcher/Drawer.qml+47−147
@@ -26,7 +26,7 @@ FocusScope {
2626 id: root
2727
2828 property int panelWidth: 0
29− readonly property bool moving: listLoader.item && listLoader.item.moving
29+ readonly property bool moving: singleGroupListView && singleGroupListView.moving
3030 readonly property Item searchTextField: searchField
3131 readonly property real delegateWidth: units.gu(10)
3232
@@ -51,10 +51,6 @@ FocusScope {
5151 event.accepted = true;
5252 }
5353
54− Settings {
55− property alias selectedTab: sections.selectedIndex
56− }
57−
5854 MouseArea {
5955 anchors.fill: parent
6056 hoverEnabled: true
@@ -83,60 +79,34 @@ FocusScope {
8379 anchors.fill: parent
8480 anchors.leftMargin: root.panelWidth
8581
86− TextField {
87− id: searchField
88− objectName: "searchField"
82+ Item {
83+ id: searchFieldContainer
84+ height: units.gu(4)
8985 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
90− placeholderText: i18n.tr("Search…")
91−
92− KeyNavigation.down: sections
9386
94− onAccepted: {
95− if (searchField.displayText != "" && listLoader.item) {
96− // In case there is no currentItem (it might have been filtered away) lets reset it to the first item
97− if (!listLoader.item.currentItem) {
98− listLoader.item.currentIndex = 0;
99− }
100− root.applicationSelected(listLoader.item.getFirstAppId());
87+ TextField {
88+ id: searchField
89+ objectName: "searchField"
90+ anchors {
91+ left: parent.left
92+ top: parent.top
93+ right: parent.right
94+ bottom: parent.bottom
95+ bottomMargin: units.gu(1)
10196 }
102− }
103− }
97+ placeholderText: i18n.tr("Search…")
98+ z: 100
10499
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
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− ]
100+ KeyNavigation.down: singleGroupListView
134101
135− Rectangle {
136− anchors.bottom: parent.bottom
137− height: units.dp(1)
138− color: 'gray'
139− width: contentContainer.width
102+ onAccepted: {
103+ if (searchField.displayText != "" && singleGroupListView) {
104+ // In case there is no currentItem (it might have been filtered away) lets reset it to the first item
105+ if (!appList.currentItem) {
106+ appList.currentIndex = 0;
107+ }
108+ root.applicationSelected(appList.getFirstAppId());
109+ }
140110 }
141111 }
142112 }
@@ -144,10 +114,10 @@ FocusScope {
144114 FocusScope {
145115 id: headerFocusScope
146116 objectName: "headerFocusScope"
147− KeyNavigation.up: sections
148− KeyNavigation.down: listLoader.item
149− KeyNavigation.backtab: sections
150− KeyNavigation.tab: listLoader.item
117+ KeyNavigation.up: searchField
118+ KeyNavigation.down: singleGroupListView
119+ KeyNavigation.backtab: searchField
120+ KeyNavigation.tab: singleGroupListView
151121 activeFocusOnTab: true
152122
153123 GSettings {
@@ -170,32 +140,9 @@ FocusScope {
170140 }
171141 }
172142
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−
196143 MouseArea {
197144 id: horizontalDragDetector
198− parent: listLoader.item ? listLoader.item : null
145+ parent: singleGroupListView
199146 anchors.fill: parent
200147 propagateComposedEvents: true
201148 property int oldX: 0
@@ -227,83 +174,37 @@ FocusScope {
227174 }
228175 }
229176
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 {
243− width: parent.width - units.gu(2)
244− anchors.horizontalCenter: parent.horizontalCenter
245−
246− readonly property string appId: model.appId
247−
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− }
177+ Item {
178+ anchors {
179+ left: parent.left
180+ right: parent.right
181+ top: searchFieldContainer.bottom
182+ bottom: parent.bottom
270183 }
271− }
184+ z: 1
185+
186+ Flickable {
187+ id: singleGroupListView
188+ clip: true
272189
273− Component {
274− id: aToZComponent
275− DrawerListView {
276− id: aToZListView
190+ contentHeight: appListContainer.height
277191
278− model: AppDrawerProxyModel {
279− source: sortProxyModel
280− sortBy: AppDrawerProxyModel.SortByAToZ
281− group: AppDrawerProxyModel.GroupByAToZ
282− dynamicSortFilter: false
283− }
192+ anchors.fill: parent
284193
285− delegate: UbuntuShape {
194+ Item {
195+ id: appListContainer
286196 width: parent.width - units.gu(2)
287197 anchors.horizontalCenter: parent.horizontalCenter
288− color: "#20ffffff"
289− aspect: UbuntuShape.Flat
290198
291199 readonly property string appId: model.appId
292200
293201 // NOTE: Cannot use gridView.rows here as it would evaluate to 0 at first and only update later,
294202 // which messes up the ListView.
295− height: (Math.ceil(gridView.model.count / gridView.columns) * gridView.delegateHeight) +
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− }
203+ height: (Math.ceil(appList.model.count / appList.columns) * appList.delegateHeight) + units.gu(2)
303204
304205 DrawerGridView {
305− id: gridView
306− anchors { left: parent.left; top: categoryNameLabel.bottom; right: parent.right; topMargin: units.gu(1) }
206+ id: appList
207+ anchors { left: parent.left; top: parent.top; right: parent.right; topMargin: units.gu(1) }
307208 height: rows * delegateHeight
308209
309210 interactive: false
@@ -312,7 +213,6 @@ FocusScope {
312213 model: AppDrawerProxyModel {
313214 id: categoryModel
314215 source: sortProxyModel
315− filterLetter: model.letter
316216 dynamicSortFilter: false
317217 }
318218 delegateWidth: root.delegateWidth
qml/Launcher/DrawerGridView.qml+4
@@ -46,4 +46,8 @@ FocusScope {
4646 cellWidth: root.delegateWidth + spacing
4747 cellHeight: root.delegateHeight
4848 }
49+
50+ function getFirstAppId() {
51+ return model.appId(0);
52+ }
4953}
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−}