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