Merge lp:~jonas-drange/ubuntu-system-settings/displays-mir into lp:ubuntu-system-settings
- displays-mir
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~jonas-drange/ubuntu-system-settings/displays-mir |
Merge into: | lp:ubuntu-system-settings |
Prerequisite: | lp:~jonas-drange/ubuntu-system-settings/displays-stub |
Diff against target: |
1995 lines (+1080/-214) (has conflicts) 28 files modified
debian/control (+1/-0) plugins/brightness/CMakeLists.txt (+25/-5) plugins/brightness/PageComponent.qml (+43/-26) plugins/brightness/brightness.cpp (+91/-12) plugins/brightness/brightness.h (+16/-3) plugins/brightness/displays/display.cpp (+155/-39) plugins/brightness/displays/display.h (+76/-52) plugins/brightness/displays/displaymodel.cpp (+64/-14) plugins/brightness/displays/displaymodel.h (+16/-5) plugins/brightness/displays/helpers.cpp (+131/-0) plugins/brightness/displays/helpers.h (+25/-0) plugins/brightness/displays/mirclient.h (+25/-0) plugins/brightness/displays/mirclient_impl.cpp (+86/-0) plugins/brightness/displays/mirclient_impl.h (+26/-0) plugins/brightness/plugin.cpp (+2/-2) plugins/brightness/plugin/brightness-plugin.cpp (+2/-18) tests/mocks/Ubuntu/SystemSettings/Brightness/CMakeLists.txt (+4/-5) tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.cpp (+11/-1) tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.h (+10/-4) tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplay.h (+32/-13) tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplayModel.h (+3/-3) tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.cpp (+2/-1) tests/mocks/plugins/brightness/fakemirclient.h (+36/-0) tests/plugins/CMakeLists.txt (+1/-0) tests/plugins/brightness/CMakeLists.txt (+25/-0) tests/plugins/brightness/tst_BrightnessPageComponent.qml (+99/-11) tests/plugins/brightness/tst_brightness.cpp (+41/-0) tests/plugins/brightness/tst_displayplugin_displaymodel.cpp (+32/-0) Text conflict in debian/changelog |
To merge this branch: | bzr merge lp:~jonas-drange/ubuntu-system-settings/displays-mir |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
system-apps-ci-bot | continuous-integration | Needs Fixing | |
Ubuntu Touch System Settings | Pending | ||
Review via email: mp+309943@code.launchpad.net |
Commit message
implement display config for mir displays
Description of the change
- 1742. By Jonas G. Drange
-
make config work well for rotation and resolution (mode9
- 1743. By Jonas G. Drange
-
minor tweaks
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:1743
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 1744. By Jonas G. Drange
-
create namespace for displayplugin
- 1745. By Jonas G. Drange
-
consume new namespace DisplayPlugin
- 1746. By Jonas G. Drange
-
rename mirdisplays to less ambiguous mirclient
- 1747. By Jonas G. Drange
-
add framework for testing brightness and displayplugin classes
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1747
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unmerged revisions
- 1747. By Jonas G. Drange
-
add framework for testing brightness and displayplugin classes
- 1746. By Jonas G. Drange
-
rename mirdisplays to less ambiguous mirclient
- 1745. By Jonas G. Drange
-
consume new namespace DisplayPlugin
- 1744. By Jonas G. Drange
-
create namespace for displayplugin
- 1743. By Jonas G. Drange
-
minor tweaks
- 1742. By Jonas G. Drange
-
make config work well for rotation and resolution (mode9
- 1741. By Jonas G. Drange
-
working changed filter
- 1740. By Jonas G. Drange
-
add mdoes
- 1739. By Jonas G. Drange
-
add mir specific read of config, add helpers
- 1738. By Jonas G. Drange
-
merge prereq
Preview Diff
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2016-11-04 18:56:02 +0000 | |||
3 | +++ debian/control 2016-11-04 18:56:02 +0000 | |||
4 | @@ -17,6 +17,7 @@ | |||
5 | 17 | libglib2.0-dev (>= 2.37.92), | 17 | libglib2.0-dev (>= 2.37.92), |
6 | 18 | libevdev-dev, | 18 | libevdev-dev, |
7 | 19 | libicu-dev, | 19 | libicu-dev, |
8 | 20 | libmirclient-dev (>= 0.24), | ||
9 | 20 | libnm-glib-dev, | 21 | libnm-glib-dev, |
10 | 21 | libpolkit-agent-1-dev, | 22 | libpolkit-agent-1-dev, |
11 | 22 | libqmenumodel-dev, | 23 | libqmenumodel-dev, |
12 | 23 | 24 | ||
13 | === modified file 'plugins/brightness/CMakeLists.txt' | |||
14 | --- plugins/brightness/CMakeLists.txt 2016-11-04 18:56:02 +0000 | |||
15 | +++ plugins/brightness/CMakeLists.txt 2016-11-04 18:56:02 +0000 | |||
16 | @@ -1,6 +1,29 @@ | |||
17 | 1 | include_directories(${ANDR_PROP_INCLUDE_DIRS}) | 1 | include_directories(${ANDR_PROP_INCLUDE_DIRS}) |
18 | 2 | add_subdirectory(plugin) | 2 | add_subdirectory(plugin) |
19 | 3 | 3 | ||
20 | 4 | pkg_search_module(MIR REQUIRED mirclient) | ||
21 | 5 | find_package(Qt5Gui) | ||
22 | 6 | include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${MIR_INCLUDE_DIRS}) | ||
23 | 7 | |||
24 | 8 | add_library(uss-displays SHARED | ||
25 | 9 | displays/helpers.h | ||
26 | 10 | |||
27 | 11 | displays/display.h | ||
28 | 12 | displays/displaymodel.h | ||
29 | 13 | |||
30 | 14 | displays/mirclient.h | ||
31 | 15 | displays/mirclient_impl.h | ||
32 | 16 | |||
33 | 17 | displays/helpers.cpp | ||
34 | 18 | displays/display.cpp | ||
35 | 19 | displays/displaymodel.cpp | ||
36 | 20 | displays/mirclient_impl.cpp | ||
37 | 21 | ../../src/i18n.cpp | ||
38 | 22 | ) | ||
39 | 23 | qt5_use_modules(uss-displays Quick) | ||
40 | 24 | set_target_properties(uss-displays PROPERTIES VERSION 0.0 SOVERSION 0.0) | ||
41 | 25 | target_link_libraries(uss-displays ${Qt5Gui_PRIVATE_LDFLAGS} ${MIR_LDFLAGS}) | ||
42 | 26 | |||
43 | 4 | set(QML_SOURCES | 27 | set(QML_SOURCES |
44 | 5 | PageComponent.qml | 28 | PageComponent.qml |
45 | 6 | WifiDisplays.qml | 29 | WifiDisplays.qml |
46 | @@ -16,8 +39,6 @@ | |||
47 | 16 | aethercast/displays.h | 39 | aethercast/displays.h |
48 | 17 | aethercast/freedesktop_properties.h | 40 | aethercast/freedesktop_properties.h |
49 | 18 | aethercast/freedesktop_objectmanager.h | 41 | aethercast/freedesktop_objectmanager.h |
50 | 19 | displays/display.h | ||
51 | 20 | displays/displaymodel.h | ||
52 | 21 | plugin.h | 42 | plugin.h |
53 | 22 | brightness.h | 43 | brightness.h |
54 | 23 | aethercast/aethercast_device.cpp | 44 | aethercast/aethercast_device.cpp |
55 | @@ -27,15 +48,14 @@ | |||
56 | 27 | aethercast/displays.cpp | 48 | aethercast/displays.cpp |
57 | 28 | aethercast/freedesktop_properties.cpp | 49 | aethercast/freedesktop_properties.cpp |
58 | 29 | aethercast/freedesktop_objectmanager.cpp | 50 | aethercast/freedesktop_objectmanager.cpp |
59 | 30 | displays/display.cpp | ||
60 | 31 | displays/displaymodel.cpp | ||
61 | 32 | plugin.cpp | 51 | plugin.cpp |
62 | 33 | brightness.cpp | 52 | brightness.cpp |
63 | 34 | ${QML_SOURCES}) | 53 | ${QML_SOURCES}) |
64 | 35 | qt5_use_modules(UbuntuBrightnessPanel Quick Qml DBus) | 54 | qt5_use_modules(UbuntuBrightnessPanel Quick Qml DBus) |
66 | 36 | target_link_libraries(UbuntuBrightnessPanel SystemSettings ${ANDR_PROP_LDFLAGS}) | 55 | target_link_libraries(UbuntuBrightnessPanel SystemSettings ${ANDR_PROP_LDFLAGS} uss-displays) |
67 | 37 | 56 | ||
68 | 38 | set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Brightness) | 57 | set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Brightness) |
69 | 58 | install(TARGETS uss-displays DESTINATION ${PLUGIN_MODULE_DIR}) | ||
70 | 39 | install(TARGETS UbuntuBrightnessPanel DESTINATION ${PLUG_DIR}) | 59 | install(TARGETS UbuntuBrightnessPanel DESTINATION ${PLUG_DIR}) |
71 | 40 | install(FILES qmldir.in DESTINATION ${PLUG_DIR} RENAME qmldir) | 60 | install(FILES qmldir.in DESTINATION ${PLUG_DIR} RENAME qmldir) |
72 | 41 | install(FILES brightness.settings DESTINATION ${PLUGIN_MANIFEST_DIR}) | 61 | install(FILES brightness.settings DESTINATION ${PLUGIN_MANIFEST_DIR}) |
73 | 42 | 62 | ||
74 | === modified file 'plugins/brightness/PageComponent.qml' | |||
75 | --- plugins/brightness/PageComponent.qml 2016-11-04 18:56:02 +0000 | |||
76 | +++ plugins/brightness/PageComponent.qml 2016-11-04 18:56:02 +0000 | |||
77 | @@ -36,14 +36,6 @@ | |||
78 | 36 | title: brightnessPanel.widiSupported ? i18n.tr("Brightness & Display") : i18n.tr("Brightness") | 36 | title: brightnessPanel.widiSupported ? i18n.tr("Brightness & Display") : i18n.tr("Brightness") |
79 | 37 | flickable: scrollWidget | 37 | flickable: scrollWidget |
80 | 38 | 38 | ||
81 | 39 | function formatMode(mode) { | ||
82 | 40 | mode = mode.split("x"); | ||
83 | 41 | /* TRANSLATORS: %1 refer to the amount of horizontal pixels in a | ||
84 | 42 | display resolution, and %2 to the vertical pixels. E.g. 1200x720. | ||
85 | 43 | %3 is the refresh rate in hz. */ | ||
86 | 44 | return i18n.tr("%1×%2 @ %3hz").arg(mode[0]).arg(mode[1]).arg(mode[2]); | ||
87 | 45 | } | ||
88 | 46 | |||
89 | 47 | GSettings { | 39 | GSettings { |
90 | 48 | id: gsettings | 40 | id: gsettings |
91 | 49 | schema.id: "com.ubuntu.touch.system" | 41 | schema.id: "com.ubuntu.touch.system" |
92 | @@ -53,7 +45,7 @@ | |||
93 | 53 | id: aethercastDisplays | 45 | id: aethercastDisplays |
94 | 54 | objectName: "aethercastDisplays" | 46 | objectName: "aethercastDisplays" |
95 | 55 | onEnabledChanged: { | 47 | onEnabledChanged: { |
97 | 56 | /* This is a hack to ensure the aethercast enabled switch stays | 48 | /* This is a hack to ensure the aethercast enabled switch stays |
98 | 57 | * in sync with the enabled property | 49 | * in sync with the enabled property |
99 | 58 | */ | 50 | */ |
100 | 59 | enabledCheck.serverChecked = enabled; | 51 | enabledCheck.serverChecked = enabled; |
101 | @@ -181,7 +173,7 @@ | |||
102 | 181 | 173 | ||
103 | 182 | Repeater { | 174 | Repeater { |
104 | 183 | objectName: "displayConfigurationRepeater" | 175 | objectName: "displayConfigurationRepeater" |
106 | 184 | model: brightnessPanel.allDisplays | 176 | model: brightnessPanel.connectedDisplays |
107 | 185 | 177 | ||
108 | 186 | Column { | 178 | Column { |
109 | 187 | objectName: "displayConfiguration_" + displayName | 179 | objectName: "displayConfiguration_" + displayName |
110 | @@ -190,15 +182,29 @@ | |||
111 | 190 | right: parent.right | 182 | right: parent.right |
112 | 191 | } | 183 | } |
113 | 192 | 184 | ||
114 | 185 | Item { | ||
115 | 186 | width: units.gu(1) | ||
116 | 187 | height: units.gu(1) | ||
117 | 188 | } | ||
118 | 189 | |||
119 | 193 | Label { | 190 | Label { |
120 | 194 | visible: brightnessPanel.allDisplays.count > 1 | ||
121 | 195 | anchors { | ||
122 | 196 | left: parent.left | ||
123 | 197 | right: parent.right | ||
124 | 198 | margins: units.gu(2) | ||
125 | 199 | } | ||
126 | 200 | |||
127 | 201 | text: displayName | 191 | text: displayName |
128 | 192 | |||
129 | 193 | anchors { | ||
130 | 194 | left: parent.left | ||
131 | 195 | right: parent.right | ||
132 | 196 | margins: units.gu(2) | ||
133 | 197 | } | ||
134 | 198 | |||
135 | 199 | Switch { | ||
136 | 200 | objectName: "enabledSwitch" | ||
137 | 201 | anchors { | ||
138 | 202 | right: parent.right | ||
139 | 203 | verticalCenter: parent.verticalCenter | ||
140 | 204 | } | ||
141 | 205 | checked: model.enabled | ||
142 | 206 | onCheckedChanged: model.enabled = checked | ||
143 | 207 | } | ||
144 | 202 | } | 208 | } |
145 | 203 | 209 | ||
146 | 204 | SettingsItemTitle { | 210 | SettingsItemTitle { |
147 | @@ -216,6 +222,8 @@ | |||
148 | 216 | } | 222 | } |
149 | 217 | containerHeight: itemHeight * 4 | 223 | containerHeight: itemHeight * 4 |
150 | 218 | model: [ | 224 | model: [ |
151 | 225 | /* TRANSLATORS: None means no rotation, or | ||
152 | 226 | 0 degrees. */ | ||
153 | 219 | i18n.tr("None"), | 227 | i18n.tr("None"), |
154 | 220 | i18n.tr("90° clockwise"), | 228 | i18n.tr("90° clockwise"), |
155 | 221 | i18n.tr("180°"), | 229 | i18n.tr("180°"), |
156 | @@ -223,15 +231,19 @@ | |||
157 | 223 | ] | 231 | ] |
158 | 224 | onDelegateClicked: { | 232 | onDelegateClicked: { |
159 | 225 | expanded = !currentlyExpanded; | 233 | expanded = !currentlyExpanded; |
160 | 234 | orientation = index; | ||
161 | 226 | } | 235 | } |
162 | 236 | selectedIndex: orientation | ||
163 | 227 | } | 237 | } |
164 | 228 | 238 | ||
165 | 229 | SettingsItemTitle { | 239 | SettingsItemTitle { |
167 | 230 | text: availableModes.length > 1 ? | 240 | objectName: "resolutionLabel" |
168 | 241 | text: modes.length > 1 ? | ||
169 | 231 | i18n.tr("Resolution:") : | 242 | i18n.tr("Resolution:") : |
173 | 232 | /* TRANSLATORS: %1 is a display mode, e.g. | 243 | /* TRANSLATORS: %1 is a display resolution, e.g. |
174 | 233 | 1200x720x24. */ | 244 | 1200x720x24. Unknown refers to an unknown |
175 | 234 | i18n.tr("Resolution: %1").arg(formatMode(mode)) | 245 | resolution (in case of an error). */ |
176 | 246 | i18n.tr("Resolution: %1").arg(modes[mode] || i18n.tr("Unknown")) | ||
177 | 235 | } | 247 | } |
178 | 236 | 248 | ||
179 | 237 | OptionSelector { | 249 | OptionSelector { |
180 | @@ -243,13 +255,17 @@ | |||
181 | 243 | right: parent.right | 255 | right: parent.right |
182 | 244 | margins: units.gu(2) | 256 | margins: units.gu(2) |
183 | 245 | } | 257 | } |
188 | 246 | visible: availableModes.length > 1 | 258 | visible: modes.length > 1 |
189 | 247 | containerHeight: itemHeight * availableModes.length | 259 | containerHeight: itemHeight * modes.length |
190 | 248 | model: availableModes | 260 | model: modes |
191 | 249 | onDelegateClicked: expanded = !currentlyExpanded | 261 | onDelegateClicked: { |
192 | 262 | expanded = !currentlyExpanded; | ||
193 | 263 | mode = index; | ||
194 | 264 | } | ||
195 | 250 | delegate: OptionSelectorDelegate { | 265 | delegate: OptionSelectorDelegate { |
197 | 251 | text: formatMode(modelData) | 266 | text: modelData |
198 | 252 | } | 267 | } |
199 | 268 | selectedIndex: mode | ||
200 | 253 | } | 269 | } |
201 | 254 | 270 | ||
202 | 255 | SettingsItemTitle { | 271 | SettingsItemTitle { |
203 | @@ -282,6 +298,7 @@ | |||
204 | 282 | 298 | ||
205 | 283 | visible: brightnessPanel.allDisplays.count > 0 | 299 | visible: brightnessPanel.allDisplays.count > 0 |
206 | 284 | height: units.gu(6) | 300 | height: units.gu(6) |
207 | 301 | |||
208 | 285 | Button { | 302 | Button { |
209 | 286 | id: applyButton | 303 | id: applyButton |
210 | 287 | objectName: "applyButton" | 304 | objectName: "applyButton" |
211 | 288 | 305 | ||
212 | === modified file 'plugins/brightness/brightness.cpp' | |||
213 | --- plugins/brightness/brightness.cpp 2016-11-04 18:56:02 +0000 | |||
214 | +++ plugins/brightness/brightness.cpp 2016-11-04 18:56:02 +0000 | |||
215 | @@ -19,6 +19,10 @@ | |||
216 | 19 | */ | 19 | */ |
217 | 20 | 20 | ||
218 | 21 | #include "brightness.h" | 21 | #include "brightness.h" |
219 | 22 | #include "displays/display.h" | ||
220 | 23 | #include "displays/helpers.h" | ||
221 | 24 | #include "displays/mirclient_impl.h" | ||
222 | 25 | |||
223 | 22 | #include <hybris/properties/properties.h> | 26 | #include <hybris/properties/properties.h> |
224 | 23 | 27 | ||
225 | 24 | #include <QDBusArgument> | 28 | #include <QDBusArgument> |
226 | @@ -26,6 +30,8 @@ | |||
227 | 26 | #include <QDBusMetaType> | 30 | #include <QDBusMetaType> |
228 | 27 | #include <QDebug> | 31 | #include <QDebug> |
229 | 28 | #include <QQmlEngine> | 32 | #include <QQmlEngine> |
230 | 33 | #include <QSharedPointer> | ||
231 | 34 | #include <QScopedPointer> | ||
232 | 29 | 35 | ||
233 | 30 | // Returned data from getBrightnessParams | 36 | // Returned data from getBrightnessParams |
234 | 31 | struct BrightnessParams { | 37 | struct BrightnessParams { |
235 | @@ -55,16 +61,32 @@ | |||
236 | 55 | return argument; | 61 | return argument; |
237 | 56 | } | 62 | } |
238 | 57 | 63 | ||
248 | 58 | Brightness::Brightness(QObject *parent) : | 64 | Brightness::Brightness(QDBusConnection dbus, |
249 | 59 | QObject(parent), | 65 | DisplayPlugin::MirClient *mirClient, |
250 | 60 | m_systemBusConnection (QDBusConnection::systemBus()), | 66 | QObject *parent) |
251 | 61 | m_powerdIface ("com.canonical.powerd", | 67 | : QObject(parent) |
252 | 62 | "/com/canonical/powerd", | 68 | , m_systemBusConnection(dbus) |
253 | 63 | "com.canonical.powerd", | 69 | , m_mirClient(mirClient) |
254 | 64 | m_systemBusConnection), | 70 | , m_powerdIface("com.canonical.powerd", |
255 | 65 | m_powerdRunning(false), | 71 | "/com/canonical/powerd", |
256 | 66 | m_autoBrightnessAvailable(false) | 72 | "com.canonical.powerd", |
257 | 73 | m_systemBusConnection) | ||
258 | 74 | , m_powerdRunning(false) | ||
259 | 75 | , m_autoBrightnessAvailable(false) | ||
260 | 76 | |||
261 | 67 | { | 77 | { |
262 | 78 | m_changedDisplays.filterOnUncommittedChanges(true); | ||
263 | 79 | m_changedDisplays.setSourceModel(&m_displays); | ||
264 | 80 | |||
265 | 81 | m_connectedDisplays.filterOnConnected(true); | ||
266 | 82 | m_connectedDisplays.setSourceModel(&m_displays); | ||
267 | 83 | |||
268 | 84 | if (m_mirClient->isConnected()) { | ||
269 | 85 | refreshMirDisplays(); | ||
270 | 86 | connect(m_mirClient, SIGNAL(configurationChanged()), | ||
271 | 87 | this, SLOT(refreshMirDisplays())); | ||
272 | 88 | } | ||
273 | 89 | |||
274 | 68 | qRegisterMetaType<BrightnessParams>(); | 90 | qRegisterMetaType<BrightnessParams>(); |
275 | 69 | m_powerdRunning = m_powerdIface.isValid(); | 91 | m_powerdRunning = m_powerdIface.isValid(); |
276 | 70 | 92 | ||
277 | @@ -82,8 +104,14 @@ | |||
278 | 82 | QDBusArgument result(reply.arguments()[0].value<QDBusArgument>()); | 104 | QDBusArgument result(reply.arguments()[0].value<QDBusArgument>()); |
279 | 83 | BrightnessParams params = qdbus_cast<BrightnessParams>(result); | 105 | BrightnessParams params = qdbus_cast<BrightnessParams>(result); |
280 | 84 | m_autoBrightnessAvailable = params.automatic; | 106 | m_autoBrightnessAvailable = params.automatic; |
283 | 85 | m_changedDisplays.filterOnUncommittedChanges(true); | 107 | |
284 | 86 | m_changedDisplays.setSourceModel(&m_displays); | 108 | m_mirClient->setParent(this); |
285 | 109 | } | ||
286 | 110 | |||
287 | 111 | Brightness::Brightness(QObject *parent) : | ||
288 | 112 | Brightness(QDBusConnection::systemBus(), | ||
289 | 113 | new DisplayPlugin::MirClientImpl(), parent) | ||
290 | 114 | { | ||
291 | 87 | } | 115 | } |
292 | 88 | 116 | ||
293 | 89 | bool Brightness::getAutoBrightnessAvailable() const | 117 | bool Brightness::getAutoBrightnessAvailable() const |
294 | @@ -95,7 +123,7 @@ | |||
295 | 95 | return m_powerdRunning; | 123 | return m_powerdRunning; |
296 | 96 | } | 124 | } |
297 | 97 | 125 | ||
299 | 98 | bool Brightness::getWidiSupported() const | 126 | bool Brightness::getWidiSupported() const |
300 | 99 | { | 127 | { |
301 | 100 | char widi[PROP_VALUE_MAX]; | 128 | char widi[PROP_VALUE_MAX]; |
302 | 101 | property_get("ubuntu.widi.supported", widi, "0"); | 129 | property_get("ubuntu.widi.supported", widi, "0"); |
303 | @@ -115,3 +143,54 @@ | |||
304 | 115 | QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership); | 143 | QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership); |
305 | 116 | return ret; | 144 | return ret; |
306 | 117 | } | 145 | } |
307 | 146 | |||
308 | 147 | |||
309 | 148 | QAbstractItemModel* Brightness::connectedDisplays() | ||
310 | 149 | { | ||
311 | 150 | auto ret = &m_connectedDisplays; | ||
312 | 151 | QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership); | ||
313 | 152 | return ret; | ||
314 | 153 | } | ||
315 | 154 | |||
316 | 155 | void Brightness::applyDisplayConfiguration() | ||
317 | 156 | { | ||
318 | 157 | auto conf = m_mirClient->getConfiguration(); | ||
319 | 158 | |||
320 | 159 | if (!conf) { | ||
321 | 160 | qWarning() << __PRETTY_FUNCTION__ << "config invalid"; | ||
322 | 161 | return; | ||
323 | 162 | } | ||
324 | 163 | |||
325 | 164 | for(uint i = 0; i < conf->num_outputs; ++i) { | ||
326 | 165 | MirDisplayOutput output = conf->outputs[i]; | ||
327 | 166 | auto display = m_displays.getById(output.output_id); | ||
328 | 167 | if (display) { | ||
329 | 168 | output.current_mode = display->mode(); | ||
330 | 169 | output.used = display->enabled(); | ||
331 | 170 | output.orientation = | ||
332 | 171 | DisplayPlugin::Helpers::orientationToMirOrientation( | ||
333 | 172 | display->orientation() | ||
334 | 173 | ); | ||
335 | 174 | } | ||
336 | 175 | conf->outputs[i] = output; | ||
337 | 176 | } | ||
338 | 177 | m_mirClient->applyConfiguration(conf); | ||
339 | 178 | } | ||
340 | 179 | |||
341 | 180 | void Brightness::refreshMirDisplays() | ||
342 | 181 | { | ||
343 | 182 | auto conf = m_mirClient->getConfiguration(); | ||
344 | 183 | |||
345 | 184 | if (!conf) { | ||
346 | 185 | qWarning() << __PRETTY_FUNCTION__ << "config invalid"; | ||
347 | 186 | return; | ||
348 | 187 | } | ||
349 | 188 | |||
350 | 189 | for(uint i = 0; i < conf->num_outputs; ++i) { | ||
351 | 190 | MirDisplayOutput output = conf->outputs[i]; | ||
352 | 191 | auto display = QSharedPointer<DisplayPlugin::Display>( | ||
353 | 192 | new DisplayPlugin::Display(output) | ||
354 | 193 | ); | ||
355 | 194 | m_displays.addDisplay(display); | ||
356 | 195 | } | ||
357 | 196 | } | ||
358 | 118 | 197 | ||
359 | === modified file 'plugins/brightness/brightness.h' | |||
360 | --- plugins/brightness/brightness.h 2016-11-04 18:56:02 +0000 | |||
361 | +++ plugins/brightness/brightness.h 2016-11-04 18:56:02 +0000 | |||
362 | @@ -22,6 +22,7 @@ | |||
363 | 22 | #define BRIGHTNESS_H | 22 | #define BRIGHTNESS_H |
364 | 23 | 23 | ||
365 | 24 | #include "displays/displaymodel.h" | 24 | #include "displays/displaymodel.h" |
366 | 25 | #include "displays/mirclient.h" | ||
367 | 25 | 26 | ||
368 | 26 | #include <QAbstractItemModel> | 27 | #include <QAbstractItemModel> |
369 | 27 | #include <QDBusInterface> | 28 | #include <QDBusInterface> |
370 | @@ -45,23 +46,35 @@ | |||
371 | 45 | Q_PROPERTY (QAbstractItemModel* changedDisplays | 46 | Q_PROPERTY (QAbstractItemModel* changedDisplays |
372 | 46 | READ changedDisplays | 47 | READ changedDisplays |
373 | 47 | CONSTANT) | 48 | CONSTANT) |
374 | 49 | Q_PROPERTY (QAbstractItemModel* connectedDisplays | ||
375 | 50 | READ connectedDisplays | ||
376 | 51 | CONSTANT) | ||
377 | 48 | 52 | ||
378 | 49 | public: | 53 | public: |
379 | 50 | explicit Brightness(QObject *parent = 0); | 54 | explicit Brightness(QObject *parent = 0); |
380 | 55 | explicit Brightness(QDBusConnection dbus, | ||
381 | 56 | DisplayPlugin::MirClient *mirClient, QObject *parent = 0); | ||
382 | 51 | bool getPowerdRunning() const; | 57 | bool getPowerdRunning() const; |
383 | 52 | bool getAutoBrightnessAvailable() const; | 58 | bool getAutoBrightnessAvailable() const; |
384 | 53 | bool getWidiSupported() const; | 59 | bool getWidiSupported() const; |
385 | 54 | QAbstractItemModel* allDisplays(); | 60 | QAbstractItemModel* allDisplays(); |
386 | 55 | QAbstractItemModel* changedDisplays(); | 61 | QAbstractItemModel* changedDisplays(); |
387 | 62 | QAbstractItemModel* connectedDisplays(); | ||
388 | 63 | Q_INVOKABLE void applyDisplayConfiguration(); | ||
389 | 56 | 64 | ||
390 | 57 | private: | 65 | private: |
391 | 58 | QDBusConnection m_systemBusConnection; | 66 | QDBusConnection m_systemBusConnection; |
392 | 67 | DisplayPlugin::MirClient *m_mirClient; | ||
393 | 68 | QDBusInterface m_powerdIface; | ||
394 | 59 | QString m_objectPath; | 69 | QString m_objectPath; |
395 | 60 | QDBusInterface m_powerdIface; | ||
396 | 61 | bool m_powerdRunning; | 70 | bool m_powerdRunning; |
397 | 62 | bool m_autoBrightnessAvailable; | 71 | bool m_autoBrightnessAvailable; |
400 | 63 | DisplayModel m_displays; | 72 | DisplayPlugin::DisplayModel m_displays; |
401 | 64 | DisplaysFilter m_changedDisplays; | 73 | DisplayPlugin::DisplaysFilter m_changedDisplays; |
402 | 74 | DisplayPlugin::DisplaysFilter m_connectedDisplays; | ||
403 | 75 | |||
404 | 76 | private slots: | ||
405 | 77 | void refreshMirDisplays(); | ||
406 | 65 | }; | 78 | }; |
407 | 66 | 79 | ||
408 | 67 | #endif // BRIGHTNESS_H | 80 | #endif // BRIGHTNESS_H |
409 | 68 | 81 | ||
410 | === modified file 'plugins/brightness/displays/display.cpp' | |||
411 | --- plugins/brightness/displays/display.cpp 2016-11-04 18:56:02 +0000 | |||
412 | +++ plugins/brightness/displays/display.cpp 2016-11-04 18:56:02 +0000 | |||
413 | @@ -1,12 +1,67 @@ | |||
414 | 1 | #include "display.h" | 1 | #include "display.h" |
415 | 2 | #include "helpers.h" | ||
416 | 3 | |||
417 | 4 | #include <QDebug> | ||
418 | 5 | |||
419 | 6 | namespace DisplayPlugin | ||
420 | 7 | { | ||
421 | 8 | QString DisplayMode::toString() const | ||
422 | 9 | { | ||
423 | 10 | /* TRANSLATORS: %1 refer to the amount of horizontal pixels in a | ||
424 | 11 | display resolution, and %2 to the vertical pixels. E.g. 1200x720. | ||
425 | 12 | %3 is the refresh rate in hz. */ | ||
426 | 13 | return SystemSettings::_("%1×%2 @ %3hz") | ||
427 | 14 | .arg(horizontal_resolution) | ||
428 | 15 | .arg(vertical_resolution) | ||
429 | 16 | .arg(refresh_rate); | ||
430 | 17 | } | ||
431 | 18 | bool DisplayMode::operator==(const DisplayMode &other) const | ||
432 | 19 | { | ||
433 | 20 | return ( | ||
434 | 21 | horizontal_resolution == other.horizontal_resolution | ||
435 | 22 | && vertical_resolution == other.vertical_resolution | ||
436 | 23 | && refresh_rate == other.refresh_rate | ||
437 | 24 | ); | ||
438 | 25 | } | ||
439 | 2 | 26 | ||
440 | 3 | Display::Display(QObject *parent) | 27 | Display::Display(QObject *parent) |
441 | 4 | : QObject(parent) | 28 | : QObject(parent) |
442 | 5 | { | 29 | { |
447 | 6 | QObject::connect(this, SIGNAL(nameChanged()), | 30 | initialize(); |
448 | 7 | this, SLOT(changedSlot())); | 31 | } |
449 | 8 | QObject::connect(this, SIGNAL(typeChanged()), | 32 | |
450 | 9 | this, SLOT(changedSlot())); | 33 | Display::Display(MirDisplayOutput &output, QObject *parent) |
451 | 34 | : Display(parent) | ||
452 | 35 | { | ||
453 | 36 | m_type = DisplayPlugin::Helpers::mirTypeToString(output.type); | ||
454 | 37 | setConnected(output.connected); | ||
455 | 38 | setEnabled(output.used); | ||
456 | 39 | |||
457 | 40 | auto modes = QList<DisplayMode>(); | ||
458 | 41 | for(uint j = 0; j < output.num_modes; j++) { | ||
459 | 42 | DisplayMode mode(output.modes[j]); | ||
460 | 43 | modes.append(mode); | ||
461 | 44 | |||
462 | 45 | if (j == output.current_mode) | ||
463 | 46 | m_mode = mode; | ||
464 | 47 | } | ||
465 | 48 | m_modes = modes; | ||
466 | 49 | m_orientation = DisplayPlugin::Helpers::mirOrientationToOritentation(output.orientation); | ||
467 | 50 | m_powerMode = DisplayPlugin::Helpers::mirPowerModeToPowerMode(output.power_mode); | ||
468 | 51 | m_id = output.output_id; | ||
469 | 52 | |||
470 | 53 | m_physicalWidthMm = output.physical_width_mm; | ||
471 | 54 | m_physicalHeightMm = output.physical_height_mm; | ||
472 | 55 | m_name = QString("%1").arg(DisplayPlugin::Helpers::mirTypeToString(output.type)); | ||
473 | 56 | qWarning() << m_name << "current_mode" << mode(); | ||
474 | 57 | |||
475 | 58 | changedSlot(); | ||
476 | 59 | storeConfiguration(); | ||
477 | 60 | } | ||
478 | 61 | |||
479 | 62 | |||
480 | 63 | void Display::initialize() | ||
481 | 64 | { | ||
482 | 10 | QObject::connect(this, SIGNAL(mirroredChanged()), | 65 | QObject::connect(this, SIGNAL(mirroredChanged()), |
483 | 11 | this, SLOT(changedSlot())); | 66 | this, SLOT(changedSlot())); |
484 | 12 | QObject::connect(this, SIGNAL(connectedChanged()), | 67 | QObject::connect(this, SIGNAL(connectedChanged()), |
485 | @@ -15,7 +70,7 @@ | |||
486 | 15 | this, SLOT(changedSlot())); | 70 | this, SLOT(changedSlot())); |
487 | 16 | QObject::connect(this, SIGNAL(modeChanged()), | 71 | QObject::connect(this, SIGNAL(modeChanged()), |
488 | 17 | this, SLOT(changedSlot())); | 72 | this, SLOT(changedSlot())); |
490 | 18 | QObject::connect(this, SIGNAL(availableModesChanged()), | 73 | QObject::connect(this, SIGNAL(modesChanged()), |
491 | 19 | this, SLOT(changedSlot())); | 74 | this, SLOT(changedSlot())); |
492 | 20 | QObject::connect(this, SIGNAL(orientationChanged()), | 75 | QObject::connect(this, SIGNAL(orientationChanged()), |
493 | 21 | this, SLOT(changedSlot())); | 76 | this, SLOT(changedSlot())); |
494 | @@ -25,6 +80,52 @@ | |||
495 | 25 | this, SLOT(changedSlot())); | 80 | this, SLOT(changedSlot())); |
496 | 26 | } | 81 | } |
497 | 27 | 82 | ||
498 | 83 | void Display::storeConfiguration() | ||
499 | 84 | { | ||
500 | 85 | m_storedConfig["name"] = QVariant(m_name); | ||
501 | 86 | m_storedConfig["type"] = QVariant(m_type); | ||
502 | 87 | m_storedConfig["mirrored"] = QVariant(m_mirrored); | ||
503 | 88 | m_storedConfig["enabled"] = QVariant(m_enabled); | ||
504 | 89 | m_storedConfig["mode"] = QVariant(mode()); | ||
505 | 90 | m_storedConfig["orientation"] = QVariant::fromValue(m_orientation); | ||
506 | 91 | m_storedConfig["scale"] = QVariant(m_scale); | ||
507 | 92 | } | ||
508 | 93 | |||
509 | 94 | bool Display::hasChanged() const | ||
510 | 95 | { | ||
511 | 96 | // qWarning() | ||
512 | 97 | // << m_storedConfig["name"].toString() << m_name | ||
513 | 98 | // << m_storedConfig["type"].toString() << m_type | ||
514 | 99 | // << m_storedConfig["mirrored"].toBool() << m_mirrored | ||
515 | 100 | // << m_storedConfig["enabled"].toBool() << m_enabled | ||
516 | 101 | // << m_storedConfig["mode"].toUInt() << mode() | ||
517 | 102 | // << (uint) m_storedConfig["orientation"].value<Orientation>() << (uint) m_orientation | ||
518 | 103 | // << m_storedConfig["scale"].toUInt() << m_scale | ||
519 | 104 | // << "truth values" | ||
520 | 105 | // << (m_storedConfig["name"].toString() != m_name) | ||
521 | 106 | // << (m_storedConfig["type"].toString() != m_type) | ||
522 | 107 | // << (m_storedConfig["mirrored"].toBool() != m_mirrored) | ||
523 | 108 | // << (m_storedConfig["enabled"].toBool() != m_enabled) | ||
524 | 109 | // << (m_storedConfig["mode"].toUInt() != mode()) | ||
525 | 110 | // << (m_storedConfig["orientation"].value<Orientation>() != m_orientation) | ||
526 | 111 | // << (m_storedConfig["scale"].toUInt() != m_scale); | ||
527 | 112 | |||
528 | 113 | return ( | ||
529 | 114 | m_storedConfig["name"].toString() != m_name | ||
530 | 115 | || m_storedConfig["type"].toString() != m_type | ||
531 | 116 | || m_storedConfig["mirrored"].toBool() != m_mirrored | ||
532 | 117 | || m_storedConfig["enabled"].toBool() != m_enabled | ||
533 | 118 | || m_storedConfig["mode"].toUInt() != mode() | ||
534 | 119 | || m_storedConfig["orientation"].value<Orientation>() != m_orientation | ||
535 | 120 | || m_storedConfig["scale"].toUInt() != m_scale | ||
536 | 121 | ); | ||
537 | 122 | } | ||
538 | 123 | |||
539 | 124 | uint Display::id() const | ||
540 | 125 | { | ||
541 | 126 | return m_id; | ||
542 | 127 | } | ||
543 | 128 | |||
544 | 28 | QString Display::name() const | 129 | QString Display::name() const |
545 | 29 | { | 130 | { |
546 | 30 | return m_name; | 131 | return m_name; |
547 | @@ -50,14 +151,23 @@ | |||
548 | 50 | return m_enabled; | 151 | return m_enabled; |
549 | 51 | } | 152 | } |
550 | 52 | 153 | ||
559 | 53 | QString Display::mode() const | 154 | uint Display::mode() const |
560 | 54 | { | 155 | { |
561 | 55 | return m_mode; | 156 | return m_modes.empty() ? 0 : m_modes.indexOf(m_mode); |
562 | 56 | } | 157 | } |
563 | 57 | 158 | ||
564 | 58 | QStringList Display::availableModes() const | 159 | QStringList Display::modes() const |
565 | 59 | { | 160 | { |
566 | 60 | return m_availableModes; | 161 | QStringList modes; |
567 | 162 | Q_FOREACH(const DisplayMode &mode, m_modes) { | ||
568 | 163 | modes.append(mode.toString()); | ||
569 | 164 | } | ||
570 | 165 | return modes; | ||
571 | 166 | } | ||
572 | 167 | |||
573 | 168 | QList<DisplayMode> Display::availableModes() const | ||
574 | 169 | { | ||
575 | 170 | return m_modes; | ||
576 | 61 | } | 171 | } |
577 | 62 | 172 | ||
578 | 63 | Display::Orientation Display::orientation() const | 173 | Display::Orientation Display::orientation() const |
579 | @@ -75,67 +185,73 @@ | |||
580 | 75 | return m_uncommittedChanges; | 185 | return m_uncommittedChanges; |
581 | 76 | } | 186 | } |
582 | 77 | 187 | ||
584 | 78 | void Display::setName(const QString &name) | 188 | uint Display::physicalWidthMm() const |
585 | 79 | { | 189 | { |
588 | 80 | m_name = name; | 190 | return m_physicalWidthMm; |
587 | 81 | Q_EMIT nameChanged(); | ||
589 | 82 | } | 191 | } |
590 | 83 | 192 | ||
592 | 84 | void Display::setType(const QString &type) | 193 | uint Display::physicalHeightMm() const |
593 | 85 | { | 194 | { |
596 | 86 | m_type = type; | 195 | return m_physicalHeightMm; |
595 | 87 | Q_EMIT typeChanged(); | ||
597 | 88 | } | 196 | } |
598 | 89 | 197 | ||
599 | 90 | void Display::setMirrored(const bool &mirrored) | 198 | void Display::setMirrored(const bool &mirrored) |
600 | 91 | { | 199 | { |
603 | 92 | m_mirrored = mirrored; | 200 | if (m_mirrored != mirrored) { |
604 | 93 | Q_EMIT mirroredChanged(); | 201 | m_mirrored = mirrored; |
605 | 202 | Q_EMIT mirroredChanged(); | ||
606 | 203 | } | ||
607 | 94 | } | 204 | } |
608 | 95 | 205 | ||
609 | 96 | void Display::setConnected(const bool &connected) | 206 | void Display::setConnected(const bool &connected) |
610 | 97 | { | 207 | { |
613 | 98 | m_connected = connected; | 208 | if (m_connected != connected) { |
614 | 99 | Q_EMIT connectedChanged(); | 209 | m_connected = connected; |
615 | 210 | Q_EMIT connectedChanged(); | ||
616 | 211 | } | ||
617 | 100 | } | 212 | } |
618 | 101 | 213 | ||
619 | 102 | void Display::setEnabled(const bool &enabled) | 214 | void Display::setEnabled(const bool &enabled) |
620 | 103 | { | 215 | { |
623 | 104 | m_enabled = enabled; | 216 | if (m_enabled != enabled) { |
624 | 105 | Q_EMIT enabledChanged(); | 217 | m_enabled = enabled; |
625 | 218 | Q_EMIT enabledChanged(); | ||
626 | 219 | } | ||
627 | 106 | } | 220 | } |
628 | 107 | 221 | ||
630 | 108 | void Display::setMode(const QString &mode) | 222 | void Display::setMode(const uint &mode) |
631 | 109 | { | 223 | { |
633 | 110 | m_mode = mode; | 224 | m_mode = m_modes.value(mode); |
634 | 111 | Q_EMIT modeChanged(); | 225 | Q_EMIT modeChanged(); |
635 | 112 | } | 226 | } |
636 | 113 | 227 | ||
637 | 114 | void Display::setAvailableModes(const QStringList &availableModes) | ||
638 | 115 | { | ||
639 | 116 | m_availableModes = availableModes; | ||
640 | 117 | Q_EMIT availableModesChanged(); | ||
641 | 118 | } | ||
642 | 119 | |||
643 | 120 | void Display::setOrientation(const Display::Orientation &orientation) | 228 | void Display::setOrientation(const Display::Orientation &orientation) |
644 | 121 | { | 229 | { |
647 | 122 | m_orientation = orientation; | 230 | if (m_orientation != orientation) { |
648 | 123 | Q_EMIT orientationChanged(); | 231 | m_orientation = orientation; |
649 | 232 | Q_EMIT orientationChanged(); | ||
650 | 233 | } | ||
651 | 124 | } | 234 | } |
652 | 125 | 235 | ||
653 | 126 | void Display::setScale(const double &scale) | 236 | void Display::setScale(const double &scale) |
654 | 127 | { | 237 | { |
657 | 128 | m_scale = scale; | 238 | if (m_scale != scale) { |
658 | 129 | Q_EMIT scaleChanged(); | 239 | m_scale = scale; |
659 | 240 | Q_EMIT scaleChanged(); | ||
660 | 241 | } | ||
661 | 130 | } | 242 | } |
662 | 131 | 243 | ||
663 | 132 | void Display::setUncommitedChanges(const bool uncommittedChanges) | 244 | void Display::setUncommitedChanges(const bool uncommittedChanges) |
664 | 133 | { | 245 | { |
667 | 134 | m_uncommittedChanges = uncommittedChanges; | 246 | if (m_uncommittedChanges != uncommittedChanges) { |
668 | 135 | Q_EMIT uncommittedChangesChanged(); | 247 | m_uncommittedChanges = uncommittedChanges; |
669 | 248 | Q_EMIT uncommittedChangesChanged(); | ||
670 | 249 | } | ||
671 | 136 | } | 250 | } |
672 | 137 | 251 | ||
673 | 138 | void Display::changedSlot() | 252 | void Display::changedSlot() |
674 | 139 | { | 253 | { |
675 | 254 | setUncommitedChanges(hasChanged()); | ||
676 | 140 | Q_EMIT displayChanged(this); | 255 | Q_EMIT displayChanged(this); |
677 | 141 | } | 256 | } |
678 | 257 | } // DisplayPlugin | ||
679 | 142 | 258 | ||
680 | === modified file 'plugins/brightness/displays/display.h' | |||
681 | --- plugins/brightness/displays/display.h 2016-11-04 18:56:02 +0000 | |||
682 | +++ plugins/brightness/displays/display.h 2016-11-04 18:56:02 +0000 | |||
683 | @@ -1,57 +1,62 @@ | |||
684 | 1 | #ifndef DISPLAY_H | 1 | #ifndef DISPLAY_H |
685 | 2 | #define DISPLAY_H | 2 | #define DISPLAY_H |
686 | 3 | 3 | ||
687 | 4 | #include "../../../src/i18n.h" | ||
688 | 5 | |||
689 | 6 | #include <mir_toolkit/mir_client_library.h> | ||
690 | 7 | |||
691 | 8 | #include <QList> | ||
692 | 4 | #include <QObject> | 9 | #include <QObject> |
693 | 5 | #include <QString> | 10 | #include <QString> |
694 | 6 | #include <QStringList> | 11 | #include <QStringList> |
695 | 12 | #include <QVariantMap> | ||
696 | 13 | |||
697 | 14 | namespace DisplayPlugin | ||
698 | 15 | { | ||
699 | 16 | class DisplayMode | ||
700 | 17 | { | ||
701 | 18 | public: | ||
702 | 19 | DisplayMode() {} | ||
703 | 20 | explicit DisplayMode(const MirDisplayMode &mirMode) | ||
704 | 21 | : vertical_resolution(mirMode.vertical_resolution) | ||
705 | 22 | , horizontal_resolution(mirMode.horizontal_resolution) | ||
706 | 23 | , refresh_rate(mirMode.refresh_rate) {} | ||
707 | 24 | uint vertical_resolution = 0; | ||
708 | 25 | uint horizontal_resolution = 0; | ||
709 | 26 | double refresh_rate = 0.0; | ||
710 | 27 | Q_INVOKABLE QString toString() const; | ||
711 | 28 | bool operator==(const DisplayMode &other) const; | ||
712 | 29 | }; | ||
713 | 7 | 30 | ||
714 | 8 | class Display : public QObject | 31 | class Display : public QObject |
715 | 9 | { | 32 | { |
716 | 10 | Q_OBJECT | 33 | Q_OBJECT |
726 | 11 | Q_PROPERTY(QString name | 34 | Q_PROPERTY(uint id READ id CONSTANT) |
727 | 12 | READ name | 35 | Q_PROPERTY(QString name READ name CONSTANT) |
728 | 13 | NOTIFY nameChanged) | 36 | Q_PROPERTY(QString type READ type CONSTANT) |
729 | 14 | Q_PROPERTY(QString type | 37 | Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored |
721 | 15 | READ type | ||
722 | 16 | NOTIFY typeChanged) | ||
723 | 17 | Q_PROPERTY(bool mirrored | ||
724 | 18 | READ mirrored | ||
725 | 19 | WRITE setMirrored | ||
730 | 20 | NOTIFY mirroredChanged) | 38 | NOTIFY mirroredChanged) |
737 | 21 | Q_PROPERTY(bool connected | 39 | Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) |
738 | 22 | READ connected | 40 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled |
733 | 23 | NOTIFY connectedChanged) | ||
734 | 24 | Q_PROPERTY(bool enabled | ||
735 | 25 | READ enabled | ||
736 | 26 | WRITE setEnabled | ||
739 | 27 | NOTIFY enabledChanged) | 41 | NOTIFY enabledChanged) |
743 | 28 | Q_PROPERTY(QString mode | 42 | Q_PROPERTY(uint mode READ mode WRITE setMode |
741 | 29 | READ mode | ||
742 | 30 | WRITE setMode | ||
744 | 31 | NOTIFY modeChanged) | 43 | NOTIFY modeChanged) |
751 | 32 | Q_PROPERTY(QStringList availableModes | 44 | Q_PROPERTY(QStringList modes READ modes |
752 | 33 | READ availableModes | 45 | NOTIFY modesChanged) |
753 | 34 | NOTIFY availableModesChanged) | 46 | Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation |
748 | 35 | Q_PROPERTY(Orientation orientation | ||
749 | 36 | READ orientation | ||
750 | 37 | WRITE setOrientation | ||
754 | 38 | NOTIFY orientationChanged) | 47 | NOTIFY orientationChanged) |
761 | 39 | Q_PROPERTY(double scale | 48 | Q_PROPERTY(double scale READ scale WRITE setScale NOTIFY scaleChanged) |
762 | 40 | READ scale | 49 | Q_PROPERTY(bool uncommittedChanges READ uncommittedChanges |
757 | 41 | WRITE setScale | ||
758 | 42 | NOTIFY scaleChanged) | ||
759 | 43 | Q_PROPERTY(bool uncommittedChanges | ||
760 | 44 | READ uncommittedChanges | ||
763 | 45 | NOTIFY uncommittedChangesChanged) | 50 | NOTIFY uncommittedChangesChanged) |
764 | 51 | Q_PROPERTY(uint physicalWidthMm READ physicalWidthMm CONSTANT) | ||
765 | 52 | Q_PROPERTY(uint physicalHeightMm READ physicalHeightMm CONSTANT) | ||
766 | 46 | 53 | ||
767 | 47 | Q_SIGNALS: | 54 | Q_SIGNALS: |
768 | 48 | void nameChanged(); | ||
769 | 49 | void typeChanged(); | ||
770 | 50 | void mirroredChanged(); | 55 | void mirroredChanged(); |
771 | 51 | void connectedChanged(); | 56 | void connectedChanged(); |
772 | 52 | void enabledChanged(); | 57 | void enabledChanged(); |
773 | 53 | void modeChanged(); | 58 | void modeChanged(); |
775 | 54 | void availableModesChanged(); | 59 | void modesChanged(); |
776 | 55 | void orientationChanged(); | 60 | void orientationChanged(); |
777 | 56 | void scaleChanged(); | 61 | void scaleChanged(); |
778 | 57 | void uncommittedChangesChanged(); | 62 | void uncommittedChangesChanged(); |
779 | @@ -59,54 +64,73 @@ | |||
780 | 59 | 64 | ||
781 | 60 | public: | 65 | public: |
782 | 61 | explicit Display(QObject *parent = nullptr); | 66 | explicit Display(QObject *parent = nullptr); |
783 | 67 | explicit Display(MirDisplayOutput &output, QObject *parent = nullptr); | ||
784 | 62 | ~Display() {}; | 68 | ~Display() {}; |
785 | 69 | |||
786 | 63 | enum class Orientation : uint { | 70 | enum class Orientation : uint { |
794 | 64 | Normal, PortraitMode, LandscapeInvertedMode, | 71 | NormalOrientation, PortraitModeOrientation, |
795 | 65 | PortraitInvertedMode | 72 | LandscapeInvertedModeOrientation, |
796 | 66 | }; | 73 | PortraitInvertedModeOrientation |
797 | 67 | enum class DisplayType : uint { | 74 | }; |
798 | 68 | PhysicalType, AethercastType | 75 | enum class PowerMode : uint { |
799 | 69 | }; | 76 | OnMode, StandbyMode, SuspendMode, OffMode |
800 | 70 | Q_ENUMS(Orientation DisplayType) | 77 | }; |
801 | 78 | Q_ENUMS(Orientation PowerMode) | ||
802 | 71 | 79 | ||
803 | 80 | uint id() const; | ||
804 | 72 | QString name() const; | 81 | QString name() const; |
805 | 73 | QString type() const; | 82 | QString type() const; |
806 | 74 | bool mirrored() const; | 83 | bool mirrored() const; |
807 | 75 | bool connected() const; | 84 | bool connected() const; |
808 | 76 | bool enabled() const; | 85 | bool enabled() const; |
811 | 77 | QString mode() const; | 86 | uint mode() const; |
812 | 78 | QStringList availableModes() const; | 87 | QList<DisplayMode> availableModes() const; |
813 | 88 | QStringList modes() const; | ||
814 | 79 | Orientation orientation() const; | 89 | Orientation orientation() const; |
815 | 80 | double scale() const; | 90 | double scale() const; |
816 | 81 | bool uncommittedChanges() const; | 91 | bool uncommittedChanges() const; |
817 | 92 | uint physicalWidthMm() const; | ||
818 | 93 | uint physicalHeightMm() const; | ||
819 | 82 | 94 | ||
820 | 83 | void setMirrored(const bool &mirrored); | 95 | void setMirrored(const bool &mirrored); |
821 | 84 | void setEnabled(const bool &enabled); | 96 | void setEnabled(const bool &enabled); |
823 | 85 | void setMode(const QString &mode); | 97 | void setMode(const uint &mode); |
824 | 86 | void setOrientation(const Orientation &orientation); | 98 | void setOrientation(const Orientation &orientation); |
825 | 87 | void setScale(const double &scale); | 99 | void setScale(const double &scale); |
826 | 88 | 100 | ||
827 | 89 | protected: | 101 | protected: |
830 | 90 | void setName(const QString &name); | 102 | void setUncommitedChanges(const bool uncommittedChanges); |
829 | 91 | void setAvailableModes(const QStringList &availableModes); | ||
831 | 92 | void setConnected(const bool &connected); | 103 | void setConnected(const bool &connected); |
834 | 93 | void setType(const QString &type); | 104 | void storeConfiguration(); |
835 | 94 | void setUncommitedChanges(const bool uncommittedChanges); | 105 | |
836 | 106 | uint m_id = 0; | ||
837 | 95 | QString m_name = QString::null; | 107 | QString m_name = QString::null; |
838 | 96 | QString m_type = QString::null; | 108 | QString m_type = QString::null; |
839 | 97 | bool m_mirrored = false; | 109 | bool m_mirrored = false; |
840 | 98 | bool m_connected = false; | 110 | bool m_connected = false; |
841 | 99 | bool m_enabled = false; | 111 | bool m_enabled = false; |
845 | 100 | QString m_mode = QString::null; | 112 | DisplayMode m_mode; |
846 | 101 | QStringList m_availableModes = QStringList(); | 113 | QList<DisplayMode> m_modes; |
847 | 102 | Orientation m_orientation = Orientation::Normal; | 114 | Orientation m_orientation = Orientation::NormalOrientation; |
848 | 103 | double m_scale = 1; | 115 | double m_scale = 1; |
849 | 104 | bool m_uncommittedChanges = false; | 116 | bool m_uncommittedChanges = false; |
850 | 117 | uint m_physicalWidthMm = 0; | ||
851 | 118 | uint m_physicalHeightMm = 0; | ||
852 | 119 | PowerMode m_powerMode = PowerMode::OffMode; | ||
853 | 105 | 120 | ||
855 | 106 | private slots: | 121 | protected slots: |
856 | 107 | void changedSlot(); | 122 | void changedSlot(); |
857 | 123 | |||
858 | 124 | private: | ||
859 | 125 | void initialize(); | ||
860 | 126 | bool hasChanged() const; | ||
861 | 127 | |||
862 | 128 | QVariantMap m_storedConfig; | ||
863 | 108 | }; | 129 | }; |
864 | 109 | 130 | ||
866 | 110 | Q_DECLARE_METATYPE(Display*) | 131 | } // DisplayPlugin |
867 | 132 | |||
868 | 133 | Q_DECLARE_METATYPE(DisplayPlugin::Display*) | ||
869 | 134 | Q_DECLARE_METATYPE(DisplayPlugin::Display::Orientation) | ||
870 | 111 | 135 | ||
871 | 112 | #endif // DISPLAY_H | 136 | #endif // DISPLAY_H |
872 | 113 | 137 | ||
873 | === modified file 'plugins/brightness/displays/displaymodel.cpp' | |||
874 | --- plugins/brightness/displays/displaymodel.cpp 2016-11-04 18:56:02 +0000 | |||
875 | +++ plugins/brightness/displays/displaymodel.cpp 2016-11-04 18:56:02 +0000 | |||
876 | @@ -2,6 +2,8 @@ | |||
877 | 2 | 2 | ||
878 | 3 | #include <QDebug> | 3 | #include <QDebug> |
879 | 4 | 4 | ||
880 | 5 | namespace DisplayPlugin | ||
881 | 6 | { | ||
882 | 5 | DisplayModel::DisplayModel(QObject *parent) | 7 | DisplayModel::DisplayModel(QObject *parent) |
883 | 6 | { | 8 | { |
884 | 7 | } | 9 | } |
885 | @@ -42,8 +44,8 @@ | |||
886 | 42 | case ModeRole: | 44 | case ModeRole: |
887 | 43 | ret = display->mode(); | 45 | ret = display->mode(); |
888 | 44 | break; | 46 | break; |
891 | 45 | case AvailableModesRole: | 47 | case ModesRole: |
892 | 46 | ret = display->availableModes(); | 48 | ret = display->modes(); |
893 | 47 | break; | 49 | break; |
894 | 48 | case OrientationRole: | 50 | case OrientationRole: |
895 | 49 | ret = (uint) display->orientation(); | 51 | ret = (uint) display->orientation(); |
896 | @@ -64,11 +66,9 @@ | |||
897 | 64 | int role) | 66 | int role) |
898 | 65 | { | 67 | { |
899 | 66 | if ((0 <= index.row()) && (index.row() < m_displays.size())) { | 68 | if ((0 <= index.row()) && (index.row() < m_displays.size())) { |
900 | 67 | |||
901 | 68 | auto display = m_displays[index.row()]; | 69 | auto display = m_displays[index.row()]; |
902 | 69 | 70 | ||
903 | 70 | switch (role) { | 71 | switch (role) { |
904 | 71 | |||
905 | 72 | case MirroredRole: | 72 | case MirroredRole: |
906 | 73 | display->setMirrored(value.toBool()); | 73 | display->setMirrored(value.toBool()); |
907 | 74 | break; | 74 | break; |
908 | @@ -76,7 +76,7 @@ | |||
909 | 76 | display->setEnabled(value.toBool()); | 76 | display->setEnabled(value.toBool()); |
910 | 77 | break; | 77 | break; |
911 | 78 | case ModeRole: | 78 | case ModeRole: |
913 | 79 | display->setMode(value.toString()); | 79 | display->setMode(value.toUInt()); |
914 | 80 | break; | 80 | break; |
915 | 81 | case OrientationRole: | 81 | case OrientationRole: |
916 | 82 | display->setOrientation((Display::Orientation) value.toUInt()); | 82 | display->setOrientation((Display::Orientation) value.toUInt()); |
917 | @@ -87,7 +87,7 @@ | |||
918 | 87 | case Qt::DisplayRole: | 87 | case Qt::DisplayRole: |
919 | 88 | case TypeRole: | 88 | case TypeRole: |
920 | 89 | case ConnectedRole: | 89 | case ConnectedRole: |
922 | 90 | case AvailableModesRole: | 90 | case ModesRole: |
923 | 91 | case UncommittedChangesRole: | 91 | case UncommittedChangesRole: |
924 | 92 | default: | 92 | default: |
925 | 93 | return false; | 93 | return false; |
926 | @@ -108,7 +108,7 @@ | |||
927 | 108 | names[ConnectedRole] = "connected"; | 108 | names[ConnectedRole] = "connected"; |
928 | 109 | names[EnabledRole] = "enabled"; | 109 | names[EnabledRole] = "enabled"; |
929 | 110 | names[ModeRole] = "mode"; | 110 | names[ModeRole] = "mode"; |
931 | 111 | names[AvailableModesRole] = "availableModes"; | 111 | names[ModesRole] = "modes"; |
932 | 112 | names[OrientationRole] = "orientation"; | 112 | names[OrientationRole] = "orientation"; |
933 | 113 | names[ScaleRole] = "scale"; | 113 | names[ScaleRole] = "scale"; |
934 | 114 | names[UncommittedChangesRole] = "uncommittedChanges"; | 114 | names[UncommittedChangesRole] = "uncommittedChanges"; |
935 | @@ -118,8 +118,7 @@ | |||
936 | 118 | 118 | ||
937 | 119 | void DisplayModel::addDisplay(const QSharedPointer<Display> &display) | 119 | void DisplayModel::addDisplay(const QSharedPointer<Display> &display) |
938 | 120 | { | 120 | { |
941 | 121 | // TODO: find display | 121 | int row = findRowFromId(display->id()); |
940 | 122 | int row = -1; | ||
942 | 123 | 122 | ||
943 | 124 | if (row >= 0) { // update existing display | 123 | if (row >= 0) { // update existing display |
944 | 125 | m_displays[row] = display; | 124 | m_displays[row] = display; |
945 | @@ -131,7 +130,7 @@ | |||
946 | 131 | endInsertRows(); | 130 | endInsertRows(); |
947 | 132 | } | 131 | } |
948 | 133 | 132 | ||
950 | 134 | if (display) { | 133 | if (display) { |
951 | 135 | QObject::connect(display.data(), SIGNAL(displayChanged(const Display*)), | 134 | QObject::connect(display.data(), SIGNAL(displayChanged(const Display*)), |
952 | 136 | this, SLOT(displayChangedSlot(const Display*))); | 135 | this, SLOT(displayChangedSlot(const Display*))); |
953 | 137 | } | 136 | } |
954 | @@ -143,7 +142,7 @@ | |||
955 | 143 | { | 142 | { |
956 | 144 | if (0 <= row && row < m_displays.size()) { | 143 | if (0 <= row && row < m_displays.size()) { |
957 | 145 | QModelIndex qmi = index(row, 0); | 144 | QModelIndex qmi = index(row, 0); |
959 | 146 | Q_EMIT(dataChanged(qmi, qmi)); | 145 | Q_EMIT dataChanged(qmi, qmi); |
960 | 147 | } | 146 | } |
961 | 148 | } | 147 | } |
962 | 149 | 148 | ||
963 | @@ -160,6 +159,32 @@ | |||
964 | 160 | emitRowChanged(row); | 159 | emitRowChanged(row); |
965 | 161 | } | 160 | } |
966 | 162 | 161 | ||
967 | 162 | QSharedPointer<Display> DisplayModel::getById(const uint &id) | ||
968 | 163 | { | ||
969 | 164 | Q_FOREACH(auto display, m_displays) { | ||
970 | 165 | if (display->id() == id) | ||
971 | 166 | return display; | ||
972 | 167 | } | ||
973 | 168 | return QSharedPointer<Display>(nullptr); | ||
974 | 169 | } | ||
975 | 170 | |||
976 | 171 | int DisplayModel::findRowFromId(const uint &id) | ||
977 | 172 | { | ||
978 | 173 | for (int i = 0; i < m_displays.size(); i++) { | ||
979 | 174 | if (m_displays[i]->id() == id) | ||
980 | 175 | return i; | ||
981 | 176 | } | ||
982 | 177 | return -1; | ||
983 | 178 | } | ||
984 | 179 | |||
985 | 180 | DisplaysFilter::DisplaysFilter() | ||
986 | 181 | { | ||
987 | 182 | connect(this, SIGNAL(rowsInserted(const QModelIndex&, int, int)), | ||
988 | 183 | this, SLOT(rowsChanged(const QModelIndex&, int, int))); | ||
989 | 184 | connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), | ||
990 | 185 | this, SLOT(rowsChanged(const QModelIndex&, int, int))); | ||
991 | 186 | } | ||
992 | 187 | |||
993 | 163 | bool DisplaysFilter::lessThan(const QModelIndex &left, | 188 | bool DisplaysFilter::lessThan(const QModelIndex &left, |
994 | 164 | const QModelIndex &right) const | 189 | const QModelIndex &right) const |
995 | 165 | { | 190 | { |
996 | @@ -168,13 +193,20 @@ | |||
997 | 168 | return a < b; | 193 | return a < b; |
998 | 169 | } | 194 | } |
999 | 170 | 195 | ||
1001 | 171 | void DisplaysFilter::filterOnUncommittedChanges(const bool apply) | 196 | void DisplaysFilter::filterOnUncommittedChanges(const bool uncommitted) |
1002 | 172 | { | 197 | { |
1004 | 173 | m_uncommittedChanges = apply; | 198 | m_uncommittedChanges = uncommitted; |
1005 | 174 | m_uncommittedChangesEnabled = true; | 199 | m_uncommittedChangesEnabled = true; |
1006 | 175 | invalidateFilter(); | 200 | invalidateFilter(); |
1007 | 176 | } | 201 | } |
1008 | 177 | 202 | ||
1009 | 203 | void DisplaysFilter::filterOnConnected(const bool connected) | ||
1010 | 204 | { | ||
1011 | 205 | m_connected = connected; | ||
1012 | 206 | m_connectedEnabled = true; | ||
1013 | 207 | invalidateFilter(); | ||
1014 | 208 | } | ||
1015 | 209 | |||
1016 | 178 | bool DisplaysFilter::filterAcceptsRow(int sourceRow, | 210 | bool DisplaysFilter::filterAcceptsRow(int sourceRow, |
1017 | 179 | const QModelIndex &sourceParent) const | 211 | const QModelIndex &sourceParent) const |
1018 | 180 | { | 212 | { |
1019 | @@ -182,9 +214,27 @@ | |||
1020 | 182 | QModelIndex childIndex = sourceModel()->index(sourceRow, 0, sourceParent); | 214 | QModelIndex childIndex = sourceModel()->index(sourceRow, 0, sourceParent); |
1021 | 183 | 215 | ||
1022 | 184 | if (accepts && m_uncommittedChangesEnabled) { | 216 | if (accepts && m_uncommittedChangesEnabled) { |
1024 | 185 | const bool uncommittedChanges = childIndex.model()->data(childIndex, DisplayModel::UncommittedChangesRole).value<bool>(); | 217 | const bool uncommittedChanges = childIndex.model()->data( |
1025 | 218 | childIndex, DisplayModel::UncommittedChangesRole | ||
1026 | 219 | ).value<bool>(); | ||
1027 | 186 | accepts = (m_uncommittedChanges == uncommittedChanges); | 220 | accepts = (m_uncommittedChanges == uncommittedChanges); |
1028 | 187 | } | 221 | } |
1029 | 188 | 222 | ||
1030 | 223 | if (accepts && m_connectedEnabled) { | ||
1031 | 224 | const bool connected = childIndex.model()->data( | ||
1032 | 225 | childIndex, DisplayModel::ConnectedRole | ||
1033 | 226 | ).value<bool>(); | ||
1034 | 227 | accepts = (m_connected == connected); | ||
1035 | 228 | } | ||
1036 | 229 | |||
1037 | 189 | return accepts; | 230 | return accepts; |
1038 | 190 | } | 231 | } |
1039 | 232 | |||
1040 | 233 | void DisplaysFilter::rowsChanged(const QModelIndex &parent, int first, int last) | ||
1041 | 234 | { | ||
1042 | 235 | Q_UNUSED(parent) | ||
1043 | 236 | Q_UNUSED(first) | ||
1044 | 237 | Q_UNUSED(last) | ||
1045 | 238 | Q_EMIT countChanged(); | ||
1046 | 239 | } | ||
1047 | 240 | } // DisplayPlugin | ||
1048 | 191 | 241 | ||
1049 | === modified file 'plugins/brightness/displays/displaymodel.h' | |||
1050 | --- plugins/brightness/displays/displaymodel.h 2016-11-04 18:56:02 +0000 | |||
1051 | +++ plugins/brightness/displays/displaymodel.h 2016-11-04 18:56:02 +0000 | |||
1052 | @@ -12,6 +12,8 @@ | |||
1053 | 12 | #include <QSortFilterProxyModel> | 12 | #include <QSortFilterProxyModel> |
1054 | 13 | #include <QVariant> | 13 | #include <QVariant> |
1055 | 14 | 14 | ||
1056 | 15 | namespace DisplayPlugin | ||
1057 | 16 | { | ||
1058 | 15 | class DisplayModel : public QAbstractListModel | 17 | class DisplayModel : public QAbstractListModel |
1059 | 16 | { | 18 | { |
1060 | 17 | Q_OBJECT | 19 | Q_OBJECT |
1061 | @@ -28,7 +30,7 @@ | |||
1062 | 28 | ConnectedRole, | 30 | ConnectedRole, |
1063 | 29 | EnabledRole, | 31 | EnabledRole, |
1064 | 30 | ModeRole, | 32 | ModeRole, |
1066 | 31 | AvailableModesRole, | 33 | ModesRole, |
1067 | 32 | OrientationRole, | 34 | OrientationRole, |
1068 | 33 | ScaleRole, | 35 | ScaleRole, |
1069 | 34 | UncommittedChangesRole, | 36 | UncommittedChangesRole, |
1070 | @@ -40,13 +42,15 @@ | |||
1071 | 40 | bool setData(const QModelIndex &index, const QVariant &value, | 42 | bool setData(const QModelIndex &index, const QVariant &value, |
1072 | 41 | int role = Qt::EditRole); | 43 | int role = Qt::EditRole); |
1073 | 42 | QHash<int,QByteArray> roleNames() const; | 44 | QHash<int,QByteArray> roleNames() const; |
1074 | 45 | void addDisplay(const QSharedPointer<Display> &display); | ||
1075 | 46 | QSharedPointer<Display> getById(const uint &id); | ||
1076 | 47 | int findRowFromId(const uint &id); | ||
1077 | 43 | 48 | ||
1078 | 44 | Q_SIGNALS: | 49 | Q_SIGNALS: |
1079 | 45 | void countChanged(); | 50 | void countChanged(); |
1080 | 46 | 51 | ||
1081 | 47 | protected: | 52 | protected: |
1082 | 48 | void emitRowChanged(const int &row); | 53 | void emitRowChanged(const int &row); |
1083 | 49 | void addDisplay(const QSharedPointer<Display> &display); | ||
1084 | 50 | 54 | ||
1085 | 51 | private: | 55 | private: |
1086 | 52 | QList<QSharedPointer<Display> > m_displays; | 56 | QList<QSharedPointer<Display> > m_displays; |
1087 | @@ -61,13 +65,14 @@ | |||
1088 | 61 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) | 65 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) |
1089 | 62 | 66 | ||
1090 | 63 | public: | 67 | public: |
1092 | 64 | DisplaysFilter() {} | 68 | DisplaysFilter(); |
1093 | 65 | virtual ~DisplaysFilter() {} | 69 | virtual ~DisplaysFilter() {} |
1094 | 66 | 70 | ||
1096 | 67 | void filterOnUncommittedChanges(const bool apply); | 71 | void filterOnUncommittedChanges(const bool uncommitted); |
1097 | 72 | void filterOnConnected(const bool connected); | ||
1098 | 68 | 73 | ||
1099 | 69 | Q_SIGNALS: | 74 | Q_SIGNALS: |
1101 | 70 | void countChanged(int count); | 75 | void countChanged(); |
1102 | 71 | 76 | ||
1103 | 72 | protected: | 77 | protected: |
1104 | 73 | virtual bool filterAcceptsRow(int, const QModelIndex&) const; | 78 | virtual bool filterAcceptsRow(int, const QModelIndex&) const; |
1105 | @@ -77,6 +82,12 @@ | |||
1106 | 77 | bool m_uncommittedChanges = false; | 82 | bool m_uncommittedChanges = false; |
1107 | 78 | bool m_uncommittedChangesEnabled = false; | 83 | bool m_uncommittedChangesEnabled = false; |
1108 | 79 | 84 | ||
1109 | 85 | bool m_connected = false; | ||
1110 | 86 | bool m_connectedEnabled = false; | ||
1111 | 87 | |||
1112 | 88 | private slots: | ||
1113 | 89 | void rowsChanged(const QModelIndex &parent, int first, int last); | ||
1114 | 80 | }; | 90 | }; |
1115 | 91 | } // DisplayPlugin | ||
1116 | 81 | 92 | ||
1117 | 82 | #endif // DISPLAY_MODEL_H | 93 | #endif // DISPLAY_MODEL_H |
1118 | 83 | 94 | ||
1119 | === added file 'plugins/brightness/displays/helpers.cpp' | |||
1120 | --- plugins/brightness/displays/helpers.cpp 1970-01-01 00:00:00 +0000 | |||
1121 | +++ plugins/brightness/displays/helpers.cpp 2016-11-04 18:56:02 +0000 | |||
1122 | @@ -0,0 +1,131 @@ | |||
1123 | 1 | #include "helpers.h" | ||
1124 | 2 | |||
1125 | 3 | namespace DisplayPlugin | ||
1126 | 4 | { | ||
1127 | 5 | Display::Orientation Helpers::mirOrientationToOritentation(const MirOrientation &mirOrientation) | ||
1128 | 6 | { | ||
1129 | 7 | Display::Orientation orientation; | ||
1130 | 8 | switch (mirOrientation) { | ||
1131 | 9 | case mir_orientation_normal: | ||
1132 | 10 | orientation = Display::Orientation::NormalOrientation; | ||
1133 | 11 | break; | ||
1134 | 12 | case mir_orientation_left: | ||
1135 | 13 | orientation = Display::Orientation::PortraitModeOrientation; | ||
1136 | 14 | break; | ||
1137 | 15 | case mir_orientation_inverted: | ||
1138 | 16 | orientation = Display::Orientation::LandscapeInvertedModeOrientation; | ||
1139 | 17 | break; | ||
1140 | 18 | case mir_orientation_right: | ||
1141 | 19 | orientation = Display::Orientation::PortraitInvertedModeOrientation; | ||
1142 | 20 | break; | ||
1143 | 21 | default: | ||
1144 | 22 | orientation = Display::Orientation::NormalOrientation; | ||
1145 | 23 | } | ||
1146 | 24 | return orientation; | ||
1147 | 25 | } | ||
1148 | 26 | |||
1149 | 27 | MirOrientation Helpers::orientationToMirOrientation(const Display::Orientation &orientation) | ||
1150 | 28 | { | ||
1151 | 29 | MirOrientation mirOrientation; | ||
1152 | 30 | switch (orientation) { | ||
1153 | 31 | case Display::Orientation::NormalOrientation: | ||
1154 | 32 | mirOrientation = mir_orientation_normal; | ||
1155 | 33 | break; | ||
1156 | 34 | case Display::Orientation::PortraitModeOrientation: | ||
1157 | 35 | mirOrientation = mir_orientation_left; | ||
1158 | 36 | break; | ||
1159 | 37 | case Display::Orientation::LandscapeInvertedModeOrientation: | ||
1160 | 38 | mirOrientation = mir_orientation_inverted; | ||
1161 | 39 | break; | ||
1162 | 40 | case Display::Orientation::PortraitInvertedModeOrientation: | ||
1163 | 41 | mirOrientation = mir_orientation_right; | ||
1164 | 42 | break; | ||
1165 | 43 | default: | ||
1166 | 44 | mirOrientation = mir_orientation_normal; | ||
1167 | 45 | } | ||
1168 | 46 | return mirOrientation; | ||
1169 | 47 | } | ||
1170 | 48 | |||
1171 | 49 | QString Helpers::mirTypeToString(const MirDisplayOutputType &type) | ||
1172 | 50 | { | ||
1173 | 51 | QString ret; | ||
1174 | 52 | switch (type) { | ||
1175 | 53 | default: | ||
1176 | 54 | case mir_display_output_type_unknown: | ||
1177 | 55 | ret = ""; | ||
1178 | 56 | break; | ||
1179 | 57 | case mir_display_output_type_vga: | ||
1180 | 58 | ret = "vga"; | ||
1181 | 59 | break; | ||
1182 | 60 | case mir_display_output_type_dvii: | ||
1183 | 61 | ret = "dvii"; | ||
1184 | 62 | break; | ||
1185 | 63 | case mir_display_output_type_dvid: | ||
1186 | 64 | ret = "dvid"; | ||
1187 | 65 | break; | ||
1188 | 66 | case mir_display_output_type_dvia: | ||
1189 | 67 | ret = "dvia"; | ||
1190 | 68 | break; | ||
1191 | 69 | case mir_display_output_type_composite: | ||
1192 | 70 | ret = "composite"; | ||
1193 | 71 | break; | ||
1194 | 72 | case mir_display_output_type_svideo: | ||
1195 | 73 | ret = "svideo"; | ||
1196 | 74 | break; | ||
1197 | 75 | case mir_display_output_type_lvds: | ||
1198 | 76 | ret = "lvds"; | ||
1199 | 77 | break; | ||
1200 | 78 | case mir_display_output_type_component: | ||
1201 | 79 | ret = "component"; | ||
1202 | 80 | break; | ||
1203 | 81 | case mir_display_output_type_ninepindin: | ||
1204 | 82 | ret = "ninepindin"; | ||
1205 | 83 | break; | ||
1206 | 84 | case mir_display_output_type_displayport: | ||
1207 | 85 | ret = "displayport"; | ||
1208 | 86 | break; | ||
1209 | 87 | case mir_display_output_type_hdmia: | ||
1210 | 88 | ret = "hdmia"; | ||
1211 | 89 | break; | ||
1212 | 90 | case mir_display_output_type_hdmib: | ||
1213 | 91 | ret = "hdmib"; | ||
1214 | 92 | break; | ||
1215 | 93 | case mir_display_output_type_tv: | ||
1216 | 94 | ret = "tv"; | ||
1217 | 95 | break; | ||
1218 | 96 | case mir_display_output_type_edp: | ||
1219 | 97 | ret = "edp"; | ||
1220 | 98 | break; | ||
1221 | 99 | } | ||
1222 | 100 | |||
1223 | 101 | return ret; | ||
1224 | 102 | } | ||
1225 | 103 | |||
1226 | 104 | Display::PowerMode Helpers::mirPowerModeToPowerMode(const MirPowerMode &mode) | ||
1227 | 105 | { | ||
1228 | 106 | switch(mode) { | ||
1229 | 107 | case mir_power_mode_on: | ||
1230 | 108 | return Display::PowerMode::OnMode; | ||
1231 | 109 | case mir_power_mode_standby: | ||
1232 | 110 | return Display::PowerMode::StandbyMode; | ||
1233 | 111 | case mir_power_mode_suspend: | ||
1234 | 112 | return Display::PowerMode::SuspendMode; | ||
1235 | 113 | case mir_power_mode_off: | ||
1236 | 114 | return Display::PowerMode::OffMode; | ||
1237 | 115 | } | ||
1238 | 116 | } | ||
1239 | 117 | |||
1240 | 118 | MirPowerMode Helpers::powerModeToMirPowerMode(const Display::PowerMode &mode) | ||
1241 | 119 | { | ||
1242 | 120 | switch(mode) { | ||
1243 | 121 | case Display::PowerMode::OnMode: | ||
1244 | 122 | return mir_power_mode_on; | ||
1245 | 123 | case Display::PowerMode::StandbyMode: | ||
1246 | 124 | return mir_power_mode_standby; | ||
1247 | 125 | case Display::PowerMode::SuspendMode: | ||
1248 | 126 | return mir_power_mode_suspend; | ||
1249 | 127 | case Display::PowerMode::OffMode: | ||
1250 | 128 | return mir_power_mode_off; | ||
1251 | 129 | } | ||
1252 | 130 | } | ||
1253 | 131 | } // DisplayPlugin | ||
1254 | 0 | 132 | ||
1255 | === added file 'plugins/brightness/displays/helpers.h' | |||
1256 | --- plugins/brightness/displays/helpers.h 1970-01-01 00:00:00 +0000 | |||
1257 | +++ plugins/brightness/displays/helpers.h 2016-11-04 18:56:02 +0000 | |||
1258 | @@ -0,0 +1,25 @@ | |||
1259 | 1 | #ifndef DISPLAY_PLUGIN_HELPERS_H | ||
1260 | 2 | #define DISPLAY_PLUGIN_HELPERS_H | ||
1261 | 3 | |||
1262 | 4 | #include "display.h" | ||
1263 | 5 | |||
1264 | 6 | #include <mir_toolkit/mir_client_library.h> | ||
1265 | 7 | |||
1266 | 8 | namespace DisplayPlugin | ||
1267 | 9 | { | ||
1268 | 10 | struct Helpers | ||
1269 | 11 | { | ||
1270 | 12 | public: | ||
1271 | 13 | static Display::Orientation mirOrientationToOritentation(const MirOrientation &mirOrientation); | ||
1272 | 14 | static MirOrientation orientationToMirOrientation(const Display::Orientation &orientation); | ||
1273 | 15 | static QString mirTypeToString(const MirDisplayOutputType &type); | ||
1274 | 16 | static QString mirModeToString(const MirDisplayOutputType &type); | ||
1275 | 17 | static Display::PowerMode mirPowerModeToPowerMode(const MirPowerMode &mode); | ||
1276 | 18 | static MirPowerMode powerModeToMirPowerMode(const Display::PowerMode &mode); | ||
1277 | 19 | |||
1278 | 20 | // Return a sorted list of modes in horizontalxverticalxrate format. | ||
1279 | 21 | // static QString mirModesToStringList(const MirDisplayOutputType &type); | ||
1280 | 22 | }; | ||
1281 | 23 | } // DisplayPlugin | ||
1282 | 24 | |||
1283 | 25 | #endif // DISPLAY_PLUGIN_HELPERS_H | ||
1284 | 0 | 26 | ||
1285 | === added file 'plugins/brightness/displays/mirclient.h' | |||
1286 | --- plugins/brightness/displays/mirclient.h 1970-01-01 00:00:00 +0000 | |||
1287 | +++ plugins/brightness/displays/mirclient.h 2016-11-04 18:56:02 +0000 | |||
1288 | @@ -0,0 +1,25 @@ | |||
1289 | 1 | #ifndef MIRCLIENT_H | ||
1290 | 2 | #define MIRCLIENT_H | ||
1291 | 3 | |||
1292 | 4 | #include <mir_toolkit/mir_client_library.h> | ||
1293 | 5 | #include <QObject> | ||
1294 | 6 | |||
1295 | 7 | namespace DisplayPlugin | ||
1296 | 8 | { | ||
1297 | 9 | class MirClient : public QObject | ||
1298 | 10 | { | ||
1299 | 11 | Q_OBJECT | ||
1300 | 12 | public: | ||
1301 | 13 | explicit MirClient(QObject *parent = 0) : QObject(parent) {} | ||
1302 | 14 | virtual ~MirClient() {}; | ||
1303 | 15 | virtual MirDisplayConfiguration* getConfiguration() const = 0; | ||
1304 | 16 | virtual void setConfiguration(MirDisplayConfiguration *conf) = 0; | ||
1305 | 17 | virtual bool applyConfiguration(MirDisplayConfiguration *conf) = 0; | ||
1306 | 18 | virtual bool isConnected() = 0; | ||
1307 | 19 | |||
1308 | 20 | Q_SIGNALS: | ||
1309 | 21 | void configurationChanged() const; | ||
1310 | 22 | }; | ||
1311 | 23 | } // DisplayPlugin | ||
1312 | 24 | |||
1313 | 25 | #endif // MIRCLIENT_H | ||
1314 | 0 | 26 | ||
1315 | === added file 'plugins/brightness/displays/mirclient_impl.cpp' | |||
1316 | --- plugins/brightness/displays/mirclient_impl.cpp 1970-01-01 00:00:00 +0000 | |||
1317 | +++ plugins/brightness/displays/mirclient_impl.cpp 2016-11-04 18:56:02 +0000 | |||
1318 | @@ -0,0 +1,86 @@ | |||
1319 | 1 | #include "mirclient_impl.h" | ||
1320 | 2 | |||
1321 | 3 | #include <QDebug> | ||
1322 | 4 | #include <QQmlEngine> | ||
1323 | 5 | #include <QGuiApplication> | ||
1324 | 6 | #include <qpa/qplatformnativeinterface.h> | ||
1325 | 7 | |||
1326 | 8 | namespace DisplayPlugin | ||
1327 | 9 | { | ||
1328 | 10 | static void mir_display_change_callback(MirConnection *connection, void *context) { | ||
1329 | 11 | MirDisplayConfiguration *conf = mir_connection_create_display_config( | ||
1330 | 12 | connection); | ||
1331 | 13 | static_cast<MirClientImpl*>(context)->setConfiguration(conf); | ||
1332 | 14 | } | ||
1333 | 15 | |||
1334 | 16 | MirClientImpl::MirClientImpl(QObject *parent) | ||
1335 | 17 | : MirClient(parent) | ||
1336 | 18 | , m_mir_connection(nullptr) | ||
1337 | 19 | , m_configuration(nullptr) | ||
1338 | 20 | { | ||
1339 | 21 | connect(); | ||
1340 | 22 | if (isConnected()) { | ||
1341 | 23 | setConfiguration( | ||
1342 | 24 | mir_connection_create_display_config(m_mir_connection) | ||
1343 | 25 | ); | ||
1344 | 26 | } | ||
1345 | 27 | } | ||
1346 | 28 | |||
1347 | 29 | MirClientImpl::~MirClientImpl() { | ||
1348 | 30 | mir_display_config_destroy(m_configuration); | ||
1349 | 31 | mir_connection_release(m_mir_connection); | ||
1350 | 32 | } | ||
1351 | 33 | |||
1352 | 34 | MirDisplayConfiguration* MirClientImpl::getConfiguration() const { | ||
1353 | 35 | return m_configuration; | ||
1354 | 36 | } | ||
1355 | 37 | |||
1356 | 38 | bool MirClientImpl::isConnected() { | ||
1357 | 39 | return mir_connection_is_valid(m_mir_connection); | ||
1358 | 40 | } | ||
1359 | 41 | |||
1360 | 42 | void MirClientImpl::setConfiguration(MirDisplayConfiguration *conf) { | ||
1361 | 43 | if (m_configuration != conf) { | ||
1362 | 44 | m_configuration = conf; | ||
1363 | 45 | Q_EMIT configurationChanged(); | ||
1364 | 46 | } | ||
1365 | 47 | } | ||
1366 | 48 | |||
1367 | 49 | bool MirClientImpl::applyConfiguration(MirDisplayConfiguration *conf) { | ||
1368 | 50 | MirWaitHandle* handle = mir_connection_set_base_display_config( | ||
1369 | 51 | m_mir_connection, conf | ||
1370 | 52 | ); | ||
1371 | 53 | |||
1372 | 54 | if (!handle) { | ||
1373 | 55 | qWarning() << __PRETTY_FUNCTION__ << "Failed to get handle."; | ||
1374 | 56 | return false; | ||
1375 | 57 | } | ||
1376 | 58 | |||
1377 | 59 | mir_wait_for(handle); | ||
1378 | 60 | QString error(mir_connection_get_error_message(m_mir_connection)); | ||
1379 | 61 | if (error.isEmpty()) { | ||
1380 | 62 | qWarning() << "Mir apply config successfully."; | ||
1381 | 63 | } else { | ||
1382 | 64 | qWarning() << "Mir configuration error:" << error; | ||
1383 | 65 | } | ||
1384 | 66 | return error.isEmpty(); | ||
1385 | 67 | } | ||
1386 | 68 | |||
1387 | 69 | void MirClientImpl::connect() { | ||
1388 | 70 | qWarning() << "Connecting to a Mir server..."; | ||
1389 | 71 | m_mir_connection = static_cast<MirConnection*>( | ||
1390 | 72 | QGuiApplication::platformNativeInterface() | ||
1391 | 73 | ->nativeResourceForIntegration("mirConnection") | ||
1392 | 74 | ); | ||
1393 | 75 | if (m_mir_connection == nullptr || !isConnected()) { | ||
1394 | 76 | const char *error = "Unknown error"; | ||
1395 | 77 | if (m_mir_connection != nullptr) | ||
1396 | 78 | error = mir_connection_get_error_message(m_mir_connection); | ||
1397 | 79 | qWarning() << __PRETTY_FUNCTION__ << "Could not connect to Mir:" << error; | ||
1398 | 80 | } else { | ||
1399 | 81 | qWarning() << "Using a Mir server."; | ||
1400 | 82 | mir_connection_set_display_config_change_callback( | ||
1401 | 83 | m_mir_connection, mir_display_change_callback, this); | ||
1402 | 84 | } | ||
1403 | 85 | } | ||
1404 | 86 | } // DisplayPlugin | ||
1405 | 0 | 87 | ||
1406 | === added file 'plugins/brightness/displays/mirclient_impl.h' | |||
1407 | --- plugins/brightness/displays/mirclient_impl.h 1970-01-01 00:00:00 +0000 | |||
1408 | +++ plugins/brightness/displays/mirclient_impl.h 2016-11-04 18:56:02 +0000 | |||
1409 | @@ -0,0 +1,26 @@ | |||
1410 | 1 | #ifndef MIRCLIENT_IMPL_H | ||
1411 | 2 | #define MIRCLIENT_IMPL_H | ||
1412 | 3 | |||
1413 | 4 | #include "mirclient.h" | ||
1414 | 5 | |||
1415 | 6 | namespace DisplayPlugin | ||
1416 | 7 | { | ||
1417 | 8 | class MirClientImpl : public MirClient | ||
1418 | 9 | { | ||
1419 | 10 | Q_OBJECT | ||
1420 | 11 | public: | ||
1421 | 12 | explicit MirClientImpl(QObject *parent = 0); | ||
1422 | 13 | ~MirClientImpl(); | ||
1423 | 14 | virtual MirDisplayConfiguration* getConfiguration() const; | ||
1424 | 15 | virtual void setConfiguration(MirDisplayConfiguration *conf) override; | ||
1425 | 16 | virtual bool applyConfiguration(MirDisplayConfiguration *conf) override; | ||
1426 | 17 | virtual bool isConnected() override; | ||
1427 | 18 | |||
1428 | 19 | private: | ||
1429 | 20 | void connect(); | ||
1430 | 21 | MirConnection *m_mir_connection; | ||
1431 | 22 | MirDisplayConfiguration *m_configuration; | ||
1432 | 23 | }; | ||
1433 | 24 | } // DisplayPlugin | ||
1434 | 25 | |||
1435 | 26 | #endif // MIRCLIENT_IMPL_H | ||
1436 | 0 | 27 | ||
1437 | === modified file 'plugins/brightness/plugin.cpp' | |||
1438 | --- plugins/brightness/plugin.cpp 2016-11-04 18:56:02 +0000 | |||
1439 | +++ plugins/brightness/plugin.cpp 2016-11-04 18:56:02 +0000 | |||
1440 | @@ -43,8 +43,8 @@ | |||
1441 | 43 | qmlRegisterType<Device>(uri, 1, 0, "AethercastDevice"); | 43 | qmlRegisterType<Device>(uri, 1, 0, "AethercastDevice"); |
1442 | 44 | qmlRegisterType<Displays>(uri, 1, 0, "AethercastDisplays"); | 44 | qmlRegisterType<Displays>(uri, 1, 0, "AethercastDisplays"); |
1443 | 45 | 45 | ||
1446 | 46 | qmlRegisterType<DisplayModel>(uri, 1, 0, "DisplayModel"); | 46 | qmlRegisterType<DisplayPlugin::DisplayModel>(uri, 1, 0, "DisplayModel"); |
1447 | 47 | qmlRegisterType<Display>(uri, 1, 0, "Display"); | 47 | qmlRegisterUncreatableType<DisplayPlugin::Display>(uri, 1, 0, "Display", "Use UbuntuBrightnessPanel."); |
1448 | 48 | } | 48 | } |
1449 | 49 | 49 | ||
1450 | 50 | void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | 50 | void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
1451 | 51 | 51 | ||
1452 | === modified file 'plugins/brightness/plugin/brightness-plugin.cpp' | |||
1453 | --- plugins/brightness/plugin/brightness-plugin.cpp 2016-04-27 16:55:42 +0000 | |||
1454 | +++ plugins/brightness/plugin/brightness-plugin.cpp 2016-11-04 18:56:02 +0000 | |||
1455 | @@ -48,24 +48,8 @@ | |||
1456 | 48 | BrightnessItem::BrightnessItem(const QVariantMap &staticData, QObject *parent): | 48 | BrightnessItem::BrightnessItem(const QVariantMap &staticData, QObject *parent): |
1457 | 49 | ItemBase(staticData, parent) | 49 | ItemBase(staticData, parent) |
1458 | 50 | { | 50 | { |
1477 | 51 | QDBusInterface m_powerdIface ("com.canonical.powerd", | 51 | setVisibility(true); |
1478 | 52 | "/com/canonical/powerd", | 52 | setDisplayName(_("Brightness")); |
1461 | 53 | "com.canonical.powerd", | ||
1462 | 54 | QDBusConnection::systemBus()); | ||
1463 | 55 | |||
1464 | 56 | // Hide the plugin if powerd isn't running; it's currently redundant | ||
1465 | 57 | setVisibility(m_powerdIface.isValid()); | ||
1466 | 58 | |||
1467 | 59 | char widi[PROP_VALUE_MAX] = ""; | ||
1468 | 60 | property_get("ubuntu.widi.supported", widi, "0"); | ||
1469 | 61 | // We want to log this property to help aid debugging | ||
1470 | 62 | qWarning() << Q_FUNC_INFO << "ubuntu.widi.supported:" << widi; | ||
1471 | 63 | |||
1472 | 64 | if (strcmp(widi, "0") == 0) { | ||
1473 | 65 | setDisplayName(_("Brightness")); | ||
1474 | 66 | } else { | ||
1475 | 67 | setDisplayName(_("Brightness & Display")); | ||
1476 | 68 | } | ||
1479 | 69 | } | 53 | } |
1480 | 70 | 54 | ||
1481 | 71 | void BrightnessItem::setDisplayName(const QString &name) | 55 | void BrightnessItem::setDisplayName(const QString &name) |
1482 | 72 | 56 | ||
1483 | === modified file 'tests/mocks/Ubuntu/SystemSettings/Brightness/CMakeLists.txt' | |||
1484 | --- tests/mocks/Ubuntu/SystemSettings/Brightness/CMakeLists.txt 2016-11-04 18:56:02 +0000 | |||
1485 | +++ tests/mocks/Ubuntu/SystemSettings/Brightness/CMakeLists.txt 2016-11-04 18:56:02 +0000 | |||
1486 | @@ -1,7 +1,10 @@ | |||
1487 | 1 | pkg_search_module(MIR REQUIRED mirclient) | ||
1488 | 2 | |||
1489 | 1 | include_directories( | 3 | include_directories( |
1490 | 2 | ${CMAKE_CURRENT_BINARY_DIR} | 4 | ${CMAKE_CURRENT_BINARY_DIR} |
1491 | 3 | ${CMAKE_SOURCE_DIR}/plugins/brightness/ | 5 | ${CMAKE_SOURCE_DIR}/plugins/brightness/ |
1492 | 4 | ${CMAKE_SOURCE_DIR}/plugins/brightness/displays | 6 | ${CMAKE_SOURCE_DIR}/plugins/brightness/displays |
1493 | 7 | ${MIR_INCLUDE_DIRS} | ||
1494 | 5 | ) | 8 | ) |
1495 | 6 | 9 | ||
1496 | 7 | set(MOCK_BRIGHTNESS_SRCS | 10 | set(MOCK_BRIGHTNESS_SRCS |
1497 | @@ -10,18 +13,14 @@ | |||
1498 | 10 | MockAethercastDisplays.cpp | 13 | MockAethercastDisplays.cpp |
1499 | 11 | MockBrightness.cpp | 14 | MockBrightness.cpp |
1500 | 12 | 15 | ||
1501 | 13 | ${CMAKE_SOURCE_DIR}/plugins/brightness/displays/display.h | ||
1502 | 14 | ${CMAKE_SOURCE_DIR}/plugins/brightness/displays/displaymodel.h | ||
1503 | 15 | MockDisplay.h | 16 | MockDisplay.h |
1504 | 16 | MockDisplayModel.h | 17 | MockDisplayModel.h |
1505 | 17 | ${CMAKE_SOURCE_DIR}/plugins/brightness/displays/display.cpp | ||
1506 | 18 | ${CMAKE_SOURCE_DIR}/plugins/brightness/displays/displaymodel.cpp | ||
1507 | 19 | plugin.cpp | 18 | plugin.cpp |
1508 | 20 | ) | 19 | ) |
1509 | 21 | 20 | ||
1510 | 22 | add_library(MockBrightnessPanel MODULE ${MOCK_BRIGHTNESS_SRCS}) | 21 | add_library(MockBrightnessPanel MODULE ${MOCK_BRIGHTNESS_SRCS}) |
1511 | 23 | 22 | ||
1513 | 24 | target_link_libraries(MockBrightnessPanel) | 23 | target_link_libraries(MockBrightnessPanel ${MIR_LDFLAGS} uss-displays) |
1514 | 25 | qt5_use_modules(MockBrightnessPanel Qml Quick Core) | 24 | qt5_use_modules(MockBrightnessPanel Qml Quick Core) |
1515 | 26 | 25 | ||
1516 | 27 | add_uss_mock(Ubuntu.SystemSettings.Brightness 1.0 Ubuntu/SystemSettings/Brightness | 26 | add_uss_mock(Ubuntu.SystemSettings.Brightness 1.0 Ubuntu/SystemSettings/Brightness |
1517 | 28 | 27 | ||
1518 | === modified file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.cpp' | |||
1519 | --- tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.cpp 2016-11-04 18:56:02 +0000 | |||
1520 | +++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.cpp 2016-11-04 18:56:02 +0000 | |||
1521 | @@ -27,6 +27,9 @@ | |||
1522 | 27 | { | 27 | { |
1523 | 28 | m_changedDisplays.filterOnUncommittedChanges(true); | 28 | m_changedDisplays.filterOnUncommittedChanges(true); |
1524 | 29 | m_changedDisplays.setSourceModel(&m_displays); | 29 | m_changedDisplays.setSourceModel(&m_displays); |
1525 | 30 | |||
1526 | 31 | m_connectedDisplays.filterOnConnected(true); | ||
1527 | 32 | m_connectedDisplays.setSourceModel(&m_displays); | ||
1528 | 30 | } | 33 | } |
1529 | 31 | 34 | ||
1530 | 32 | bool MockBrightness::getPowerdRunning() const | 35 | bool MockBrightness::getPowerdRunning() const |
1531 | @@ -76,9 +79,16 @@ | |||
1532 | 76 | return ret; | 79 | return ret; |
1533 | 77 | } | 80 | } |
1534 | 78 | 81 | ||
1535 | 82 | QAbstractItemModel* MockBrightness::connectedDisplays() | ||
1536 | 83 | { | ||
1537 | 84 | auto ret = &m_connectedDisplays; | ||
1538 | 85 | QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership); | ||
1539 | 86 | return ret; | ||
1540 | 87 | } | ||
1541 | 88 | |||
1542 | 79 | void MockBrightness::applyDisplayConfiguration() | 89 | void MockBrightness::applyDisplayConfiguration() |
1543 | 80 | { | 90 | { |
1545 | 81 | 91 | Q_EMIT applied(); | |
1546 | 82 | } | 92 | } |
1547 | 83 | 93 | ||
1548 | 84 | MockDisplayModel* MockBrightness::displayModel() | 94 | MockDisplayModel* MockBrightness::displayModel() |
1549 | 85 | 95 | ||
1550 | === modified file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.h' | |||
1551 | --- tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.h 2016-11-04 18:56:02 +0000 | |||
1552 | +++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.h 2016-11-04 18:56:02 +0000 | |||
1553 | @@ -43,6 +43,9 @@ | |||
1554 | 43 | Q_PROPERTY (QAbstractItemModel* changedDisplays | 43 | Q_PROPERTY (QAbstractItemModel* changedDisplays |
1555 | 44 | READ changedDisplays | 44 | READ changedDisplays |
1556 | 45 | CONSTANT) | 45 | CONSTANT) |
1557 | 46 | Q_PROPERTY (QAbstractItemModel* connectedDisplays | ||
1558 | 47 | READ connectedDisplays | ||
1559 | 48 | CONSTANT) | ||
1560 | 46 | 49 | ||
1561 | 47 | public: | 50 | public: |
1562 | 48 | explicit MockBrightness(QObject *parent = 0); | 51 | explicit MockBrightness(QObject *parent = 0); |
1563 | @@ -54,20 +57,23 @@ | |||
1564 | 54 | Q_INVOKABLE void setWidiSupported(const bool supported); | 57 | Q_INVOKABLE void setWidiSupported(const bool supported); |
1565 | 55 | QAbstractItemModel* allDisplays(); | 58 | QAbstractItemModel* allDisplays(); |
1566 | 56 | QAbstractItemModel* changedDisplays(); | 59 | QAbstractItemModel* changedDisplays(); |
1567 | 60 | QAbstractItemModel* connectedDisplays(); | ||
1568 | 57 | Q_INVOKABLE void applyDisplayConfiguration(); | 61 | Q_INVOKABLE void applyDisplayConfiguration(); |
1569 | 58 | Q_INVOKABLE MockDisplayModel* displayModel(); // mock only | 62 | Q_INVOKABLE MockDisplayModel* displayModel(); // mock only |
1570 | 59 | 63 | ||
1571 | 60 | Q_SIGNALS: | 64 | Q_SIGNALS: |
1575 | 61 | void powerdRunningChanged(); // mock only | 65 | void powerdRunningChanged(); |
1576 | 62 | void autoBrightnessAvailableChanged(); // mock only | 66 | void autoBrightnessAvailableChanged(); |
1577 | 63 | void widiSupportedChanged(); // mock only | 67 | void widiSupportedChanged(); |
1578 | 68 | void applied(); // mock only | ||
1579 | 64 | 69 | ||
1580 | 65 | private: | 70 | private: |
1581 | 66 | bool m_powerdRunning = false; | 71 | bool m_powerdRunning = false; |
1582 | 67 | bool m_autoBrightnessAvailable = false; | 72 | bool m_autoBrightnessAvailable = false; |
1583 | 68 | bool m_widiSupported = false; | 73 | bool m_widiSupported = false; |
1584 | 69 | MockDisplayModel m_displays; | 74 | MockDisplayModel m_displays; |
1586 | 70 | DisplaysFilter m_changedDisplays; | 75 | DisplayPlugin::DisplaysFilter m_changedDisplays; |
1587 | 76 | DisplayPlugin::DisplaysFilter m_connectedDisplays; | ||
1588 | 71 | }; | 77 | }; |
1589 | 72 | 78 | ||
1590 | 73 | #endif // MOCK_BRIGHTNESS_H | 79 | #endif // MOCK_BRIGHTNESS_H |
1591 | 74 | 80 | ||
1592 | === modified file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplay.h' | |||
1593 | --- tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplay.h 2016-11-04 18:56:02 +0000 | |||
1594 | +++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplay.h 2016-11-04 18:56:02 +0000 | |||
1595 | @@ -6,7 +6,8 @@ | |||
1596 | 6 | #include <QObject> | 6 | #include <QObject> |
1597 | 7 | #include <QDebug> | 7 | #include <QDebug> |
1598 | 8 | 8 | ||
1600 | 9 | struct MockDisplay : public Display | 9 | |
1601 | 10 | struct MockDisplay : public DisplayPlugin::Display | ||
1602 | 10 | { | 11 | { |
1603 | 11 | Q_OBJECT | 12 | Q_OBJECT |
1604 | 12 | public: | 13 | public: |
1605 | @@ -22,31 +23,49 @@ | |||
1606 | 22 | Q_EMIT typeChanged(); | 23 | Q_EMIT typeChanged(); |
1607 | 23 | } | 24 | } |
1608 | 24 | 25 | ||
1609 | 26 | Q_INVOKABLE void setEnabled(const bool &enabled) // mock only | ||
1610 | 27 | { | ||
1611 | 28 | m_enabled = enabled; | ||
1612 | 29 | Q_EMIT enabledChanged(); | ||
1613 | 30 | } | ||
1614 | 31 | |||
1615 | 25 | Q_INVOKABLE void setConnected(const bool &connected) // mock only | 32 | Q_INVOKABLE void setConnected(const bool &connected) // mock only |
1616 | 26 | { | 33 | { |
1617 | 27 | m_connected = connected; | 34 | m_connected = connected; |
1618 | 28 | Q_EMIT connectedChanged(); | 35 | Q_EMIT connectedChanged(); |
1619 | 29 | } | 36 | } |
1620 | 30 | 37 | ||
1621 | 31 | Q_INVOKABLE void setAvailableModes(const QStringList &availableModes) // mock only | ||
1622 | 32 | { | ||
1623 | 33 | m_availableModes = availableModes; | ||
1624 | 34 | Q_EMIT availableModesChanged(); | ||
1625 | 35 | } | ||
1626 | 36 | |||
1627 | 37 | Q_INVOKABLE void setUncommitedChanges(const bool uncommittedChanges) // mock only | 38 | Q_INVOKABLE void setUncommitedChanges(const bool uncommittedChanges) // mock only |
1628 | 38 | { | 39 | { |
1629 | 39 | m_uncommittedChanges = uncommittedChanges; | 40 | m_uncommittedChanges = uncommittedChanges; |
1630 | 40 | Q_EMIT uncommittedChangesChanged(); | 41 | Q_EMIT uncommittedChangesChanged(); |
1631 | 41 | } | 42 | } |
1632 | 42 | 43 | ||
1638 | 43 | Q_INVOKABLE void addMode(const QString &mode) // mock only | 44 | // Return at what index the new mode was placed. |
1639 | 44 | { | 45 | Q_INVOKABLE uint addMode(const uint &horizontal, const uint &vertical, |
1640 | 45 | m_availableModes.append(mode); | 46 | const uint &refresh) // mock only |
1641 | 46 | Q_EMIT availableModesChanged(); | 47 | { |
1642 | 47 | } | 48 | DisplayPlugin::DisplayMode mode; |
1643 | 49 | mode.vertical_resolution = vertical; | ||
1644 | 50 | mode.horizontal_resolution = horizontal; | ||
1645 | 51 | mode.refresh_rate = refresh; | ||
1646 | 52 | |||
1647 | 53 | m_modes.append(mode); | ||
1648 | 54 | Q_EMIT modesChanged(); | ||
1649 | 55 | return m_modes.indexOf(mode); | ||
1650 | 56 | } | ||
1651 | 57 | |||
1652 | 58 | // Mark a display as unchanged, and save the current config. | ||
1653 | 59 | Q_INVOKABLE void save() | ||
1654 | 60 | { | ||
1655 | 61 | storeConfiguration(); | ||
1656 | 62 | setUncommitedChanges(false); | ||
1657 | 63 | } | ||
1658 | 64 | Q_SIGNALS: | ||
1659 | 65 | void nameChanged(); | ||
1660 | 66 | void typeChanged(); | ||
1661 | 48 | }; | 67 | }; |
1662 | 49 | 68 | ||
1664 | 50 | Q_DECLARE_METATYPE(MockDisplay*) | 69 | // Q_DECLARE_METATYPE(MockDisplay*) |
1665 | 51 | 70 | ||
1666 | 52 | #endif // MOCK_DISPLAY_H | 71 | #endif // MOCK_DISPLAY_H |
1667 | 53 | 72 | ||
1668 | === modified file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplayModel.h' | |||
1669 | --- tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplayModel.h 2016-11-04 18:56:02 +0000 | |||
1670 | +++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplayModel.h 2016-11-04 18:56:02 +0000 | |||
1671 | @@ -7,12 +7,12 @@ | |||
1672 | 7 | #include <QObject> | 7 | #include <QObject> |
1673 | 8 | #include <QQmlEngine> | 8 | #include <QQmlEngine> |
1674 | 9 | 9 | ||
1676 | 10 | class MockDisplayModel : public DisplayModel | 10 | class MockDisplayModel : public DisplayPlugin::DisplayModel |
1677 | 11 | { | 11 | { |
1678 | 12 | Q_OBJECT | 12 | Q_OBJECT |
1679 | 13 | public: | 13 | public: |
1682 | 14 | MockDisplayModel(QObject *parent = 0) : DisplayModel(parent) { | 14 | MockDisplayModel(QObject *parent = 0) |
1683 | 15 | }; | 15 | : DisplayPlugin::DisplayModel(parent) {}; |
1684 | 16 | ~MockDisplayModel() {}; | 16 | ~MockDisplayModel() {}; |
1685 | 17 | Q_INVOKABLE MockDisplay* mockAddDisplay() // mock only | 17 | Q_INVOKABLE MockDisplay* mockAddDisplay() // mock only |
1686 | 18 | { | 18 | { |
1687 | 19 | 19 | ||
1688 | === modified file 'tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.cpp' | |||
1689 | --- tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.cpp 2016-11-04 18:56:02 +0000 | |||
1690 | +++ tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.cpp 2016-11-04 18:56:02 +0000 | |||
1691 | @@ -34,6 +34,7 @@ | |||
1692 | 34 | qmlRegisterType<MockAethercastDevice>(uri, 1, 0, "AethercastDevice"); | 34 | qmlRegisterType<MockAethercastDevice>(uri, 1, 0, "AethercastDevice"); |
1693 | 35 | qmlRegisterType<MockAethercastDisplays>(uri, 1, 0, "AethercastDisplays"); | 35 | qmlRegisterType<MockAethercastDisplays>(uri, 1, 0, "AethercastDisplays"); |
1694 | 36 | 36 | ||
1695 | 37 | qmlRegisterUncreatableType<MockDisplay>(uri, 1, 0, "Display", "Not to be instantiated directly."); | ||
1696 | 38 | qmlRegisterType<MockDisplayModel>(uri, 1, 0, "DisplayModel"); | 37 | qmlRegisterType<MockDisplayModel>(uri, 1, 0, "DisplayModel"); |
1697 | 38 | qmlRegisterUncreatableType<MockDisplay>(uri, 1, 0, "Display", | ||
1698 | 39 | "Not to be instantiated directly."); | ||
1699 | 39 | } | 40 | } |
1700 | 40 | 41 | ||
1701 | === added file 'tests/mocks/plugins/brightness/fakemirclient.h' | |||
1702 | --- tests/mocks/plugins/brightness/fakemirclient.h 1970-01-01 00:00:00 +0000 | |||
1703 | +++ tests/mocks/plugins/brightness/fakemirclient.h 2016-11-04 18:56:02 +0000 | |||
1704 | @@ -0,0 +1,36 @@ | |||
1705 | 1 | #ifndef FAKEMIRCLIENT_H | ||
1706 | 2 | #define FAKEMIRCLIENT_H | ||
1707 | 3 | |||
1708 | 4 | #include "mirclient.h" | ||
1709 | 5 | |||
1710 | 6 | #include <mir_toolkit/mir_client_library.h> | ||
1711 | 7 | #include <QObject> | ||
1712 | 8 | |||
1713 | 9 | class FakeMirClient : public DisplayPlugin::MirClient | ||
1714 | 10 | { | ||
1715 | 11 | Q_OBJECT | ||
1716 | 12 | public: | ||
1717 | 13 | explicit FakeMirClient(QObject *parent = 0) | ||
1718 | 14 | : DisplayPlugin::MirClient(parent) {} | ||
1719 | 15 | virtual ~FakeMirClient() {} | ||
1720 | 16 | virtual MirDisplayConfiguration* getConfiguration() const override | ||
1721 | 17 | { | ||
1722 | 18 | |||
1723 | 19 | } | ||
1724 | 20 | virtual void setConfiguration(MirDisplayConfiguration *conf) override | ||
1725 | 21 | { | ||
1726 | 22 | |||
1727 | 23 | } | ||
1728 | 24 | virtual bool applyConfiguration(MirDisplayConfiguration *conf) override | ||
1729 | 25 | { | ||
1730 | 26 | |||
1731 | 27 | } | ||
1732 | 28 | virtual bool isConnected() override | ||
1733 | 29 | { | ||
1734 | 30 | return connected; | ||
1735 | 31 | } | ||
1736 | 32 | |||
1737 | 33 | bool connected = false; | ||
1738 | 34 | }; | ||
1739 | 35 | |||
1740 | 36 | #endif // FAKEMIRCLIENT_H | ||
1741 | 0 | 37 | ||
1742 | === modified file 'tests/plugins/CMakeLists.txt' | |||
1743 | --- tests/plugins/CMakeLists.txt 2016-11-04 18:56:02 +0000 | |||
1744 | +++ tests/plugins/CMakeLists.txt 2016-11-04 18:56:02 +0000 | |||
1745 | @@ -4,6 +4,7 @@ | |||
1746 | 4 | add_subdirectory(security-privacy) | 4 | add_subdirectory(security-privacy) |
1747 | 5 | add_subdirectory(system-update) | 5 | add_subdirectory(system-update) |
1748 | 6 | add_subdirectory(bluetooth) | 6 | add_subdirectory(bluetooth) |
1749 | 7 | add_subdirectory(brightness) | ||
1750 | 7 | add_subdirectory(wifi) | 8 | add_subdirectory(wifi) |
1751 | 8 | add_subdirectory(notifications) | 9 | add_subdirectory(notifications) |
1752 | 9 | 10 | ||
1753 | 10 | 11 | ||
1754 | === added file 'tests/plugins/brightness/CMakeLists.txt' | |||
1755 | --- tests/plugins/brightness/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1756 | +++ tests/plugins/brightness/CMakeLists.txt 2016-11-04 18:56:02 +0000 | |||
1757 | @@ -0,0 +1,25 @@ | |||
1758 | 1 | include_directories( | ||
1759 | 2 | ${CMAKE_CURRENT_BINARY_DIR} | ||
1760 | 3 | ${CMAKE_SOURCE_DIR}/plugins/brightness | ||
1761 | 4 | ${CMAKE_SOURCE_DIR}/plugins/brightness/displays | ||
1762 | 5 | ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/brightness | ||
1763 | 6 | ${QTDBUSMOCK_INCLUDE_DIRS} | ||
1764 | 7 | # ${QTDBUSTEST_INCLUDE_DIRS} | ||
1765 | 8 | ${MIR_INCLUDE_DIRS} | ||
1766 | 9 | ${ANDR_PROP_INCLUDE_DIRS} | ||
1767 | 10 | ) | ||
1768 | 11 | |||
1769 | 12 | pkg_search_module(MIR REQUIRED mirclient) | ||
1770 | 13 | find_package(Qt5Test REQUIRED) | ||
1771 | 14 | find_package(Qt5DBus REQUIRED) | ||
1772 | 15 | |||
1773 | 16 | #set(CMAKE_AUTOMOC ON) | ||
1774 | 17 | #set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
1775 | 18 | set(PLUGIN_LIBS uss-displays Qt5::Test Qt5::DBus) | ||
1776 | 19 | |||
1777 | 20 | add_executable(tst-brightness | ||
1778 | 21 | ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/brightness/fakemirclient.h | ||
1779 | 22 | tst_brightness.cpp | ||
1780 | 23 | ${CMAKE_SOURCE_DIR}/plugins/brightness/brightness.cpp) | ||
1781 | 24 | add_test(tst-brightness tst-brightness) | ||
1782 | 25 | target_link_libraries(tst-brightness ${PLUGIN_LIBS} ${ANDR_PROP_LDFLAGS} ${QTDBUSMOCK_LIBRARIES} ${QTDBUSTEST_LIBRARIES}) | ||
1783 | 0 | 26 | ||
1784 | === modified file 'tests/plugins/brightness/tst_BrightnessPageComponent.qml' | |||
1785 | --- tests/plugins/brightness/tst_BrightnessPageComponent.qml 2016-11-04 18:56:02 +0000 | |||
1786 | +++ tests/plugins/brightness/tst_BrightnessPageComponent.qml 2016-11-04 18:56:02 +0000 | |||
1787 | @@ -87,25 +87,113 @@ | |||
1788 | 87 | compare(entry.value, i18n.tr("Not connected")); | 87 | compare(entry.value, i18n.tr("Not connected")); |
1789 | 88 | } | 88 | } |
1790 | 89 | 89 | ||
1793 | 90 | // Test that everything is hidden if only aethercast devices (or none) | 90 | function test_no_mir_displays() { |
1792 | 91 | function test_no_displays() { | ||
1794 | 92 | var repeater = findChild(instance, "displayConfigurationRepeater"); | 91 | var repeater = findChild(instance, "displayConfigurationRepeater"); |
1795 | 93 | compare(repeater.count, 0); | 92 | compare(repeater.count, 0); |
1796 | 94 | } | 93 | } |
1797 | 95 | 94 | ||
1800 | 96 | // Test that there's a UI when we have some display available. | 95 | function test_one_mir_display() { |
1799 | 97 | function test_one_display() { | ||
1801 | 98 | var displayModel = get_panel_plugin().displayModel(); | 96 | var displayModel = get_panel_plugin().displayModel(); |
1802 | 99 | var display = displayModel.mockAddDisplay(); | 97 | var display = displayModel.mockAddDisplay(); |
1808 | 100 | display.setName("Foo") | 98 | display.setConnected(true); |
1804 | 101 | display.addMode("1600x1200x60") | ||
1805 | 102 | display.addMode("1280x1024x60") | ||
1806 | 103 | display.mode = "1600x1200x60" | ||
1807 | 104 | |||
1809 | 105 | var repeater = findChild(instance, "displayConfigurationRepeater"); | 99 | var repeater = findChild(instance, "displayConfigurationRepeater"); |
1810 | 106 | var panel = findChild(instance, "displayConfiguration_" + display.name); | ||
1811 | 107 | verify(panel.visible); | ||
1812 | 108 | compare(repeater.count, 1); | 100 | compare(repeater.count, 1); |
1813 | 109 | } | 101 | } |
1814 | 110 | } | 102 | } |
1815 | 103 | |||
1816 | 104 | |||
1817 | 105 | UbuntuTestCase { | ||
1818 | 106 | name: "BrightnessPageComponent for one Mir display" | ||
1819 | 107 | when: windowShown | ||
1820 | 108 | |||
1821 | 109 | SignalSpy { | ||
1822 | 110 | id: signalSpy | ||
1823 | 111 | signalName: "" | ||
1824 | 112 | target: null | ||
1825 | 113 | } | ||
1826 | 114 | |||
1827 | 115 | property var instance: null | ||
1828 | 116 | property var display: null | ||
1829 | 117 | |||
1830 | 118 | function init() { | ||
1831 | 119 | instance = pageComponent.createObject(testRoot, {}); | ||
1832 | 120 | var displayModel = get_panel_plugin().displayModel(); | ||
1833 | 121 | display = displayModel.mockAddDisplay(); | ||
1834 | 122 | display.setConnected(true); | ||
1835 | 123 | display.setName("test"); | ||
1836 | 124 | display.save(); | ||
1837 | 125 | } | ||
1838 | 126 | |||
1839 | 127 | function cleanup() { | ||
1840 | 128 | instance.destroy(); | ||
1841 | 129 | signalSpy.target = null; | ||
1842 | 130 | } | ||
1843 | 131 | |||
1844 | 132 | function get_panel_plugin() { | ||
1845 | 133 | return findInvisibleChild(instance, "brightnessPanel"); | ||
1846 | 134 | } | ||
1847 | 135 | |||
1848 | 136 | function test_no_changes_disables_apply() { | ||
1849 | 137 | var obj = findChild(instance, "applyButton"); | ||
1850 | 138 | verify(!obj.enabled); | ||
1851 | 139 | } | ||
1852 | 140 | |||
1853 | 141 | function test_a_change_enables_apply() { | ||
1854 | 142 | var obj = findChild(instance, "enabledSwitch"); | ||
1855 | 143 | var apply = findChild(instance, "applyButton"); | ||
1856 | 144 | mouseClick(obj, obj.width / 2, obj.height / 2); | ||
1857 | 145 | } | ||
1858 | 146 | |||
1859 | 147 | function test_apply() { | ||
1860 | 148 | signalSpy.target = get_panel_plugin(); | ||
1861 | 149 | signalSpy.signalName = "applied"; | ||
1862 | 150 | |||
1863 | 151 | display.setEnabled(true); | ||
1864 | 152 | var obj = findChild(instance, "applyButton"); | ||
1865 | 153 | mouseClick(obj, obj.width / 2, obj.height / 2); | ||
1866 | 154 | |||
1867 | 155 | signalSpy.wait(); | ||
1868 | 156 | } | ||
1869 | 157 | |||
1870 | 158 | function test_default_rotation() { | ||
1871 | 159 | var obj = findChild(instance, "rotationSelector"); | ||
1872 | 160 | compare(obj.selectedIndex, 0); | ||
1873 | 161 | } | ||
1874 | 162 | |||
1875 | 163 | function test_other_rotation() { | ||
1876 | 164 | display.orientation = 1; | ||
1877 | 165 | var obj = findChild(instance, "rotationSelector"); | ||
1878 | 166 | compare(obj.selectedIndex, 1); | ||
1879 | 167 | } | ||
1880 | 168 | |||
1881 | 169 | function test_change_rotation() { | ||
1882 | 170 | var obj = findChild(instance, "rotationSelector"); | ||
1883 | 171 | obj.delegateClicked(2); | ||
1884 | 172 | compare(display.orientation, 2); | ||
1885 | 173 | } | ||
1886 | 174 | |||
1887 | 175 | function test_one_resolution() { | ||
1888 | 176 | display.mode = display.addMode(1024, 768, 60); | ||
1889 | 177 | var obj = findChild(instance, "resolutionLabel"); | ||
1890 | 178 | var res = i18n.tr("%1×%2 @ %3hz").arg(1024).arg(768).arg(60); | ||
1891 | 179 | compare(obj.text, i18n.tr("Resolution: %1").arg(res)); | ||
1892 | 180 | } | ||
1893 | 181 | |||
1894 | 182 | function test_many_resolutions() { | ||
1895 | 183 | display.addMode(1024, 768, 60); | ||
1896 | 184 | display.addMode(640, 320, 40); | ||
1897 | 185 | display.mode = 1; | ||
1898 | 186 | var obj = findChild(instance, "resolutionSelector"); | ||
1899 | 187 | compare(obj.selectedIndex, 1); | ||
1900 | 188 | } | ||
1901 | 189 | |||
1902 | 190 | function test_change_resolution() { | ||
1903 | 191 | display.addMode(1024, 768, 60); | ||
1904 | 192 | display.addMode(640, 320, 40); | ||
1905 | 193 | display.mode = 1; | ||
1906 | 194 | var obj = findChild(instance, "resolutionSelector"); | ||
1907 | 195 | obj.delegateClicked(0); | ||
1908 | 196 | compare(display.mode, 0); | ||
1909 | 197 | } | ||
1910 | 198 | } | ||
1911 | 111 | } | 199 | } |
1912 | 112 | 200 | ||
1913 | === added file 'tests/plugins/brightness/tst_brightness.cpp' | |||
1914 | --- tests/plugins/brightness/tst_brightness.cpp 1970-01-01 00:00:00 +0000 | |||
1915 | +++ tests/plugins/brightness/tst_brightness.cpp 2016-11-04 18:56:02 +0000 | |||
1916 | @@ -0,0 +1,41 @@ | |||
1917 | 1 | #include "brightness.h" | ||
1918 | 2 | #include "fakemirclient.h" | ||
1919 | 3 | |||
1920 | 4 | #include <QSignalSpy> | ||
1921 | 5 | #include <QTest> | ||
1922 | 6 | |||
1923 | 7 | using namespace DisplayPlugin; | ||
1924 | 8 | |||
1925 | 9 | class TstBrightness : public QObject | ||
1926 | 10 | { | ||
1927 | 11 | Q_OBJECT | ||
1928 | 12 | private slots: | ||
1929 | 13 | void initTestCase() | ||
1930 | 14 | { | ||
1931 | 15 | } | ||
1932 | 16 | void cleanupTestCase() | ||
1933 | 17 | { | ||
1934 | 18 | } | ||
1935 | 19 | void init() | ||
1936 | 20 | { | ||
1937 | 21 | m_mirClient = new FakeMirClient(); | ||
1938 | 22 | m_instance = new Brightness(QDBusConnection::systemBus(), m_mirClient); | ||
1939 | 23 | } | ||
1940 | 24 | void cleanup() | ||
1941 | 25 | { | ||
1942 | 26 | QSignalSpy destroyedSpy(m_instance, SIGNAL(destroyed(QObject*))); | ||
1943 | 27 | m_instance->deleteLater(); | ||
1944 | 28 | QTRY_COMPARE(destroyedSpy.count(), 1); | ||
1945 | 29 | } | ||
1946 | 30 | void test_foo() | ||
1947 | 31 | { | ||
1948 | 32 | |||
1949 | 33 | } | ||
1950 | 34 | private: | ||
1951 | 35 | MirClient *m_mirClient = nullptr; | ||
1952 | 36 | Brightness *m_instance = nullptr; | ||
1953 | 37 | }; | ||
1954 | 38 | |||
1955 | 39 | QTEST_GUILESS_MAIN(TstBrightness) | ||
1956 | 40 | #include "tst_brightness.moc" | ||
1957 | 41 | |||
1958 | 0 | 42 | ||
1959 | === added file 'tests/plugins/brightness/tst_displayplugin_display.cpp' | |||
1960 | === added file 'tests/plugins/brightness/tst_displayplugin_displaymodel.cpp' | |||
1961 | --- tests/plugins/brightness/tst_displayplugin_displaymodel.cpp 1970-01-01 00:00:00 +0000 | |||
1962 | +++ tests/plugins/brightness/tst_displayplugin_displaymodel.cpp 2016-11-04 18:56:02 +0000 | |||
1963 | @@ -0,0 +1,32 @@ | |||
1964 | 1 | #include <QSignalSpy> | ||
1965 | 2 | #include <QTest> | ||
1966 | 3 | |||
1967 | 4 | using namespace DisplayPlugin; | ||
1968 | 5 | |||
1969 | 6 | class TstDisplayModel : public QObject | ||
1970 | 7 | { | ||
1971 | 8 | Q_OBJECT | ||
1972 | 9 | private slots: | ||
1973 | 10 | void initTestCase() | ||
1974 | 11 | { | ||
1975 | 12 | } | ||
1976 | 13 | void cleanupTestCase() | ||
1977 | 14 | { | ||
1978 | 15 | } | ||
1979 | 16 | void init() | ||
1980 | 17 | { | ||
1981 | 18 | m_instance = nullptr; | ||
1982 | 19 | } | ||
1983 | 20 | void cleanup() | ||
1984 | 21 | { | ||
1985 | 22 | // QSignalSpy destroyedSpy(m_instance, SIGNAL(destroyed(QObject*))); | ||
1986 | 23 | // m_instance->deleteLater(); | ||
1987 | 24 | // QTRY_COMPARE(destroyedSpy.count(), 1); | ||
1988 | 25 | } | ||
1989 | 26 | private: | ||
1990 | 27 | QObject *m_instance = nullptr; | ||
1991 | 28 | }; | ||
1992 | 29 | |||
1993 | 30 | QTEST_GUILESS_MAIN(TstDisplayModel) | ||
1994 | 31 | #include "tst_displayplugin_displaymodel.moc" | ||
1995 | 32 |
FAILED: Continuous integration, rev:1739 /jenkins. canonical. com/system- apps/job/ lp-ubuntu- system- settings- ci/222/ /jenkins. canonical. com/system- apps/job/ build/1925/ console /jenkins. canonical. com/system- apps/job/ build-0- fetch/1926 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 1765/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1765 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1765/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 1765 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 1765/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 1765/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1765 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1765/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 1765 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 1765/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 1765/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1765 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1765/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= yakkety/ 1765/console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- apps/job/ lp-ubuntu- system- settings- ci/222/ rebuild
https:/