Merge lp:~nick-dedekind/unity8/1398888.secondary-indicator-actions into lp:unity8

Proposed by Nick Dedekind
Status: Merged
Approved by: Lukáš Tinkl
Approved revision: 2106
Merged at revision: 2182
Proposed branch: lp:~nick-dedekind/unity8/1398888.secondary-indicator-actions
Merge into: lp:unity8
Diff against target: 363 lines (+160/-19)
5 files modified
plugins/Unity/Indicators/modelactionrootstate.cpp (+76/-1)
plugins/Unity/Indicators/modelactionrootstate.h (+15/-4)
qml/Components/VolumeControl.qml (+1/-6)
qml/Panel/IndicatorItem.qml (+57/-7)
tests/mocks/Unity/Indicators/ModelActionRootState.qml (+11/-1)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/1398888.secondary-indicator-actions
Reviewer Review Type Date Requested Status
Lukáš Tinkl (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+281228@code.launchpad.net

Commit message

Added support for secondary indicator actions

Description of the change

Added support for secondary indicator actions

 * Are there any related MPs required for this MP to build/function as expected? Please list.
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) :
2105. By Nick Dedekind

removed accidental readonly

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

2 minor code issues spotted

review: Needs Fixing (code-review)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Update the code copyright, we're 2016 now :)

review: Needs Fixing
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

In VolumeControl.qml:
property var indicators // passed from Shell.qml

The above isn't needed anymore after your fixes, should also be removed from Shell.qml

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

> In VolumeControl.qml:
> property var indicators // passed from Shell.qml
>
>
> The above isn't needed anymore after your fixes, should also be removed from
> Shell.qml

It's used for the GlobalSHortcut mute action.

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

> > In VolumeControl.qml:
> > property var indicators // passed from Shell.qml
> >
> >
> > The above isn't needed anymore after your fixes, should also be removed from
> > Shell.qml
>
> It's used for the GlobalSHortcut mute action.

Hmm are you sure? I can't see that

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:2105
http://jenkins.qa.ubuntu.com/job/unity8-ci/7005/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/5911
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/420/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1710
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/413
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1605
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1605
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/412
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/411
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/4562
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5922
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5922/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26381
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/176/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/418
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/418/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26382

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/7005/rebuild

review: Needs Fixing (continuous-integration)
2106. By Nick Dedekind

review comments

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:2106
http://jenkins.qa.ubuntu.com/job/unity8-ci/7012/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/5923
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/427/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1717
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/420
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1612
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1612
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/419
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/418
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/4571
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5934
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5934/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26406
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/181/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/425
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/425/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26407

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/7012/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> Update the code copyright, we're 2016 now :)

Fixed.

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

> 2 minor code issues spotted

Fixed.

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Works fine, thanks

* Did you perform an exploratory manual test run of the code change and any related functionality?

Yes

* Did CI run pass? If not, please explain why.

Nope but no regressions in the indicator code

* Did you make sure that the branch does not contain spurious tags?

Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/Indicators/modelactionrootstate.cpp'
2--- plugins/Unity/Indicators/modelactionrootstate.cpp 2015-08-19 13:56:21 +0000
3+++ plugins/Unity/Indicators/modelactionrootstate.cpp 2016-01-05 06:10:29 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright 2013 Canonical Ltd.
7+ * Copyright 2013-2016 Canonical Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11@@ -32,6 +32,7 @@
12 ModelActionRootState::ModelActionRootState(QObject *parent)
13 : RootStateObject(parent),
14 m_menu(nullptr)
15+ , m_reentryGuard(false)
16 {
17 }
18
19@@ -62,6 +63,7 @@
20 connect(m_menu, &UnityMenuModel::destroyed, this, &ModelActionRootState::reset);
21 }
22 updateActionState();
23+ updateOtherActions();
24 Q_EMIT menuChanged();
25
26 if (wasValid != valid())
27@@ -69,6 +71,21 @@
28 }
29 }
30
31+QString ModelActionRootState::secondaryAction() const
32+{
33+ return m_secondaryAction;
34+}
35+
36+QString ModelActionRootState::scrollAction() const
37+{
38+ return m_scrollAction;
39+}
40+
41+QString ModelActionRootState::submenuAction() const
42+{
43+ return m_submenuAction;
44+}
45+
46 bool ModelActionRootState::valid() const
47 {
48 return !currentState().empty();
49@@ -79,6 +96,7 @@
50 Q_UNUSED(parent);
51 if (start == 0 && end >= 0) {
52 updateActionState();
53+ updateOtherActions();
54 }
55 }
56
57@@ -87,6 +105,7 @@
58 Q_UNUSED(parent);
59 if (start == 0 && end >= 0) {
60 updateActionState();
61+ updateOtherActions();
62 }
63 }
64
65@@ -99,6 +118,7 @@
66
67 if (topLeft.row() <= 0 && bottomRight.row() >= 0) {
68 updateActionState();
69+ updateOtherActions();
70 }
71 }
72
73@@ -108,10 +128,15 @@
74
75 Q_EMIT menuChanged();
76 setCurrentState(QVariantMap());
77+
78+ updateOtherActions();
79 }
80
81 void ModelActionRootState::updateActionState()
82 {
83+ if (m_reentryGuard) return;
84+ m_reentryGuard = true;
85+
86 if (m_menu && m_menu->rowCount() > 0) {
87 ActionStateParser* oldParser = m_menu->actionStateParser();
88 m_menu->setActionStateParser(&m_parser);
89@@ -126,4 +151,54 @@
90 }
91 // else if m_menu->rowCount() == 0, let's leave existing cache in place
92 // until the new menu comes in, to avoid flashing the UI empty for a moment
93+
94+ m_reentryGuard = false;
95+}
96+
97+void ModelActionRootState::updateOtherActions()
98+{
99+ if (m_reentryGuard) return;
100+ m_reentryGuard = true;
101+
102+ if (m_menu && m_menu->rowCount() > 0) {
103+ QVariantMap map;
104+ map[QStringLiteral("submenu-action")] = QStringLiteral("string");
105+ map[QStringLiteral("x-canonical-scroll-action")] = QStringLiteral("string");
106+ map[QStringLiteral("x-canonical-secondary-action")] = QStringLiteral("string");
107+ m_menu->loadExtendedAttributes(0, map);
108+ QVariantMap extMap = m_menu->get(0, "ext").toMap();
109+
110+ QString secondaryAction = extMap.value(QStringLiteral("xCanonicalSecondaryAction")).toString();
111+ if (m_secondaryAction != secondaryAction) {
112+ m_secondaryAction = secondaryAction;
113+ Q_EMIT secondaryActionChanged();
114+ }
115+
116+ QString scrollAction = extMap.value(QStringLiteral("xCanonicalScrollAction")).toString();
117+ if (m_scrollAction != scrollAction) {
118+ m_scrollAction = scrollAction;
119+ Q_EMIT scrollActionChanged();
120+ }
121+
122+ QString submenuAction = extMap.value(QStringLiteral("submenuAction")).toString();
123+ if (m_submenuAction != submenuAction) {
124+ m_submenuAction = submenuAction;
125+ Q_EMIT submenuActionChanged();
126+ }
127+ } else {
128+ if (!m_secondaryAction.isEmpty()) {
129+ m_secondaryAction.clear();
130+ Q_EMIT secondaryActionChanged();
131+ }
132+ if (!m_scrollAction.isEmpty()) {
133+ m_scrollAction.clear();
134+ Q_EMIT scrollActionChanged();
135+ }
136+ if (!m_submenuAction.isEmpty()) {
137+ m_submenuAction.clear();
138+ Q_EMIT submenuActionChanged();
139+ }
140+ }
141+
142+ m_reentryGuard = false;
143 }
144
145=== modified file 'plugins/Unity/Indicators/modelactionrootstate.h'
146--- plugins/Unity/Indicators/modelactionrootstate.h 2014-11-11 10:45:41 +0000
147+++ plugins/Unity/Indicators/modelactionrootstate.h 2016-01-05 06:10:29 +0000
148@@ -1,5 +1,5 @@
149 /*
150- * Copyright 2013 Canonical Ltd.
151+ * Copyright 2013-2016 Canonical Ltd.
152 *
153 * This program is free software; you can redistribute it and/or modify
154 * it under the terms of the GNU Lesser General Public License as published by
155@@ -30,6 +30,9 @@
156 {
157 Q_OBJECT
158 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
159+ Q_PROPERTY(QString secondaryAction READ secondaryAction NOTIFY secondaryActionChanged)
160+ Q_PROPERTY(QString scrollAction READ scrollAction NOTIFY scrollActionChanged)
161+ Q_PROPERTY(QString submenuAction READ submenuAction NOTIFY submenuActionChanged)
162 public:
163 ModelActionRootState(QObject *parent = 0);
164 virtual ~ModelActionRootState();
165@@ -37,14 +40,17 @@
166 UnityMenuModel* menu() const;
167 void setMenu(UnityMenuModel* menu);
168
169- int index() const;
170- void setIndex(int index);
171+ QString secondaryAction() const;
172+ QString scrollAction() const;
173+ QString submenuAction() const;
174
175 bool valid() const override;
176
177 Q_SIGNALS:
178 void menuChanged();
179- void indexChanged();
180+ void secondaryActionChanged();
181+ void scrollActionChanged();
182+ void submenuActionChanged();
183
184 private Q_SLOTS:
185 void onModelRowsAdded(const QModelIndex& parent, int start, int end);
186@@ -54,8 +60,13 @@
187
188 private:
189 void updateActionState();
190+ void updateOtherActions();
191
192 UnityMenuModel* m_menu;
193+ QString m_secondaryAction;
194+ QString m_scrollAction;
195+ QString m_submenuAction;
196+ bool m_reentryGuard;
197 };
198
199 #endif // MODELACTIONROOTSTATE_H
200
201=== modified file 'qml/Components/VolumeControl.qml'
202--- qml/Components/VolumeControl.qml 2015-11-18 15:07:35 +0000
203+++ qml/Components/VolumeControl.qml 2016-01-05 06:10:29 +0000
204@@ -1,5 +1,5 @@
205 /*
206- * Copyright (C) 2013-2015 Canonical, Ltd.
207+ * Copyright (C) 2013-2016 Canonical, Ltd.
208 *
209 * This program is free software; you can redistribute it and/or modify
210 * it under the terms of the GNU General Public License as published by
211@@ -28,10 +28,6 @@
212 readonly property int stepDown: -1
213
214 property var indicators // passed from Shell.qml
215- readonly property bool showNotification: indicators && indicators.fullyOpened && indicators.currentIndicator === "indicator-sound"
216- onShowNotificationChanged: { // disallow the volume notification when using the slider, lpbug#1484126
217- actionGroup.indicatorsAction.updateState(root.showNotification);
218- }
219
220 GlobalShortcut {
221 id: muteShortcut
222@@ -47,7 +43,6 @@
223
224 property variant actionObject: action("volume")
225 property variant muteActionObject: indicators.indicatorsModel.profile === "desktop" ? action("mute") : action("silent-mode")
226- property variant indicatorsAction: action("indicator-shown")
227 }
228
229 function volumeUp() {
230
231=== modified file 'qml/Panel/IndicatorItem.qml'
232--- qml/Panel/IndicatorItem.qml 2015-11-25 16:12:05 +0000
233+++ qml/Panel/IndicatorItem.qml 2016-01-05 06:10:29 +0000
234@@ -1,5 +1,5 @@
235 /*
236- * Copyright 2013-2014 Canonical Ltd.
237+ * Copyright 2013-2016 Canonical Ltd.
238 *
239 * This program is free software; you can redistribute it and/or modify
240 * it under the terms of the GNU Lesser General Public License as published by
241@@ -17,6 +17,7 @@
242 import QtQuick 2.4
243 import Ubuntu.Components 1.3
244 import Ubuntu.Settings.Components 0.1
245+import QMenuModel 0.1
246 import "Indicators"
247
248 IndicatorDelegate {
249@@ -36,13 +37,24 @@
250 return "#ffffff";
251 }
252
253- signal clicked()
254-
255 implicitWidth: mainItems.width
256
257 MouseArea {
258+ readonly property int stepUp: 1
259+ readonly property int stepDown: -1
260+
261 anchors.fill: parent
262- onClicked: parent.clicked()
263+ acceptedButtons: Qt.MiddleButton
264+ onClicked: {
265+ if ((!expanded || selected) && secondaryAction.valid) {
266+ secondaryAction.activate();
267+ }
268+ }
269+ onWheel: {
270+ if ((!expanded || selected) && scrollAction.valid) {
271+ scrollAction.activate(wheel.angleDelta.y > 0 ? stepUp : stepDown);
272+ }
273+ }
274 }
275
276 Item {
277@@ -152,9 +164,6 @@
278 }
279
280 StateGroup {
281- id: d
282- property bool useFallbackIcon: false
283-
284 states: [
285 State {
286 name: "minimised"
287@@ -251,4 +260,45 @@
288 rightLabel = rootActionState.rightLabel ? rootActionState.rightLabel : "";
289 icons = rootActionState.icons;
290 }
291+
292+ QtObject {
293+ id: d
294+
295+ property bool useFallbackIcon: false
296+ property var shouldIndicatorBeShown: undefined
297+
298+ onShouldIndicatorBeShownChanged: {
299+ if (shouldIndicatorBeShown !== undefined) {
300+ submenuAction.changeState(shouldIndicatorBeShown);
301+ }
302+ }
303+ }
304+
305+ UnityMenuAction {
306+ id: secondaryAction
307+ model: menuModel
308+ index: 0
309+ name: rootActionState.secondaryAction
310+ }
311+
312+ UnityMenuAction {
313+ id: scrollAction
314+ model: menuModel
315+ index: 0
316+ name: rootActionState.scrollAction
317+ }
318+
319+ UnityMenuAction {
320+ id: submenuAction
321+ model: menuModel
322+ index: 0
323+ name: rootActionState.submenuAction
324+ }
325+
326+ Binding {
327+ target: d
328+ property: "shouldIndicatorBeShown"
329+ when: submenuAction.valid
330+ value: root.selected && root.expanded
331+ }
332 }
333
334=== modified file 'tests/mocks/Unity/Indicators/ModelActionRootState.qml'
335--- tests/mocks/Unity/Indicators/ModelActionRootState.qml 2015-07-15 15:07:19 +0000
336+++ tests/mocks/Unity/Indicators/ModelActionRootState.qml 2016-01-05 06:10:29 +0000
337@@ -1,5 +1,5 @@
338 /*
339- * Copyright 2013 Canonical Ltd.
340+ * Copyright 2013-2016 Canonical Ltd.
341 *
342 * This program is free software; you can redistribute it and/or modify
343 * it under the terms of the GNU Lesser General Public License as published by
344@@ -30,10 +30,20 @@
345 property bool indicatorVisible: cachedState && cachedState.hasOwnProperty("visible") ? cachedState["visible"] : true
346
347 property var cachedState: menu ? menu.get(0, "actionState") : undefined
348+ property string submenuAction: {
349+ if (!menu) return "";
350+ var ext = menu.get(0, "ext");
351+ var submenuVar = ext ? ext["submenu-action"] : undefined;
352+ return submenuVar ? submenuVar : ""
353+ }
354 Connections {
355 target: menu
356 onModelDataChanged: {
357 cachedState = menu.get(0, "actionState");
358+
359+ var ext = menu.get(0, "ext");
360+ var submenuVar = ext ? ext["submenu-action"] : undefined;
361+ submenuAction = submenuVar ? submenuVar : ""
362 }
363 }
364

Subscribers

People subscribed via source and target branches