on xenial help sign in
Add 'light' property to IndicatorsModel for tests
eba99afDalton Durst
plugins/Unity/Indicators/indicatorsmodel.cpp+13
@@ -103,6 +103,19 @@ void IndicatorsModel::setProfile(const QString &profile)
103 m_manager->setProfile(profile);
103 m_manager->setProfile(profile);
104}
104}
105
105
106+bool IndicatorsModel::light() const
107+{
108+ return m_light;
109+}
110+
111+void IndicatorsModel::setLight(const bool &light)
112+{
113+ if (m_light != light) {
114+ m_light = light;
115+ Q_EMIT lightChanged();
116+ }
117+}
118+
106/*!
119/*!
107 \qmlmethod IndicatorsModel::unload()
120 \qmlmethod IndicatorsModel::unload()
108
121
plugins/Unity/Indicators/indicatorsmodel.h+9
@@ -35,6 +35,9 @@ class UNITYINDICATORS_EXPORT IndicatorsModel : public QAbstractListModel
35 Q_PROPERTY(int count READ count NOTIFY countChanged)
35 Q_PROPERTY(int count READ count NOTIFY countChanged)
36 Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged)
36 Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged)
37
37
38+ // Used for tests
39+ Q_PROPERTY(bool light READ light WRITE setLight NOTIFY lightChanged)
40+
38public:
41public:
39
42
40 IndicatorsModel(QObject *parent=nullptr);
43 IndicatorsModel(QObject *parent=nullptr);
@@ -48,6 +51,9 @@ public:
48 QString profile() const;
51 QString profile() const;
49 void setProfile(const QString& profile);
52 void setProfile(const QString& profile);
50
53
54+ bool light() const;
55+ void setLight(const bool &light);
56+
51 /* QAbstractItemModel */
57 /* QAbstractItemModel */
52 QHash<int, QByteArray> roleNames() const override;
58 QHash<int, QByteArray> roleNames() const override;
53 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
59 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -60,6 +66,7 @@ Q_SIGNALS:
60 void countChanged();
66 void countChanged();
61 void profileChanged();
67 void profileChanged();
62 void indicatorDataChanged(const QVariant& data);
68 void indicatorDataChanged(const QVariant& data);
69+ void lightChanged();
63
70
64private Q_SLOTS:
71private Q_SLOTS:
65 void onIdentifierChanged();
72 void onIdentifierChanged();
@@ -74,6 +81,8 @@ private:
74
81
75 void notifyDataChanged(QObject *sender, int role);
82 void notifyDataChanged(QObject *sender, int role);
76 int count() const;
83 int count() const;
84+
85+ bool m_light;
77};
86};
78
87
79#endif // INDICATORSMODEL_H
88#endif // INDICATORSMODEL_H
qml/OrientedShell.qml+2
@@ -40,6 +40,7 @@ Item {
40 }
40 }
41
41
42 property alias orientations: d.orientations
42 property alias orientations: d.orientations
43+ property bool lightIndicators: false
43
44
44 Item {
45 Item {
45 id: d
46 id: d
@@ -276,6 +277,7 @@ Item {
276 hasKeyboard: keyboardsModel.count > 0
277 hasKeyboard: keyboardsModel.count > 0
277 hasTouchscreen: touchScreensModel.count > 0
278 hasTouchscreen: touchScreensModel.count > 0
278 supportsMultiColorLed: deviceConfiguration.supportsMultiColorLed
279 supportsMultiColorLed: deviceConfiguration.supportsMultiColorLed
280+ lightIndicators: root.lightIndicators
279
281
280 // Since we dont have proper multiscreen support yet
282 // Since we dont have proper multiscreen support yet
281 // hardcode screen count to only show osk on this screen
283 // hardcode screen count to only show osk on this screen
qml/Shell.qml+4
@@ -71,6 +71,9 @@ StyledItem {
71 property bool hasTouchscreen: false
71 property bool hasTouchscreen: false
72 property bool supportsMultiColorLed: true
72 property bool supportsMultiColorLed: true
73
73
74+ // Used by tests
75+ property bool lightIndicators: false
76+
74 // to be read from outside
77 // to be read from outside
75 readonly property int mainAppWindowOrientationAngle: stage.mainAppWindowOrientationAngle
78 readonly property int mainAppWindowOrientationAngle: stage.mainAppWindowOrientationAngle
76
79
@@ -539,6 +542,7 @@ StyledItem {
539 // involve taking the url-dispatcher dbus name and using
542 // involve taking the url-dispatcher dbus name and using
540 // SessionBroadcast to tell the session.
543 // SessionBroadcast to tell the session.
541 profile: shell.mode === "greeter" ? "desktop_greeter" : "phone"
544 profile: shell.mode === "greeter" ? "desktop_greeter" : "phone"
545+ light: root.lightIndicators
542 Component.onCompleted: load();
546 Component.onCompleted: load();
543 }
547 }
544 }
548 }
tests/mocks/Unity/Indicators/IndicatorsModel.qml+30−12
@@ -23,6 +23,10 @@ import "fakeindicatorsmodeldata.js" as FakeIndicators
23Indicators.FakeIndicatorsModel {
23Indicators.FakeIndicatorsModel {
24 id: root
24 id: root
25
25
26+ property var light: false
27+
28+ onLightChanged: load()
29+
26 property var originalModelData: [
30 property var originalModelData: [
27 {
31 {
28 "identifier": "indicator-keyboard",
32 "identifier": "indicator-keyboard",
@@ -126,51 +130,65 @@ Indicators.FakeIndicatorsModel {
126 getUnityMenuModelData("indicator-keyboard",
130 getUnityMenuModelData("indicator-keyboard",
127 "English (F)",
131 "English (F)",
128 "",
132 "",
129− [ "image://theme/input-keyboard-symbolic" ]));
133+ [ "image://theme/input-keyboard-symbolic" ],
134+ root.light));
130 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake1",
135 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake1",
131 getUnityMenuModelData("fake-indicator-bluetooth",
136 getUnityMenuModelData("fake-indicator-bluetooth",
132 "Bluetooth (F)",
137 "Bluetooth (F)",
133 "",
138 "",
134− [ "image://theme/bluetooth-active" ]));
139+ [ "image://theme/bluetooth-active" ],
140+ root.light));
135 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake2",
141 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake2",
136 getUnityMenuModelData("fake-indicator-network",
142 getUnityMenuModelData("fake-indicator-network",
137 "Network (F)",
143 "Network (F)",
138 "",
144 "",
139− [ "image://theme/simcard-error", "image://theme/wifi-high" ]));
145+ [ "image://theme/simcard-error", "image://theme/wifi-high" ],
146+ root.light));
140 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake3",
147 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake3",
141 getUnityMenuModelData("fake-indicator-messages",
148 getUnityMenuModelData("fake-indicator-messages",
142 "Messages (F)",
149 "Messages (F)",
143 "",
150 "",
144− [ "image://theme/messages-new" ]));
151+ [ "image://theme/messages-new" ],
152+ root.light));
145 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake4",
153 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake4",
146 getUnityMenuModelData("fake-indicator-files",
154 getUnityMenuModelData("fake-indicator-files",
147 "Files (F)",
155 "Files (F)",
148 "",
156 "",
149− [ "image://theme/transfer-progress" ]));
157+ [ "image://theme/transfer-progress" ],
158+ root.light));
150 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake5",
159 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake5",
151 getUnityMenuModelData("fake-indicator-sound",
160 getUnityMenuModelData("fake-indicator-sound",
152 "Sound (F)",
161 "Sound (F)",
153 "",
162 "",
154− [ "image://theme/audio-volume-high" ]));
163+ [ "image://theme/audio-volume-high" ],
164+ root.light));
155 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake6",
165 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake6",
156 getUnityMenuModelData("fake-indicator-power",
166 getUnityMenuModelData("fake-indicator-power",
157 "Battery (F)",
167 "Battery (F)",
158 "",
168 "",
159− [ "image://theme/battery-020" ]));
169+ [ "image://theme/battery-020" ],
170+ root.light));
160 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake7",
171 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake7",
161 getUnityMenuModelData("fake-indicator-datetime",
172 getUnityMenuModelData("fake-indicator-datetime",
162 "Upcoming Events (F)",
173 "Upcoming Events (F)",
163 "12:04",
174 "12:04",
164− []));
175+ [],
176+ root.light));
165 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake8",
177 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake8",
166 getUnityMenuModelData("fake-indicator-session",
178 getUnityMenuModelData("fake-indicator-session",
167 "System (F)",
179 "System (F)",
168 "",
180 "",
169− ["image://theme/system-devices-panel"]));
181+ ["image://theme/system-devices-panel"],
182+ root.light));
170 }
183 }
171
184
172− function getUnityMenuModelData(identifier, title, label, icons) {
185+ function getUnityMenuModelData(identifier, title, label, icons, light) {
186+ var menudata = undefined;
187+ var maxItems = 1;
188+ if (!light) {
173− var menudata = FakeIndicators.fakeMenuData[identifier];
189+ var menudata = FakeIndicators.fakeMenuData[identifier];
190+ maxItems = 8;
191+ }
174
192
175 if (menudata !== undefined) {
193 if (menudata !== undefined) {
176 var rootState = menudata[0]["rowData"].actionState;
194 var rootState = menudata[0]["rowData"].actionState;
@@ -203,7 +221,7 @@ Indicators.FakeIndicatorsModel {
203 }];
221 }];
204
222
205 var submenus = [];
223 var submenus = [];
206− for (var i = 0; i < 8; i++) {
224+ for (var i = 0; i < maxItems; i++) {
207 var submenu = {
225 var submenu = {
208 "rowData": { // 1.1
226 "rowData": { // 1.1
209 "label": identifier,
227 "label": identifier,
tests/qmltests/tst_OrientedShell.qml+1
@@ -165,6 +165,7 @@ Rectangle {
165 physicalOrientation: root.physicalOrientation0
165 physicalOrientation: root.physicalOrientation0
166 orientationLocked: orientationLockedCheckBox.checked
166 orientationLocked: orientationLockedCheckBox.checked
167 orientationLock: mockOrientationLock
167 orientationLock: mockOrientationLock
168+ lightIndicators: true
168 }
169 }
169 }
170 }
170
171