on xenial help sign in
Move Base.qml to DashCategoryBase

It's the only place we use it and we can simplify stuff quite a bit Approved by: Michael Zanetti

commit08613d902cc413d5cdb789f34bbf856a86ca71dd authorAlbert Astals <albert.astals@canonical.com> dateMon 13 Oct 2014, 15:41 (12 years ago) parentabb33d571f40d2
5 files changed+64−165
qml/Components/ListItems/Base.qml−116 qml/Components/ListItems/Highlight.qml−46 qml/Dash/DashCategoryBase.qml+62 qml/Dash/GenericScopeView.qml+1−2 tests/autopilot/unity8/shell/emulators/dash.py+1−1
qml/Components/ListItems/Base.qmldeleted−116
@@ -1,116 +0,0 @@
1−/*
2− * Copyright (C) 2012 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.0
18−import Ubuntu.Components 0.1
19−
20−Item {
21− id: emptyListItem
22− width: parent ? parent.width : units.gu(31)
23− height: body.height + bottomDividerLine.height
24−
25− /*!
26− \preliminary
27− Specifies whether the list item is selected.
28− */
29− property bool selected: false
30−
31− /*!
32− \preliminary
33− Set to show or hide the thin bottom divider line (drawn by the \l ThinDivider component).
34− This line is shown by default except in cases where this item is the delegate of a ListView.
35− */
36− property bool showDivider: __showDivider()
37−
38− /*!
39− \internal
40− Method to automatically determine if the bottom divider line should be drawn.
41− This always returns true, unless item is a delegate in a ListView. If in a ListView
42− it will return false only when:
43− + if this is the final item in the list, and ListView.footer is set (again as thin
44− divider line won't look well with footer below it)
45− */
46− function __showDivider() {
47− // if we're not in ListView, always show a thin dividing line at the bottom
48− var model = null;
49− if (typeof ListViewWithPageHeader !== 'undefined') {
50− if (typeof ListViewWithPageHeader.model !== 'undefined') {
51− model = ListViewWithPageHeader.model;
52− }
53− } else if (ListView.view !== null) {
54− model = ListView.view.model;
55− }
56− // if we're last item in ListView don't show divider
57− if (model && index === model.count - 1) return false;
58−
59− return true;
60− }
61−
62− /* Relevant really only for ListViewWithPageHeader case: specify how many pixels we can overlap with the section header */
63− readonly property int allowedOverlap: units.dp(1)
64−
65− property real __heightToClip: {
66− // Check this is in position where clipping is needed
67− if (typeof ListViewWithPageHeader !== 'undefined') {
68− if (typeof heightToClip !== 'undefined') {
69− if (heightToClip >= allowedOverlap) {
70− return heightToClip - allowedOverlap;
71− }
72− }
73− }
74− return 0;
75− }
76−
77− /*!
78− \internal
79− Reparent so that the visuals of the children does not
80− occlude the bottom divider line.
81− */
82− default property alias children: body.children
83−
84− Item {
85− id: clippingContainer
86− height: parent.height - __heightToClip
87− anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
88− clip: __heightToClip > 0
89−
90− Item {
91− id: body
92− anchors {
93− left: parent.left
94− right: parent.right
95− bottom: bottomDividerLine.top
96− }
97− height: childrenRect.height
98− }
99−
100− ThinDivider {
101− id: bottomDividerLine
102− anchors.bottom: parent.bottom
103− visible: showDivider
104− }
105−
106− Highlight {
107− anchors {
108− top: parent.top
109− left: parent.left
110− right: parent.right
111− bottom: bottomDividerLine.top
112− }
113− pressed: emptyListItem.selected
114− }
115− }
116−}
qml/Components/ListItems/Highlight.qmldeleted−46
@@ -1,46 +0,0 @@
1−/*
2− * Copyright (C) 2013 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.0
18−
19−Rectangle {
20− id: highlight
21−
22− property bool pressed: false
23− property real pressedOpacity: 0.3
24−
25− color: "black"
26− opacity: 0
27− state: pressed ? "pressed" : ""
28− states: [
29− State {
30− name: "pressed"
31− PropertyChanges { target: highlight; opacity: pressedOpacity}
32− }
33− ]
34− transitions: [
35− Transition {
36− from: ""
37− to: "pressed"
38− NumberAnimation { target: highlight; property: "opacity"; duration: 50}
39− },
40− Transition {
41− from: "pressed"
42− to: ""
43− NumberAnimation { target: highlight; property: "opacity"; duration: 100}
44− }
45− ]
46−}
qml/Dash/DashCategoryBase.qmlnew file+62
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (C) 2012-2014 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.0
18+import Ubuntu.Components 0.1
19+
20+Item {
21+ width: parent.width
22+ height: body.height
23+
24+ /* Relevant really only for ListViewWithPageHeader case: specify how many pixels we can overlap with the section header */
25+ readonly property int allowedOverlap: units.dp(1)
26+
27+ property real __heightToClip: {
28+ // Check this is in position where clipping is needed
29+ if (typeof ListViewWithPageHeader !== 'undefined') {
30+ if (typeof heightToClip !== 'undefined') {
31+ if (heightToClip >= allowedOverlap) {
32+ return heightToClip - allowedOverlap;
33+ }
34+ }
35+ }
36+ return 0;
37+ }
38+
39+ /*!
40+ \internal
41+ Reparent so that the visuals of the children does not
42+ occlude the bottom divider line.
43+ */
44+ default property alias children: body.children
45+
46+ Item {
47+ id: clippingContainer
48+ height: parent.height - __heightToClip
49+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
50+ clip: __heightToClip > 0
51+
52+ Item {
53+ id: body
54+ anchors {
55+ left: parent.left
56+ right: parent.right
57+ bottom: parent.bottom
58+ }
59+ height: childrenRect.height
60+ }
61+ }
62+}
qml/Dash/GenericScopeView.qml+1−2
@@ -210,10 +210,9 @@ FocusScope {
210210 }
211211 }
212212
213− delegate: ListItems.Base {
213+ delegate: DashCategoryBase {
214214 id: baseItem
215215 objectName: "dashCategory" + category
216− showDivider: false
217216
218217 property Item seeAllButton: seeAll
219218
tests/autopilot/unity8/shell/emulators/dash.py+1−1
@@ -206,7 +206,7 @@ class GenericScopeView(emulators.UnityEmulatorBase):
206206 def _get_category_element(self, category):
207207 try:
208208 return self.wait_select_single(
209− 'Base', objectName='dashCategory{}'.format(category))
209+ 'DashCategoryBase', objectName='dashCategory{}'.format(category))
210210 except dbus.StateNotFoundError:
211211 raise emulators.UnityEmulatorException(
212212 'No category found with name {}'.format(category))