on xenial help sign in
Fix disabled scopes and add weather renderer
commitf58f482cf77669334092f007b6bcf17985ddb97a authorAndrea Cimitan <andrea.cimitan@canonical.com> dateThu 3 Oct 2013, 17:20 (13 years ago) parent8748fa0
6 files changed+71−3
Dash/Apps/DashPluginFilterGrid.qml+50 Dash/Generic/TileStyleDashPlugin.qml → Dash/Generic/FlatTileStyle.qml+3 Dash/Generic/GenericFilterGridDashPlugin.qml → Dash/Generic/WeatherFilterGrid.qml+1−1 Dash/GenericScopeView.qml+2−1 plugins/Unity/categoryresults.cpp+13 plugins/Unity/categoryresults.h+2−1
Dash/Apps/DashPluginFilterGrid.qmlnew file+50
@@ -0,0 +1,50 @@
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+import Ubuntu.Components 0.1
19+import "../../Components"
20+import "../Generic"
21+
22+GenericFilterGrid {
23+ id: filtergrid
24+
25+ delegate: Tile {
26+ id: tile
27+ objectName: "delegate" + index
28+ width: filtergrid.cellWidth
29+ height: filtergrid.cellHeight
30+ text: model.title
31+ imageWidth: filtergrid.iconWidth
32+ imageHeight: filtergrid.iconHeight
33+ source: model.icon
34+ fillMode: Image.PreserveAspectCrop
35+
36+ style: FlatTileStyle {
37+ disabled: model.scopeDisabled
38+ }
39+
40+ onClicked: {
41+ var data = { model: model }
42+ filtergrid.clicked(index, data, tile.y)
43+ }
44+
45+ onPressAndHold: {
46+ var data = { model: model }
47+ filtergrid.pressAndHold(index, data, tile.y)
48+ }
49+ }
50+}
Dash/Generic/TileStyleDashPlugin.qml → Dash/Generic/FlatTileStyle.qmlrenamed+3
@@ -20,6 +20,8 @@ import Ubuntu.Components 0.1
2020Item {
2121 id: tile
2222
23+ property bool disabled: false
24+
2325 anchors.fill: parent
2426
2527 Item {
@@ -39,6 +41,7 @@ Item {
3941 cache: false
4042 source: styledItem.source
4143 fillMode: styledItem.fillMode
44+ opacity: tile.disabled ? 0.5 : 1.0
4245 horizontalAlignment: styledItem.horizontalAlignment
4346 verticalAlignment: styledItem.verticalAlignment
4447 }
Dash/Generic/GenericFilterGridDashPlugin.qml → Dash/Generic/WeatherFilterGrid.qmlrenamed+1−1
@@ -32,7 +32,7 @@ GenericFilterGrid {
3232 source: model.icon
3333 fillMode: Image.PreserveAspectCrop
3434
35− style: TileStyleDashPlugin {}
35+ style: FlatTileStyle {}
3636
3737 onClicked: {
3838 var data = { model: model }
Dash/GenericScopeView.qml+2−1
@@ -199,10 +199,11 @@ ScopeView {
199199 case "music": return "Music/MusicFilterGrid.qml";
200200 case "apps": {
201201 if (rendererHint == "toggled")
202− return "Generic/GenericFilterGridDashPlugin.qml";
202+ return "Apps/DashPluginFilterGrid.qml";
203203 else
204204 return "Generic/GenericFilterGrid.qml";
205205 }
206+ case "weather": return "Generic/WeatherFilterGrid.qml";
206207 default: return "Generic/GenericFilterGrid.qml";
207208 }
208209 }
plugins/Unity/categoryresults.cpp+13
@@ -46,6 +46,7 @@ CategoryResults::CategoryResults(QObject* parent)
4646 m_roles[CategoryResults::RoleComment] = "comment";
4747 m_roles[CategoryResults::RoleDndUri] = "dndUri";
4848 m_roles[CategoryResults::RoleMetadata] = "metadata";
49+ m_roles[CategoryResults::RoleMetadataScopeDisabled] = "scopeDisabled";
4950}
5051
5152int CategoryResults::categoryIndex() const
@@ -93,6 +94,18 @@ CategoryResults::data(const QModelIndex& index, int role) const
9394 return DeeListModel::data(index, ResultsColumn::DND_URI);
9495 case RoleMetadata:
9596 return DeeListModel::data(index, ResultsColumn::METADATA);
97+ // nasty hack while we don't support annotated icons
98+ case RoleMetadataScopeDisabled:
99+ {
100+ QVariantHash hash(DeeListModel::data(index, ResultsColumn::METADATA).toHash());
101+ if (hash.contains("content")) {
102+ QVariantHash innerHash(hash["content"].toHash());
103+ if (innerHash.contains("scope_disabled")) {
104+ return innerHash["scope_disabled"];
105+ }
106+ }
107+ return QVariant();
108+ }
96109 default:
97110 return QVariant();
98111 }
plugins/Unity/categoryresults.h+2−1
@@ -43,7 +43,8 @@ public:
4343 RoleTitle,
4444 RoleComment,
4545 RoleDndUri,
46− RoleMetadata
46+ RoleMetadata,
47+ RoleMetadataScopeDisabled
4748 };
4849
4950 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;