Merge lp:~nick-dedekind/unity8/rtm-1385331 into lp:unity8/rtm-14.09
- rtm-1385331
- Merge into rtm-14.09
Status: | Merged |
---|---|
Approved by: | Michael Zanetti |
Approved revision: | 1432 |
Merged at revision: | 1414 |
Proposed branch: | lp:~nick-dedekind/unity8/rtm-1385331 |
Merge into: | lp:unity8/rtm-14.09 |
Prerequisite: | lp:~unity-team/unity8/rtm-20150113 |
Diff against target: |
1841 lines (+1038/-301) 33 files modified
debian/control (+3/-3) plugins/Lights/Lights.cpp (+9/-24) plugins/Unity/Indicators/CMakeLists.txt (+3/-1) plugins/Unity/Indicators/actionrootstate.cpp (+97/-0) plugins/Unity/Indicators/actionrootstate.h (+55/-0) plugins/Unity/Indicators/modelactionrootstate.cpp (+127/-0) plugins/Unity/Indicators/modelactionrootstate.h (+61/-0) plugins/Unity/Indicators/plugin.cpp (+4/-2) plugins/Unity/Indicators/rootstateparser.cpp (+75/-142) plugins/Unity/Indicators/rootstateparser.h (+20/-36) qml/Greeter/Clock.qml (+1/-1) qml/Panel/IndicatorItem.qml (+0/-8) qml/Panel/Indicators/IndicatorBase.qml (+1/-1) qml/Panel/Indicators/IndicatorsLight.qml (+19/-1) qml/Panel/IndicatorsBar.qml (+29/-20) qml/Panel/IndicatorsMenu.qml (+5/-0) tests/mocks/CMakeLists.txt (+1/-0) tests/mocks/Lights/CMakeLists.txt (+8/-0) tests/mocks/Lights/Lights.cpp (+84/-0) tests/mocks/Lights/Lights.h (+66/-0) tests/mocks/Lights/plugin.cpp (+33/-0) tests/mocks/Lights/plugin.h (+32/-0) tests/mocks/Lights/qmldir (+3/-0) tests/mocks/QMenuModel/CMakeLists.txt (+1/-0) tests/mocks/QMenuModel/QDBusActionGroup.qml (+7/-57) tests/mocks/QMenuModel/actiondata.h (+52/-0) tests/mocks/QMenuModel/plugin.cpp (+10/-0) tests/mocks/Unity/Indicators/ActionRootState.qml (+46/-0) tests/mocks/Unity/Indicators/qmldir (+2/-1) tests/plugins/Unity/Indicators/rootactionstatetest.cpp (+4/-4) tests/qmltests/CMakeLists.txt (+1/-0) tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml (+129/-0) tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml (+50/-0) |
To merge this branch: | bzr merge lp:~nick-dedekind/unity8/rtm-1385331 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Zanetti (community) | Approve | ||
Michał Sawicz | Needs Fixing | ||
Review via email: mp+246403@code.launchpad.net |
Commit message
Unhook Lights interface from indicator widgets
Approved by: Albert Astals Cid
Description of the change
Led fix
- 1428. By Nick Dedekind
-
removed old file
- 1429. By Nick Dedekind
-
removed multiple new lines
Michał Sawicz (saviq) wrote : | # |
:(
file://
Panel {
^
file://
^
file://
^
- 1430. By Nick Dedekind
-
merged parent
- 1431. By Nick Dedekind
-
added import
Nick Dedekind (nick-dedekind) wrote : | # |
> :(
>
> file://
> Panel {
> ^
> file://
> unavailable
> IndicatorsMenu {
> ^
> file://
> a type
> IndicatorsLight {
> ^
Fixed.
Michael Zanetti (mzanetti) wrote : | # |
This seems to break the panel: http://
- 1432. By Nick Dedekind
-
fixes for indicators
Michael Zanetti (mzanetti) wrote : | # |
seems to work fine now.
Preview Diff
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2015-01-08 12:51:33 +0000 | |||
3 | +++ debian/control 2015-01-19 17:39:20 +0000 | |||
4 | @@ -23,7 +23,7 @@ | |||
5 | 23 | libpam0g-dev, | 23 | libpam0g-dev, |
6 | 24 | libpay2-dev, | 24 | libpay2-dev, |
7 | 25 | libpulse-dev, | 25 | libpulse-dev, |
9 | 26 | libqmenumodel-dev (>= 0.2.8), | 26 | libqmenumodel-dev (>= 0.2.9), |
10 | 27 | libqt5xmlpatterns5-dev, | 27 | libqt5xmlpatterns5-dev, |
11 | 28 | libunity-api-dev (>= 7.94~), | 28 | libunity-api-dev (>= 7.94~), |
12 | 29 | libusermetricsoutput1-dev, | 29 | libusermetricsoutput1-dev, |
13 | @@ -59,7 +59,7 @@ | |||
14 | 59 | 59 | ||
15 | 60 | Package: indicators-client | 60 | Package: indicators-client |
16 | 61 | Architecture: amd64 armhf i386 | 61 | Architecture: amd64 armhf i386 |
18 | 62 | Depends: qmenumodel-qml (>= 0.2.8), | 62 | Depends: qmenumodel-qml (>= 0.2.9), |
19 | 63 | qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.49) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 0.1.49), | 63 | qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.49) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 0.1.49), |
20 | 64 | unity8 (= ${binary:Version}), | 64 | unity8 (= ${binary:Version}), |
21 | 65 | ${misc:Depends}, | 65 | ${misc:Depends}, |
22 | @@ -83,7 +83,7 @@ | |||
23 | 83 | Depends: gsettings-desktop-schemas, | 83 | Depends: gsettings-desktop-schemas, |
24 | 84 | libcap2-bin, | 84 | libcap2-bin, |
25 | 85 | libglib2.0-bin, | 85 | libglib2.0-bin, |
27 | 86 | qmenumodel-qml (>= 0.2.8), | 86 | qmenumodel-qml (>= 0.2.9), |
28 | 87 | qml-module-qtquick-xmllistmodel, | 87 | qml-module-qtquick-xmllistmodel, |
29 | 88 | qtdeclarative5-gsettings1.0, | 88 | qtdeclarative5-gsettings1.0, |
30 | 89 | qtdeclarative5-qtmir-plugin (>= 0.4.4), | 89 | qtdeclarative5-qtmir-plugin (>= 0.4.4), |
31 | 90 | 90 | ||
32 | === modified file 'plugins/Lights/Lights.cpp' | |||
33 | --- plugins/Lights/Lights.cpp 2014-09-08 15:07:24 +0000 | |||
34 | +++ plugins/Lights/Lights.cpp 2015-01-19 17:39:20 +0000 | |||
35 | @@ -44,12 +44,20 @@ | |||
36 | 44 | 44 | ||
37 | 45 | void Lights::setState(Lights::State newState) | 45 | void Lights::setState(Lights::State newState) |
38 | 46 | { | 46 | { |
39 | 47 | if (!init()) { | ||
40 | 48 | qWarning() << "No lights device"; | ||
41 | 49 | return; | ||
42 | 50 | } | ||
43 | 51 | |||
44 | 47 | if (m_state != newState) { | 52 | if (m_state != newState) { |
45 | 48 | if (newState == Lights::On) { | 53 | if (newState == Lights::On) { |
46 | 49 | turnOn(); | 54 | turnOn(); |
47 | 50 | } else { | 55 | } else { |
48 | 51 | turnOff(); | 56 | turnOff(); |
49 | 52 | } | 57 | } |
50 | 58 | |||
51 | 59 | m_state = newState; | ||
52 | 60 | Q_EMIT stateChanged(m_state); | ||
53 | 53 | } | 61 | } |
54 | 54 | } | 62 | } |
55 | 55 | 63 | ||
56 | @@ -115,6 +123,7 @@ | |||
57 | 115 | err = module->methods->open(module, LIGHT_ID_NOTIFICATIONS, &device); | 123 | err = module->methods->open(module, LIGHT_ID_NOTIFICATIONS, &device); |
58 | 116 | if (err == 0) { | 124 | if (err == 0) { |
59 | 117 | m_lightDevice = (light_device_t*)device; | 125 | m_lightDevice = (light_device_t*)device; |
60 | 126 | turnOff(); | ||
61 | 118 | return true; | 127 | return true; |
62 | 119 | } else { | 128 | } else { |
63 | 120 | qWarning() << "Failed to access notification lights"; | 129 | qWarning() << "Failed to access notification lights"; |
64 | @@ -127,15 +136,6 @@ | |||
65 | 127 | 136 | ||
66 | 128 | void Lights::turnOn() | 137 | void Lights::turnOn() |
67 | 129 | { | 138 | { |
68 | 130 | if (!init()) { | ||
69 | 131 | qWarning() << "No lights device"; | ||
70 | 132 | return; | ||
71 | 133 | } | ||
72 | 134 | |||
73 | 135 | if (m_state == Lights::On) { | ||
74 | 136 | return; | ||
75 | 137 | } | ||
76 | 138 | |||
77 | 139 | // pulse | 139 | // pulse |
78 | 140 | light_state_t state; | 140 | light_state_t state; |
79 | 141 | memset(&state, 0, sizeof(light_state_t)); | 141 | memset(&state, 0, sizeof(light_state_t)); |
80 | @@ -147,23 +147,11 @@ | |||
81 | 147 | 147 | ||
82 | 148 | if (m_lightDevice->set_light(m_lightDevice, &state) != 0) { | 148 | if (m_lightDevice->set_light(m_lightDevice, &state) != 0) { |
83 | 149 | qWarning() << "Failed to turn the light off"; | 149 | qWarning() << "Failed to turn the light off"; |
84 | 150 | } else { | ||
85 | 151 | m_state = Lights::On; | ||
86 | 152 | Q_EMIT stateChanged(m_state); | ||
87 | 153 | } | 150 | } |
88 | 154 | } | 151 | } |
89 | 155 | 152 | ||
90 | 156 | void Lights::turnOff() | 153 | void Lights::turnOff() |
91 | 157 | { | 154 | { |
92 | 158 | if (!init()) { | ||
93 | 159 | qWarning() << "No lights device"; | ||
94 | 160 | return; | ||
95 | 161 | } | ||
96 | 162 | |||
97 | 163 | if (m_state == Lights::Off) { | ||
98 | 164 | return; | ||
99 | 165 | } | ||
100 | 166 | |||
101 | 167 | light_state_t state; | 155 | light_state_t state; |
102 | 168 | memset(&state, 0, sizeof(light_state_t)); | 156 | memset(&state, 0, sizeof(light_state_t)); |
103 | 169 | state.color = 0x00000000; | 157 | state.color = 0x00000000; |
104 | @@ -174,8 +162,5 @@ | |||
105 | 174 | 162 | ||
106 | 175 | if (m_lightDevice->set_light(m_lightDevice, &state) != 0) { | 163 | if (m_lightDevice->set_light(m_lightDevice, &state) != 0) { |
107 | 176 | qWarning() << "Failed to turn the light off"; | 164 | qWarning() << "Failed to turn the light off"; |
108 | 177 | } else { | ||
109 | 178 | m_state = Lights::Off; | ||
110 | 179 | Q_EMIT stateChanged(m_state); | ||
111 | 180 | } | 165 | } |
112 | 181 | } | 166 | } |
113 | 182 | 167 | ||
114 | === modified file 'plugins/Unity/Indicators/CMakeLists.txt' | |||
115 | --- plugins/Unity/Indicators/CMakeLists.txt 2014-10-03 10:53:02 +0000 | |||
116 | +++ plugins/Unity/Indicators/CMakeLists.txt 2015-01-19 17:39:20 +0000 | |||
117 | @@ -16,14 +16,16 @@ | |||
118 | 16 | ) | 16 | ) |
119 | 17 | 17 | ||
120 | 18 | set(IndicatorsQML_SOURCES | 18 | set(IndicatorsQML_SOURCES |
121 | 19 | actionrootstate.cpp | ||
122 | 19 | indicator.cpp | 20 | indicator.cpp |
123 | 20 | indicators.h | 21 | indicators.h |
124 | 21 | indicatorsmanager.cpp | 22 | indicatorsmanager.cpp |
125 | 22 | indicatorsmodel.cpp | 23 | indicatorsmodel.cpp |
126 | 23 | menucontentactivator.cpp | 24 | menucontentactivator.cpp |
127 | 25 | modelactionrootstate.cpp | ||
128 | 24 | modelprinter.cpp | 26 | modelprinter.cpp |
129 | 25 | plugin.cpp | 27 | plugin.cpp |
131 | 26 | rootactionstate.cpp | 28 | rootstateparser.cpp |
132 | 27 | sharedunitymenumodel.cpp | 29 | sharedunitymenumodel.cpp |
133 | 28 | unitymenumodelcache.cpp | 30 | unitymenumodelcache.cpp |
134 | 29 | unitymenumodelstack.cpp | 31 | unitymenumodelstack.cpp |
135 | 30 | 32 | ||
136 | === added file 'plugins/Unity/Indicators/actionrootstate.cpp' | |||
137 | --- plugins/Unity/Indicators/actionrootstate.cpp 1970-01-01 00:00:00 +0000 | |||
138 | +++ plugins/Unity/Indicators/actionrootstate.cpp 2015-01-19 17:39:20 +0000 | |||
139 | @@ -0,0 +1,97 @@ | |||
140 | 1 | /* | ||
141 | 2 | * Copyright 2014 Canonical Ltd. | ||
142 | 3 | * | ||
143 | 4 | * This program is free software; you can redistribute it and/or modify | ||
144 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
145 | 6 | * the Free Software Foundation; version 3. | ||
146 | 7 | * | ||
147 | 8 | * This program is distributed in the hope that it will be useful, | ||
148 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
149 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
150 | 11 | * GNU Lesser General Public License for more details. | ||
151 | 12 | * | ||
152 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
153 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
154 | 15 | */ | ||
155 | 16 | |||
156 | 17 | #include "actionrootstate.h" | ||
157 | 18 | |||
158 | 19 | #include <qdbusactiongroup.h> | ||
159 | 20 | #include <QDebug> | ||
160 | 21 | |||
161 | 22 | ActionRootState::ActionRootState(QObject *parent) | ||
162 | 23 | : RootStateObject(parent) | ||
163 | 24 | , m_actionGroup(nullptr) | ||
164 | 25 | { | ||
165 | 26 | } | ||
166 | 27 | |||
167 | 28 | QDBusActionGroup *ActionRootState::actionGroup() const | ||
168 | 29 | { | ||
169 | 30 | return m_actionGroup; | ||
170 | 31 | } | ||
171 | 32 | |||
172 | 33 | void ActionRootState::setActionGroup(QDBusActionGroup *actionGroup) | ||
173 | 34 | { | ||
174 | 35 | if (m_actionGroup != actionGroup) { | ||
175 | 36 | bool wasValid = valid(); | ||
176 | 37 | |||
177 | 38 | if (m_actionGroup) { | ||
178 | 39 | disconnect(m_actionGroup, 0, this, 0); | ||
179 | 40 | } | ||
180 | 41 | m_actionGroup = actionGroup; | ||
181 | 42 | |||
182 | 43 | if (m_actionGroup) { | ||
183 | 44 | connect(m_actionGroup, &QDBusActionGroup::statusChanged, this, [&](bool) { updateActionState(); }); | ||
184 | 45 | connect(m_actionGroup, &QDBusActionGroup::actionAppear, this, [&](const QString&) { updateActionState(); }); | ||
185 | 46 | connect(m_actionGroup, &QDBusActionGroup::actionVanish, this, [&](const QString&) { updateActionState(); }); | ||
186 | 47 | connect(m_actionGroup, &QDBusActionGroup::actionStateChanged, this, [&](QVariant) { updateActionState(); }); | ||
187 | 48 | |||
188 | 49 | connect(m_actionGroup, &QObject::destroyed, this, [&](QObject*) { updateActionState(); }); | ||
189 | 50 | } | ||
190 | 51 | updateActionState(); | ||
191 | 52 | Q_EMIT actionGroupChanged(); | ||
192 | 53 | |||
193 | 54 | if (wasValid != valid()) Q_EMIT validChanged(); | ||
194 | 55 | } | ||
195 | 56 | } | ||
196 | 57 | |||
197 | 58 | QString ActionRootState::actionName() const | ||
198 | 59 | { | ||
199 | 60 | return m_actionName; | ||
200 | 61 | } | ||
201 | 62 | |||
202 | 63 | void ActionRootState::setActionName(const QString &actionName) | ||
203 | 64 | { | ||
204 | 65 | if (m_actionName != actionName) { | ||
205 | 66 | bool wasValid = valid(); | ||
206 | 67 | |||
207 | 68 | m_actionName = actionName; | ||
208 | 69 | updateActionState(); | ||
209 | 70 | |||
210 | 71 | Q_EMIT actionNameChanged(); | ||
211 | 72 | |||
212 | 73 | if (wasValid != valid()) Q_EMIT validChanged(); | ||
213 | 74 | } | ||
214 | 75 | } | ||
215 | 76 | |||
216 | 77 | bool ActionRootState::valid() const | ||
217 | 78 | { | ||
218 | 79 | return m_actionGroup && m_actionGroup->status() == DBusEnums::Connected && | ||
219 | 80 | !m_actionName.isEmpty() && m_actionGroup->hasAction(m_actionName); | ||
220 | 81 | } | ||
221 | 82 | |||
222 | 83 | void ActionRootState::updateActionState() | ||
223 | 84 | { | ||
224 | 85 | if (valid()) { | ||
225 | 86 | ActionStateParser* oldParser = m_actionGroup->actionStateParser(); | ||
226 | 87 | m_actionGroup->setActionStateParser(&m_parser); | ||
227 | 88 | |||
228 | 89 | QVariantMap state = m_actionGroup->actionState(m_actionName).toMap(); | ||
229 | 90 | |||
230 | 91 | m_actionGroup->setActionStateParser(oldParser); | ||
231 | 92 | |||
232 | 93 | setCurrentState(state); | ||
233 | 94 | } else { | ||
234 | 95 | setCurrentState(QVariantMap()); | ||
235 | 96 | } | ||
236 | 97 | } | ||
237 | 0 | 98 | ||
238 | === added file 'plugins/Unity/Indicators/actionrootstate.h' | |||
239 | --- plugins/Unity/Indicators/actionrootstate.h 1970-01-01 00:00:00 +0000 | |||
240 | +++ plugins/Unity/Indicators/actionrootstate.h 2015-01-19 17:39:20 +0000 | |||
241 | @@ -0,0 +1,55 @@ | |||
242 | 1 | /* | ||
243 | 2 | * Copyright 2014 Canonical Ltd. | ||
244 | 3 | * | ||
245 | 4 | * This program is free software; you can redistribute it and/or modify | ||
246 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
247 | 6 | * the Free Software Foundation; version 3. | ||
248 | 7 | * | ||
249 | 8 | * This program is distributed in the hope that it will be useful, | ||
250 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
251 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
252 | 11 | * GNU Lesser General Public License for more details. | ||
253 | 12 | * | ||
254 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
255 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
256 | 15 | */ | ||
257 | 16 | |||
258 | 17 | #ifndef ACTIONROOTSTATE_H | ||
259 | 18 | #define ACTIONROOTSTATE_H | ||
260 | 19 | |||
261 | 20 | #include "unityindicatorsglobal.h" | ||
262 | 21 | |||
263 | 22 | #include "rootstateparser.h" | ||
264 | 23 | |||
265 | 24 | class QDBusActionGroup; | ||
266 | 25 | |||
267 | 26 | class UNITYINDICATORS_EXPORT ActionRootState : public RootStateObject | ||
268 | 27 | { | ||
269 | 28 | Q_OBJECT | ||
270 | 29 | Q_PROPERTY(QDBusActionGroup* actionGroup READ actionGroup WRITE setActionGroup NOTIFY actionGroupChanged) | ||
271 | 30 | Q_PROPERTY(QString actionName READ actionName WRITE setActionName NOTIFY actionNameChanged) | ||
272 | 31 | |||
273 | 32 | public: | ||
274 | 33 | ActionRootState(QObject *parent = 0); | ||
275 | 34 | |||
276 | 35 | QDBusActionGroup *actionGroup() const; | ||
277 | 36 | void setActionGroup(QDBusActionGroup *actionGroup); | ||
278 | 37 | |||
279 | 38 | QString actionName() const; | ||
280 | 39 | void setActionName(const QString& actionName); | ||
281 | 40 | |||
282 | 41 | bool valid() const override; | ||
283 | 42 | |||
284 | 43 | Q_SIGNALS: | ||
285 | 44 | void actionGroupChanged(); | ||
286 | 45 | void actionNameChanged(); | ||
287 | 46 | |||
288 | 47 | private Q_SLOTS: | ||
289 | 48 | void updateActionState(); | ||
290 | 49 | |||
291 | 50 | private: | ||
292 | 51 | QDBusActionGroup* m_actionGroup; | ||
293 | 52 | QString m_actionName; | ||
294 | 53 | }; | ||
295 | 54 | |||
296 | 55 | #endif // ACTIONROOTSTATE_H | ||
297 | 0 | 56 | ||
298 | === added file 'plugins/Unity/Indicators/modelactionrootstate.cpp' | |||
299 | --- plugins/Unity/Indicators/modelactionrootstate.cpp 1970-01-01 00:00:00 +0000 | |||
300 | +++ plugins/Unity/Indicators/modelactionrootstate.cpp 2015-01-19 17:39:20 +0000 | |||
301 | @@ -0,0 +1,127 @@ | |||
302 | 1 | /* | ||
303 | 2 | * Copyright 2013 Canonical Ltd. | ||
304 | 3 | * | ||
305 | 4 | * This program is free software; you can redistribute it and/or modify | ||
306 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
307 | 6 | * the Free Software Foundation; version 3. | ||
308 | 7 | * | ||
309 | 8 | * This program is distributed in the hope that it will be useful, | ||
310 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
311 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
312 | 11 | * GNU Lesser General Public License for more details. | ||
313 | 12 | * | ||
314 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
315 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
316 | 15 | * | ||
317 | 16 | * Authors: | ||
318 | 17 | * Nick Dedekind <nick.dedekind@canonical.com> | ||
319 | 18 | */ | ||
320 | 19 | |||
321 | 20 | #include "modelactionrootstate.h" | ||
322 | 21 | #include "indicators.h" | ||
323 | 22 | |||
324 | 23 | #include <unitymenumodel.h> | ||
325 | 24 | #include <QVariant> | ||
326 | 25 | #include <QIcon> | ||
327 | 26 | |||
328 | 27 | extern "C" { | ||
329 | 28 | #include <glib.h> | ||
330 | 29 | #include <gio/gio.h> | ||
331 | 30 | } | ||
332 | 31 | |||
333 | 32 | ModelActionRootState::ModelActionRootState(QObject *parent) | ||
334 | 33 | : RootStateObject(parent), | ||
335 | 34 | m_menu(nullptr) | ||
336 | 35 | { | ||
337 | 36 | } | ||
338 | 37 | |||
339 | 38 | ModelActionRootState::~ModelActionRootState() | ||
340 | 39 | { | ||
341 | 40 | } | ||
342 | 41 | |||
343 | 42 | UnityMenuModel* ModelActionRootState::menu() const | ||
344 | 43 | { | ||
345 | 44 | return m_menu; | ||
346 | 45 | } | ||
347 | 46 | |||
348 | 47 | void ModelActionRootState::setMenu(UnityMenuModel* menu) | ||
349 | 48 | { | ||
350 | 49 | if (m_menu != menu) { | ||
351 | 50 | bool wasValid = valid(); | ||
352 | 51 | |||
353 | 52 | if (m_menu) { | ||
354 | 53 | m_menu->disconnect(this); | ||
355 | 54 | } | ||
356 | 55 | m_menu = menu; | ||
357 | 56 | |||
358 | 57 | if (m_menu) { | ||
359 | 58 | connect(m_menu, SIGNAL(rowsInserted(const QModelIndex&, int, int)), SLOT(onModelRowsAdded(const QModelIndex&, int, int))); | ||
360 | 59 | connect(m_menu, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onModelRowsRemoved(const QModelIndex&, int, int))); | ||
361 | 60 | connect(m_menu, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SLOT(onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&))); | ||
362 | 61 | |||
363 | 62 | connect(m_menu, SIGNAL(destroyed()), SLOT(reset())); | ||
364 | 63 | } | ||
365 | 64 | updateActionState(); | ||
366 | 65 | Q_EMIT menuChanged(); | ||
367 | 66 | |||
368 | 67 | if (wasValid != valid()) | ||
369 | 68 | Q_EMIT validChanged(); | ||
370 | 69 | } | ||
371 | 70 | } | ||
372 | 71 | |||
373 | 72 | bool ModelActionRootState::valid() const | ||
374 | 73 | { | ||
375 | 74 | return m_menu && m_menu->rowCount() > 0; | ||
376 | 75 | } | ||
377 | 76 | |||
378 | 77 | void ModelActionRootState::onModelRowsAdded(const QModelIndex& parent, int start, int end) | ||
379 | 78 | { | ||
380 | 79 | Q_UNUSED(parent); | ||
381 | 80 | if (start == 0 && end >= 0) { | ||
382 | 81 | updateActionState(); | ||
383 | 82 | } | ||
384 | 83 | } | ||
385 | 84 | |||
386 | 85 | void ModelActionRootState::onModelRowsRemoved(const QModelIndex& parent, int start, int end) | ||
387 | 86 | { | ||
388 | 87 | Q_UNUSED(parent); | ||
389 | 88 | if (start == 0 && end >= 0) { | ||
390 | 89 | updateActionState(); | ||
391 | 90 | } | ||
392 | 91 | } | ||
393 | 92 | |||
394 | 93 | void ModelActionRootState::onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles) | ||
395 | 94 | { | ||
396 | 95 | Q_UNUSED(roles); | ||
397 | 96 | if (!topLeft.isValid() || !bottomRight.isValid()) { | ||
398 | 97 | return; | ||
399 | 98 | } | ||
400 | 99 | |||
401 | 100 | if (topLeft.row() <= 0 && bottomRight.row() >= 0) { | ||
402 | 101 | updateActionState(); | ||
403 | 102 | } | ||
404 | 103 | } | ||
405 | 104 | |||
406 | 105 | void ModelActionRootState::reset() | ||
407 | 106 | { | ||
408 | 107 | m_menu = nullptr; | ||
409 | 108 | |||
410 | 109 | Q_EMIT menuChanged(); | ||
411 | 110 | setCurrentState(QVariantMap()); | ||
412 | 111 | } | ||
413 | 112 | |||
414 | 113 | void ModelActionRootState::updateActionState() | ||
415 | 114 | { | ||
416 | 115 | if (m_menu && m_menu->rowCount() > 0) { | ||
417 | 116 | ActionStateParser* oldParser = m_menu->actionStateParser(); | ||
418 | 117 | m_menu->setActionStateParser(&m_parser); | ||
419 | 118 | |||
420 | 119 | QVariantMap state = m_menu->get(0, "actionState").toMap(); | ||
421 | 120 | |||
422 | 121 | m_menu->setActionStateParser(oldParser); | ||
423 | 122 | |||
424 | 123 | setCurrentState(state); | ||
425 | 124 | } else { | ||
426 | 125 | setCurrentState(QVariantMap()); | ||
427 | 126 | } | ||
428 | 127 | } | ||
429 | 0 | 128 | ||
430 | === added file 'plugins/Unity/Indicators/modelactionrootstate.h' | |||
431 | --- plugins/Unity/Indicators/modelactionrootstate.h 1970-01-01 00:00:00 +0000 | |||
432 | +++ plugins/Unity/Indicators/modelactionrootstate.h 2015-01-19 17:39:20 +0000 | |||
433 | @@ -0,0 +1,61 @@ | |||
434 | 1 | /* | ||
435 | 2 | * Copyright 2013 Canonical Ltd. | ||
436 | 3 | * | ||
437 | 4 | * This program is free software; you can redistribute it and/or modify | ||
438 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
439 | 6 | * the Free Software Foundation; version 3. | ||
440 | 7 | * | ||
441 | 8 | * This program is distributed in the hope that it will be useful, | ||
442 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
443 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
444 | 11 | * GNU Lesser General Public License for more details. | ||
445 | 12 | * | ||
446 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
447 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
448 | 15 | * | ||
449 | 16 | * Authors: | ||
450 | 17 | * Nick Dedekind <nick.dedekind@canonical.com> | ||
451 | 18 | */ | ||
452 | 19 | |||
453 | 20 | #ifndef MODELACTIONROOTSTATE_H | ||
454 | 21 | #define MODELACTIONROOTSTATE_H | ||
455 | 22 | |||
456 | 23 | #include "unityindicatorsglobal.h" | ||
457 | 24 | |||
458 | 25 | #include "rootstateparser.h" | ||
459 | 26 | |||
460 | 27 | class UnityMenuModel; | ||
461 | 28 | |||
462 | 29 | class UNITYINDICATORS_EXPORT ModelActionRootState : public RootStateObject | ||
463 | 30 | { | ||
464 | 31 | Q_OBJECT | ||
465 | 32 | Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged) | ||
466 | 33 | public: | ||
467 | 34 | ModelActionRootState(QObject *parent = 0); | ||
468 | 35 | virtual ~ModelActionRootState(); | ||
469 | 36 | |||
470 | 37 | UnityMenuModel* menu() const; | ||
471 | 38 | void setMenu(UnityMenuModel* menu); | ||
472 | 39 | |||
473 | 40 | int index() const; | ||
474 | 41 | void setIndex(int index); | ||
475 | 42 | |||
476 | 43 | bool valid() const override; | ||
477 | 44 | |||
478 | 45 | Q_SIGNALS: | ||
479 | 46 | void menuChanged(); | ||
480 | 47 | void indexChanged(); | ||
481 | 48 | |||
482 | 49 | private Q_SLOTS: | ||
483 | 50 | void onModelRowsAdded(const QModelIndex& parent, int start, int end); | ||
484 | 51 | void onModelRowsRemoved(const QModelIndex& parent, int start, int end); | ||
485 | 52 | void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&); | ||
486 | 53 | void reset(); | ||
487 | 54 | |||
488 | 55 | private: | ||
489 | 56 | void updateActionState(); | ||
490 | 57 | |||
491 | 58 | UnityMenuModel* m_menu; | ||
492 | 59 | }; | ||
493 | 60 | |||
494 | 61 | #endif // MODELACTIONROOTSTATE_H | ||
495 | 0 | 62 | ||
496 | === modified file 'plugins/Unity/Indicators/plugin.cpp' | |||
497 | --- plugins/Unity/Indicators/plugin.cpp 2014-10-07 10:28:59 +0000 | |||
498 | +++ plugins/Unity/Indicators/plugin.cpp 2015-01-19 17:39:20 +0000 | |||
499 | @@ -24,12 +24,13 @@ | |||
500 | 24 | #include "plugin.h" | 24 | #include "plugin.h" |
501 | 25 | 25 | ||
502 | 26 | // local | 26 | // local |
503 | 27 | #include "actionrootstate.h" | ||
504 | 27 | #include "indicators.h" | 28 | #include "indicators.h" |
505 | 28 | #include "indicatorsmanager.h" | 29 | #include "indicatorsmanager.h" |
506 | 29 | #include "indicatorsmodel.h" | 30 | #include "indicatorsmodel.h" |
507 | 30 | #include "menucontentactivator.h" | 31 | #include "menucontentactivator.h" |
508 | 32 | #include "modelactionrootstate.h" | ||
509 | 31 | #include "modelprinter.h" | 33 | #include "modelprinter.h" |
510 | 32 | #include "rootactionstate.h" | ||
511 | 33 | #include "sharedunitymenumodel.h" | 34 | #include "sharedunitymenumodel.h" |
512 | 34 | #include "unitymenumodelcache.h" | 35 | #include "unitymenumodelcache.h" |
513 | 35 | #include "unitymenumodelstack.h" | 36 | #include "unitymenumodelstack.h" |
514 | @@ -51,7 +52,8 @@ | |||
515 | 51 | qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel"); | 52 | qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel"); |
516 | 52 | qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator"); | 53 | qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator"); |
517 | 53 | qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack"); | 54 | qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack"); |
519 | 54 | qmlRegisterType<RootActionState>(uri, 0, 1, "RootActionState"); | 55 | qmlRegisterType<ModelActionRootState>(uri, 0, 1, "ModelActionRootState"); |
520 | 56 | qmlRegisterType<ActionRootState>(uri, 0, 1, "ActionRootState"); | ||
521 | 55 | qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter"); | 57 | qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter"); |
522 | 56 | qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel"); | 58 | qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel"); |
523 | 57 | qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel"); | 59 | qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel"); |
524 | 58 | 60 | ||
525 | === renamed file 'plugins/Unity/Indicators/rootactionstate.cpp' => 'plugins/Unity/Indicators/rootstateparser.cpp' | |||
526 | --- plugins/Unity/Indicators/rootactionstate.cpp 2014-10-20 12:38:16 +0000 | |||
527 | +++ plugins/Unity/Indicators/rootstateparser.cpp 2015-01-19 17:39:20 +0000 | |||
528 | @@ -12,155 +12,18 @@ | |||
529 | 12 | * | 12 | * |
530 | 13 | * You should have received a copy of the GNU Lesser General Public License | 13 | * You should have received a copy of the GNU Lesser General Public License |
531 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
532 | 15 | * | ||
533 | 16 | * Authors: | ||
534 | 17 | * Nick Dedekind <nick.dedekind@canonical.com> | ||
535 | 18 | */ | 15 | */ |
536 | 19 | 16 | ||
543 | 20 | #include "rootactionstate.h" | 17 | #include "rootstateparser.h" |
538 | 21 | #include "indicators.h" | ||
539 | 22 | |||
540 | 23 | #include <unitymenumodel.h> | ||
541 | 24 | #include <QVariant> | ||
542 | 25 | #include <QIcon> | ||
544 | 26 | 18 | ||
545 | 27 | extern "C" { | 19 | extern "C" { |
546 | 28 | #include <glib.h> | 20 | #include <glib.h> |
547 | 29 | #include <gio/gio.h> | 21 | #include <gio/gio.h> |
548 | 30 | } | 22 | } |
549 | 31 | 23 | ||
682 | 32 | RootActionState::RootActionState(QObject *parent) | 24 | RootStateParser::RootStateParser(QObject* parent) |
683 | 33 | : ActionStateParser(parent), | 25 | : ActionStateParser(parent) |
684 | 34 | m_menu(nullptr) | 26 | { |
553 | 35 | { | ||
554 | 36 | } | ||
555 | 37 | |||
556 | 38 | RootActionState::~RootActionState() | ||
557 | 39 | { | ||
558 | 40 | } | ||
559 | 41 | |||
560 | 42 | UnityMenuModel* RootActionState::menu() const | ||
561 | 43 | { | ||
562 | 44 | return m_menu; | ||
563 | 45 | } | ||
564 | 46 | |||
565 | 47 | void RootActionState::setMenu(UnityMenuModel* menu) | ||
566 | 48 | { | ||
567 | 49 | if (m_menu != menu) { | ||
568 | 50 | if (m_menu) { | ||
569 | 51 | m_menu->disconnect(this); | ||
570 | 52 | } | ||
571 | 53 | m_menu = menu; | ||
572 | 54 | |||
573 | 55 | if (m_menu) { | ||
574 | 56 | connect(m_menu, SIGNAL(rowsInserted(const QModelIndex&, int, int)), SLOT(onModelRowsAdded(const QModelIndex&, int, int))); | ||
575 | 57 | connect(m_menu, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onModelRowsRemoved(const QModelIndex&, int, int))); | ||
576 | 58 | connect(m_menu, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SLOT(onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&))); | ||
577 | 59 | |||
578 | 60 | connect(m_menu, SIGNAL(destroyed()), SLOT(reset())); | ||
579 | 61 | } | ||
580 | 62 | updateActionState(); | ||
581 | 63 | Q_EMIT menuChanged(); | ||
582 | 64 | } | ||
583 | 65 | } | ||
584 | 66 | |||
585 | 67 | void RootActionState::onModelRowsAdded(const QModelIndex& parent, int start, int end) | ||
586 | 68 | { | ||
587 | 69 | Q_UNUSED(parent); | ||
588 | 70 | if (start == 0 && end >= 0) { | ||
589 | 71 | updateActionState(); | ||
590 | 72 | } | ||
591 | 73 | } | ||
592 | 74 | |||
593 | 75 | void RootActionState::onModelRowsRemoved(const QModelIndex& parent, int start, int end) | ||
594 | 76 | { | ||
595 | 77 | Q_UNUSED(parent); | ||
596 | 78 | if (start == 0 && end >= 0) { | ||
597 | 79 | updateActionState(); | ||
598 | 80 | } | ||
599 | 81 | } | ||
600 | 82 | |||
601 | 83 | void RootActionState::onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles) | ||
602 | 84 | { | ||
603 | 85 | Q_UNUSED(roles); | ||
604 | 86 | if (!topLeft.isValid() || !bottomRight.isValid()) { | ||
605 | 87 | return; | ||
606 | 88 | } | ||
607 | 89 | |||
608 | 90 | if (topLeft.row() <= 0 && bottomRight.row() >= 0) { | ||
609 | 91 | updateActionState(); | ||
610 | 92 | } | ||
611 | 93 | } | ||
612 | 94 | |||
613 | 95 | void RootActionState::reset() | ||
614 | 96 | { | ||
615 | 97 | m_cachedState.clear(); | ||
616 | 98 | m_menu = nullptr; | ||
617 | 99 | |||
618 | 100 | Q_EMIT menuChanged(); | ||
619 | 101 | Q_EMIT updated(); | ||
620 | 102 | } | ||
621 | 103 | |||
622 | 104 | void RootActionState::updateActionState() | ||
623 | 105 | { | ||
624 | 106 | if (m_menu && m_menu->rowCount() > 0) { | ||
625 | 107 | ActionStateParser* oldParser = m_menu->actionStateParser(); | ||
626 | 108 | m_menu->setActionStateParser(this); | ||
627 | 109 | |||
628 | 110 | m_cachedState = m_menu->get(0, "actionState").toMap(); | ||
629 | 111 | |||
630 | 112 | m_menu->setActionStateParser(oldParser); | ||
631 | 113 | } else { | ||
632 | 114 | m_cachedState.clear(); | ||
633 | 115 | } | ||
634 | 116 | Q_EMIT updated(); | ||
635 | 117 | } | ||
636 | 118 | |||
637 | 119 | bool RootActionState::isValid() const | ||
638 | 120 | { | ||
639 | 121 | return m_menu && m_menu->rowCount() > 0; | ||
640 | 122 | } | ||
641 | 123 | |||
642 | 124 | QString RootActionState::title() const | ||
643 | 125 | { | ||
644 | 126 | if (!isValid()) return QString(); | ||
645 | 127 | |||
646 | 128 | return m_cachedState.value("title", QVariant::fromValue(QString())).toString(); | ||
647 | 129 | } | ||
648 | 130 | |||
649 | 131 | QString RootActionState::leftLabel() const | ||
650 | 132 | { | ||
651 | 133 | if (!isValid()) return QString(); | ||
652 | 134 | |||
653 | 135 | return m_cachedState.value("pre-label", QVariant::fromValue(QString())).toString(); | ||
654 | 136 | } | ||
655 | 137 | |||
656 | 138 | QString RootActionState::rightLabel() const | ||
657 | 139 | { | ||
658 | 140 | if (!isValid()) return QString(); | ||
659 | 141 | |||
660 | 142 | return m_cachedState.value("label", QVariant::fromValue(QString())).toString(); | ||
661 | 143 | } | ||
662 | 144 | |||
663 | 145 | QStringList RootActionState::icons() const | ||
664 | 146 | { | ||
665 | 147 | if (!isValid()) return QStringList(); | ||
666 | 148 | |||
667 | 149 | return m_cachedState.value("icons", QVariant::fromValue(QStringList())).toStringList(); | ||
668 | 150 | } | ||
669 | 151 | |||
670 | 152 | QString RootActionState::accessibleName() const | ||
671 | 153 | { | ||
672 | 154 | if (!isValid()) return QString(); | ||
673 | 155 | |||
674 | 156 | return m_cachedState.value("accessible-desc", QVariant::fromValue(QString())).toString(); | ||
675 | 157 | } | ||
676 | 158 | |||
677 | 159 | bool RootActionState::indicatorVisible() const | ||
678 | 160 | { | ||
679 | 161 | if (!isValid()) return false; | ||
680 | 162 | |||
681 | 163 | return m_cachedState.value("visible", QVariant::fromValue(true)).toBool(); | ||
685 | 164 | } | 27 | } |
686 | 165 | 28 | ||
687 | 166 | static QString iconUri(GIcon *icon) | 29 | static QString iconUri(GIcon *icon) |
688 | @@ -209,7 +72,7 @@ | |||
689 | 209 | return uri; | 72 | return uri; |
690 | 210 | } | 73 | } |
691 | 211 | 74 | ||
693 | 212 | QVariant RootActionState::toQVariant(GVariant* state) const | 75 | QVariant RootStateParser::toQVariant(GVariant* state) const |
694 | 213 | { | 76 | { |
695 | 214 | if (!state) { | 77 | if (!state) { |
696 | 215 | return QVariant(); | 78 | return QVariant(); |
697 | @@ -296,3 +159,73 @@ | |||
698 | 296 | } | 159 | } |
699 | 297 | return ActionStateParser::toQVariant(state); | 160 | return ActionStateParser::toQVariant(state); |
700 | 298 | } | 161 | } |
701 | 162 | |||
702 | 163 | |||
703 | 164 | RootStateObject::RootStateObject(QObject* parent) | ||
704 | 165 | : QObject(parent) | ||
705 | 166 | { | ||
706 | 167 | } | ||
707 | 168 | |||
708 | 169 | QString RootStateObject::title() const | ||
709 | 170 | { | ||
710 | 171 | if (!valid()) return QString(); | ||
711 | 172 | |||
712 | 173 | return m_currentState.value("title", QVariant::fromValue(QString())).toString(); | ||
713 | 174 | } | ||
714 | 175 | |||
715 | 176 | QString RootStateObject::leftLabel() const | ||
716 | 177 | { | ||
717 | 178 | if (!valid()) return QString(); | ||
718 | 179 | |||
719 | 180 | return m_currentState.value("pre-label", QVariant::fromValue(QString())).toString(); | ||
720 | 181 | } | ||
721 | 182 | |||
722 | 183 | QString RootStateObject::rightLabel() const | ||
723 | 184 | { | ||
724 | 185 | if (!valid()) return QString(); | ||
725 | 186 | |||
726 | 187 | return m_currentState.value("label", QVariant::fromValue(QString())).toString(); | ||
727 | 188 | } | ||
728 | 189 | |||
729 | 190 | QStringList RootStateObject::icons() const | ||
730 | 191 | { | ||
731 | 192 | if (!valid()) return QStringList(); | ||
732 | 193 | |||
733 | 194 | return m_currentState.value("icons", QVariant::fromValue(QStringList())).toStringList(); | ||
734 | 195 | } | ||
735 | 196 | |||
736 | 197 | QString RootStateObject::accessibleName() const | ||
737 | 198 | { | ||
738 | 199 | if (!valid()) return QString(); | ||
739 | 200 | |||
740 | 201 | return m_currentState.value("accessible-desc", QVariant::fromValue(QString())).toString(); | ||
741 | 202 | } | ||
742 | 203 | |||
743 | 204 | bool RootStateObject::indicatorVisible() const | ||
744 | 205 | { | ||
745 | 206 | if (!valid()) return false; | ||
746 | 207 | |||
747 | 208 | return m_currentState.value("visible", QVariant::fromValue(true)).toBool(); | ||
748 | 209 | } | ||
749 | 210 | |||
750 | 211 | void RootStateObject::setCurrentState(const QVariantMap& newState) | ||
751 | 212 | { | ||
752 | 213 | QString oldTitle = title(); | ||
753 | 214 | QString oldLeftLabel = leftLabel(); | ||
754 | 215 | QString oldRightLabel = rightLabel(); | ||
755 | 216 | QStringList oldIcons = icons(); | ||
756 | 217 | QString oldAccessibleName = accessibleName(); | ||
757 | 218 | bool oldIndicatorVisible = indicatorVisible(); | ||
758 | 219 | |||
759 | 220 | if (m_currentState != newState) { | ||
760 | 221 | m_currentState = newState; | ||
761 | 222 | Q_EMIT updated(); | ||
762 | 223 | |||
763 | 224 | if (oldTitle != title()) Q_EMIT titleChanged(); | ||
764 | 225 | if (oldLeftLabel != leftLabel()) Q_EMIT leftLabelChanged(); | ||
765 | 226 | if (oldRightLabel != rightLabel()) Q_EMIT rightLabelChanged(); | ||
766 | 227 | if (oldIcons != icons()) Q_EMIT iconsChanged(); | ||
767 | 228 | if (oldAccessibleName != accessibleName()) Q_EMIT accessibleNameChanged(); | ||
768 | 229 | if (oldIndicatorVisible != indicatorVisible()) Q_EMIT indicatorVisibleChanged(); | ||
769 | 230 | } | ||
770 | 231 | } | ||
771 | 299 | 232 | ||
772 | === renamed file 'plugins/Unity/Indicators/rootactionstate.h' => 'plugins/Unity/Indicators/rootstateparser.h' | |||
773 | --- plugins/Unity/Indicators/rootactionstate.h 2014-10-20 12:38:16 +0000 | |||
774 | +++ plugins/Unity/Indicators/rootstateparser.h 2015-01-19 17:39:20 +0000 | |||
775 | @@ -12,26 +12,27 @@ | |||
776 | 12 | * | 12 | * |
777 | 13 | * You should have received a copy of the GNU Lesser General Public License | 13 | * You should have received a copy of the GNU Lesser General Public License |
778 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
779 | 15 | * | ||
780 | 16 | * Authors: | ||
781 | 17 | * Nick Dedekind <nick.dedekind@canonical.com> | ||
782 | 18 | */ | 15 | */ |
783 | 19 | 16 | ||
786 | 20 | #ifndef ROOTACTIONSTATE_H | 17 | #ifndef ROOTSTATEPARSER_H |
787 | 21 | #define ROOTACTIONSTATE_H | 18 | #define ROOTSTATEPARSER_H |
788 | 22 | 19 | ||
789 | 23 | #include "unityindicatorsglobal.h" | 20 | #include "unityindicatorsglobal.h" |
790 | 24 | 21 | ||
791 | 25 | #include <actionstateparser.h> | 22 | #include <actionstateparser.h> |
792 | 26 | 23 | ||
794 | 27 | class UnityMenuModel; | 24 | class UNITYINDICATORS_EXPORT RootStateParser : public ActionStateParser |
795 | 25 | { | ||
796 | 26 | public: | ||
797 | 27 | RootStateParser(QObject* parent = nullptr); | ||
798 | 28 | virtual QVariant toQVariant(GVariant* state) const override; | ||
799 | 29 | }; | ||
800 | 28 | 30 | ||
802 | 29 | class UNITYINDICATORS_EXPORT RootActionState : public ActionStateParser | 31 | class UNITYINDICATORS_EXPORT RootStateObject : public QObject |
803 | 30 | { | 32 | { |
804 | 31 | Q_OBJECT | 33 | Q_OBJECT |
805 | 32 | Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged) | ||
806 | 33 | 34 | ||
808 | 34 | Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) | 35 | Q_PROPERTY(bool valid READ valid NOTIFY validChanged) |
809 | 35 | Q_PROPERTY(QString title READ title NOTIFY titleChanged) | 36 | Q_PROPERTY(QString title READ title NOTIFY titleChanged) |
810 | 36 | Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged) | 37 | Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged) |
811 | 37 | Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged) | 38 | Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged) |
812 | @@ -39,16 +40,10 @@ | |||
813 | 39 | Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged) | 40 | Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged) |
814 | 40 | Q_PROPERTY(bool indicatorVisible READ indicatorVisible NOTIFY indicatorVisibleChanged) | 41 | Q_PROPERTY(bool indicatorVisible READ indicatorVisible NOTIFY indicatorVisibleChanged) |
815 | 41 | public: | 42 | public: |
826 | 42 | RootActionState(QObject *parent = 0); | 43 | RootStateObject(QObject* parent = 0); |
827 | 43 | virtual ~RootActionState(); | 44 | |
828 | 44 | 45 | virtual bool valid() const = 0; | |
829 | 45 | UnityMenuModel* menu() const; | 46 | |
820 | 46 | void setMenu(UnityMenuModel* menu); | ||
821 | 47 | |||
822 | 48 | int index() const; | ||
823 | 49 | void setIndex(int index); | ||
824 | 50 | |||
825 | 51 | bool isValid() const; | ||
830 | 52 | QString title() const; | 47 | QString title() const; |
831 | 53 | QString leftLabel() const; | 48 | QString leftLabel() const; |
832 | 54 | QString rightLabel() const; | 49 | QString rightLabel() const; |
833 | @@ -56,15 +51,12 @@ | |||
834 | 56 | QString accessibleName() const; | 51 | QString accessibleName() const; |
835 | 57 | bool indicatorVisible() const; | 52 | bool indicatorVisible() const; |
836 | 58 | 53 | ||
839 | 59 | // from ActionStateParser | 54 | QVariantMap currentState() const { return m_currentState; } |
840 | 60 | virtual QVariant toQVariant(GVariant* state) const override; | 55 | void setCurrentState(const QVariantMap& currentState); |
841 | 61 | 56 | ||
842 | 62 | Q_SIGNALS: | 57 | Q_SIGNALS: |
843 | 63 | void updated(); | 58 | void updated(); |
844 | 64 | 59 | ||
845 | 65 | void menuChanged(); | ||
846 | 66 | void indexChanged(); | ||
847 | 67 | |||
848 | 68 | void validChanged(); | 60 | void validChanged(); |
849 | 69 | void titleChanged(); | 61 | void titleChanged(); |
850 | 70 | void leftLabelChanged(); | 62 | void leftLabelChanged(); |
851 | @@ -73,17 +65,9 @@ | |||
852 | 73 | void accessibleNameChanged(); | 65 | void accessibleNameChanged(); |
853 | 74 | void indicatorVisibleChanged(); | 66 | void indicatorVisibleChanged(); |
854 | 75 | 67 | ||
866 | 76 | private Q_SLOTS: | 68 | protected: |
867 | 77 | void onModelRowsAdded(const QModelIndex& parent, int start, int end); | 69 | RootStateParser m_parser; |
868 | 78 | void onModelRowsRemoved(const QModelIndex& parent, int start, int end); | 70 | QVariantMap m_currentState; |
858 | 79 | void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&); | ||
859 | 80 | void reset(); | ||
860 | 81 | |||
861 | 82 | private: | ||
862 | 83 | void updateActionState(); | ||
863 | 84 | |||
864 | 85 | UnityMenuModel* m_menu; | ||
865 | 86 | QVariantMap m_cachedState; | ||
869 | 87 | }; | 71 | }; |
870 | 88 | 72 | ||
872 | 89 | #endif // ROOTACTIONSTATE_H | 73 | #endif // ROOTSTATEPARSER_H |
873 | 90 | 74 | ||
874 | === modified file 'qml/Greeter/Clock.qml' | |||
875 | --- qml/Greeter/Clock.qml 2014-10-07 10:28:59 +0000 | |||
876 | +++ qml/Greeter/Clock.qml 2015-01-19 17:39:20 +0000 | |||
877 | @@ -43,7 +43,7 @@ | |||
878 | 43 | menuObjectPath: clock.visible ? "/com/canonical/indicator/datetime/phone" : "" | 43 | menuObjectPath: clock.visible ? "/com/canonical/indicator/datetime/phone" : "" |
879 | 44 | } | 44 | } |
880 | 45 | 45 | ||
882 | 46 | Indicators.RootActionState { | 46 | Indicators.ModelActionRootState { |
883 | 47 | menu: timeModel.model | 47 | menu: timeModel.model |
884 | 48 | onUpdated: { | 48 | onUpdated: { |
885 | 49 | if (timeLabel.text != rightLabel) { | 49 | if (timeLabel.text != rightLabel) { |
886 | 50 | 50 | ||
887 | === modified file 'qml/Panel/IndicatorItem.qml' | |||
888 | --- qml/Panel/IndicatorItem.qml 2014-10-17 14:55:35 +0000 | |||
889 | +++ qml/Panel/IndicatorItem.qml 2015-01-19 17:39:20 +0000 | |||
890 | @@ -45,14 +45,6 @@ | |||
891 | 45 | onClicked: parent.clicked() | 45 | onClicked: parent.clicked() |
892 | 46 | } | 46 | } |
893 | 47 | 47 | ||
894 | 48 | // FIXME: For now we will enable led indicator support only for messaging indicator | ||
895 | 49 | // in the future we should export a led API insted of doing that, | ||
896 | 50 | Loader { | ||
897 | 51 | id: indicatorLed | ||
898 | 52 | // only load source Component if the icons contains the new message icon | ||
899 | 53 | source: (root.icons && (String(root.icons).indexOf("indicator-messages-new") != -1)) ? Qt.resolvedUrl("Indicators/IndicatorsLight.qml") : "" | ||
900 | 54 | } | ||
901 | 55 | |||
902 | 56 | Item { | 48 | Item { |
903 | 57 | id: mainItems | 49 | id: mainItems |
904 | 58 | anchors.centerIn: parent | 50 | anchors.centerIn: parent |
905 | 59 | 51 | ||
906 | === modified file 'qml/Panel/Indicators/IndicatorBase.qml' | |||
907 | --- qml/Panel/Indicators/IndicatorBase.qml 2014-10-17 14:55:35 +0000 | |||
908 | +++ qml/Panel/Indicators/IndicatorBase.qml 2015-01-19 17:39:20 +0000 | |||
909 | @@ -40,7 +40,7 @@ | |||
910 | 40 | menuObjectPath: indicatorItem.menuObjectPath | 40 | menuObjectPath: indicatorItem.menuObjectPath |
911 | 41 | } | 41 | } |
912 | 42 | 42 | ||
914 | 43 | RootActionState { | 43 | ModelActionRootState { |
915 | 44 | id: rootAction | 44 | id: rootAction |
916 | 45 | menu: menuModel ? menuModel : null | 45 | menu: menuModel ? menuModel : null |
917 | 46 | onUpdated: indicatorItem.rootActionStateChanged() | 46 | onUpdated: indicatorItem.rootActionStateChanged() |
918 | 47 | 47 | ||
919 | === modified file 'qml/Panel/Indicators/IndicatorsLight.qml' | |||
920 | --- qml/Panel/Indicators/IndicatorsLight.qml 2014-08-05 14:31:12 +0000 | |||
921 | +++ qml/Panel/Indicators/IndicatorsLight.qml 2015-01-19 17:39:20 +0000 | |||
922 | @@ -20,16 +20,34 @@ | |||
923 | 20 | import QtQuick 2.0 | 20 | import QtQuick 2.0 |
924 | 21 | import Powerd 0.1 | 21 | import Powerd 0.1 |
925 | 22 | import Lights 0.1 | 22 | import Lights 0.1 |
926 | 23 | import QMenuModel 0.1 as QMenuModel | ||
927 | 24 | import Unity.Indicators 0.1 as Indicators | ||
928 | 23 | 25 | ||
929 | 24 | QtObject { | 26 | QtObject { |
930 | 25 | id: root | 27 | id: root |
931 | 26 | 28 | ||
932 | 29 | property var _actionGroup: QMenuModel.QDBusActionGroup { | ||
933 | 30 | busType: 1 | ||
934 | 31 | busName: "com.canonical.indicator.messages" | ||
935 | 32 | objectPath: "/com/canonical/indicator/messages" | ||
936 | 33 | } | ||
937 | 34 | |||
938 | 35 | property var _rootState: Indicators.ActionRootState { | ||
939 | 36 | actionGroup: _actionGroup | ||
940 | 37 | actionName: "messages" | ||
941 | 38 | Component.onCompleted: actionGroup.start() | ||
942 | 39 | |||
943 | 40 | property bool hasMessages: valid && (String(icons).indexOf("indicator-messages-new") != -1) | ||
944 | 41 | } | ||
945 | 42 | |||
946 | 27 | Component.onDestruction: Lights.state = Lights.Off | 43 | Component.onDestruction: Lights.state = Lights.Off |
947 | 28 | 44 | ||
948 | 29 | // QtObject does not have children | 45 | // QtObject does not have children |
949 | 30 | property var _binding: Binding { | 46 | property var _binding: Binding { |
950 | 31 | target: Lights | 47 | target: Lights |
951 | 32 | property: "state" | 48 | property: "state" |
953 | 33 | value: (Powerd.status === Powerd.Off) ? Lights.On : Lights.Off | 49 | value: { |
954 | 50 | return (Powerd.status === Powerd.Off && _rootState.hasMessages) ? Lights.On : Lights.Off | ||
955 | 51 | } | ||
956 | 34 | } | 52 | } |
957 | 35 | } | 53 | } |
958 | 36 | 54 | ||
959 | === modified file 'qml/Panel/IndicatorsBar.qml' | |||
960 | --- qml/Panel/IndicatorsBar.qml 2014-10-20 20:35:50 +0000 | |||
961 | +++ qml/Panel/IndicatorsBar.qml 2015-01-19 17:39:20 +0000 | |||
962 | @@ -46,13 +46,14 @@ | |||
963 | 46 | 46 | ||
964 | 47 | function addScrollOffset(scrollAmmout) { | 47 | function addScrollOffset(scrollAmmout) { |
965 | 48 | if (scrollAmmout < 0) { // left scroll | 48 | if (scrollAmmout < 0) { // left scroll |
968 | 49 | if (flickable.contentX < 0) return; // already off the left. | 49 | if (flickable.contentX + flickable.width > row.width) return; // already off the left. |
969 | 50 | if (flickable.contentX + scrollAmmout < 0) scrollAmmout = -flickable.contentX; // going to be off the left | 50 | |
970 | 51 | if (flickable.contentX + flickable.width - scrollAmmout > row.width) { // going to be off the right | ||
971 | 52 | scrollAmmout = (flickable.contentX + flickable.width) - row.width; | ||
972 | 53 | } | ||
973 | 51 | } else { // right scroll | 54 | } else { // right scroll |
978 | 52 | if (flickable.contentX + flickable.width > row.width) return; // already off the right. | 55 | if (flickable.contentX < 0) return; // already off the right. |
979 | 53 | if (flickable.contentX + flickable.width + scrollAmmout > row.width) { // going to be off the right | 56 | if (flickable.contentX - scrollAmmout < 0) scrollAmmout = flickable.contentX; // going to be off the right |
976 | 54 | scrollAmmout = row.width - (flickable.contentX + flickable.width); | ||
977 | 55 | } | ||
980 | 56 | } | 57 | } |
981 | 57 | d.scrollOffset = d.scrollOffset + scrollAmmout; | 58 | d.scrollOffset = d.scrollOffset + scrollAmmout; |
982 | 58 | } | 59 | } |
983 | @@ -91,24 +92,26 @@ | |||
984 | 91 | flickable.resetContentXComponents(); | 92 | flickable.resetContentXComponents(); |
985 | 92 | 93 | ||
986 | 93 | if (expanded && !flickable.moving) { | 94 | if (expanded && !flickable.moving) { |
987 | 94 | |||
988 | 95 | // gap between left and row? | 95 | // gap between left and row? |
993 | 96 | if (flickable.contentX < 0) { | 96 | if (flickable.contentX + flickable.width > row.width) { |
990 | 97 | d.alignmentAdjustment += flickable.contentX; | ||
991 | 98 | // gap between right and row? | ||
992 | 99 | } else if (flickable.contentX + flickable.width > row.width) { | ||
994 | 100 | // row width is less than flickable | 97 | // row width is less than flickable |
995 | 101 | if (row.width < flickable.width) { | 98 | if (row.width < flickable.width) { |
997 | 102 | d.alignmentAdjustment += flickable.contentX; | 99 | d.alignmentAdjustment -= flickable.contentX; |
998 | 103 | } else { | 100 | } else { |
1000 | 104 | d.alignmentAdjustment += ((flickable.contentX + flickable.width) - row.width); | 101 | d.alignmentAdjustment -= ((flickable.contentX + flickable.width) - row.width); |
1001 | 105 | } | 102 | } |
1002 | 103 | |||
1003 | 104 | // gap between right and row? | ||
1004 | 105 | } else if (flickable.contentX < 0) { | ||
1005 | 106 | d.alignmentAdjustment -= flickable.contentX; | ||
1006 | 107 | |||
1007 | 106 | // current item overlap on left | 108 | // current item overlap on left |
1010 | 107 | } else if (row.currentItem && row.currentItem.x < flickable.contentX) { | 109 | } else if (row.currentItem && (flickable.contentX + flickable.width) < (row.width - row.currentItem.x)) { |
1011 | 108 | d.alignmentAdjustment -= (row.currentItem.x - flickable.contentX); | 110 | d.alignmentAdjustment += ((row.width - row.currentItem.x) - (flickable.contentX + flickable.width)); |
1012 | 111 | |||
1013 | 109 | // current item overlap on right | 112 | // current item overlap on right |
1016 | 110 | } else if (row.currentItem && row.currentItem.x + row.currentItem.width > flickable.contentX + flickable.width) { | 113 | } else if (row.currentItem && flickable.contentX > (row.width - row.currentItem.x - row.currentItem.width)) { |
1017 | 111 | d.alignmentAdjustment -= ((row.currentItem.x + row.currentItem.width) - (flickable.contentX + flickable.width)); | 114 | d.alignmentAdjustment -= flickable.contentX - (row.width - row.currentItem.x - row.currentItem.width); |
1018 | 112 | } | 115 | } |
1019 | 113 | } | 116 | } |
1020 | 114 | } | 117 | } |
1021 | @@ -134,16 +137,19 @@ | |||
1022 | 134 | id: flickable | 137 | id: flickable |
1023 | 135 | objectName: "flickable" | 138 | objectName: "flickable" |
1024 | 136 | 139 | ||
1025 | 140 | // we rotate it because we want the Flickable to align its content item | ||
1026 | 141 | // on the right instead of on the left | ||
1027 | 142 | rotation: 180 | ||
1028 | 143 | |||
1029 | 137 | anchors.fill: parent | 144 | anchors.fill: parent |
1030 | 138 | contentWidth: row.width | 145 | contentWidth: row.width |
1031 | 146 | contentX: d.combinedOffset | ||
1032 | 139 | interactive: false | 147 | interactive: false |
1033 | 140 | // align right + offset from row selection + scrolling | ||
1034 | 141 | contentX: row.width - flickable.width - d.combinedOffset | ||
1035 | 142 | 148 | ||
1036 | 143 | // contentX can change by user interaction as well as user offset changes | 149 | // contentX can change by user interaction as well as user offset changes |
1037 | 144 | // This function re-aligns the offsets so that the offsets match the contentX | 150 | // This function re-aligns the offsets so that the offsets match the contentX |
1038 | 145 | function resetContentXComponents() { | 151 | function resetContentXComponents() { |
1040 | 146 | d.scrollOffset += (flickable.contentX - (row.width - flickable.width - d.combinedOffset)); | 152 | d.scrollOffset += d.combinedOffset - flickable.contentX; |
1041 | 147 | } | 153 | } |
1042 | 148 | 154 | ||
1043 | 149 | rebound: Transition { | 155 | rebound: Transition { |
1044 | @@ -162,6 +168,9 @@ | |||
1045 | 162 | bottom: parent.bottom | 168 | bottom: parent.bottom |
1046 | 163 | } | 169 | } |
1047 | 164 | 170 | ||
1048 | 171 | // Compensate for the Flickable rotation (ie, counter-rotate) | ||
1049 | 172 | rotation: 180 | ||
1050 | 173 | |||
1051 | 165 | lateralPosition: { | 174 | lateralPosition: { |
1052 | 166 | if (root.lateralPosition == -1) return -1; | 175 | if (root.lateralPosition == -1) return -1; |
1053 | 167 | 176 | ||
1054 | 168 | 177 | ||
1055 | === modified file 'qml/Panel/IndicatorsMenu.qml' | |||
1056 | --- qml/Panel/IndicatorsMenu.qml 2014-10-21 19:32:03 +0000 | |||
1057 | +++ qml/Panel/IndicatorsMenu.qml 2015-01-19 17:39:20 +0000 | |||
1058 | @@ -18,6 +18,7 @@ | |||
1059 | 18 | import Ubuntu.Components 1.1 | 18 | import Ubuntu.Components 1.1 |
1060 | 19 | import Ubuntu.Gestures 0.1 | 19 | import Ubuntu.Gestures 0.1 |
1061 | 20 | import "../Components" | 20 | import "../Components" |
1062 | 21 | import "Indicators" | ||
1063 | 21 | 22 | ||
1064 | 22 | Showable { | 23 | Showable { |
1065 | 23 | id: root | 24 | id: root |
1066 | @@ -60,6 +61,10 @@ | |||
1067 | 60 | onUnitProgressChanged: d.updateState() | 61 | onUnitProgressChanged: d.updateState() |
1068 | 61 | clip: root.partiallyOpened | 62 | clip: root.partiallyOpened |
1069 | 62 | 63 | ||
1070 | 64 | IndicatorsLight { | ||
1071 | 65 | id: indicatorLights | ||
1072 | 66 | } | ||
1073 | 67 | |||
1074 | 63 | // eater | 68 | // eater |
1075 | 64 | MouseArea { | 69 | MouseArea { |
1076 | 65 | anchors.fill: parent | 70 | anchors.fill: parent |
1077 | 66 | 71 | ||
1078 | === modified file 'tests/mocks/CMakeLists.txt' | |||
1079 | --- tests/mocks/CMakeLists.txt 2014-06-11 15:36:51 +0000 | |||
1080 | +++ tests/mocks/CMakeLists.txt 2015-01-19 17:39:20 +0000 | |||
1081 | @@ -33,6 +33,7 @@ | |||
1082 | 33 | add_subdirectory(HudClient) | 33 | add_subdirectory(HudClient) |
1083 | 34 | add_subdirectory(libusermetrics) | 34 | add_subdirectory(libusermetrics) |
1084 | 35 | add_subdirectory(LightDM) | 35 | add_subdirectory(LightDM) |
1085 | 36 | add_subdirectory(Lights) | ||
1086 | 36 | add_subdirectory(Powerd) | 37 | add_subdirectory(Powerd) |
1087 | 37 | add_subdirectory(QMenuModel) | 38 | add_subdirectory(QMenuModel) |
1088 | 38 | add_subdirectory(Ubuntu) | 39 | add_subdirectory(Ubuntu) |
1089 | 39 | 40 | ||
1090 | === added directory 'tests/mocks/Lights' | |||
1091 | === added file 'tests/mocks/Lights/CMakeLists.txt' | |||
1092 | --- tests/mocks/Lights/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1093 | +++ tests/mocks/Lights/CMakeLists.txt 2015-01-19 17:39:20 +0000 | |||
1094 | @@ -0,0 +1,8 @@ | |||
1095 | 1 | add_library(MockLights-qml MODULE | ||
1096 | 2 | plugin.cpp | ||
1097 | 3 | Lights.cpp | ||
1098 | 4 | ) | ||
1099 | 5 | |||
1100 | 6 | qt5_use_modules(MockLights-qml Qml Gui) | ||
1101 | 7 | |||
1102 | 8 | add_unity8_mock(Lights 0.1 Lights TARGETS MockLights-qml) | ||
1103 | 0 | 9 | ||
1104 | === added file 'tests/mocks/Lights/Lights.cpp' | |||
1105 | --- tests/mocks/Lights/Lights.cpp 1970-01-01 00:00:00 +0000 | |||
1106 | +++ tests/mocks/Lights/Lights.cpp 2015-01-19 17:39:20 +0000 | |||
1107 | @@ -0,0 +1,84 @@ | |||
1108 | 1 | /* | ||
1109 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
1110 | 3 | * | ||
1111 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1112 | 5 | * it under the terms of the GNU General Public License as published by | ||
1113 | 6 | * the Free Software Foundation; version 3. | ||
1114 | 7 | * | ||
1115 | 8 | * This program is distributed in the hope that it will be useful, | ||
1116 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1117 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1118 | 11 | * GNU General Public License for more details. | ||
1119 | 12 | * | ||
1120 | 13 | * You should have received a copy of the GNU General Public License | ||
1121 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1122 | 15 | */ | ||
1123 | 16 | |||
1124 | 17 | #include "Lights.h" | ||
1125 | 18 | |||
1126 | 19 | #include <QDebug> | ||
1127 | 20 | |||
1128 | 21 | Lights::Lights(QObject* parent) | ||
1129 | 22 | : QObject(parent), | ||
1130 | 23 | m_color("blue"), | ||
1131 | 24 | m_state(Lights::Off), | ||
1132 | 25 | m_onMs(1000), | ||
1133 | 26 | m_offMs(3000) | ||
1134 | 27 | { | ||
1135 | 28 | } | ||
1136 | 29 | |||
1137 | 30 | Lights::~Lights() | ||
1138 | 31 | { | ||
1139 | 32 | } | ||
1140 | 33 | |||
1141 | 34 | void Lights::setState(Lights::State newState) | ||
1142 | 35 | { | ||
1143 | 36 | if (m_state != newState) { | ||
1144 | 37 | m_state = newState; | ||
1145 | 38 | Q_EMIT stateChanged(m_state); | ||
1146 | 39 | } | ||
1147 | 40 | } | ||
1148 | 41 | |||
1149 | 42 | Lights::State Lights::state() const | ||
1150 | 43 | { | ||
1151 | 44 | return m_state; | ||
1152 | 45 | } | ||
1153 | 46 | |||
1154 | 47 | void Lights::setColor(const QColor &color) | ||
1155 | 48 | { | ||
1156 | 49 | if (m_color != color) { | ||
1157 | 50 | m_color = color; | ||
1158 | 51 | Q_EMIT colorChanged(m_color); | ||
1159 | 52 | } | ||
1160 | 53 | } | ||
1161 | 54 | |||
1162 | 55 | QColor Lights::color() const | ||
1163 | 56 | { | ||
1164 | 57 | return m_color; | ||
1165 | 58 | } | ||
1166 | 59 | |||
1167 | 60 | int Lights::onMillisec() const | ||
1168 | 61 | { | ||
1169 | 62 | return m_onMs; | ||
1170 | 63 | } | ||
1171 | 64 | |||
1172 | 65 | void Lights::setOnMillisec(int onMs) | ||
1173 | 66 | { | ||
1174 | 67 | if (m_onMs != onMs) { | ||
1175 | 68 | m_onMs = onMs; | ||
1176 | 69 | Q_EMIT onMillisecChanged(m_onMs); | ||
1177 | 70 | } | ||
1178 | 71 | } | ||
1179 | 72 | |||
1180 | 73 | int Lights::offMillisec() const | ||
1181 | 74 | { | ||
1182 | 75 | return m_offMs; | ||
1183 | 76 | } | ||
1184 | 77 | |||
1185 | 78 | void Lights::setOffMillisec(int offMs) | ||
1186 | 79 | { | ||
1187 | 80 | if (m_offMs != offMs) { | ||
1188 | 81 | m_offMs = offMs; | ||
1189 | 82 | Q_EMIT offMillisecChanged(m_offMs); | ||
1190 | 83 | } | ||
1191 | 84 | } | ||
1192 | 0 | 85 | ||
1193 | === added file 'tests/mocks/Lights/Lights.h' | |||
1194 | --- tests/mocks/Lights/Lights.h 1970-01-01 00:00:00 +0000 | |||
1195 | +++ tests/mocks/Lights/Lights.h 2015-01-19 17:39:20 +0000 | |||
1196 | @@ -0,0 +1,66 @@ | |||
1197 | 1 | /* | ||
1198 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
1199 | 3 | * | ||
1200 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1201 | 5 | * it under the terms of the GNU General Public License as published by | ||
1202 | 6 | * the Free Software Foundation; version 3. | ||
1203 | 7 | * | ||
1204 | 8 | * This program is distributed in the hope that it will be useful, | ||
1205 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1206 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1207 | 11 | * GNU General Public License for more details. | ||
1208 | 12 | * | ||
1209 | 13 | * You should have received a copy of the GNU General Public License | ||
1210 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1211 | 15 | */ | ||
1212 | 16 | |||
1213 | 17 | #ifndef UNITY_MOCK_LIGHTS_H | ||
1214 | 18 | #define UNITY_MOCK_LIGHTS_H | ||
1215 | 19 | |||
1216 | 20 | #include <QtCore/QObject> | ||
1217 | 21 | #include <QtGui/QColor> | ||
1218 | 22 | |||
1219 | 23 | class Lights: public QObject | ||
1220 | 24 | { | ||
1221 | 25 | Q_OBJECT | ||
1222 | 26 | Q_ENUMS(State) | ||
1223 | 27 | Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged) | ||
1224 | 28 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | ||
1225 | 29 | Q_PROPERTY(int onMillisec READ onMillisec WRITE setOnMillisec NOTIFY onMillisecChanged) | ||
1226 | 30 | Q_PROPERTY(int offMillisec READ offMillisec WRITE setOffMillisec NOTIFY offMillisecChanged) | ||
1227 | 31 | |||
1228 | 32 | public: | ||
1229 | 33 | enum State { | ||
1230 | 34 | Off, | ||
1231 | 35 | On, | ||
1232 | 36 | }; | ||
1233 | 37 | |||
1234 | 38 | explicit Lights(QObject *parent = 0); | ||
1235 | 39 | ~Lights(); | ||
1236 | 40 | |||
1237 | 41 | void setState(State newState); | ||
1238 | 42 | State state() const; | ||
1239 | 43 | |||
1240 | 44 | void setColor(const QColor &color); | ||
1241 | 45 | QColor color() const; | ||
1242 | 46 | |||
1243 | 47 | int onMillisec() const; | ||
1244 | 48 | void setOnMillisec(int onMs); | ||
1245 | 49 | |||
1246 | 50 | int offMillisec() const; | ||
1247 | 51 | void setOffMillisec(int offMs); | ||
1248 | 52 | |||
1249 | 53 | Q_SIGNALS: | ||
1250 | 54 | void stateChanged(State newState); | ||
1251 | 55 | void colorChanged(const QColor &color); | ||
1252 | 56 | void onMillisecChanged(int onMs); | ||
1253 | 57 | void offMillisecChanged(int offMs); | ||
1254 | 58 | |||
1255 | 59 | private: | ||
1256 | 60 | QColor m_color; | ||
1257 | 61 | State m_state; | ||
1258 | 62 | int m_onMs; | ||
1259 | 63 | int m_offMs; | ||
1260 | 64 | }; | ||
1261 | 65 | |||
1262 | 66 | #endif | ||
1263 | 0 | 67 | ||
1264 | === added file 'tests/mocks/Lights/plugin.cpp' | |||
1265 | --- tests/mocks/Lights/plugin.cpp 1970-01-01 00:00:00 +0000 | |||
1266 | +++ tests/mocks/Lights/plugin.cpp 2015-01-19 17:39:20 +0000 | |||
1267 | @@ -0,0 +1,33 @@ | |||
1268 | 1 | /* | ||
1269 | 2 | * Copyright (C) 2012,2013 Canonical, Ltd. | ||
1270 | 3 | * | ||
1271 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1272 | 5 | * it under the terms of the GNU General Public License as published by | ||
1273 | 6 | * the Free Software Foundation; version 3. | ||
1274 | 7 | * | ||
1275 | 8 | * This program is distributed in the hope that it will be useful, | ||
1276 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1277 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1278 | 11 | * GNU General Public License for more details. | ||
1279 | 12 | * | ||
1280 | 13 | * You should have received a copy of the GNU General Public License | ||
1281 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1282 | 15 | */ | ||
1283 | 16 | |||
1284 | 17 | #include "plugin.h" | ||
1285 | 18 | #include "Lights.h" | ||
1286 | 19 | |||
1287 | 20 | #include <QtQml/qqml.h> | ||
1288 | 21 | |||
1289 | 22 | static QObject *lights_provider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
1290 | 23 | { | ||
1291 | 24 | Q_UNUSED(engine) | ||
1292 | 25 | Q_UNUSED(scriptEngine) | ||
1293 | 26 | return new Lights(); | ||
1294 | 27 | } | ||
1295 | 28 | |||
1296 | 29 | void PowerdPlugin::registerTypes(const char *uri) | ||
1297 | 30 | { | ||
1298 | 31 | Q_ASSERT(uri == QLatin1String("Lights")); | ||
1299 | 32 | qmlRegisterSingletonType<Lights>(uri, 0, 1, "Lights", lights_provider); | ||
1300 | 33 | } | ||
1301 | 0 | 34 | ||
1302 | === added file 'tests/mocks/Lights/plugin.h' | |||
1303 | --- tests/mocks/Lights/plugin.h 1970-01-01 00:00:00 +0000 | |||
1304 | +++ tests/mocks/Lights/plugin.h 2015-01-19 17:39:20 +0000 | |||
1305 | @@ -0,0 +1,32 @@ | |||
1306 | 1 | /* | ||
1307 | 2 | * Copyright (C) 2012,2013 Canonical, Ltd. | ||
1308 | 3 | * | ||
1309 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1310 | 5 | * it under the terms of the GNU General Public License as published by | ||
1311 | 6 | * the Free Software Foundation; version 3. | ||
1312 | 7 | * | ||
1313 | 8 | * This program is distributed in the hope that it will be useful, | ||
1314 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1315 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1316 | 11 | * GNU General Public License for more details. | ||
1317 | 12 | * | ||
1318 | 13 | * You should have received a copy of the GNU General Public License | ||
1319 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1320 | 15 | */ | ||
1321 | 16 | |||
1322 | 17 | #ifndef MOCK_POWER_PLUGIN_H | ||
1323 | 18 | #define MOCK_POWER_PLUGIN_H | ||
1324 | 19 | |||
1325 | 20 | #include <QtQml/QQmlEngine> | ||
1326 | 21 | #include <QtQml/QQmlExtensionPlugin> | ||
1327 | 22 | |||
1328 | 23 | class PowerdPlugin : public QQmlExtensionPlugin | ||
1329 | 24 | { | ||
1330 | 25 | Q_OBJECT | ||
1331 | 26 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
1332 | 27 | |||
1333 | 28 | public: | ||
1334 | 29 | void registerTypes(const char *uri); | ||
1335 | 30 | }; | ||
1336 | 31 | |||
1337 | 32 | #endif | ||
1338 | 0 | 33 | ||
1339 | === added file 'tests/mocks/Lights/qmldir' | |||
1340 | --- tests/mocks/Lights/qmldir 1970-01-01 00:00:00 +0000 | |||
1341 | +++ tests/mocks/Lights/qmldir 2015-01-19 17:39:20 +0000 | |||
1342 | @@ -0,0 +1,3 @@ | |||
1343 | 1 | module Lights | ||
1344 | 2 | plugin MockLights-qml | ||
1345 | 3 | typeinfo Lights.qmltypes | ||
1346 | 0 | 4 | ||
1347 | === modified file 'tests/mocks/QMenuModel/CMakeLists.txt' | |||
1348 | --- tests/mocks/QMenuModel/CMakeLists.txt 2014-05-02 22:57:21 +0000 | |||
1349 | +++ tests/mocks/QMenuModel/CMakeLists.txt 2015-01-19 17:39:20 +0000 | |||
1350 | @@ -4,6 +4,7 @@ | |||
1351 | 4 | ) | 4 | ) |
1352 | 5 | 5 | ||
1353 | 6 | set(QMenuModelQml_SOURCES | 6 | set(QMenuModelQml_SOURCES |
1354 | 7 | actiondata.h | ||
1355 | 7 | actionstateparser.cpp | 8 | actionstateparser.cpp |
1356 | 8 | plugin.cpp | 9 | plugin.cpp |
1357 | 9 | unitymenumodel.cpp | 10 | unitymenumodel.cpp |
1358 | 10 | 11 | ||
1359 | === modified file 'tests/mocks/QMenuModel/QDBusActionGroup.qml' | |||
1360 | --- tests/mocks/QMenuModel/QDBusActionGroup.qml 2014-07-04 17:53:52 +0000 | |||
1361 | +++ tests/mocks/QMenuModel/QDBusActionGroup.qml 2015-01-19 17:39:20 +0000 | |||
1362 | @@ -19,69 +19,19 @@ | |||
1363 | 19 | 19 | ||
1364 | 20 | import QtQuick 2.0 | 20 | import QtQuick 2.0 |
1365 | 21 | import Ubuntu.Settings.Menus 0.1 as Menus | 21 | import Ubuntu.Settings.Menus 0.1 as Menus |
1366 | 22 | import QMenuModel 0.1 | ||
1367 | 22 | 23 | ||
1368 | 23 | QtObject { | 24 | QtObject { |
1369 | 24 | property int busType | 25 | property int busType |
1370 | 25 | property string busName | 26 | property string busName |
1371 | 26 | property string objectPath | 27 | property string objectPath |
1372 | 28 | property var actions: ActionData ? ActionData.data : undefined | ||
1373 | 29 | |||
1374 | 30 | signal dataChanged | ||
1375 | 31 | |||
1376 | 27 | function start() {} | 32 | function start() {} |
1377 | 33 | |||
1378 | 28 | function action(actionName) { | 34 | function action(actionName) { |
1436 | 29 | switch (actionName) { | 35 | return actions[actionName]; |
1380 | 30 | case "transfer-state.queued": | ||
1381 | 31 | return { | ||
1382 | 32 | 'valid': true, | ||
1383 | 33 | 'state': { | ||
1384 | 34 | 'state': Menus.TransferState.Queued, | ||
1385 | 35 | 'percent': 0.0 | ||
1386 | 36 | } | ||
1387 | 37 | } | ||
1388 | 38 | case "transfer-state.running": | ||
1389 | 39 | return { | ||
1390 | 40 | 'valid': true, | ||
1391 | 41 | 'state': { | ||
1392 | 42 | 'state': Menus.TransferState.Running, | ||
1393 | 43 | 'seconds-left': 100, | ||
1394 | 44 | 'percent': 0.1 | ||
1395 | 45 | } | ||
1396 | 46 | } | ||
1397 | 47 | case "transfer-state.paused": | ||
1398 | 48 | return { | ||
1399 | 49 | 'valid': true, | ||
1400 | 50 | 'state': { | ||
1401 | 51 | 'state': Menus.TransferState.Paused, | ||
1402 | 52 | 'seconds-left': 100, | ||
1403 | 53 | 'percent': 0.5 | ||
1404 | 54 | } | ||
1405 | 55 | } | ||
1406 | 56 | case "transfer-state.cancelled": | ||
1407 | 57 | return { | ||
1408 | 58 | 'valid': true, | ||
1409 | 59 | 'state': { | ||
1410 | 60 | 'state': Menus.TransferState.Canceled, | ||
1411 | 61 | 'percent': 0.4 | ||
1412 | 62 | } | ||
1413 | 63 | } | ||
1414 | 64 | case "transfer-state.finished": return { | ||
1415 | 65 | 'valid': true, | ||
1416 | 66 | 'state': { | ||
1417 | 67 | 'state': Menus.TransferState.Finished, | ||
1418 | 68 | 'seconds-left': 0, | ||
1419 | 69 | 'percent': 1.0 | ||
1420 | 70 | } | ||
1421 | 71 | } | ||
1422 | 72 | case "transfer-state.error": | ||
1423 | 73 | return { | ||
1424 | 74 | 'valid': true, | ||
1425 | 75 | 'state': { | ||
1426 | 76 | 'state': Menus.TransferState.Error, | ||
1427 | 77 | 'seconds-left': 100, | ||
1428 | 78 | 'percent': 0.0 | ||
1429 | 79 | } | ||
1430 | 80 | } | ||
1431 | 81 | default: | ||
1432 | 82 | break; | ||
1433 | 83 | } | ||
1434 | 84 | |||
1435 | 85 | return null; | ||
1437 | 86 | } | 36 | } |
1438 | 87 | } | 37 | } |
1439 | 88 | 38 | ||
1440 | === added file 'tests/mocks/QMenuModel/actiondata.h' | |||
1441 | --- tests/mocks/QMenuModel/actiondata.h 1970-01-01 00:00:00 +0000 | |||
1442 | +++ tests/mocks/QMenuModel/actiondata.h 2015-01-19 17:39:20 +0000 | |||
1443 | @@ -0,0 +1,52 @@ | |||
1444 | 1 | /* | ||
1445 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
1446 | 3 | * | ||
1447 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1448 | 5 | * it under the terms of the GNU General Public License as published by | ||
1449 | 6 | * the Free Software Foundation; version 3. | ||
1450 | 7 | * | ||
1451 | 8 | * This program is distributed in the hope that it will be useful, | ||
1452 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1453 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1454 | 11 | * GNU General Public License for more details. | ||
1455 | 12 | * | ||
1456 | 13 | * You should have received a copy of the GNU General Public License | ||
1457 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1458 | 15 | * | ||
1459 | 16 | * Authors: Nick Dedekind <nick.dedekind@canonical.com> | ||
1460 | 17 | */ | ||
1461 | 18 | |||
1462 | 19 | #ifndef ACTIONDATA_H | ||
1463 | 20 | #define ACTIONDATA_H | ||
1464 | 21 | |||
1465 | 22 | #include <QObject> | ||
1466 | 23 | #include <QVariant> | ||
1467 | 24 | |||
1468 | 25 | typedef struct _GVariant GVariant; | ||
1469 | 26 | |||
1470 | 27 | class Q_DECL_EXPORT ActionData : public QObject | ||
1471 | 28 | { | ||
1472 | 29 | Q_OBJECT | ||
1473 | 30 | Q_PROPERTY(QVariant data READ data WRITE setData NOTIFY dataChanged) | ||
1474 | 31 | public: | ||
1475 | 32 | ActionData(QObject* parent = 0) | ||
1476 | 33 | : QObject(parent) | ||
1477 | 34 | {} | ||
1478 | 35 | |||
1479 | 36 | QVariant data() const { return m_data; } | ||
1480 | 37 | void setData(const QVariant& data) | ||
1481 | 38 | { | ||
1482 | 39 | if (m_data != data) { | ||
1483 | 40 | m_data = data; | ||
1484 | 41 | Q_EMIT dataChanged(); | ||
1485 | 42 | } | ||
1486 | 43 | } | ||
1487 | 44 | |||
1488 | 45 | Q_SIGNALS: | ||
1489 | 46 | void dataChanged(); | ||
1490 | 47 | |||
1491 | 48 | private: | ||
1492 | 49 | QVariant m_data; | ||
1493 | 50 | }; | ||
1494 | 51 | |||
1495 | 52 | #endif // ACTIONDATA_H | ||
1496 | 0 | 53 | ||
1497 | === modified file 'tests/mocks/QMenuModel/plugin.cpp' | |||
1498 | --- tests/mocks/QMenuModel/plugin.cpp 2013-11-19 17:01:25 +0000 | |||
1499 | +++ tests/mocks/QMenuModel/plugin.cpp 2015-01-19 17:39:20 +0000 | |||
1500 | @@ -18,13 +18,23 @@ | |||
1501 | 18 | 18 | ||
1502 | 19 | #include "plugin.h" | 19 | #include "plugin.h" |
1503 | 20 | #include "unitymenumodel.h" | 20 | #include "unitymenumodel.h" |
1504 | 21 | #include "actiondata.h" | ||
1505 | 21 | #include "actionstateparser.h" | 22 | #include "actionstateparser.h" |
1506 | 22 | 23 | ||
1507 | 23 | #include <QtQml/qqml.h> | 24 | #include <QtQml/qqml.h> |
1508 | 24 | 25 | ||
1509 | 26 | static QObject* actionDataSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) | ||
1510 | 27 | { | ||
1511 | 28 | Q_UNUSED(engine); | ||
1512 | 29 | Q_UNUSED(scriptEngine); | ||
1513 | 30 | return new ActionData; | ||
1514 | 31 | } | ||
1515 | 32 | |||
1516 | 25 | void QMenuModelPlugin::registerTypes(const char *uri) | 33 | void QMenuModelPlugin::registerTypes(const char *uri) |
1517 | 26 | { | 34 | { |
1518 | 27 | Q_ASSERT(uri == QLatin1String("QMenuModel")); | 35 | Q_ASSERT(uri == QLatin1String("QMenuModel")); |
1519 | 28 | qmlRegisterType<UnityMenuModel>(uri, 0, 1, "UnityMenuModel"); | 36 | qmlRegisterType<UnityMenuModel>(uri, 0, 1, "UnityMenuModel"); |
1520 | 29 | qmlRegisterType<ActionStateParser>(uri, 0, 1, "ActionStateParser"); | 37 | qmlRegisterType<ActionStateParser>(uri, 0, 1, "ActionStateParser"); |
1521 | 38 | |||
1522 | 39 | qmlRegisterSingletonType<ActionData>(uri, 0, 1, "ActionData", actionDataSingleton); | ||
1523 | 30 | } | 40 | } |
1524 | 31 | 41 | ||
1525 | === added file 'tests/mocks/Unity/Indicators/ActionRootState.qml' | |||
1526 | --- tests/mocks/Unity/Indicators/ActionRootState.qml 1970-01-01 00:00:00 +0000 | |||
1527 | +++ tests/mocks/Unity/Indicators/ActionRootState.qml 2015-01-19 17:39:20 +0000 | |||
1528 | @@ -0,0 +1,46 @@ | |||
1529 | 1 | /* | ||
1530 | 2 | * Copyright 2013 Canonical Ltd. | ||
1531 | 3 | * | ||
1532 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1533 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1534 | 6 | * the Free Software Foundation; version 3. | ||
1535 | 7 | * | ||
1536 | 8 | * This program is distributed in the hope that it will be useful, | ||
1537 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1538 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1539 | 11 | * GNU Lesser General Public License for more details. | ||
1540 | 12 | * | ||
1541 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1542 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1543 | 15 | * | ||
1544 | 16 | * Authors: | ||
1545 | 17 | * Nick Dedekind <nick.dedekind@canonical.com> | ||
1546 | 18 | */ | ||
1547 | 19 | |||
1548 | 20 | import QtQuick 2.0 | ||
1549 | 21 | |||
1550 | 22 | QtObject { | ||
1551 | 23 | property var actionGroup | ||
1552 | 24 | property var actionName | ||
1553 | 25 | |||
1554 | 26 | property var action: actionGroup ? actionGroup.actions[actionName] : undefined | ||
1555 | 27 | property var state: action && action.hasOwnProperty("state") ? action.state : undefined | ||
1556 | 28 | |||
1557 | 29 | property bool valid: action && action.hasOwnProperty("valid") ? action.valid : false | ||
1558 | 30 | property string title: state && state.hasOwnProperty("title") ? state["title"] : "" | ||
1559 | 31 | property string leftLabel: state && state.hasOwnProperty("pre-label") ? state["pre-label"] : "" | ||
1560 | 32 | property string rightLabel: state && state.hasOwnProperty("label") ? state["label"] : "" | ||
1561 | 33 | property var icons: state && state.hasOwnProperty("icons") ? state["icons"] : [] | ||
1562 | 34 | property string accessibleName: state && state.hasOwnProperty("accessible-desc") ? state["accessible-desc"] : "" | ||
1563 | 35 | property bool visible: state && state.hasOwnProperty("visible") ? state["visible"] : true | ||
1564 | 36 | |||
1565 | 37 | signal updated | ||
1566 | 38 | |||
1567 | 39 | onValidChanged: updated() | ||
1568 | 40 | onTitleChanged: updated() | ||
1569 | 41 | onLeftLabelChanged: updated() | ||
1570 | 42 | onRightLabelChanged: updated() | ||
1571 | 43 | onIconsChanged: updated() | ||
1572 | 44 | onAccessibleNameChanged: updated() | ||
1573 | 45 | onVisibleChanged: updated() | ||
1574 | 46 | } | ||
1575 | 0 | 47 | ||
1576 | === renamed file 'tests/mocks/Unity/Indicators/RootActionState.qml' => 'tests/mocks/Unity/Indicators/ModelActionRootState.qml' | |||
1577 | === modified file 'tests/mocks/Unity/Indicators/qmldir' | |||
1578 | --- tests/mocks/Unity/Indicators/qmldir 2014-10-07 10:28:59 +0000 | |||
1579 | +++ tests/mocks/Unity/Indicators/qmldir 2015-01-19 17:39:20 +0000 | |||
1580 | @@ -2,5 +2,6 @@ | |||
1581 | 2 | plugin IndicatorsFakeQml | 2 | plugin IndicatorsFakeQml |
1582 | 3 | typeinfo Indicators.qmltypes | 3 | typeinfo Indicators.qmltypes |
1583 | 4 | 4 | ||
1584 | 5 | ActionRootState 0.1 ActionRootState.qml | ||
1585 | 5 | IndicatorsModel 0.1 IndicatorsModel.qml | 6 | IndicatorsModel 0.1 IndicatorsModel.qml |
1587 | 6 | RootActionState 0.1 RootActionState.qml | 7 | ModelActionRootState 0.1 ModelActionRootState.qml |
1588 | 7 | 8 | ||
1589 | === modified file 'tests/plugins/Unity/Indicators/rootactionstatetest.cpp' | |||
1590 | --- tests/plugins/Unity/Indicators/rootactionstatetest.cpp 2014-08-26 08:14:44 +0000 | |||
1591 | +++ tests/plugins/Unity/Indicators/rootactionstatetest.cpp 2015-01-19 17:39:20 +0000 | |||
1592 | @@ -17,7 +17,7 @@ | |||
1593 | 17 | * Nick Dedekind <nick.dedekind@canonical.com> | 17 | * Nick Dedekind <nick.dedekind@canonical.com> |
1594 | 18 | */ | 18 | */ |
1595 | 19 | 19 | ||
1597 | 20 | #include "rootactionstate.h" | 20 | #include "modelactionrootstate.h" |
1598 | 21 | 21 | ||
1599 | 22 | #include <unitymenumodel.h> | 22 | #include <unitymenumodel.h> |
1600 | 23 | #include <QtTest> | 23 | #include <QtTest> |
1601 | @@ -32,7 +32,7 @@ | |||
1602 | 32 | { | 32 | { |
1603 | 33 | UnityMenuModel* menuModel = new UnityMenuModel(); | 33 | UnityMenuModel* menuModel = new UnityMenuModel(); |
1604 | 34 | ActionStateParser* originalParser = menuModel->actionStateParser(); | 34 | ActionStateParser* originalParser = menuModel->actionStateParser(); |
1606 | 35 | RootActionState* rootState = new RootActionState(); | 35 | ModelActionRootState* rootState = new ModelActionRootState(); |
1607 | 36 | 36 | ||
1608 | 37 | rootState->setMenu(menuModel); | 37 | rootState->setMenu(menuModel); |
1609 | 38 | 38 | ||
1610 | @@ -44,7 +44,7 @@ | |||
1611 | 44 | void testDeleteUnityMenuModel() | 44 | void testDeleteUnityMenuModel() |
1612 | 45 | { | 45 | { |
1613 | 46 | UnityMenuModel* menuModel = new UnityMenuModel(); | 46 | UnityMenuModel* menuModel = new UnityMenuModel(); |
1615 | 47 | RootActionState* rootState = new RootActionState(); | 47 | ModelActionRootState* rootState = new ModelActionRootState(); |
1616 | 48 | 48 | ||
1617 | 49 | rootState->setMenu(menuModel); | 49 | rootState->setMenu(menuModel); |
1618 | 50 | 50 | ||
1619 | @@ -77,7 +77,7 @@ | |||
1620 | 77 | 77 | ||
1621 | 78 | GVariant* params = g_variant_builder_end (&builderParams); | 78 | GVariant* params = g_variant_builder_end (&builderParams); |
1622 | 79 | 79 | ||
1624 | 80 | RootActionState rootState; | 80 | RootStateParser rootState; |
1625 | 81 | QVariant result = rootState.toQVariant(params); | 81 | QVariant result = rootState.toQVariant(params); |
1626 | 82 | g_variant_unref(params); | 82 | g_variant_unref(params); |
1627 | 83 | 83 | ||
1628 | 84 | 84 | ||
1629 | === modified file 'tests/qmltests/CMakeLists.txt' | |||
1630 | --- tests/qmltests/CMakeLists.txt 2014-11-10 09:14:30 +0000 | |||
1631 | +++ tests/qmltests/CMakeLists.txt 2015-01-19 17:39:20 +0000 | |||
1632 | @@ -81,6 +81,7 @@ | |||
1633 | 81 | add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") | 81 | add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
1634 | 82 | add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") | 82 | add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
1635 | 83 | add_qml_test(Panel SearchIndicator) | 83 | add_qml_test(Panel SearchIndicator) |
1636 | 84 | add_qml_test(Panel/Indicators IndicatorsLight ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") | ||
1637 | 84 | # These MenuItemFactory tests need the test/mocks/ to come before plugins/ | 85 | # These MenuItemFactory tests need the test/mocks/ to come before plugins/ |
1638 | 85 | add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS}) | 86 | add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS}) |
1639 | 86 | add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS}) | 87 | add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS}) |
1640 | 87 | 88 | ||
1641 | === added file 'tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml' | |||
1642 | --- tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml 1970-01-01 00:00:00 +0000 | |||
1643 | +++ tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml 2015-01-19 17:39:20 +0000 | |||
1644 | @@ -0,0 +1,129 @@ | |||
1645 | 1 | /* | ||
1646 | 2 | * Copyright 2014 Canonical Ltd. | ||
1647 | 3 | * | ||
1648 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1649 | 5 | * it under the terms of the GNU General Public License as published by | ||
1650 | 6 | * the Free Software Foundation; version 3. | ||
1651 | 7 | * | ||
1652 | 8 | * This program is distributed in the hope that it will be useful, | ||
1653 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1654 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1655 | 11 | * GNU General Public License for more details. | ||
1656 | 12 | * | ||
1657 | 13 | * You should have received a copy of the GNU General Public License | ||
1658 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1659 | 15 | */ | ||
1660 | 16 | |||
1661 | 17 | import QtQuick 2.0 | ||
1662 | 18 | import QtQuick.Layouts 1.1 | ||
1663 | 19 | import Unity.Test 0.1 as UT | ||
1664 | 20 | import Unity.Indicators 0.1 as Indicators | ||
1665 | 21 | import Ubuntu.Components 1.1 | ||
1666 | 22 | import Powerd 0.1 | ||
1667 | 23 | import Lights 0.1 | ||
1668 | 24 | import QMenuModel 0.1 | ||
1669 | 25 | import "../../../../qml/Panel/Indicators" | ||
1670 | 26 | |||
1671 | 27 | Item { | ||
1672 | 28 | id: root | ||
1673 | 29 | width: units.gu(30) | ||
1674 | 30 | height: units.gu(30) | ||
1675 | 31 | |||
1676 | 32 | property var newMessage: { | ||
1677 | 33 | "messages" : { | ||
1678 | 34 | 'valid': true, | ||
1679 | 35 | 'state': { | ||
1680 | 36 | 'icons': [ 'indicator-messages-new' ] | ||
1681 | 37 | } | ||
1682 | 38 | } | ||
1683 | 39 | }; | ||
1684 | 40 | property var noNewMessage: { | ||
1685 | 41 | "messages" : { | ||
1686 | 42 | 'valid': true, | ||
1687 | 43 | 'state': { | ||
1688 | 44 | 'icons': [ 'indicator-messages' ] | ||
1689 | 45 | } | ||
1690 | 46 | } | ||
1691 | 47 | }; | ||
1692 | 48 | |||
1693 | 49 | Component { | ||
1694 | 50 | id: light | ||
1695 | 51 | IndicatorsLight {} | ||
1696 | 52 | } | ||
1697 | 53 | |||
1698 | 54 | Loader { | ||
1699 | 55 | id: loader | ||
1700 | 56 | sourceComponent: light | ||
1701 | 57 | } | ||
1702 | 58 | |||
1703 | 59 | Component.onCompleted: { | ||
1704 | 60 | ActionData.data = newMessage; | ||
1705 | 61 | Powerd.status = Powerd.On | ||
1706 | 62 | } | ||
1707 | 63 | |||
1708 | 64 | RowLayout { | ||
1709 | 65 | anchors.fill: parent | ||
1710 | 66 | anchors.margins: units.gu(1) | ||
1711 | 67 | |||
1712 | 68 | Item { | ||
1713 | 69 | Layout.fillWidth: true | ||
1714 | 70 | Layout.fillHeight: true | ||
1715 | 71 | |||
1716 | 72 | Rectangle { | ||
1717 | 73 | width: units.gu(4) | ||
1718 | 74 | height: width | ||
1719 | 75 | radius: width / 2 | ||
1720 | 76 | anchors.centerIn: parent | ||
1721 | 77 | |||
1722 | 78 | color: Lights.state === Lights.On ? Lights.color : "transparent" | ||
1723 | 79 | |||
1724 | 80 | border.color: "black" | ||
1725 | 81 | border.width: 1 | ||
1726 | 82 | } | ||
1727 | 83 | } | ||
1728 | 84 | |||
1729 | 85 | ColumnLayout { | ||
1730 | 86 | Layout.alignment: Qt.AlignTop | ||
1731 | 87 | Layout.fillWidth: false | ||
1732 | 88 | Layout.preferredWidth: units.gu(15) | ||
1733 | 89 | |||
1734 | 90 | Button { | ||
1735 | 91 | Layout.fillWidth: true | ||
1736 | 92 | text: Powerd.status === Powerd.On ? "Power Off" : "Power On" | ||
1737 | 93 | onClicked: { | ||
1738 | 94 | if (Powerd.status === Powerd.On) Powerd.status = Powerd.Off; | ||
1739 | 95 | else Powerd.status = Powerd.On; | ||
1740 | 96 | } | ||
1741 | 97 | } | ||
1742 | 98 | } | ||
1743 | 99 | } | ||
1744 | 100 | |||
1745 | 101 | UT.UnityTestCase { | ||
1746 | 102 | name: "IndicatorsLight" | ||
1747 | 103 | when: windowShown | ||
1748 | 104 | |||
1749 | 105 | function init() { | ||
1750 | 106 | // reload | ||
1751 | 107 | ActionData.data = noNewMessage; | ||
1752 | 108 | loader.sourceComponent = undefined; | ||
1753 | 109 | loader.sourceComponent = light; | ||
1754 | 110 | Powerd.status = Powerd.On | ||
1755 | 111 | } | ||
1756 | 112 | |||
1757 | 113 | function test_LightsStatus_data() { | ||
1758 | 114 | return [ | ||
1759 | 115 | { tag: "Powerd.On with No Message", powerd: Powerd.On, actionData: noNewMessage, expected: Lights.Off }, | ||
1760 | 116 | { tag: "Powerd.Off with No Message", powerd: Powerd.Off, actionData: noNewMessage, expected: Lights.Off }, | ||
1761 | 117 | { tag: "Powerd.On with New Message", powerd: Powerd.On, actionData: newMessage, expected: Lights.Off }, | ||
1762 | 118 | { tag: "Powerd.Off with New Message", powerd: Powerd.Off, actionData: newMessage, expected: Lights.On }, | ||
1763 | 119 | ] | ||
1764 | 120 | } | ||
1765 | 121 | |||
1766 | 122 | function test_LightsStatus(data) { | ||
1767 | 123 | Powerd.status = data.powerd; | ||
1768 | 124 | ActionData.data = data.actionData; | ||
1769 | 125 | |||
1770 | 126 | compare(Lights.state, data.expected, "Light does not match expected value"); | ||
1771 | 127 | } | ||
1772 | 128 | } | ||
1773 | 129 | } | ||
1774 | 0 | 130 | ||
1775 | === modified file 'tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml' | |||
1776 | --- tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml 2014-11-05 00:20:05 +0000 | |||
1777 | +++ tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml 2015-01-19 17:39:20 +0000 | |||
1778 | @@ -17,6 +17,7 @@ | |||
1779 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.0 |
1780 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
1781 | 19 | import Unity.Test 0.1 as UT | 19 | import Unity.Test 0.1 as UT |
1782 | 20 | import Ubuntu.Settings.Menus 0.1 as Menus | ||
1783 | 20 | import QMenuModel 0.1 | 21 | import QMenuModel 0.1 |
1784 | 21 | import Utils 0.1 as Utils | 22 | import Utils 0.1 as Utils |
1785 | 22 | import "../../../../qml/Panel/Indicators" | 23 | import "../../../../qml/Panel/Indicators" |
1786 | @@ -448,6 +449,55 @@ | |||
1787 | 448 | } | 449 | } |
1788 | 449 | 450 | ||
1789 | 450 | function test_create_transferMenu(data) { | 451 | function test_create_transferMenu(data) { |
1790 | 452 | ActionData.data = { | ||
1791 | 453 | "transfer-state.queued": { | ||
1792 | 454 | 'valid': true, | ||
1793 | 455 | 'state': { | ||
1794 | 456 | 'state': Menus.TransferState.Queued, | ||
1795 | 457 | 'percent': 0.0 | ||
1796 | 458 | } | ||
1797 | 459 | }, | ||
1798 | 460 | "transfer-state.running": { | ||
1799 | 461 | 'valid': true, | ||
1800 | 462 | 'state': { | ||
1801 | 463 | 'state': Menus.TransferState.Running, | ||
1802 | 464 | 'seconds-left': 100, | ||
1803 | 465 | 'percent': 0.1 | ||
1804 | 466 | } | ||
1805 | 467 | }, | ||
1806 | 468 | "transfer-state.paused": { | ||
1807 | 469 | 'valid': true, | ||
1808 | 470 | 'state': { | ||
1809 | 471 | 'state': Menus.TransferState.Paused, | ||
1810 | 472 | 'seconds-left': 100, | ||
1811 | 473 | 'percent': 0.5 | ||
1812 | 474 | } | ||
1813 | 475 | }, | ||
1814 | 476 | "transfer-state.cancelled": { | ||
1815 | 477 | 'valid': true, | ||
1816 | 478 | 'state': { | ||
1817 | 479 | 'state': Menus.TransferState.Canceled, | ||
1818 | 480 | 'percent': 0.4 | ||
1819 | 481 | } | ||
1820 | 482 | }, | ||
1821 | 483 | "transfer-state.finished": { | ||
1822 | 484 | 'valid': true, | ||
1823 | 485 | 'state': { | ||
1824 | 486 | 'state': Menus.TransferState.Finished, | ||
1825 | 487 | 'seconds-left': 0, | ||
1826 | 488 | 'percent': 1.0 | ||
1827 | 489 | } | ||
1828 | 490 | }, | ||
1829 | 491 | "transfer-state.error": { | ||
1830 | 492 | 'valid': true, | ||
1831 | 493 | 'state': { | ||
1832 | 494 | 'state': Menus.TransferState.Error, | ||
1833 | 495 | 'seconds-left': 100, | ||
1834 | 496 | 'percent': 0.0 | ||
1835 | 497 | } | ||
1836 | 498 | } | ||
1837 | 499 | }; | ||
1838 | 500 | |||
1839 | 451 | menuData.type = "com.canonical.indicator.transfer"; | 501 | menuData.type = "com.canonical.indicator.transfer"; |
1840 | 452 | menuData.label = data.label; | 502 | menuData.label = data.label; |
1841 | 453 | menuData.sensitive = data.enabled; | 503 | menuData.sensitive = data.enabled; |
Hey, this caused a FTBFS:
unity8- 8.02+15. 04.20150114~ rtm/plugins/ Unity/Indicator s/plugin. cpp:34: 29: fatal error: rootactionstate.h: No such file or directory
^
#include "rootactionstate.h"
compilation terminated.