Merge lp:~nick-dedekind/unity8/indicator.multi-icon into lp:unity8

Proposed by Nick Dedekind
Status: Merged
Approved by: Michael Zanetti
Approved revision: 217
Merged at revision: 284
Proposed branch: lp:~nick-dedekind/unity8/indicator.multi-icon
Merge into: lp:unity8
Diff against target: 263 lines (+100/-40)
5 files modified
Panel/Indicators/DefaultIndicatorWidget.qml (+1/-1)
Panel/Indicators/DefaultIndicatorWidget2.qml (+43/-16)
Panel/Indicators/NetworkIndicatorWidget.qml (+1/-1)
plugins/Unity/Indicators/rootactionstate.cpp (+46/-16)
plugins/Unity/Indicators/rootactionstate.h (+9/-6)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/indicator.multi-icon
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Daniel d'Andrada (community) Approve
Albert Astals Cid (community) Needs Information
Review via email: mp+181862@code.launchpad.net

Commit message

Multiple icon/label support for indicators.

Description of the change

Multiple icon/label support for indicators.

Format:
pre-label
icon(s)
label

To post a comment you must log in.
214. By Nick Dedekind

respaced icons

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

0.7 grid units seems a weird number. In theory we're told to never use decimal grid units, but i don't mind using 0.5 as you do somewhere else since
      \li Most laptops
      \li 1 gu = 8 px

      \li Retina laptops
      \li 1 gu = 16 px

      \li Phone with 4 inch screen at HD resolution (around 720x1,280 pixels)
      \li 1 gu = 18 px

      \li Tablet with 10 inch screen at HD resolution (around 720x1,280 pixels)
      \li 1 gu = 10 px

So 0.5 gu will 99.99% still be an exact number of pixels, but 0.7gu mean 5.6, 10.2, 12.6 and 7 pixels respectively, which is a bit weird to declare that we want something to be 5.6 pixels width

So, the question is: Why 0.7?

review: Needs Information
215. By Nick Dedekind

pixel boundary respacing.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> 0.7 grid units seems a weird number. In theory we're told to never use decimal
> grid units, but i don't mind using 0.5 as you do somewhere else since
> \li Most laptops
> \li 1 gu = 8 px
>
> \li Retina laptops
> \li 1 gu = 16 px
>
> \li Phone with 4 inch screen at HD resolution (around 720x1,280 pixels)
> \li 1 gu = 18 px
>
> \li Tablet with 10 inch screen at HD resolution (around 720x1,280
> pixels)
> \li 1 gu = 10 px
>
> So 0.5 gu will 99.99% still be an exact number of pixels, but 0.7gu mean 5.6,
> 10.2, 12.6 and 7 pixels respectively, which is a bit weird to declare that we
> want something to be 5.6 pixels width
>
> So, the question is: Why 0.7?

Respaced to 0.5 gu.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

From DefaultIndicatorWidget2.qml:

"""
    onActionStateChanged: {
        if (actionState == undefined) {
            label = "";
            iconSource = "";
            enabled = false;
            return;
        }
"""

Forgot to update the contents of this "if".

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In plugins/Unity/Indicators/rootactionstate.cpp

@@ -198,16 +205,38 @@ QVariant RootActionState::toQVariant(GVa
         while (g_variant_iter_loop (&iter, "{sv}", &key, &vvalue))
         {
             QString str = QString::fromUtf8(key);
- if (str == "icon") {
+ if (str == "icon" && !qmap.contains("icons")) {
+ QStringList icons;
+
                 // FIXME - should be sending a url.
- GIcon *icon = g_icon_deserialize (vvalue);
- if (icon) {
- qmap.insert(str, iconUri(icon));
- g_object_unref (icon);
+ GIcon *gicon = g_icon_deserialize (vvalue);
+ if (gicon) {
+ icons << iconUri(gicon);
                 }
- else {
- qmap.insert(str, QVariant(""));
+ qmap.insert("icons", icons);

I think you should keep the "g_object_unref(icon);" call on the icon created by "g_icon_deserialize(vvalue)".

review: Needs Fixing
216. By Nick Dedekind

fixed up some old variables

217. By Nick Dedekind

added unref for icon

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> In plugins/Unity/Indicators/rootactionstate.cpp
>
> @@ -198,16 +205,38 @@ QVariant RootActionState::toQVariant(GVa
> while (g_variant_iter_loop (&iter, "{sv}", &key, &vvalue))
> {
> QString str = QString::fromUtf8(key);
> - if (str == "icon") {
> + if (str == "icon" && !qmap.contains("icons")) {
> + QStringList icons;
> +
> // FIXME - should be sending a url.
> - GIcon *icon = g_icon_deserialize (vvalue);
> - if (icon) {
> - qmap.insert(str, iconUri(icon));
> - g_object_unref (icon);
> + GIcon *gicon = g_icon_deserialize (vvalue);
> + if (gicon) {
> + icons << iconUri(gicon);
> }
> - else {
> - qmap.insert(str, QVariant(""));
> + qmap.insert("icons", icons);
>
> I think you should keep the "g_object_unref(icon);" call on the icon created
> by "g_icon_deserialize(vvalue)".

Thanks. Fixed.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> From DefaultIndicatorWidget2.qml:
>
> """
> onActionStateChanged: {
> if (actionState == undefined) {
> label = "";
> iconSource = "";
> enabled = false;
> return;
> }
> """
>
> Forgot to update the contents of this "if".

Fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Panel/Indicators/DefaultIndicatorWidget.qml'
2--- Panel/Indicators/DefaultIndicatorWidget.qml 2013-08-14 09:07:45 +0000
3+++ Panel/Indicators/DefaultIndicatorWidget.qml 2013-09-03 17:19:05 +0000
4@@ -24,7 +24,7 @@
5 Indicators.IndicatorWidget {
6 id: indicatorWidget
7
8- width: itemRow.width + units.gu(1)
9+ width: itemRow.width + units.gu(0.5)
10
11 property alias label: itemLabel.text
12 property alias iconSource: itemImage.source
13
14=== modified file 'Panel/Indicators/DefaultIndicatorWidget2.qml'
15--- Panel/Indicators/DefaultIndicatorWidget2.qml 2013-08-14 09:07:45 +0000
16+++ Panel/Indicators/DefaultIndicatorWidget2.qml 2013-09-03 17:19:05 +0000
17@@ -24,10 +24,11 @@
18 Indicators.IndicatorWidget {
19 id: indicatorWidget
20
21- width: itemRow.width + units.gu(1)
22+ width: itemRow.width + units.gu(0.5)
23
24- property alias label: itemLabel.text
25- property alias iconSource: itemImage.source
26+ property alias leftLabel: itemLeftLabel.text
27+ property alias rightLabel: itemRightLabel.text
28+ property var icons: undefined
29
30 Row {
31 id: itemRow
32@@ -39,19 +40,43 @@
33 }
34 spacing: units.gu(0.5)
35
36- // FIXME : Should us Ubuntu.Icon . results in low res images
37- Image {
38- id: itemImage
39- objectName: "itemImage"
40- visible: source != ""
41- height: indicatorWidget.iconSize
42- width: indicatorWidget.iconSize
43+ Label {
44+ id: itemLeftLabel
45+ objectName: "leftLabel"
46+ color: Theme.palette.selected.backgroundText
47+ opacity: 0.8
48+ font.family: "Ubuntu"
49+ fontSize: "medium"
50 anchors.verticalCenter: parent.verticalCenter
51+ visible: text != ""
52+ }
53+
54+ Row {
55+ width: childrenRect.width
56+ anchors {
57+ top: parent.top
58+ bottom: parent.bottom
59+ }
60+ spacing: units.gu(0.5)
61+
62+ Repeater {
63+ model: indicatorWidget.icons
64+
65+ Image {
66+ id: itemImage
67+ objectName: "itemImage"
68+ visible: source != ""
69+ source: modelData
70+ height: indicatorWidget.iconSize
71+ width: indicatorWidget.iconSize
72+ anchors.verticalCenter: parent.verticalCenter
73+ }
74+ }
75 }
76
77 Label {
78- id: itemLabel
79- objectName: "itemLabel"
80+ id: itemRightLabel
81+ objectName: "rightLabel"
82 color: Theme.palette.selected.backgroundText
83 opacity: 0.8
84 font.family: "Ubuntu"
85@@ -63,14 +88,16 @@
86
87 onActionStateChanged: {
88 if (actionState == undefined) {
89- label = "";
90- iconSource = "";
91+ leftLabel = "";
92+ rightLabel = "";
93+ icons = undefined;
94 enabled = false;
95 return;
96 }
97
98- label = actionState.label;
99- iconSource = actionState.icon;
100+ leftLabel = actionState.leftLabel ? actionState.leftLabel : "";
101+ rightLabel = actionState.rightLabel ? actionState.rightLabel : "";
102+ icons = actionState.icons;
103 enabled = actionState.visible;
104 }
105 }
106
107=== modified file 'Panel/Indicators/NetworkIndicatorWidget.qml'
108--- Panel/Indicators/NetworkIndicatorWidget.qml 2013-08-14 09:07:45 +0000
109+++ Panel/Indicators/NetworkIndicatorWidget.qml 2013-09-03 17:19:05 +0000
110@@ -24,7 +24,7 @@
111 Indicators.IndicatorWidget {
112 id: indicatorWidget
113
114- width: networkIcon.width + units.gu(1)
115+ width: networkIcon.width + units.gu(0.5)
116
117 property int signalStrength: 0
118 property int connectionState: Indicators.NetworkConnection.Initial
119
120=== modified file 'plugins/Unity/Indicators/rootactionstate.cpp'
121--- plugins/Unity/Indicators/rootactionstate.cpp 2013-08-14 09:07:45 +0000
122+++ plugins/Unity/Indicators/rootactionstate.cpp 2013-09-03 17:19:05 +0000
123@@ -108,25 +108,32 @@
124 return m_menu && m_menu->rowCount() > 0;
125 }
126
127-QString RootActionState::label() const
128+QString RootActionState::leftLabel() const
129+{
130+ if (!isValid()) return QString();
131+
132+ return m_cachedState.value("pre-label", QVariant::fromValue(QString())).toString();
133+}
134+
135+QString RootActionState::rightLabel() const
136 {
137 if (!isValid()) return QString();
138
139 return m_cachedState.value("label", QVariant::fromValue(QString())).toString();
140 }
141
142-QString RootActionState::icon() const
143+QStringList RootActionState::icons() const
144 {
145- if (!isValid()) return QString();
146+ if (!isValid()) return QStringList();
147
148- return m_cachedState.value("icon", QVariant::fromValue(QString())).toString();
149+ return m_cachedState.value("icons", QVariant::fromValue(QStringList())).toStringList();
150 }
151
152 QString RootActionState::accessibleName() const
153 {
154 if (!isValid()) return QString();
155
156- return m_cachedState.value("accessible-name", QVariant::fromValue(QString())).toString();
157+ return m_cachedState.value("accessible-desc", QVariant::fromValue(QString())).toString();
158 }
159
160 bool RootActionState::isVisible() const
161@@ -198,16 +205,39 @@
162 while (g_variant_iter_loop (&iter, "{sv}", &key, &vvalue))
163 {
164 QString str = QString::fromUtf8(key);
165- if (str == "icon") {
166+ if (str == "icon" && !qmap.contains("icons")) {
167+ QStringList icons;
168+
169 // FIXME - should be sending a url.
170- GIcon *icon = g_icon_deserialize (vvalue);
171- if (icon) {
172- qmap.insert(str, iconUri(icon));
173- g_object_unref (icon);
174- }
175- else {
176- qmap.insert(str, QVariant(""));
177- }
178+ GIcon *gicon = g_icon_deserialize (vvalue);
179+ if (gicon) {
180+ icons << iconUri(gicon);
181+ g_object_unref (gicon);
182+ }
183+ qmap.insert("icons", icons);
184+
185+ } else if (str == "icons") {
186+
187+ QStringList icons;
188+
189+ if (g_variant_type_is_array(g_variant_get_type(vvalue))) {
190+
191+
192+ for (int i = 0, iMax = g_variant_n_children(vvalue); i < iMax; i++) {
193+ GVariant *child = g_variant_get_child_value(vvalue, i);
194+
195+ // FIXME - should be sending a url.
196+ GIcon *gicon = g_icon_deserialize (child);
197+ if (gicon) {
198+ icons << iconUri(gicon);
199+ g_object_unref (gicon);
200+ }
201+ g_variant_unref(child);
202+ }
203+ }
204+ // will overwrite icon.
205+ qmap.insert("icons", icons);
206+
207 } else {
208 qmap.insert(str, ActionStateParser::toQVariant(vvalue));
209 }
210@@ -230,12 +260,12 @@
211 &visible);
212
213 qmap["label"] = label ? QString::fromUtf8(label) : "";
214- qmap["accessible-name"] = accessible_name ? QString::fromUtf8(accessible_name) : "";
215+ qmap["accessible-desc"] = accessible_name ? QString::fromUtf8(accessible_name) : "";
216 qmap["visible"] = visible;
217
218 gicon = g_icon_new_for_string (icon, NULL);
219 if (gicon) {
220- qmap["icon"] = iconUri(gicon);
221+ qmap["icons"] = QStringList() << iconUri(gicon);
222 g_object_unref (gicon);
223 }
224
225
226=== modified file 'plugins/Unity/Indicators/rootactionstate.h'
227--- plugins/Unity/Indicators/rootactionstate.h 2013-08-14 09:07:45 +0000
228+++ plugins/Unity/Indicators/rootactionstate.h 2013-09-03 17:19:05 +0000
229@@ -32,8 +32,9 @@
230 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
231
232 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
233- Q_PROPERTY(QString label READ label NOTIFY labelChanged)
234- Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
235+ Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged)
236+ Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged)
237+ Q_PROPERTY(QStringList icons READ icons NOTIFY iconsChanged)
238 Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged)
239 Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
240 public:
241@@ -47,8 +48,9 @@
242 void setIndex(int index);
243
244 bool isValid() const;
245- QString label() const;
246- QString icon() const;
247+ QString leftLabel() const;
248+ QString rightLabel() const;
249+ QStringList icons() const;
250 QString accessibleName() const;
251 bool isVisible() const;
252
253@@ -62,8 +64,9 @@
254 void indexChanged();
255
256 void validChanged();
257- void labelChanged();
258- void iconChanged();
259+ void leftLabelChanged();
260+ void rightLabelChanged();
261+ void iconsChanged();
262 void accessibleNameChanged();
263 void visibleChanged();
264

Subscribers

People subscribed via source and target branches