Merge lp:~nick-dedekind/unity8/lp1385331.led into lp:unity8

Proposed by Nick Dedekind
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
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://code.launchpad.net/~nick-dedekind/qmenumodel/lp1385331.led/+merge/241422

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

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

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

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

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1374. By Nick Dedekind

removed author

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

Text conflict in debian/control
1 conflicts encountered.

1375. By Nick Dedekind

merged with trunk

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

> Text conflict in debian/control
> 1 conflicts encountered.

Fixed.

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

Text conflict in debian/control
Text conflict in tests/mocks/CMakeLists.txt
Text conflict in tests/mocks/QMenuModel/QDBusActionGroup.qml
3 conflicts encountered.

review: Needs Fixing
1376. By Nick Dedekind

merged with trunk

1377. By Nick Dedekind

better lights init

Revision history for this message
Albert Astals Cid (aacid) wrote :

Is there an easy way to reproduce the problem this is fixing?

review: Needs Information
Revision history for this message
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

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

/home/phablet/unity8-lp1385331.led/plugins/Unity/Indicators/modelactionrootstate.cpp: multiple new lines at end of file

review: Needs Fixing
Revision history for this message
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?

review: Needs Information
Revision history for this message
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.

Revision history for this message
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

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

> /home/phablet/unity8-lp1385331.led/plugins/Unity/Indicators/modelactionrootsta
> te.cpp: multiple new lines at end of file

Fixed.

Revision history for this message
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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2014-12-08 18:15:11 +0000
+++ debian/control 2014-12-17 11:19:14 +0000
@@ -22,7 +22,7 @@
22 libpam0g-dev,22 libpam0g-dev,
23 libpay2-dev,23 libpay2-dev,
24 libpulse-dev,24 libpulse-dev,
25 libqmenumodel-dev (>= 0.2.8),25 libqmenumodel-dev (>= 0.2.9),
26 libqt5xmlpatterns5-dev,26 libqt5xmlpatterns5-dev,
27 libsystemsettings-dev,27 libsystemsettings-dev,
28 libunity-api-dev (>= 7.94),28 libunity-api-dev (>= 7.94),
@@ -61,7 +61,7 @@
6161
62Package: indicators-client62Package: indicators-client
63Architecture: amd64 armhf i38663Architecture: amd64 armhf i386
64Depends: qmenumodel-qml (>= 0.2.8),64Depends: qmenumodel-qml (>= 0.2.9),
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),
66 unity8 (= ${binary:Version}),66 unity8 (= ${binary:Version}),
67 ${misc:Depends},67 ${misc:Depends},
@@ -85,7 +85,7 @@
85Depends: gsettings-desktop-schemas,85Depends: gsettings-desktop-schemas,
86 libcap2-bin,86 libcap2-bin,
87 libglib2.0-bin,87 libglib2.0-bin,
88 qmenumodel-qml (>= 0.2.8),88 qmenumodel-qml (>= 0.2.9),
89 qml-module-qt-labs-folderlistmodel,89 qml-module-qt-labs-folderlistmodel,
90 qml-module-qtquick-xmllistmodel,90 qml-module-qtquick-xmllistmodel,
91 qtdeclarative5-gsettings1.0,91 qtdeclarative5-gsettings1.0,
9292
=== modified file 'plugins/Lights/Lights.cpp'
--- plugins/Lights/Lights.cpp 2014-09-08 15:07:24 +0000
+++ plugins/Lights/Lights.cpp 2014-12-17 11:19:14 +0000
@@ -44,12 +44,20 @@
4444
45void Lights::setState(Lights::State newState)45void Lights::setState(Lights::State newState)
46{46{
47 if (!init()) {
48 qWarning() << "No lights device";
49 return;
50 }
51
47 if (m_state != newState) {52 if (m_state != newState) {
48 if (newState == Lights::On) {53 if (newState == Lights::On) {
49 turnOn();54 turnOn();
50 } else {55 } else {
51 turnOff();56 turnOff();
52 }57 }
58
59 m_state = newState;
60 Q_EMIT stateChanged(m_state);
53 }61 }
54}62}
5563
@@ -115,6 +123,7 @@
115 err = module->methods->open(module, LIGHT_ID_NOTIFICATIONS, &device);123 err = module->methods->open(module, LIGHT_ID_NOTIFICATIONS, &device);
116 if (err == 0) {124 if (err == 0) {
117 m_lightDevice = (light_device_t*)device;125 m_lightDevice = (light_device_t*)device;
126 turnOff();
118 return true;127 return true;
119 } else {128 } else {
120 qWarning() << "Failed to access notification lights";129 qWarning() << "Failed to access notification lights";
@@ -127,15 +136,6 @@
127136
128void Lights::turnOn()137void Lights::turnOn()
129{138{
130 if (!init()) {
131 qWarning() << "No lights device";
132 return;
133 }
134
135 if (m_state == Lights::On) {
136 return;
137 }
138
139 // pulse139 // pulse
140 light_state_t state;140 light_state_t state;
141 memset(&state, 0, sizeof(light_state_t));141 memset(&state, 0, sizeof(light_state_t));
@@ -147,23 +147,11 @@
147147
148 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {148 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
149 qWarning() << "Failed to turn the light off";149 qWarning() << "Failed to turn the light off";
150 } else {
151 m_state = Lights::On;
152 Q_EMIT stateChanged(m_state);
153 }150 }
154}151}
155152
156void Lights::turnOff()153void Lights::turnOff()
157{154{
158 if (!init()) {
159 qWarning() << "No lights device";
160 return;
161 }
162
163 if (m_state == Lights::Off) {
164 return;
165 }
166
167 light_state_t state;155 light_state_t state;
168 memset(&state, 0, sizeof(light_state_t));156 memset(&state, 0, sizeof(light_state_t));
169 state.color = 0x00000000;157 state.color = 0x00000000;
@@ -174,8 +162,5 @@
174162
175 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {163 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
176 qWarning() << "Failed to turn the light off";164 qWarning() << "Failed to turn the light off";
177 } else {
178 m_state = Lights::Off;
179 Q_EMIT stateChanged(m_state);
180 }165 }
181}166}
182167
=== modified file 'plugins/Unity/Indicators/CMakeLists.txt'
--- plugins/Unity/Indicators/CMakeLists.txt 2014-10-03 10:53:02 +0000
+++ plugins/Unity/Indicators/CMakeLists.txt 2014-12-17 11:19:14 +0000
@@ -16,14 +16,16 @@
16)16)
1717
18set(IndicatorsQML_SOURCES18set(IndicatorsQML_SOURCES
19 actionrootstate.cpp
19 indicator.cpp20 indicator.cpp
20 indicators.h21 indicators.h
21 indicatorsmanager.cpp22 indicatorsmanager.cpp
22 indicatorsmodel.cpp23 indicatorsmodel.cpp
23 menucontentactivator.cpp24 menucontentactivator.cpp
25 modelactionrootstate.cpp
24 modelprinter.cpp26 modelprinter.cpp
25 plugin.cpp27 plugin.cpp
26 rootactionstate.cpp28 rootstateparser.cpp
27 sharedunitymenumodel.cpp29 sharedunitymenumodel.cpp
28 unitymenumodelcache.cpp30 unitymenumodelcache.cpp
29 unitymenumodelstack.cpp31 unitymenumodelstack.cpp
3032
=== modified file 'plugins/Unity/Indicators/Indicators.qmltypes'
--- plugins/Unity/Indicators/Indicators.qmltypes 2014-10-07 10:58:39 +0000
+++ plugins/Unity/Indicators/Indicators.qmltypes 2014-12-17 11:19:14 +0000
@@ -8,6 +8,14 @@
88
9Module {9Module {
10 Component {10 Component {
11 name: "ActionRootState"
12 prototype: "RootStateObject"
13 exports: ["Unity.Indicators/ActionRootState 0.1"]
14 exportMetaObjectRevisions: [0]
15 Property { name: "actionGroup"; type: "QDBusActionGroup"; isPointer: true }
16 Property { name: "actionName"; type: "string" }
17 }
18 Component {
11 name: "ActionState"19 name: "ActionState"
12 prototype: "QObject"20 prototype: "QObject"
13 exports: ["Unity.Indicators/ActionState 0.1"]21 exports: ["Unity.Indicators/ActionState 0.1"]
@@ -23,7 +31,6 @@
23 }31 }
24 }32 }
25 }33 }
26 Component { name: "ActionStateParser"; prototype: "QObject" }
27 Component {34 Component {
28 name: "FlatMenuProxyModelRole"35 name: "FlatMenuProxyModelRole"
29 prototype: "QObject"36 prototype: "QObject"
@@ -147,6 +154,14 @@
147 Property { name: "active"; type: "bool"; isReadonly: true }154 Property { name: "active"; type: "bool"; isReadonly: true }
148 }155 }
149 Component {156 Component {
157 name: "ModelActionRootState"
158 prototype: "RootStateObject"
159 exports: ["Unity.Indicators/ModelActionRootState 0.1"]
160 exportMetaObjectRevisions: [0]
161 Property { name: "menu"; type: "UnityMenuModel"; isPointer: true }
162 Signal { name: "indexChanged" }
163 }
164 Component {
150 name: "ModelPrinter"165 name: "ModelPrinter"
151 prototype: "QObject"166 prototype: "QObject"
152 exports: ["Unity.Indicators/ModelPrinter 0.1"]167 exports: ["Unity.Indicators/ModelPrinter 0.1"]
@@ -192,11 +207,8 @@
192 }207 }
193 Component { name: "QIdentityProxyModel"; prototype: "QAbstractProxyModel" }208 Component { name: "QIdentityProxyModel"; prototype: "QAbstractProxyModel" }
194 Component {209 Component {
195 name: "RootActionState"210 name: "RootStateObject"
196 prototype: "ActionStateParser"211 prototype: "QObject"
197 exports: ["Unity.Indicators/RootActionState 0.1"]
198 exportMetaObjectRevisions: [0]
199 Property { name: "menu"; type: "UnityMenuModel"; isPointer: true }
200 Property { name: "valid"; type: "bool"; isReadonly: true }212 Property { name: "valid"; type: "bool"; isReadonly: true }
201 Property { name: "title"; type: "string"; isReadonly: true }213 Property { name: "title"; type: "string"; isReadonly: true }
202 Property { name: "leftLabel"; type: "string"; isReadonly: true }214 Property { name: "leftLabel"; type: "string"; isReadonly: true }
@@ -205,7 +217,6 @@
205 Property { name: "accessibleName"; type: "string"; isReadonly: true }217 Property { name: "accessibleName"; type: "string"; isReadonly: true }
206 Property { name: "visible"; type: "bool"; isReadonly: true }218 Property { name: "visible"; type: "bool"; isReadonly: true }
207 Signal { name: "updated" }219 Signal { name: "updated" }
208 Signal { name: "indexChanged" }
209 }220 }
210 Component {221 Component {
211 name: "SharedUnityMenuModel"222 name: "SharedUnityMenuModel"
212223
=== added file 'plugins/Unity/Indicators/actionrootstate.cpp'
--- plugins/Unity/Indicators/actionrootstate.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/actionrootstate.cpp 2014-12-17 11:19:14 +0000
@@ -0,0 +1,97 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "actionrootstate.h"
18
19#include <qdbusactiongroup.h>
20#include <QDebug>
21
22ActionRootState::ActionRootState(QObject *parent)
23 : RootStateObject(parent)
24 , m_actionGroup(nullptr)
25{
26}
27
28QDBusActionGroup *ActionRootState::actionGroup() const
29{
30 return m_actionGroup;
31}
32
33void ActionRootState::setActionGroup(QDBusActionGroup *actionGroup)
34{
35 if (m_actionGroup != actionGroup) {
36 bool wasValid = valid();
37
38 if (m_actionGroup) {
39 disconnect(m_actionGroup, 0, this, 0);
40 }
41 m_actionGroup = actionGroup;
42
43 if (m_actionGroup) {
44 connect(m_actionGroup, &QDBusActionGroup::statusChanged, this, [&](bool) { updateActionState(); });
45 connect(m_actionGroup, &QDBusActionGroup::actionAppear, this, [&](const QString&) { updateActionState(); });
46 connect(m_actionGroup, &QDBusActionGroup::actionVanish, this, [&](const QString&) { updateActionState(); });
47 connect(m_actionGroup, &QDBusActionGroup::actionStateChanged, this, [&](QVariant) { updateActionState(); });
48
49 connect(m_actionGroup, &QObject::destroyed, this, [&](QObject*) { updateActionState(); });
50 }
51 updateActionState();
52 Q_EMIT actionGroupChanged();
53
54 if (wasValid != valid()) Q_EMIT validChanged();
55 }
56}
57
58QString ActionRootState::actionName() const
59{
60 return m_actionName;
61}
62
63void ActionRootState::setActionName(const QString &actionName)
64{
65 if (m_actionName != actionName) {
66 bool wasValid = valid();
67
68 m_actionName = actionName;
69 updateActionState();
70
71 Q_EMIT actionNameChanged();
72
73 if (wasValid != valid()) Q_EMIT validChanged();
74 }
75}
76
77bool ActionRootState::valid() const
78{
79 return m_actionGroup && m_actionGroup->status() == DBusEnums::Connected &&
80 !m_actionName.isEmpty() && m_actionGroup->hasAction(m_actionName);
81}
82
83void ActionRootState::updateActionState()
84{
85 if (valid()) {
86 ActionStateParser* oldParser = m_actionGroup->actionStateParser();
87 m_actionGroup->setActionStateParser(&m_parser);
88
89 QVariantMap state = m_actionGroup->actionState(m_actionName).toMap();
90
91 m_actionGroup->setActionStateParser(oldParser);
92
93 setCurrentState(state);
94 } else {
95 setCurrentState(QVariantMap());
96 }
97}
098
=== added file 'plugins/Unity/Indicators/actionrootstate.h'
--- plugins/Unity/Indicators/actionrootstate.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/actionrootstate.h 2014-12-17 11:19:14 +0000
@@ -0,0 +1,55 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef ACTIONROOTSTATE_H
18#define ACTIONROOTSTATE_H
19
20#include "unityindicatorsglobal.h"
21
22#include "rootstateparser.h"
23
24class QDBusActionGroup;
25
26class UNITYINDICATORS_EXPORT ActionRootState : public RootStateObject
27{
28 Q_OBJECT
29 Q_PROPERTY(QDBusActionGroup* actionGroup READ actionGroup WRITE setActionGroup NOTIFY actionGroupChanged)
30 Q_PROPERTY(QString actionName READ actionName WRITE setActionName NOTIFY actionNameChanged)
31
32public:
33 ActionRootState(QObject *parent = 0);
34
35 QDBusActionGroup *actionGroup() const;
36 void setActionGroup(QDBusActionGroup *actionGroup);
37
38 QString actionName() const;
39 void setActionName(const QString& actionName);
40
41 bool valid() const override;
42
43Q_SIGNALS:
44 void actionGroupChanged();
45 void actionNameChanged();
46
47private Q_SLOTS:
48 void updateActionState();
49
50private:
51 QDBusActionGroup* m_actionGroup;
52 QString m_actionName;
53};
54
55#endif // ACTIONROOTSTATE_H
056
=== added file 'plugins/Unity/Indicators/modelactionrootstate.cpp'
--- plugins/Unity/Indicators/modelactionrootstate.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/modelactionrootstate.cpp 2014-12-17 11:19:14 +0000
@@ -0,0 +1,127 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20#include "modelactionrootstate.h"
21#include "indicators.h"
22
23#include <unitymenumodel.h>
24#include <QVariant>
25#include <QIcon>
26
27extern "C" {
28#include <glib.h>
29#include <gio/gio.h>
30}
31
32ModelActionRootState::ModelActionRootState(QObject *parent)
33 : RootStateObject(parent),
34 m_menu(nullptr)
35{
36}
37
38ModelActionRootState::~ModelActionRootState()
39{
40}
41
42UnityMenuModel* ModelActionRootState::menu() const
43{
44 return m_menu;
45}
46
47void ModelActionRootState::setMenu(UnityMenuModel* menu)
48{
49 if (m_menu != menu) {
50 bool wasValid = valid();
51
52 if (m_menu) {
53 m_menu->disconnect(this);
54 }
55 m_menu = menu;
56
57 if (m_menu) {
58 connect(m_menu, SIGNAL(rowsInserted(const QModelIndex&, int, int)), SLOT(onModelRowsAdded(const QModelIndex&, int, int)));
59 connect(m_menu, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onModelRowsRemoved(const QModelIndex&, int, int)));
60 connect(m_menu, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SLOT(onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
61
62 connect(m_menu, SIGNAL(destroyed()), SLOT(reset()));
63 }
64 updateActionState();
65 Q_EMIT menuChanged();
66
67 if (wasValid != valid())
68 Q_EMIT validChanged();
69 }
70}
71
72bool ModelActionRootState::valid() const
73{
74 return m_menu && m_menu->rowCount() > 0;
75}
76
77void ModelActionRootState::onModelRowsAdded(const QModelIndex& parent, int start, int end)
78{
79 Q_UNUSED(parent);
80 if (start == 0 && end >= 0) {
81 updateActionState();
82 }
83}
84
85void ModelActionRootState::onModelRowsRemoved(const QModelIndex& parent, int start, int end)
86{
87 Q_UNUSED(parent);
88 if (start == 0 && end >= 0) {
89 updateActionState();
90 }
91}
92
93void ModelActionRootState::onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
94{
95 Q_UNUSED(roles);
96 if (!topLeft.isValid() || !bottomRight.isValid()) {
97 return;
98 }
99
100 if (topLeft.row() <= 0 && bottomRight.row() >= 0) {
101 updateActionState();
102 }
103}
104
105void ModelActionRootState::reset()
106{
107 m_menu = nullptr;
108
109 Q_EMIT menuChanged();
110 setCurrentState(QVariantMap());
111}
112
113void ModelActionRootState::updateActionState()
114{
115 if (m_menu && m_menu->rowCount() > 0) {
116 ActionStateParser* oldParser = m_menu->actionStateParser();
117 m_menu->setActionStateParser(&m_parser);
118
119 QVariantMap state = m_menu->get(0, "actionState").toMap();
120
121 m_menu->setActionStateParser(oldParser);
122
123 setCurrentState(state);
124 } else {
125 setCurrentState(QVariantMap());
126 }
127}
0128
=== added file 'plugins/Unity/Indicators/modelactionrootstate.h'
--- plugins/Unity/Indicators/modelactionrootstate.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/modelactionrootstate.h 2014-12-17 11:19:14 +0000
@@ -0,0 +1,61 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20#ifndef MODELACTIONROOTSTATE_H
21#define MODELACTIONROOTSTATE_H
22
23#include "unityindicatorsglobal.h"
24
25#include "rootstateparser.h"
26
27class UnityMenuModel;
28
29class UNITYINDICATORS_EXPORT ModelActionRootState : public RootStateObject
30{
31 Q_OBJECT
32 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
33public:
34 ModelActionRootState(QObject *parent = 0);
35 virtual ~ModelActionRootState();
36
37 UnityMenuModel* menu() const;
38 void setMenu(UnityMenuModel* menu);
39
40 int index() const;
41 void setIndex(int index);
42
43 bool valid() const override;
44
45Q_SIGNALS:
46 void menuChanged();
47 void indexChanged();
48
49private Q_SLOTS:
50 void onModelRowsAdded(const QModelIndex& parent, int start, int end);
51 void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
52 void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
53 void reset();
54
55private:
56 void updateActionState();
57
58 UnityMenuModel* m_menu;
59};
60
61#endif // MODELACTIONROOTSTATE_H
062
=== modified file 'plugins/Unity/Indicators/plugin.cpp'
--- plugins/Unity/Indicators/plugin.cpp 2014-10-07 10:28:59 +0000
+++ plugins/Unity/Indicators/plugin.cpp 2014-12-17 11:19:14 +0000
@@ -24,12 +24,13 @@
24#include "plugin.h"24#include "plugin.h"
2525
26// local26// local
27#include "actionrootstate.h"
27#include "indicators.h"28#include "indicators.h"
28#include "indicatorsmanager.h"29#include "indicatorsmanager.h"
29#include "indicatorsmodel.h"30#include "indicatorsmodel.h"
30#include "menucontentactivator.h"31#include "menucontentactivator.h"
32#include "modelactionrootstate.h"
31#include "modelprinter.h"33#include "modelprinter.h"
32#include "rootactionstate.h"
33#include "sharedunitymenumodel.h"34#include "sharedunitymenumodel.h"
34#include "unitymenumodelcache.h"35#include "unitymenumodelcache.h"
35#include "unitymenumodelstack.h"36#include "unitymenumodelstack.h"
@@ -51,7 +52,8 @@
51 qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel");52 qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel");
52 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");53 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
53 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");54 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
54 qmlRegisterType<RootActionState>(uri, 0, 1, "RootActionState");55 qmlRegisterType<ModelActionRootState>(uri, 0, 1, "ModelActionRootState");
56 qmlRegisterType<ActionRootState>(uri, 0, 1, "ActionRootState");
55 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");57 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");
56 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");58 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
57 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");59 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
5860
=== renamed file 'plugins/Unity/Indicators/rootactionstate.cpp' => 'plugins/Unity/Indicators/rootstateparser.cpp'
--- plugins/Unity/Indicators/rootactionstate.cpp 2014-10-20 12:38:16 +0000
+++ plugins/Unity/Indicators/rootstateparser.cpp 2014-12-17 11:19:14 +0000
@@ -12,155 +12,18 @@
12 *12 *
13 * You should have received a copy of the GNU Lesser General Public License13 * You should have received a copy of the GNU Lesser General Public License
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/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */15 */
1916
20#include "rootactionstate.h"17#include "rootstateparser.h"
21#include "indicators.h"
22
23#include <unitymenumodel.h>
24#include <QVariant>
25#include <QIcon>
2618
27extern "C" {19extern "C" {
28#include <glib.h>20#include <glib.h>
29#include <gio/gio.h>21#include <gio/gio.h>
30}22}
3123
32RootActionState::RootActionState(QObject *parent)24RootStateParser::RootStateParser(QObject* parent)
33 : ActionStateParser(parent),25 : ActionStateParser(parent)
34 m_menu(nullptr)26{
35{
36}
37
38RootActionState::~RootActionState()
39{
40}
41
42UnityMenuModel* RootActionState::menu() const
43{
44 return m_menu;
45}
46
47void RootActionState::setMenu(UnityMenuModel* menu)
48{
49 if (m_menu != menu) {
50 if (m_menu) {
51 m_menu->disconnect(this);
52 }
53 m_menu = menu;
54
55 if (m_menu) {
56 connect(m_menu, SIGNAL(rowsInserted(const QModelIndex&, int, int)), SLOT(onModelRowsAdded(const QModelIndex&, int, int)));
57 connect(m_menu, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SLOT(onModelRowsRemoved(const QModelIndex&, int, int)));
58 connect(m_menu, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)), SLOT(onModelDataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
59
60 connect(m_menu, SIGNAL(destroyed()), SLOT(reset()));
61 }
62 updateActionState();
63 Q_EMIT menuChanged();
64 }
65}
66
67void RootActionState::onModelRowsAdded(const QModelIndex& parent, int start, int end)
68{
69 Q_UNUSED(parent);
70 if (start == 0 && end >= 0) {
71 updateActionState();
72 }
73}
74
75void RootActionState::onModelRowsRemoved(const QModelIndex& parent, int start, int end)
76{
77 Q_UNUSED(parent);
78 if (start == 0 && end >= 0) {
79 updateActionState();
80 }
81}
82
83void RootActionState::onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
84{
85 Q_UNUSED(roles);
86 if (!topLeft.isValid() || !bottomRight.isValid()) {
87 return;
88 }
89
90 if (topLeft.row() <= 0 && bottomRight.row() >= 0) {
91 updateActionState();
92 }
93}
94
95void RootActionState::reset()
96{
97 m_cachedState.clear();
98 m_menu = nullptr;
99
100 Q_EMIT menuChanged();
101 Q_EMIT updated();
102}
103
104void RootActionState::updateActionState()
105{
106 if (m_menu && m_menu->rowCount() > 0) {
107 ActionStateParser* oldParser = m_menu->actionStateParser();
108 m_menu->setActionStateParser(this);
109
110 m_cachedState = m_menu->get(0, "actionState").toMap();
111
112 m_menu->setActionStateParser(oldParser);
113 } else {
114 m_cachedState.clear();
115 }
116 Q_EMIT updated();
117}
118
119bool RootActionState::isValid() const
120{
121 return m_menu && m_menu->rowCount() > 0;
122}
123
124QString RootActionState::title() const
125{
126 if (!isValid()) return QString();
127
128 return m_cachedState.value("title", QVariant::fromValue(QString())).toString();
129}
130
131QString RootActionState::leftLabel() const
132{
133 if (!isValid()) return QString();
134
135 return m_cachedState.value("pre-label", QVariant::fromValue(QString())).toString();
136}
137
138QString RootActionState::rightLabel() const
139{
140 if (!isValid()) return QString();
141
142 return m_cachedState.value("label", QVariant::fromValue(QString())).toString();
143}
144
145QStringList RootActionState::icons() const
146{
147 if (!isValid()) return QStringList();
148
149 return m_cachedState.value("icons", QVariant::fromValue(QStringList())).toStringList();
150}
151
152QString RootActionState::accessibleName() const
153{
154 if (!isValid()) return QString();
155
156 return m_cachedState.value("accessible-desc", QVariant::fromValue(QString())).toString();
157}
158
159bool RootActionState::indicatorVisible() const
160{
161 if (!isValid()) return false;
162
163 return m_cachedState.value("visible", QVariant::fromValue(true)).toBool();
164}27}
16528
166static QString iconUri(GIcon *icon)29static QString iconUri(GIcon *icon)
@@ -209,7 +72,7 @@
209 return uri;72 return uri;
210}73}
21174
212QVariant RootActionState::toQVariant(GVariant* state) const75QVariant RootStateParser::toQVariant(GVariant* state) const
213{76{
214 if (!state) {77 if (!state) {
215 return QVariant();78 return QVariant();
@@ -296,3 +159,73 @@
296 }159 }
297 return ActionStateParser::toQVariant(state);160 return ActionStateParser::toQVariant(state);
298}161}
162
163
164RootStateObject::RootStateObject(QObject* parent)
165 : QObject(parent)
166{
167}
168
169QString RootStateObject::title() const
170{
171 if (!valid()) return QString();
172
173 return m_currentState.value("title", QVariant::fromValue(QString())).toString();
174}
175
176QString RootStateObject::leftLabel() const
177{
178 if (!valid()) return QString();
179
180 return m_currentState.value("pre-label", QVariant::fromValue(QString())).toString();
181}
182
183QString RootStateObject::rightLabel() const
184{
185 if (!valid()) return QString();
186
187 return m_currentState.value("label", QVariant::fromValue(QString())).toString();
188}
189
190QStringList RootStateObject::icons() const
191{
192 if (!valid()) return QStringList();
193
194 return m_currentState.value("icons", QVariant::fromValue(QStringList())).toStringList();
195}
196
197QString RootStateObject::accessibleName() const
198{
199 if (!valid()) return QString();
200
201 return m_currentState.value("accessible-desc", QVariant::fromValue(QString())).toString();
202}
203
204bool RootStateObject::indicatorVisible() const
205{
206 if (!valid()) return false;
207
208 return m_currentState.value("visible", QVariant::fromValue(true)).toBool();
209}
210
211void RootStateObject::setCurrentState(const QVariantMap& newState)
212{
213 QString oldTitle = title();
214 QString oldLeftLabel = leftLabel();
215 QString oldRightLabel = rightLabel();
216 QStringList oldIcons = icons();
217 QString oldAccessibleName = accessibleName();
218 bool oldIndicatorVisible = indicatorVisible();
219
220 if (m_currentState != newState) {
221 m_currentState = newState;
222 Q_EMIT updated();
223
224 if (oldTitle != title()) Q_EMIT titleChanged();
225 if (oldLeftLabel != leftLabel()) Q_EMIT leftLabelChanged();
226 if (oldRightLabel != rightLabel()) Q_EMIT rightLabelChanged();
227 if (oldIcons != icons()) Q_EMIT iconsChanged();
228 if (oldAccessibleName != accessibleName()) Q_EMIT accessibleNameChanged();
229 if (oldIndicatorVisible != indicatorVisible()) Q_EMIT indicatorVisibleChanged();
230 }
231}
299232
=== renamed file 'plugins/Unity/Indicators/rootactionstate.h' => 'plugins/Unity/Indicators/rootstateparser.h'
--- plugins/Unity/Indicators/rootactionstate.h 2014-10-20 12:38:16 +0000
+++ plugins/Unity/Indicators/rootstateparser.h 2014-12-17 11:19:14 +0000
@@ -12,26 +12,27 @@
12 *12 *
13 * You should have received a copy of the GNU Lesser General Public License13 * You should have received a copy of the GNU Lesser General Public License
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/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */15 */
1916
20#ifndef ROOTACTIONSTATE_H17#ifndef ROOTSTATEPARSER_H
21#define ROOTACTIONSTATE_H18#define ROOTSTATEPARSER_H
2219
23#include "unityindicatorsglobal.h"20#include "unityindicatorsglobal.h"
2421
25#include <actionstateparser.h>22#include <actionstateparser.h>
2623
27class UnityMenuModel;24class UNITYINDICATORS_EXPORT RootStateParser : public ActionStateParser
25{
26public:
27 RootStateParser(QObject* parent = nullptr);
28 virtual QVariant toQVariant(GVariant* state) const override;
29};
2830
29class UNITYINDICATORS_EXPORT RootActionState : public ActionStateParser31class UNITYINDICATORS_EXPORT RootStateObject : public QObject
30{32{
31 Q_OBJECT33 Q_OBJECT
32 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
3334
34 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)35 Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
35 Q_PROPERTY(QString title READ title NOTIFY titleChanged)36 Q_PROPERTY(QString title READ title NOTIFY titleChanged)
36 Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged)37 Q_PROPERTY(QString leftLabel READ leftLabel NOTIFY leftLabelChanged)
37 Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged)38 Q_PROPERTY(QString rightLabel READ rightLabel NOTIFY rightLabelChanged)
@@ -39,16 +40,10 @@
39 Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged)40 Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged)
40 Q_PROPERTY(bool indicatorVisible READ indicatorVisible NOTIFY indicatorVisibleChanged)41 Q_PROPERTY(bool indicatorVisible READ indicatorVisible NOTIFY indicatorVisibleChanged)
41public:42public:
42 RootActionState(QObject *parent = 0);43 RootStateObject(QObject* parent = 0);
43 virtual ~RootActionState();44
4445 virtual bool valid() const = 0;
45 UnityMenuModel* menu() const;46
46 void setMenu(UnityMenuModel* menu);
47
48 int index() const;
49 void setIndex(int index);
50
51 bool isValid() const;
52 QString title() const;47 QString title() const;
53 QString leftLabel() const;48 QString leftLabel() const;
54 QString rightLabel() const;49 QString rightLabel() const;
@@ -56,15 +51,12 @@
56 QString accessibleName() const;51 QString accessibleName() const;
57 bool indicatorVisible() const;52 bool indicatorVisible() const;
5853
59 // from ActionStateParser54 QVariantMap currentState() const { return m_currentState; }
60 virtual QVariant toQVariant(GVariant* state) const override;55 void setCurrentState(const QVariantMap& currentState);
6156
62Q_SIGNALS:57Q_SIGNALS:
63 void updated();58 void updated();
6459
65 void menuChanged();
66 void indexChanged();
67
68 void validChanged();60 void validChanged();
69 void titleChanged();61 void titleChanged();
70 void leftLabelChanged();62 void leftLabelChanged();
@@ -73,17 +65,9 @@
73 void accessibleNameChanged();65 void accessibleNameChanged();
74 void indicatorVisibleChanged();66 void indicatorVisibleChanged();
7567
76private Q_SLOTS:68protected:
77 void onModelRowsAdded(const QModelIndex& parent, int start, int end);69 RootStateParser m_parser;
78 void onModelRowsRemoved(const QModelIndex& parent, int start, int end);70 QVariantMap m_currentState;
79 void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
80 void reset();
81
82private:
83 void updateActionState();
84
85 UnityMenuModel* m_menu;
86 QVariantMap m_cachedState;
87};71};
8872
89#endif // ROOTACTIONSTATE_H73#endif // ROOTSTATEPARSER_H
9074
=== modified file 'qml/Greeter/Clock.qml'
--- qml/Greeter/Clock.qml 2014-11-21 19:23:57 +0000
+++ qml/Greeter/Clock.qml 2014-12-17 11:19:14 +0000
@@ -53,7 +53,7 @@
53 menuObjectPath: clock.visible ? "/com/canonical/indicator/datetime/phone" : ""53 menuObjectPath: clock.visible ? "/com/canonical/indicator/datetime/phone" : ""
54 }54 }
5555
56 Indicators.RootActionState {56 Indicators.ModelActionRootState {
57 menu: timeModel.model57 menu: timeModel.model
58 onUpdated: {58 onUpdated: {
59 if (timeLabel.text != rightLabel) {59 if (timeLabel.text != rightLabel) {
6060
=== modified file 'qml/Panel/IndicatorItem.qml'
--- qml/Panel/IndicatorItem.qml 2014-11-21 15:01:59 +0000
+++ qml/Panel/IndicatorItem.qml 2014-12-17 11:19:14 +0000
@@ -45,14 +45,6 @@
45 onClicked: parent.clicked()45 onClicked: parent.clicked()
46 }46 }
4747
48 // FIXME: For now we will enable led indicator support only for messaging indicator
49 // in the future we should export a led API insted of doing that,
50 Loader {
51 id: indicatorLed
52 // only load source Component if the icons contains the new message icon
53 source: (root.icons && (String(root.icons).indexOf("indicator-messages-new") != -1)) ? Qt.resolvedUrl("Indicators/IndicatorsLight.qml") : ""
54 }
55
56 Item {48 Item {
57 id: mainItems49 id: mainItems
58 anchors.centerIn: parent50 anchors.centerIn: parent
5951
=== modified file 'qml/Panel/Indicators/IndicatorBase.qml'
--- qml/Panel/Indicators/IndicatorBase.qml 2014-10-17 14:55:35 +0000
+++ qml/Panel/Indicators/IndicatorBase.qml 2014-12-17 11:19:14 +0000
@@ -40,7 +40,7 @@
40 menuObjectPath: indicatorItem.menuObjectPath40 menuObjectPath: indicatorItem.menuObjectPath
41 }41 }
4242
43 RootActionState {43 ModelActionRootState {
44 id: rootAction44 id: rootAction
45 menu: menuModel ? menuModel : null45 menu: menuModel ? menuModel : null
46 onUpdated: indicatorItem.rootActionStateChanged()46 onUpdated: indicatorItem.rootActionStateChanged()
4747
=== modified file 'qml/Panel/Indicators/IndicatorsLight.qml'
--- qml/Panel/Indicators/IndicatorsLight.qml 2014-08-05 14:31:12 +0000
+++ qml/Panel/Indicators/IndicatorsLight.qml 2014-12-17 11:19:14 +0000
@@ -20,16 +20,34 @@
20import QtQuick 2.020import QtQuick 2.0
21import Powerd 0.121import Powerd 0.1
22import Lights 0.122import Lights 0.1
23import QMenuModel 0.1 as QMenuModel
24import Unity.Indicators 0.1 as Indicators
2325
24QtObject {26QtObject {
25 id: root27 id: root
2628
29 property var _actionGroup: QMenuModel.QDBusActionGroup {
30 busType: 1
31 busName: "com.canonical.indicator.messages"
32 objectPath: "/com/canonical/indicator/messages"
33 }
34
35 property var _rootState: Indicators.ActionRootState {
36 actionGroup: _actionGroup
37 actionName: "messages"
38 Component.onCompleted: actionGroup.start()
39
40 property bool hasMessages: valid && (String(icons).indexOf("indicator-messages-new") != -1)
41 }
42
27 Component.onDestruction: Lights.state = Lights.Off43 Component.onDestruction: Lights.state = Lights.Off
2844
29 // QtObject does not have children45 // QtObject does not have children
30 property var _binding: Binding {46 property var _binding: Binding {
31 target: Lights47 target: Lights
32 property: "state"48 property: "state"
33 value: (Powerd.status === Powerd.Off) ? Lights.On : Lights.Off49 value: {
50 return (Powerd.status === Powerd.Off && _rootState.hasMessages) ? Lights.On : Lights.Off
51 }
34 }52 }
35}53}
3654
=== modified file 'qml/Panel/IndicatorsMenu.qml'
--- qml/Panel/IndicatorsMenu.qml 2014-10-21 19:32:03 +0000
+++ qml/Panel/IndicatorsMenu.qml 2014-12-17 11:19:14 +0000
@@ -18,6 +18,7 @@
18import Ubuntu.Components 1.118import Ubuntu.Components 1.1
19import Ubuntu.Gestures 0.119import Ubuntu.Gestures 0.1
20import "../Components"20import "../Components"
21import "Indicators"
2122
22Showable {23Showable {
23 id: root24 id: root
@@ -60,6 +61,10 @@
60 onUnitProgressChanged: d.updateState()61 onUnitProgressChanged: d.updateState()
61 clip: root.partiallyOpened62 clip: root.partiallyOpened
6263
64 IndicatorsLight {
65 id: indicatorLights
66 }
67
63 // eater68 // eater
64 MouseArea {69 MouseArea {
65 anchors.fill: parent70 anchors.fill: parent
6671
=== modified file 'tests/mocks/CMakeLists.txt'
--- tests/mocks/CMakeLists.txt 2014-11-21 19:28:16 +0000
+++ tests/mocks/CMakeLists.txt 2014-12-17 11:19:14 +0000
@@ -32,6 +32,7 @@
32add_subdirectory(GSettings.1.0)32add_subdirectory(GSettings.1.0)
33add_subdirectory(libusermetrics)33add_subdirectory(libusermetrics)
34add_subdirectory(LightDM)34add_subdirectory(LightDM)
35add_subdirectory(Lights)
35add_subdirectory(MeeGo)36add_subdirectory(MeeGo)
36add_subdirectory(Powerd)37add_subdirectory(Powerd)
37add_subdirectory(QMenuModel)38add_subdirectory(QMenuModel)
3839
=== added directory 'tests/mocks/Lights'
=== added file 'tests/mocks/Lights/CMakeLists.txt'
--- tests/mocks/Lights/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/mocks/Lights/CMakeLists.txt 2014-12-17 11:19:14 +0000
@@ -0,0 +1,8 @@
1add_library(MockLights-qml MODULE
2 plugin.cpp
3 Lights.cpp
4 )
5
6qt5_use_modules(MockLights-qml Qml Gui)
7
8add_unity8_mock(Lights 0.1 Lights TARGETS MockLights-qml)
09
=== added file 'tests/mocks/Lights/Lights.cpp'
--- tests/mocks/Lights/Lights.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Lights/Lights.cpp 2014-12-17 11:19:14 +0000
@@ -0,0 +1,84 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "Lights.h"
18
19#include <QDebug>
20
21Lights::Lights(QObject* parent)
22 : QObject(parent),
23 m_color("blue"),
24 m_state(Lights::Off),
25 m_onMs(1000),
26 m_offMs(3000)
27{
28}
29
30Lights::~Lights()
31{
32}
33
34void Lights::setState(Lights::State newState)
35{
36 if (m_state != newState) {
37 m_state = newState;
38 Q_EMIT stateChanged(m_state);
39 }
40}
41
42Lights::State Lights::state() const
43{
44 return m_state;
45}
46
47void Lights::setColor(const QColor &color)
48{
49 if (m_color != color) {
50 m_color = color;
51 Q_EMIT colorChanged(m_color);
52 }
53}
54
55QColor Lights::color() const
56{
57 return m_color;
58}
59
60int Lights::onMillisec() const
61{
62 return m_onMs;
63}
64
65void Lights::setOnMillisec(int onMs)
66{
67 if (m_onMs != onMs) {
68 m_onMs = onMs;
69 Q_EMIT onMillisecChanged(m_onMs);
70 }
71}
72
73int Lights::offMillisec() const
74{
75 return m_offMs;
76}
77
78void Lights::setOffMillisec(int offMs)
79{
80 if (m_offMs != offMs) {
81 m_offMs = offMs;
82 Q_EMIT offMillisecChanged(m_offMs);
83 }
84}
085
=== added file 'tests/mocks/Lights/Lights.h'
--- tests/mocks/Lights/Lights.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Lights/Lights.h 2014-12-17 11:19:14 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_MOCK_LIGHTS_H
18#define UNITY_MOCK_LIGHTS_H
19
20#include <QtCore/QObject>
21#include <QtGui/QColor>
22
23class Lights: public QObject
24{
25 Q_OBJECT
26 Q_ENUMS(State)
27 Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
28 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
29 Q_PROPERTY(int onMillisec READ onMillisec WRITE setOnMillisec NOTIFY onMillisecChanged)
30 Q_PROPERTY(int offMillisec READ offMillisec WRITE setOffMillisec NOTIFY offMillisecChanged)
31
32public:
33 enum State {
34 Off,
35 On,
36 };
37
38 explicit Lights(QObject *parent = 0);
39 ~Lights();
40
41 void setState(State newState);
42 State state() const;
43
44 void setColor(const QColor &color);
45 QColor color() const;
46
47 int onMillisec() const;
48 void setOnMillisec(int onMs);
49
50 int offMillisec() const;
51 void setOffMillisec(int offMs);
52
53Q_SIGNALS:
54 void stateChanged(State newState);
55 void colorChanged(const QColor &color);
56 void onMillisecChanged(int onMs);
57 void offMillisecChanged(int offMs);
58
59private:
60 QColor m_color;
61 State m_state;
62 int m_onMs;
63 int m_offMs;
64};
65
66#endif
067
=== added file 'tests/mocks/Lights/Lights.qmltypes'
--- tests/mocks/Lights/Lights.qmltypes 1970-01-01 00:00:00 +0000
+++ tests/mocks/Lights/Lights.qmltypes 2014-12-17 11:19:14 +0000
@@ -0,0 +1,45 @@
1import QtQuick.tooling 1.1
2
3// This file describes the plugin-supplied types contained in the library.
4// It is used for QML tooling purposes only.
5//
6// This file was auto-generated by:
7// 'qmlplugindump -notrelocatable Lights 0.1 tests/mocks'
8
9Module {
10 Component {
11 name: "Lights"
12 prototype: "QObject"
13 exports: ["Lights/Lights 0.1"]
14 isCreatable: false
15 isSingleton: true
16 exportMetaObjectRevisions: [0]
17 Enum {
18 name: "State"
19 values: {
20 "Off": 0,
21 "On": 1
22 }
23 }
24 Property { name: "state"; type: "State" }
25 Property { name: "color"; type: "QColor" }
26 Property { name: "onMillisec"; type: "int" }
27 Property { name: "offMillisec"; type: "int" }
28 Signal {
29 name: "stateChanged"
30 Parameter { name: "newState"; type: "State" }
31 }
32 Signal {
33 name: "colorChanged"
34 Parameter { name: "color"; type: "QColor" }
35 }
36 Signal {
37 name: "onMillisecChanged"
38 Parameter { name: "onMs"; type: "int" }
39 }
40 Signal {
41 name: "offMillisecChanged"
42 Parameter { name: "offMs"; type: "int" }
43 }
44 }
45}
046
=== added file 'tests/mocks/Lights/plugin.cpp'
--- tests/mocks/Lights/plugin.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Lights/plugin.cpp 2014-12-17 11:19:14 +0000
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 2012,2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "plugin.h"
18#include "Lights.h"
19
20#include <QtQml/qqml.h>
21
22static QObject *lights_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
23{
24 Q_UNUSED(engine)
25 Q_UNUSED(scriptEngine)
26 return new Lights();
27}
28
29void PowerdPlugin::registerTypes(const char *uri)
30{
31 Q_ASSERT(uri == QLatin1String("Lights"));
32 qmlRegisterSingletonType<Lights>(uri, 0, 1, "Lights", lights_provider);
33}
034
=== added file 'tests/mocks/Lights/plugin.h'
--- tests/mocks/Lights/plugin.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Lights/plugin.h 2014-12-17 11:19:14 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2012,2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_POWER_PLUGIN_H
18#define MOCK_POWER_PLUGIN_H
19
20#include <QtQml/QQmlEngine>
21#include <QtQml/QQmlExtensionPlugin>
22
23class PowerdPlugin : public QQmlExtensionPlugin
24{
25 Q_OBJECT
26 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
27
28public:
29 void registerTypes(const char *uri);
30};
31
32#endif
033
=== added file 'tests/mocks/Lights/qmldir'
--- tests/mocks/Lights/qmldir 1970-01-01 00:00:00 +0000
+++ tests/mocks/Lights/qmldir 2014-12-17 11:19:14 +0000
@@ -0,0 +1,3 @@
1module Lights
2plugin MockLights-qml
3typeinfo Lights.qmltypes
04
=== modified file 'tests/mocks/QMenuModel/CMakeLists.txt'
--- tests/mocks/QMenuModel/CMakeLists.txt 2014-11-14 17:47:00 +0000
+++ tests/mocks/QMenuModel/CMakeLists.txt 2014-12-17 11:19:14 +0000
@@ -4,6 +4,7 @@
4)4)
55
6set(QMenuModelQml_SOURCES6set(QMenuModelQml_SOURCES
7 actiondata.h
7 actionstateparser.cpp8 actionstateparser.cpp
8 dbus-enums.h9 dbus-enums.h
9 plugin.cpp10 plugin.cpp
1011
=== modified file 'tests/mocks/QMenuModel/QDBusActionGroup.qml'
--- tests/mocks/QMenuModel/QDBusActionGroup.qml 2014-11-21 19:28:16 +0000
+++ tests/mocks/QMenuModel/QDBusActionGroup.qml 2014-12-17 11:19:14 +0000
@@ -19,81 +19,34 @@
1919
20import QtQuick 2.020import QtQuick 2.0
21import Ubuntu.Settings.Menus 0.1 as Menus21import Ubuntu.Settings.Menus 0.1 as Menus
22import QMenuModel 0.1
2223
23QtObject {24QtObject {
24 id: actionGroup25 id: actionGroup
25 property int busType26 property int busType
26 property string busName27 property string busName
27 property string objectPath28 property string objectPath
29 property var actions: ActionData ? ActionData.data : undefined
30
31 signal dataChanged
32
28 function start() {}33 function start() {}
34
29 function action(actionName) {35 function action(actionName) {
30 switch (actionName) {36 return Qt.createQmlObject("
31 case "transfer-state.queued":37 import QtQuick 2.3
32 return {38 import QMenuModel 0.1
33 'valid': true,39
34 'state': {40 QtObject {
35 'state': Menus.TransferState.Queued,41 signal activated
36 'percent': 0.042
37 }43 property string actionName: \"" + actionName + "\"
38 }44 property bool valid: ActionData.data[actionName] != undefined ? ActionData.data[actionName].valid : false
39 case "transfer-state.running":45 property var state: ActionData.data[actionName] != undefined ? ActionData.data[actionName].state : undefined
40 return {46
41 'valid': true,47 function activate() {
42 'state': {48 activated();
43 'state': Menus.TransferState.Running,49 }
44 'seconds-left': 100,50 }", actionGroup);
45 'percent': 0.1
46 }
47 }
48 case "transfer-state.paused":
49 return {
50 'valid': true,
51 'state': {
52 'state': Menus.TransferState.Paused,
53 'seconds-left': 100,
54 'percent': 0.5
55 }
56 }
57 case "transfer-state.cancelled":
58 return {
59 'valid': true,
60 'state': {
61 'state': Menus.TransferState.Canceled,
62 'percent': 0.4
63 }
64 }
65 case "transfer-state.finished": return {
66 'valid': true,
67 'state': {
68 'state': Menus.TransferState.Finished,
69 'seconds-left': 0,
70 'percent': 1.0
71 }
72 }
73 case "transfer-state.error":
74 return {
75 'valid': true,
76 'state': {
77 'state': Menus.TransferState.Error,
78 'seconds-left': 100,
79 'percent': 0.0
80 }
81 }
82 case "gps-detection-enabled":
83 case "location-detection-enabled":
84 return Qt.createQmlObject("
85import QtQuick 2.3
86QtObject {
87 property bool valid: true
88 property bool state: false
89 function activate() {
90 state = !state;
91 }
92}", actionGroup);
93 default:
94 break;
95 }
96
97 return null;
98 }51 }
99}52}
10053
=== added file 'tests/mocks/QMenuModel/actiondata.h'
--- tests/mocks/QMenuModel/actiondata.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/QMenuModel/actiondata.h 2014-12-17 11:19:14 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19#ifndef ACTIONDATA_H
20#define ACTIONDATA_H
21
22#include <QObject>
23#include <QVariant>
24
25typedef struct _GVariant GVariant;
26
27class Q_DECL_EXPORT ActionData : public QObject
28{
29 Q_OBJECT
30 Q_PROPERTY(QVariant data READ data WRITE setData NOTIFY dataChanged)
31public:
32 ActionData(QObject* parent = 0)
33 : QObject(parent)
34 {}
35
36 QVariant data() const { return m_data; }
37 void setData(const QVariant& data)
38 {
39 if (m_data != data) {
40 m_data = data;
41 Q_EMIT dataChanged();
42 }
43 }
44
45Q_SIGNALS:
46 void dataChanged();
47
48private:
49 QVariant m_data;
50};
51
52#endif // ACTIONDATA_H
053
=== modified file 'tests/mocks/QMenuModel/plugin.cpp'
--- tests/mocks/QMenuModel/plugin.cpp 2014-11-14 17:47:00 +0000
+++ tests/mocks/QMenuModel/plugin.cpp 2014-12-17 11:19:14 +0000
@@ -18,11 +18,19 @@
1818
19#include "plugin.h"19#include "plugin.h"
20#include "unitymenumodel.h"20#include "unitymenumodel.h"
21#include "actiondata.h"
21#include "actionstateparser.h"22#include "actionstateparser.h"
22#include "dbus-enums.h"23#include "dbus-enums.h"
2324
24#include <QtQml/qqml.h>25#include <QtQml/qqml.h>
2526
27static QObject* actionDataSingleton(QQmlEngine* engine, QJSEngine* scriptEngine)
28{
29 Q_UNUSED(engine);
30 Q_UNUSED(scriptEngine);
31 return new ActionData;
32}
33
26void QMenuModelPlugin::registerTypes(const char *uri)34void QMenuModelPlugin::registerTypes(const char *uri)
27{35{
28 Q_ASSERT(uri == QLatin1String("QMenuModel"));36 Q_ASSERT(uri == QLatin1String("QMenuModel"));
@@ -30,4 +38,6 @@
30 "DBus is only a namespace");38 "DBus is only a namespace");
31 qmlRegisterType<UnityMenuModel>(uri, 0, 1, "UnityMenuModel");39 qmlRegisterType<UnityMenuModel>(uri, 0, 1, "UnityMenuModel");
32 qmlRegisterType<ActionStateParser>(uri, 0, 1, "ActionStateParser");40 qmlRegisterType<ActionStateParser>(uri, 0, 1, "ActionStateParser");
41
42 qmlRegisterSingletonType<ActionData>(uri, 0, 1, "ActionData", actionDataSingleton);
33}43}
3444
=== added file 'tests/mocks/Unity/Indicators/ActionRootState.qml'
--- tests/mocks/Unity/Indicators/ActionRootState.qml 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Indicators/ActionRootState.qml 2014-12-17 11:19:14 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21
22QtObject {
23 property var actionGroup
24 property var actionName
25
26 property var action: actionGroup ? actionGroup.actions[actionName] : undefined
27 property var state: action && action.hasOwnProperty("state") ? action.state : undefined
28
29 property bool valid: action && action.hasOwnProperty("valid") ? action.valid : false
30 property string title: state && state.hasOwnProperty("title") ? state["title"] : ""
31 property string leftLabel: state && state.hasOwnProperty("pre-label") ? state["pre-label"] : ""
32 property string rightLabel: state && state.hasOwnProperty("label") ? state["label"] : ""
33 property var icons: state && state.hasOwnProperty("icons") ? state["icons"] : []
34 property string accessibleName: state && state.hasOwnProperty("accessible-desc") ? state["accessible-desc"] : ""
35 property bool visible: state && state.hasOwnProperty("visible") ? state["visible"] : true
36
37 signal updated
38
39 onValidChanged: updated()
40 onTitleChanged: updated()
41 onLeftLabelChanged: updated()
42 onRightLabelChanged: updated()
43 onIconsChanged: updated()
44 onAccessibleNameChanged: updated()
45 onVisibleChanged: updated()
46}
047
=== renamed file 'tests/mocks/Unity/Indicators/RootActionState.qml' => 'tests/mocks/Unity/Indicators/ModelActionRootState.qml'
=== modified file 'tests/mocks/Unity/Indicators/qmldir'
--- tests/mocks/Unity/Indicators/qmldir 2014-10-07 10:28:59 +0000
+++ tests/mocks/Unity/Indicators/qmldir 2014-12-17 11:19:14 +0000
@@ -2,5 +2,6 @@
2plugin IndicatorsFakeQml2plugin IndicatorsFakeQml
3typeinfo Indicators.qmltypes3typeinfo Indicators.qmltypes
44
5ActionRootState 0.1 ActionRootState.qml
5IndicatorsModel 0.1 IndicatorsModel.qml6IndicatorsModel 0.1 IndicatorsModel.qml
6RootActionState 0.1 RootActionState.qml7ModelActionRootState 0.1 ModelActionRootState.qml
78
=== modified file 'tests/plugins/Unity/Indicators/rootactionstatetest.cpp'
--- tests/plugins/Unity/Indicators/rootactionstatetest.cpp 2014-08-26 08:14:44 +0000
+++ tests/plugins/Unity/Indicators/rootactionstatetest.cpp 2014-12-17 11:19:14 +0000
@@ -17,7 +17,7 @@
17 * Nick Dedekind <nick.dedekind@canonical.com>17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */18 */
1919
20#include "rootactionstate.h"20#include "modelactionrootstate.h"
2121
22#include <unitymenumodel.h>22#include <unitymenumodel.h>
23#include <QtTest>23#include <QtTest>
@@ -32,7 +32,7 @@
32 {32 {
33 UnityMenuModel* menuModel = new UnityMenuModel();33 UnityMenuModel* menuModel = new UnityMenuModel();
34 ActionStateParser* originalParser = menuModel->actionStateParser();34 ActionStateParser* originalParser = menuModel->actionStateParser();
35 RootActionState* rootState = new RootActionState();35 ModelActionRootState* rootState = new ModelActionRootState();
3636
37 rootState->setMenu(menuModel);37 rootState->setMenu(menuModel);
3838
@@ -44,7 +44,7 @@
44 void testDeleteUnityMenuModel()44 void testDeleteUnityMenuModel()
45 {45 {
46 UnityMenuModel* menuModel = new UnityMenuModel();46 UnityMenuModel* menuModel = new UnityMenuModel();
47 RootActionState* rootState = new RootActionState();47 ModelActionRootState* rootState = new ModelActionRootState();
4848
49 rootState->setMenu(menuModel);49 rootState->setMenu(menuModel);
5050
@@ -77,7 +77,7 @@
7777
78 GVariant* params = g_variant_builder_end (&builderParams);78 GVariant* params = g_variant_builder_end (&builderParams);
7979
80 RootActionState rootState;80 RootStateParser rootState;
81 QVariant result = rootState.toQVariant(params);81 QVariant result = rootState.toQVariant(params);
82 g_variant_unref(params);82 g_variant_unref(params);
8383
8484
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2014-12-08 13:39:01 +0000
+++ tests/qmltests/CMakeLists.txt 2014-12-17 11:19:14 +0000
@@ -79,6 +79,7 @@
79add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")79add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
80add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")80add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
81add_qml_test(Panel SearchIndicator)81add_qml_test(Panel SearchIndicator)
82add_qml_test(Panel/Indicators IndicatorsLight ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
82# These MenuItemFactory tests need the test/mocks/ to come before plugins/83# These MenuItemFactory tests need the test/mocks/ to come before plugins/
83add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})84add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
84add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})85add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
8586
=== added file 'tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml'
--- tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml 2014-12-17 11:19:14 +0000
@@ -0,0 +1,129 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import QtQuick.Layouts 1.1
19import Unity.Test 0.1 as UT
20import Unity.Indicators 0.1 as Indicators
21import Ubuntu.Components 1.1
22import Powerd 0.1
23import Lights 0.1
24import QMenuModel 0.1
25import "../../../../qml/Panel/Indicators"
26
27Item {
28 id: root
29 width: units.gu(30)
30 height: units.gu(30)
31
32 property var newMessage: {
33 "messages" : {
34 'valid': true,
35 'state': {
36 'icons': [ 'indicator-messages-new' ]
37 }
38 }
39 };
40 property var noNewMessage: {
41 "messages" : {
42 'valid': true,
43 'state': {
44 'icons': [ 'indicator-messages' ]
45 }
46 }
47 };
48
49 Component {
50 id: light
51 IndicatorsLight {}
52 }
53
54 Loader {
55 id: loader
56 sourceComponent: light
57 }
58
59 Component.onCompleted: {
60 ActionData.data = newMessage;
61 Powerd.status = Powerd.On
62 }
63
64 RowLayout {
65 anchors.fill: parent
66 anchors.margins: units.gu(1)
67
68 Item {
69 Layout.fillWidth: true
70 Layout.fillHeight: true
71
72 Rectangle {
73 width: units.gu(4)
74 height: width
75 radius: width / 2
76 anchors.centerIn: parent
77
78 color: Lights.state === Lights.On ? Lights.color : "transparent"
79
80 border.color: "black"
81 border.width: 1
82 }
83 }
84
85 ColumnLayout {
86 Layout.alignment: Qt.AlignTop
87 Layout.fillWidth: false
88 Layout.preferredWidth: units.gu(15)
89
90 Button {
91 Layout.fillWidth: true
92 text: Powerd.status === Powerd.On ? "Power Off" : "Power On"
93 onClicked: {
94 if (Powerd.status === Powerd.On) Powerd.status = Powerd.Off;
95 else Powerd.status = Powerd.On;
96 }
97 }
98 }
99 }
100
101 UT.UnityTestCase {
102 name: "IndicatorsLight"
103 when: windowShown
104
105 function init() {
106 // reload
107 ActionData.data = noNewMessage;
108 loader.sourceComponent = undefined;
109 loader.sourceComponent = light;
110 Powerd.status = Powerd.On
111 }
112
113 function test_LightsStatus_data() {
114 return [
115 { tag: "Powerd.On with No Message", powerd: Powerd.On, actionData: noNewMessage, expected: Lights.Off },
116 { tag: "Powerd.Off with No Message", powerd: Powerd.Off, actionData: noNewMessage, expected: Lights.Off },
117 { tag: "Powerd.On with New Message", powerd: Powerd.On, actionData: newMessage, expected: Lights.Off },
118 { tag: "Powerd.Off with New Message", powerd: Powerd.Off, actionData: newMessage, expected: Lights.On },
119 ]
120 }
121
122 function test_LightsStatus(data) {
123 Powerd.status = data.powerd;
124 ActionData.data = data.actionData;
125
126 compare(Lights.state, data.expected, "Light does not match expected value");
127 }
128 }
129}
0130
=== modified file 'tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml'
--- tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml 2014-10-09 17:06:00 +0000
+++ tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml 2014-12-17 11:19:14 +0000
@@ -17,6 +17,7 @@
17import QtQuick 2.017import QtQuick 2.0
18import QtTest 1.018import QtTest 1.0
19import Unity.Test 0.1 as UT19import Unity.Test 0.1 as UT
20import Ubuntu.Settings.Menus 0.1 as Menus
20import QMenuModel 0.121import QMenuModel 0.1
21import Utils 0.1 as Utils22import Utils 0.1 as Utils
22import "../../../../qml/Panel/Indicators"23import "../../../../qml/Panel/Indicators"
@@ -448,9 +449,59 @@
448 }449 }
449450
450 function test_create_transferMenu(data) {451 function test_create_transferMenu(data) {
452 ActionData.data = {
453 "transfer-state.queued": {
454 'valid': true,
455 'state': {
456 'state': Menus.TransferState.Queued,
457 'percent': data.progress
458 }
459 },
460 "transfer-state.running": {
461 'valid': true,
462 'state': {
463 'state': Menus.TransferState.Running,
464 'seconds-left': 100,
465 'percent': data.progress
466 }
467 },
468 "transfer-state.paused": {
469 'valid': true,
470 'state': {
471 'state': Menus.TransferState.Paused,
472 'seconds-left': 100,
473 'percent': data.progress
474 }
475 },
476 "transfer-state.cancelled": {
477 'valid': true,
478 'state': {
479 'state': Menus.TransferState.Canceled,
480 'percent': data.progress
481 }
482 },
483 "transfer-state.finished": {
484 'valid': true,
485 'state': {
486 'state': Menus.TransferState.Finished,
487 'seconds-left': 0,
488 'percent': data.progress
489 }
490 },
491 "transfer-state.error": {
492 'valid': true,
493 'state': {
494 'state': Menus.TransferState.Error,
495 'seconds-left': 100,
496 'percent': data.progress
497 }
498 }
499 };
500
451 menuData.type = "com.canonical.indicator.transfer";501 menuData.type = "com.canonical.indicator.transfer";
452 menuData.label = data.label;502 menuData.label = data.label;
453 menuData.sensitive = data.enabled;503 menuData.sensitive = data.enabled;
504 menuData.isToggled = data.active;
454 menuData.icon = data.icon;505 menuData.icon = data.icon;
455 menuData.ext = {506 menuData.ext = {
456 'xCanonicalUid': data.tag507 'xCanonicalUid': data.tag
@@ -464,7 +515,7 @@
464 compare(loader.item.text, data.label, "Label does not match data");515 compare(loader.item.text, data.label, "Label does not match data");
465 compare(loader.item.iconSource, data.icon, "Icon does not match data");516 compare(loader.item.iconSource, data.icon, "Icon does not match data");
466 compare(loader.item.enabled, data.enabled, "Enabled does not match data");517 compare(loader.item.enabled, data.enabled, "Enabled does not match data");
467 compare(loader.item.progress, data.progress, "Icon does not match data");518 compare(loader.item.progress, data.progress, "Progress does not match data");
468 compare(loader.item.active, data.active, "Active does not match data");519 compare(loader.item.active, data.active, "Active does not match data");
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");
470 }521 }
471522
=== modified file 'tests/qmltests/Wizard/tst_Wizard.qml'
--- tests/qmltests/Wizard/tst_Wizard.qml 2014-12-02 17:43:25 +0000
+++ tests/qmltests/Wizard/tst_Wizard.qml 2014-12-17 11:19:14 +0000
@@ -18,6 +18,7 @@
18import QtTest 1.018import QtTest 1.0
19import AccountsService 0.119import AccountsService 0.1
20import MeeGo.QOfono 0.220import MeeGo.QOfono 0.2
21import QMenuModel 0.1
21import Ubuntu.Components 1.122import Ubuntu.Components 1.1
22import Ubuntu.SystemSettings.SecurityPrivacy 1.023import Ubuntu.SystemSettings.SecurityPrivacy 1.0
23import Unity.Test 0.1 as UT24import Unity.Test 0.1 as UT
@@ -58,6 +59,16 @@
58 signalName: "setSecurityCalled"59 signalName: "setSecurityCalled"
59 }60 }
6061
62 SignalSpy {
63 id: activateLocationSpy
64 signalName: "activated"
65 }
66
67 SignalSpy {
68 id: activateGPSSpy
69 signalName: "activated"
70 }
71
61 function setup() {72 function setup() {
62 AccountsService.hereEnabled = false;73 AccountsService.hereEnabled = false;
63 AccountsService.hereLicensePath = Qt.resolvedUrl("licenses");74 AccountsService.hereLicensePath = Qt.resolvedUrl("licenses");
@@ -68,6 +79,19 @@
6879
69 updateSessionLanguageSpy.clear();80 updateSessionLanguageSpy.clear();
70 setSecuritySpy.clear();81 setSecuritySpy.clear();
82 activateLocationSpy.clear();
83 activateGPSSpy.clear();
84
85 ActionData.data = {
86 "location-detection-enabled": {
87 'valid': true,
88 'state': false
89 },
90 "gps-detection-enabled": {
91 'valid': true,
92 'state': false
93 }
94 };
71 }95 }
7296
73 Component.onCompleted: {97 Component.onCompleted: {
@@ -360,8 +384,8 @@
360 var nopeCheck = findChild(page, "nopeCheck");384 var nopeCheck = findChild(page, "nopeCheck");
361385
362 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");386 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
363 tryCompare(locationActionGroup.location, "state", false);387 activateLocationSpy.target = locationActionGroup.location;
364 tryCompare(locationActionGroup.gps, "state", false);388 activateGPSSpy.target = locationActionGroup.gps;
365389
366 tap(gpsCheck);390 tap(gpsCheck);
367 tryCompare(gpsCheck, "checked", true);391 tryCompare(gpsCheck, "checked", true);
@@ -370,8 +394,8 @@
370394
371 tap(findChild(page, "forwardButton"));395 tap(findChild(page, "forwardButton"));
372 tryCompare(AccountsService, "hereEnabled", false);396 tryCompare(AccountsService, "hereEnabled", false);
373 tryCompare(locationActionGroup.location, "state", true);397 tryCompare(activateLocationSpy, "count", 1)
374 tryCompare(locationActionGroup.gps, "state", true);398 tryCompare(activateGPSSpy, "count", 1)
375 }399 }
376400
377 function test_locationNope() {401 function test_locationNope() {
@@ -381,8 +405,8 @@
381 var nopeCheck = findChild(page, "nopeCheck");405 var nopeCheck = findChild(page, "nopeCheck");
382406
383 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");407 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
384 tryCompare(locationActionGroup.location, "state", false);408 activateLocationSpy.target = locationActionGroup.location;
385 tryCompare(locationActionGroup.gps, "state", false);409 activateGPSSpy.target = locationActionGroup.gps;
386410
387 tap(nopeCheck);411 tap(nopeCheck);
388 tryCompare(gpsCheck, "checked", false);412 tryCompare(gpsCheck, "checked", false);
@@ -391,8 +415,8 @@
391415
392 tap(findChild(page, "forwardButton"));416 tap(findChild(page, "forwardButton"));
393 tryCompare(AccountsService, "hereEnabled", false);417 tryCompare(AccountsService, "hereEnabled", false);
394 tryCompare(locationActionGroup.location, "state", false);418 tryCompare(activateLocationSpy, "count", 0)
395 tryCompare(locationActionGroup.gps, "state", false);419 tryCompare(activateGPSSpy, "count", 0)
396 }420 }
397421
398 function test_locationHere() {422 function test_locationHere() {
@@ -402,8 +426,8 @@
402 var nopeCheck = findChild(page, "nopeCheck");426 var nopeCheck = findChild(page, "nopeCheck");
403427
404 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");428 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
405 tryCompare(locationActionGroup.location, "state", false);429 activateLocationSpy.target = locationActionGroup.location;
406 tryCompare(locationActionGroup.gps, "state", false);430 activateGPSSpy.target = locationActionGroup.gps;
407431
408 // no tap because HERE is the default432 // no tap because HERE is the default
409 tryCompare(gpsCheck, "checked", false);433 tryCompare(gpsCheck, "checked", false);
@@ -412,8 +436,8 @@
412436
413 tap(findChild(page, "forwardButton"));437 tap(findChild(page, "forwardButton"));
414 tryCompare(AccountsService, "hereEnabled", true);438 tryCompare(AccountsService, "hereEnabled", true);
415 tryCompare(locationActionGroup.location, "state", true);439 tryCompare(activateLocationSpy, "count", 1)
416 tryCompare(locationActionGroup.gps, "state", true);440 tryCompare(activateGPSSpy, "count", 1)
417 }441 }
418442
419 function test_locationHereTerms() {443 function test_locationHereTerms() {

Subscribers

People subscribed via source and target branches