@@ -24,6 +24,10 @@ Item {
2424 property real progress: 0
2525 property var scope: null
2626 property real scopeScale: 1
27+ property QtObject scopeStyle: QtObject {
28+ property string headerLogo: ""
29+ property color foreground: "white"
30+ }
2731
2832 signal done()
2933 signal favoriteSelected(int index)
@@ -39,218 +43,240 @@ Item {
3943 }
4044
4145 Item {
42− id: topBar
46+ id: scopesOverviewContent
47+ x: previewListView.open ? -width : 0
48+ Behavior on x { UbuntuNumberAnimation { } }
4349 width: parent.width
44− height: childrenRect.height
50+ height: parent.height
4551
46− y: {
47− if (root.progress < 0.5) {
48− return -height;
49− } else {
50− return -height + (root.progress - 0.5) * height * 2;
52+ Item {
53+ id: topBar
54+ width: parent.width
55+ height: childrenRect.height
56+
57+ y: {
58+ if (root.progress < 0.5) {
59+ return -height;
60+ } else {
61+ return -height + (root.progress - 0.5) * height * 2;
62+ }
5163 }
52− }
5364
54− PageHeader {
55− id: pageHeader
56− width: parent.width
57− clip: true
58− title: i18n.tr("Manage Dash")
59− scopeStyle: QtObject {
60− property string headerLogo: ""
61− property color foreground: "white"
65+ PageHeader {
66+ id: pageHeader
67+ width: parent.width
68+ clip: true
69+ title: i18n.tr("Manage Dash")
70+ scopeStyle: root.scopeStyle
71+ showSignatureLine: false
72+ searchEntryEnabled: true
73+ // searchInProgress: scope ? scope.searchInProgress : false
6274 }
63− showSignatureLine: false
64− searchEntryEnabled: true
65−// searchInProgress: scope ? scope.searchInProgress : false
66− }
6775
68− Item {
69− id: tabBarHolder
76+ Item {
77+ id: tabBarHolder
7078
71− property int currentTab: 0
79+ property int currentTab: 0
7280
73− anchors {
74− left: parent.left
75− right: parent.right
76− top: pageHeader.bottom
77− margins: units.gu(2)
78− }
79− height: units.gu(4)
81+ anchors {
82+ left: parent.left
83+ right: parent.right
84+ top: pageHeader.bottom
85+ margins: units.gu(2)
86+ }
87+ height: units.gu(4)
8088
81− AbstractButton {
82− id: tab1
83− height: parent.height
84− width: parent.width / 2
85− Rectangle {
86− anchors.fill: parent
87− color: tabBarHolder.currentTab == 0 ? "white" : "transparent"
88− radius: units.dp(10)
89+ AbstractButton {
90+ id: tab1
91+ height: parent.height
92+ width: parent.width / 2
93+ Rectangle {
94+ anchors.fill: parent
95+ color: tabBarHolder.currentTab == 0 ? "white" : "transparent"
96+ radius: units.dp(10)
97+ }
98+ Label {
99+ anchors.centerIn: parent
100+ text: i18n.tr("Favourites")
101+ color: tabBarHolder.currentTab == 0 ? "black" : "white"
102+ }
103+ onClicked: tabBarHolder.currentTab = 0
89104 }
90− Label {
91− anchors.centerIn: parent
92− text: i18n.tr("Favourites")
93− color: tabBarHolder.currentTab == 0 ? "black" : "white"
105+ AbstractButton {
106+ id: tab2
107+ x: width
108+ height: parent.height
109+ width: parent.width / 2
110+ Rectangle {
111+ anchors.fill: parent
112+ color: tabBarHolder.currentTab == 1 ? "white" : "transparent"
113+ radius: units.dp(10)
114+ }
115+ Label {
116+ anchors.centerIn: parent
117+ text: i18n.tr("All")
118+ color: tabBarHolder.currentTab == 1 ? "black" : "white"
119+ }
120+ onClicked: tabBarHolder.currentTab = 1
121+ }
122+ Rectangle {
123+ id: centerPiece
124+ width: units.dp(10)
125+ height: parent.height
126+ color: "white"
127+ x: tabBarHolder.currentTab == 1 ? tab2.x : tab2.x - width
94128 }
95− onClicked: tabBarHolder.currentTab = 0
96− }
97− AbstractButton {
98− id: tab2
99− x: width
100− height: parent.height
101− width: parent.width / 2
102129 Rectangle {
130+ id: border
103131 anchors.fill: parent
104− color: tabBarHolder.currentTab == 1 ? "white" : "transparent"
105132 radius: units.dp(10)
133+ color: "transparent"
134+ border.color: centerPiece.color
135+ border.width: units.dp(1)
106136 }
107− Label {
108− anchors.centerIn: parent
109− text: i18n.tr("All")
110− color: tabBarHolder.currentTab == 1 ? "black" : "white"
111− }
112− onClicked: tabBarHolder.currentTab = 1
113− }
114− Rectangle {
115− id: centerPiece
116− width: units.dp(10)
117− height: parent.height
118− color: "white"
119− x: tabBarHolder.currentTab == 1 ? tab2.x : tab2.x - width
120− }
121− Rectangle {
122− id: border
123− anchors.fill: parent
124− radius: units.dp(10)
125− color: "transparent"
126− border.color: centerPiece.color
127− border.width: units.dp(1)
128137 }
129138 }
130− }
131139
132− Repeater {
133− id: middleItems
134− model: scope ? scope.categories : null
135− delegate: Loader {
136− id: loader
140+ Repeater {
141+ id: middleItems
142+ model: scope ? scope.categories : null
143+ delegate: Loader {
144+ id: loader
137145
138− height: {
139− if (index == 0) {
140− return parent.height;
141− } else {
142− return parent.height - topBar.height - units.gu(2)
146+ height: {
147+ if (index == 0) {
148+ return parent.height;
149+ } else {
150+ return parent.height - topBar.height - units.gu(2)
151+ }
143152 }
144− }
145− width: {
146− if (index == 0) {
147− return parent.width / scopeScale
148− } else {
149− return parent.width
153+ width: {
154+ if (index == 0) {
155+ return parent.width / scopeScale
156+ } else {
157+ return parent.width
158+ }
150159 }
151− }
152− x: {
153− if (index == 0) {
154− return (root.width - width) / 2;
155− } else {
156− return 0;
160+ x: {
161+ if (index == 0) {
162+ return (root.width - width) / 2;
163+ } else {
164+ return 0;
165+ }
166+ }
167+ anchors {
168+ bottom: parent.bottom
157169 }
158− }
159− anchors {
160− bottom: parent.bottom
161− }
162170
163− scale: index == 0 ? scopeScale : 1
171+ scale: index == 0 ? scopeScale : 1
164172
165− opacity: tabBarHolder.currentTab == index ? 1 : 0
166− Behavior on opacity { UbuntuNumberAnimation { } }
167− enabled: opacity == 1
173+ opacity: tabBarHolder.currentTab == index ? 1 : 0
174+ Behavior on opacity { UbuntuNumberAnimation { } }
175+ enabled: opacity == 1
168176
169− clip: index == 1
177+ clip: index == 1
170178
171− CardTool {
172− id: cardTool
173− objectName: "cardTool"
174− count: results.count
175− template: model.renderer
176− components: model.components
177− viewWidth: parent.width
178− }
179+ CardTool {
180+ id: cardTool
181+ objectName: "cardTool"
182+ count: results.count
183+ template: model.renderer
184+ components: model.components
185+ viewWidth: parent.width
186+ }
179187
180− source: {
181− if (index == 0) return "ScopesOverviewFavourites.qml";
182− else if (index == 1) return "ScopesOverviewAll.qml";
183− else {
184− console.log("WARNING: ScopesOverview scope is not supposed to have more than 2 categories");
185− return "";
188+ source: {
189+ if (index == 0) return "ScopesOverviewFavourites.qml";
190+ else if (index == 1) return "ScopesOverviewAll.qml";
191+ else {
192+ console.log("WARNING: ScopesOverview scope is not supposed to have more than 2 categories");
193+ return "";
194+ }
186195 }
187− }
188196
189− onLoaded: {
190− item.model = Qt.binding(function() { return results })
191− item.cardTool = cardTool;
192− if (index == 0) {
193− item.scopeWidth = root.width;
194− item.scopeHeight = root.height;
195− } else if (index == 1) {
196− item.extraHeight = bottomBar.height;
197+ onLoaded: {
198+ item.model = Qt.binding(function() { return results })
199+ item.cardTool = cardTool;
200+ if (index == 0) {
201+ item.scopeWidth = root.width;
202+ item.scopeHeight = root.height;
203+ } else if (index == 1) {
204+ item.extraHeight = bottomBar.height;
205+ }
197206 }
198− }
199207
200− Connections {
201− target: loader.item
202− onClicked: {
203− if (tabBarHolder.currentTab == 0) {
204− root.favoriteSelected(index)
205− } else {
206− // This will result in an openScope
207− // that we handle in Dash.qml
208− scope.activate(result)
208+ Connections {
209+ target: loader.item
210+ onClicked: {
211+ if (tabBarHolder.currentTab == 0) {
212+ root.favoriteSelected(index)
213+ } else {
214+ // This will result in an openScope
215+ // that we handle in Dash.qml
216+ scope.activate(result)
217+ }
209218 }
210− }
219+ onPressAndHold: {
220+ previewListView.model = target.model;
221+ previewListView.currentIndex = -1
222+ previewListView.currentIndex = index;
223+ previewListView.open = true
224+ }
225+ }
211226 }
212227 }
213− }
214228
215− Rectangle {
216− id: bottomBar
217− color: "black"
218− height: units.gu(6)
219− width: parent.width
220− opacity: 0.4
221− y: {
222− if (root.progress < 0.5) {
223− return parent.height;
224− } else {
225− return parent.height - (root.progress - 0.5) * height * 2;
229+ Rectangle {
230+ id: bottomBar
231+ color: "black"
232+ height: units.gu(6)
233+ width: parent.width
234+ opacity: 0.4
235+ y: {
236+ if (root.progress < 0.5) {
237+ return parent.height;
238+ } else {
239+ return parent.height - (root.progress - 0.5) * height * 2;
240+ }
226241 }
227− }
228242
229− AbstractButton {
230− width: Math.max(label.width + units.gu(2), units.gu(10))
231− height: units.gu(4)
232− anchors {
233− left: parent.left
234− leftMargin: units.gu(2)
235− verticalCenter: parent.verticalCenter
236− }
237− Rectangle {
238− anchors.fill: parent
239− border.color: "white"
240− border.width: units.dp(1)
241− radius: units.dp(10)
242− color: parent.pressed ? "gray" : "transparent"
243− }
244− Label {
245− id: label
246− anchors.centerIn: parent
247− text: i18n.tr("Done")
248− color: parent.pressed ? "black" : "white"
249− }
250− onClicked: {
251− root.done();
252− tabBarHolder.currentTab = 0;
243+ AbstractButton {
244+ width: Math.max(label.width + units.gu(2), units.gu(10))
245+ height: units.gu(4)
246+ anchors {
247+ left: parent.left
248+ leftMargin: units.gu(2)
249+ verticalCenter: parent.verticalCenter
250+ }
251+ Rectangle {
252+ anchors.fill: parent
253+ border.color: "white"
254+ border.width: units.dp(1)
255+ radius: units.dp(10)
256+ color: parent.pressed ? "gray" : "transparent"
257+ }
258+ Label {
259+ id: label
260+ anchors.centerIn: parent
261+ text: i18n.tr("Done")
262+ color: parent.pressed ? "black" : "white"
263+ }
264+ onClicked: {
265+ root.done();
266+ tabBarHolder.currentTab = 0;
267+ }
253268 }
254269 }
255270 }
271+
272+ PreviewListView {
273+ id: previewListView
274+ objectName: "scopesOverviewPreviewListView"
275+ scope: root.scope
276+ scopeStyle: root.scopeStyle
277+ visible: x != width
278+ width: parent.width
279+ height: parent.height
280+ anchors.left: scopesOverviewContent.right
281+ }
256282}