on 5ea3c69 help sign in
unity8/qml/Launcher/DrawerGridView.qml
86 lines 2.7 kB history raw
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 * Copyright (C) 2020 UBports Foundation.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
18import QtQuick 2.4
19import Ubuntu.Components 1.3
20import "../Components"
22FocusScope {
23 id: root
25 property int delegateWidth: units.gu(11)
26 property int delegateHeight: units.gu(11)
27 property alias delegate: gridView.delegate
28 property alias model: gridView.model
29 property alias interactive: gridView.interactive
30 property alias currentIndex: gridView.currentIndex
31 property alias draggingVertically: gridView.draggingVertically
33 property alias header: gridView.header
34 property alias topMargin: gridView.topMargin
35 property alias bottomMargin: gridView.bottomMargin
37 readonly property int columns: width / delegateWidth
38 readonly property int rows: Math.ceil(gridView.model.count / root.columns)
40 property alias refreshing: pullToRefresh.refreshing
41 signal refresh();
43 GridView {
44 id: gridView
45 anchors.fill: parent
46 anchors.topMargin: units.gu(2)
47 leftMargin: spacing
48 focus: true
50 readonly property int overflow: width - (root.columns * root.delegateWidth)
51 readonly property real spacing: overflow / (root.columns)
53 cellWidth: root.delegateWidth + spacing
54 cellHeight: root.delegateHeight
56 PullToRefresh {
57 id: pullToRefresh
58 parent: gridView
59 target: gridView
61 readonly property real contentY: gridView.contentY - gridView.originY
62 y: -contentY - units.gu(5)
64 readonly property color pullLabelColor: "white"
65 style: PullToRefreshScopeStyle {
66 activationThreshold: Math.min(units.gu(14), gridView.height / 5)
67 }
69 onRefresh: root.refresh();
70 }
71 }
73 ProgressBar {
74 anchors {
75 left: parent.left
76 right: parent.right
77 bottom: parent.bottom
78 }
79 visible: refreshing
80 indeterminate: true
81 }
83 function getFirstAppId() {
84 return model.appId(0);
85 }