Merge lp:~mzanetti/unity8/focus-first-if-running-at-startup into lp:unity8
- focus-first-if-running-at-startup
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~mzanetti/unity8/focus-first-if-running-at-startup |
Merge into: | lp:unity8 |
Diff against target: |
744 lines (+385/-6) 17 files modified
plugins/Unity/Session/CMakeLists.txt (+7/-0) plugins/Unity/Session/orientationlock.cpp (+74/-0) plugins/Unity/Session/orientationlock.h (+62/-0) plugins/Unity/Session/plugin.cpp (+8/-4) qml/Shell.qml (+28/-0) qml/Stages/ApplicationWindow.qml (+2/-0) qml/Stages/PhoneStage.qml (+9/-0) qml/Stages/SessionContainer.qml (+7/-0) qml/Stages/SpreadDelegate.qml (+2/-0) qml/Stages/SurfaceContainer.qml (+5/-0) qml/Stages/TabletStage.qml (+8/-0) tests/mocks/Unity/Application/MirSurfaceItem.cpp (+14/-0) tests/mocks/Unity/Application/MirSurfaceItem.h (+7/-0) tests/mocks/Unity/Application/MirSurfaceItem.qml (+12/-2) tests/qmltests/Stages/tst_ApplicationWindow.qml (+19/-0) tests/qmltests/Stages/tst_PhoneStage.qml (+58/-0) tests/qmltests/Stages/tst_SessionContainer.qml (+63/-0) |
To merge this branch: | bzr merge lp:~mzanetti/unity8/focus-first-if-running-at-startup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Review via email: mp+234124@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-09-16.
Commit message
focus the first application if there are already some running when we start up.
In practice this should only happen for the dash and helps qtmir to keep track of the focused app.
Description of the change
* Are there any related MPs required for this MP to build/function as expected? Please list.
https:/
* Did you perform an exploratory manual test run of your code change and any related functionality?
yes
* Did you make sure that your branch does not contain spurious tags?
yes
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
no
* If you changed the UI, has there been a design review?
no
PS Jenkins bot (ps-jenkins) wrote : | # |
- 1260. By Michael Zanetti
-
merge orientation branch to get around conflicts
Unmerged revisions
Preview Diff
1 | === modified file 'plugins/Unity/Session/CMakeLists.txt' |
2 | --- plugins/Unity/Session/CMakeLists.txt 2014-06-13 13:13:16 +0000 |
3 | +++ plugins/Unity/Session/CMakeLists.txt 2014-09-16 08:46:18 +0000 |
4 | @@ -1,10 +1,16 @@ |
5 | +include(FindPkgConfig) |
6 | + |
7 | +pkg_search_module(GIO REQUIRED gio-2.0) |
8 | + |
9 | include_directories( |
10 | ${CMAKE_CURRENT_SOURCE_DIR} |
11 | + ${GIO_INCLUDE_DIRS} |
12 | ) |
13 | |
14 | set(QMLSESSIONPLUGIN_SRC |
15 | plugin.cpp |
16 | dbusunitysessionservice.cpp |
17 | + orientationlock.cpp |
18 | ) |
19 | |
20 | add_library(UnitySession-qml MODULE |
21 | @@ -12,6 +18,7 @@ |
22 | ) |
23 | |
24 | qt5_use_modules(UnitySession-qml DBus Qml) |
25 | +target_link_libraries(UnitySession-qml ${GIO_LDFLAGS}) |
26 | |
27 | # export the qmldir and qmltypes files |
28 | add_unity8_plugin(Unity.Session 0.1 Unity/Session TARGETS UnitySession-qml) |
29 | |
30 | === added file 'plugins/Unity/Session/orientationlock.cpp' |
31 | --- plugins/Unity/Session/orientationlock.cpp 1970-01-01 00:00:00 +0000 |
32 | +++ plugins/Unity/Session/orientationlock.cpp 2014-09-16 08:46:18 +0000 |
33 | @@ -0,0 +1,74 @@ |
34 | +/* |
35 | + * Copyright (C) 2014 Canonical, Ltd. |
36 | + * |
37 | + * This program is free software: you can redistribute it and/or modify it under |
38 | + * the terms of the GNU Lesser General Public License version 3, as published by |
39 | + * the Free Software Foundation. |
40 | + * |
41 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
42 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
43 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
44 | + * Lesser General Public License for more details. |
45 | + * |
46 | + * You should have received a copy of the GNU Lesser General Public License |
47 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
48 | + */ |
49 | + |
50 | +#include "orientationlock.h" |
51 | + |
52 | +#include <QDBusConnection> |
53 | +#include <QDBusInterface> |
54 | + |
55 | +OrientationLock::OrientationLock(QObject *parent) |
56 | + : QObject(parent) |
57 | + , m_enabled(false) |
58 | + , m_savedOrientation(Qt::PortraitOrientation) |
59 | +{ |
60 | + systemSettings = g_settings_new("com.ubuntu.touch.system"); |
61 | + g_signal_connect(systemSettings, "changed::rotation-lock", |
62 | + G_CALLBACK(OrientationLock::onEnabledChangedProxy), this); |
63 | + m_enabled = g_settings_get_boolean(systemSettings, "rotation-lock"); |
64 | +} |
65 | + |
66 | +OrientationLock::~OrientationLock() |
67 | +{ |
68 | + g_signal_handlers_disconnect_by_data(systemSettings, this); |
69 | + g_object_unref(systemSettings); |
70 | +} |
71 | + |
72 | +bool OrientationLock::enabled() const |
73 | +{ |
74 | + return m_enabled; |
75 | +} |
76 | + |
77 | +Qt::ScreenOrientation OrientationLock::savedOrientation() const |
78 | +{ |
79 | + return m_savedOrientation; |
80 | +} |
81 | + |
82 | +void OrientationLock::onEnabledChangedProxy(GSettings */*settings*/, const gchar */*key*/, gpointer data) |
83 | +{ |
84 | + OrientationLock* _this = static_cast<OrientationLock*>(data); |
85 | + _this->onEnabledChanged(); |
86 | +} |
87 | + |
88 | +void OrientationLock::onEnabledChanged() |
89 | +{ |
90 | + const bool enabled = g_settings_get_boolean(systemSettings, "rotation-lock"); |
91 | + if (m_enabled != enabled) { |
92 | + m_enabled = enabled; |
93 | + Q_EMIT enabledChanged(); |
94 | + } |
95 | +} |
96 | + |
97 | +void OrientationLock::setSavedOrientation(const Qt::ScreenOrientation orientation) |
98 | +{ |
99 | + if (orientation == m_savedOrientation) { |
100 | + return; |
101 | + } |
102 | + |
103 | + m_savedOrientation = orientation; |
104 | + |
105 | + //TODO - save value with dbus to persist over sessions |
106 | + Q_EMIT savedOrientationChanged(); |
107 | +} |
108 | |
109 | === added file 'plugins/Unity/Session/orientationlock.h' |
110 | --- plugins/Unity/Session/orientationlock.h 1970-01-01 00:00:00 +0000 |
111 | +++ plugins/Unity/Session/orientationlock.h 2014-09-16 08:46:18 +0000 |
112 | @@ -0,0 +1,62 @@ |
113 | +/* |
114 | + * Copyright (C) 2014 Canonical, Ltd. |
115 | + * |
116 | + * This program is free software: you can redistribute it and/or modify it under |
117 | + * the terms of the GNU Lesser General Public License version 3, as published by |
118 | + * the Free Software Foundation. |
119 | + * |
120 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
121 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
122 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
123 | + * Lesser General Public License for more details. |
124 | + * |
125 | + * You should have received a copy of the GNU Lesser General Public License |
126 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
127 | + */ |
128 | + |
129 | +#ifndef ORIENTATIONLOCK_H |
130 | +#define ORIENTATIONLOCK_H |
131 | + |
132 | +#include <gio/gio.h> |
133 | +#include <QtCore/QObject> |
134 | +#include <QtDBus/QDBusInterface> |
135 | + |
136 | +/** |
137 | + * @brief The OrientationLock class exports orientation lock related properties to QML |
138 | + * It has two properties: |
139 | + * - readonly boolean with the Orientation lock property state |
140 | + * - Qt::ScreenOrientation to save the locked orientation state across Sessions (only relevant if lock is true) |
141 | + */ |
142 | +class OrientationLock : public QObject |
143 | +{ |
144 | + Q_OBJECT |
145 | + |
146 | + Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged) |
147 | + Q_PROPERTY(Qt::ScreenOrientation savedOrientation READ savedOrientation WRITE setSavedOrientation |
148 | + NOTIFY savedOrientationChanged) |
149 | + |
150 | +public: |
151 | + explicit OrientationLock(QObject *parent = 0); |
152 | + ~OrientationLock(); |
153 | + |
154 | + bool enabled() const; |
155 | + Qt::ScreenOrientation savedOrientation() const; |
156 | + void setSavedOrientation(const Qt::ScreenOrientation orientation); |
157 | + |
158 | +Q_SIGNALS: |
159 | + void enabledChanged(); |
160 | + void savedOrientationChanged(); |
161 | + |
162 | +private Q_SLOTS: |
163 | + static void onEnabledChangedProxy(GSettings *settings, const gchar *key, gpointer data); |
164 | + void onEnabledChanged(); |
165 | + |
166 | +private: |
167 | + QDBusInterface *dbusInterface; |
168 | + GSettings *systemSettings; |
169 | + |
170 | + bool m_enabled; |
171 | + Qt::ScreenOrientation m_savedOrientation; |
172 | +}; |
173 | + |
174 | +#endif // ORIENTATIONLOCK_H |
175 | |
176 | === modified file 'plugins/Unity/Session/plugin.cpp' |
177 | --- plugins/Unity/Session/plugin.cpp 2014-05-07 15:21:51 +0000 |
178 | +++ plugins/Unity/Session/plugin.cpp 2014-09-16 08:46:18 +0000 |
179 | @@ -18,23 +18,27 @@ |
180 | |
181 | #include "plugin.h" |
182 | #include "dbusunitysessionservice.h" |
183 | +#include "orientationlock.h" |
184 | |
185 | #include <QAbstractItemModel> |
186 | #include <QDBusConnection> |
187 | #include <QtQml/qqml.h> |
188 | |
189 | -static QObject *dbusunitysessionservice_provider(QQmlEngine *engine, QJSEngine *scriptEngine) |
190 | +static QObject *dbusunitysessionservice_provider(QQmlEngine */*engine*/, QJSEngine */*jsEngine*/) |
191 | { |
192 | - Q_UNUSED(engine) |
193 | - Q_UNUSED(scriptEngine) |
194 | - |
195 | return new DBusUnitySessionService(); |
196 | } |
197 | |
198 | +static QObject *orientationlock_provider(QQmlEngine */*engine*/, QJSEngine */*jsEngine*/) |
199 | +{ |
200 | + return new OrientationLock(); |
201 | +} |
202 | + |
203 | void SessionPlugin::registerTypes(const char *uri) |
204 | { |
205 | qmlRegisterType<QAbstractItemModel>(); |
206 | |
207 | Q_ASSERT(uri == QLatin1String("Unity.Session")); |
208 | qmlRegisterSingletonType<DBusUnitySessionService>(uri, 0, 1, "DBusUnitySessionService", dbusunitysessionservice_provider); |
209 | + qmlRegisterSingletonType<OrientationLock>(uri, 0, 1, "OrientationLock", orientationlock_provider); |
210 | } |
211 | |
212 | === modified file 'qml/Shell.qml' |
213 | --- qml/Shell.qml 2014-09-08 14:15:51 +0000 |
214 | +++ qml/Shell.qml 2014-09-16 08:46:18 +0000 |
215 | @@ -15,6 +15,7 @@ |
216 | */ |
217 | |
218 | import QtQuick 2.0 |
219 | +import QtQuick.Window 2.0 |
220 | import AccountsService 0.1 |
221 | import GSettings 1.0 |
222 | import Unity.Application 0.1 |
223 | @@ -61,6 +62,22 @@ |
224 | property int failedLoginsDelayAttempts: 7 // number of failed logins |
225 | property int failedLoginsDelaySeconds: 5 * 60 // seconds of forced waiting |
226 | |
227 | + property int orientation |
228 | + readonly property int deviceOrientationAngle: Screen.angleBetween(Screen.primaryOrientation, Screen.orientation) |
229 | + onDeviceOrientationAngleChanged: { |
230 | + if (!OrientationLock.enabled) { |
231 | + orientation = Screen.orientation; |
232 | + } |
233 | + } |
234 | + readonly property bool orientationLockEnabled: OrientationLock.enabled |
235 | + onOrientationLockEnabledChanged: { |
236 | + if (orientationLockEnabled) { |
237 | + OrientationLock.savedOrientation = Screen.orientation; |
238 | + } else { |
239 | + orientation = Screen.orientation; |
240 | + } |
241 | + } |
242 | + |
243 | function activateApplication(appId) { |
244 | if (ApplicationManager.findApplication(appId)) { |
245 | ApplicationManager.requestFocusApplication(appId); |
246 | @@ -85,6 +102,12 @@ |
247 | |
248 | Component.onCompleted: { |
249 | Theme.name = "Ubuntu.Components.Themes.SuruGradient" |
250 | + if (ApplicationManager.count > 0) { |
251 | + ApplicationManager.focusApplication(ApplicationManager.get(0).appId); |
252 | + } |
253 | + if (orientationLockEnabled) { |
254 | + orientation = OrientationLock.savedOrientation; |
255 | + } |
256 | } |
257 | |
258 | GSettings { |
259 | @@ -207,6 +230,11 @@ |
260 | property: "inverseProgress" |
261 | value: launcher.progress |
262 | } |
263 | + Binding { |
264 | + target: applicationsDisplayLoader.item |
265 | + property: "orientation" |
266 | + value: shell.orientation |
267 | + } |
268 | } |
269 | } |
270 | |
271 | |
272 | === modified file 'qml/Stages/ApplicationWindow.qml' |
273 | --- qml/Stages/ApplicationWindow.qml 2014-09-03 16:38:10 +0000 |
274 | +++ qml/Stages/ApplicationWindow.qml 2014-09-16 08:46:18 +0000 |
275 | @@ -27,6 +27,7 @@ |
276 | |
277 | // to be set from outside |
278 | property QtObject application |
279 | + property int orientation |
280 | |
281 | QtObject { |
282 | id: d |
283 | @@ -111,6 +112,7 @@ |
284 | id: sessionContainer |
285 | session: application ? application.session : null |
286 | anchors.fill: parent |
287 | + orientation: root.orientation |
288 | |
289 | onSurfaceChanged: { |
290 | if (sessionContainer.surface) { |
291 | |
292 | === modified file 'qml/Stages/PhoneStage.qml' |
293 | --- qml/Stages/PhoneStage.qml 2014-09-02 14:57:05 +0000 |
294 | +++ qml/Stages/PhoneStage.qml 2014-09-16 08:46:18 +0000 |
295 | @@ -18,6 +18,7 @@ |
296 | import Ubuntu.Components 0.1 |
297 | import Ubuntu.Gestures 0.1 |
298 | import Unity.Application 0.1 |
299 | +import Unity.Session 0.1 |
300 | import Utils 0.1 |
301 | import "../Components" |
302 | |
303 | @@ -30,6 +31,7 @@ |
304 | property bool interactive |
305 | property bool spreadEnabled: true // If false, animations and right edge will be disabled |
306 | property real inverseProgress: 0 // This is the progress for left edge drags, in pixels. |
307 | + property int orientation: Qt.PortraitOrientation |
308 | |
309 | color: "black" |
310 | |
311 | @@ -372,6 +374,13 @@ |
312 | progress: appDelegate.progress - spreadView.positionMarker1 |
313 | } |
314 | |
315 | + Binding { |
316 | + target: appDelegate |
317 | + property: "orientation" |
318 | + when: appDelegate.interactive |
319 | + value: root.orientation |
320 | + } |
321 | + |
322 | onClicked: { |
323 | if (spreadView.phase == 2) { |
324 | if (ApplicationManager.focusedApplicationId == ApplicationManager.get(index).appId) { |
325 | |
326 | === modified file 'qml/Stages/SessionContainer.qml' |
327 | --- qml/Stages/SessionContainer.qml 2014-09-02 15:51:04 +0000 |
328 | +++ qml/Stages/SessionContainer.qml 2014-09-16 08:46:18 +0000 |
329 | @@ -24,12 +24,14 @@ |
330 | readonly property var childSessions: session ? session.childSessions : null |
331 | readonly property alias surface: _surfaceContainer.surface |
332 | property bool interactive: true |
333 | + property int orientation |
334 | |
335 | readonly property alias surfaceContainer: _surfaceContainer |
336 | SurfaceContainer { |
337 | id: _surfaceContainer |
338 | anchors.fill: parent |
339 | surface: session ? session.surface : null |
340 | + orientation: root.orientation |
341 | } |
342 | |
343 | Binding { |
344 | @@ -74,6 +76,11 @@ |
345 | target: item; when: item |
346 | property: "height"; value: root.height |
347 | } |
348 | + |
349 | + Binding { |
350 | + target: item; when: item |
351 | + property: "orientation"; value: root.orientation |
352 | + } |
353 | } |
354 | } |
355 | |
356 | |
357 | === modified file 'qml/Stages/SpreadDelegate.qml' |
358 | --- qml/Stages/SpreadDelegate.qml 2014-08-27 20:58:10 +0000 |
359 | +++ qml/Stages/SpreadDelegate.qml 2014-09-16 08:46:18 +0000 |
360 | @@ -36,6 +36,7 @@ |
361 | property alias swipeToCloseEnabled: dragArea.enabled |
362 | property bool closeable |
363 | property alias application: appWindow.application |
364 | + property int orientation |
365 | |
366 | Item { |
367 | objectName: "appWindowWithShadow" |
368 | @@ -62,6 +63,7 @@ |
369 | } |
370 | |
371 | interactive: root.interactive |
372 | + orientation: root.orientation |
373 | } |
374 | } |
375 | |
376 | |
377 | === modified file 'qml/Stages/SurfaceContainer.qml' |
378 | --- qml/Stages/SurfaceContainer.qml 2014-09-01 12:48:57 +0000 |
379 | +++ qml/Stages/SurfaceContainer.qml 2014-09-16 08:46:18 +0000 |
380 | @@ -22,6 +22,7 @@ |
381 | objectName: "surfaceContainer" |
382 | property Item surface: null |
383 | property bool hadSurface: false |
384 | + property int orientation |
385 | |
386 | onSurfaceChanged: { |
387 | if (surface) { |
388 | @@ -34,6 +35,10 @@ |
389 | target: surface |
390 | property: "anchors.fill"; value: root |
391 | } |
392 | + Binding { |
393 | + target: surface |
394 | + property: "orientation"; value: root.orientation |
395 | + } |
396 | |
397 | states: [ |
398 | State { |
399 | |
400 | === modified file 'qml/Stages/TabletStage.qml' |
401 | --- qml/Stages/TabletStage.qml 2014-09-02 18:10:49 +0000 |
402 | +++ qml/Stages/TabletStage.qml 2014-09-16 08:46:18 +0000 |
403 | @@ -34,6 +34,7 @@ |
404 | property real maximizedAppTopMargin |
405 | property bool interactive |
406 | property real inverseProgress: 0 // This is the progress for left edge drags, in pixels. |
407 | + property int orientation: Qt.PortraitOrientation |
408 | |
409 | onInverseProgressChanged: { |
410 | // This can't be a simple binding because that would be triggered after this handler |
411 | @@ -535,6 +536,13 @@ |
412 | return progress; |
413 | } |
414 | |
415 | + Binding { |
416 | + target: spreadTile |
417 | + property: "orientation" |
418 | + when: spreadTile.interactive |
419 | + value: root.orientation |
420 | + } |
421 | + |
422 | onClicked: { |
423 | if (spreadView.phase == 2) { |
424 | spreadView.snapTo(index); |
425 | |
426 | === modified file 'tests/mocks/Unity/Application/MirSurfaceItem.cpp' |
427 | --- tests/mocks/Unity/Application/MirSurfaceItem.cpp 2014-08-29 14:50:49 +0000 |
428 | +++ tests/mocks/Unity/Application/MirSurfaceItem.cpp 2014-09-16 08:46:18 +0000 |
429 | @@ -39,6 +39,7 @@ |
430 | , m_type(type) |
431 | , m_state(state) |
432 | , m_live(true) |
433 | + , m_orientation(Qt::PortraitOrientation) |
434 | , m_qmlItem(nullptr) |
435 | , m_screenshotUrl(screenshot) |
436 | { |
437 | @@ -108,6 +109,19 @@ |
438 | } |
439 | } |
440 | |
441 | +void MirSurfaceItem::setOrientation(const Qt::ScreenOrientation orientation) |
442 | +{ |
443 | + if (m_orientation == orientation) |
444 | + return; |
445 | + |
446 | + m_orientation = orientation; |
447 | + |
448 | + QQmlProperty orientationProp(m_qmlItem, "orientation"); |
449 | + orientationProp.write(QVariant::fromValue(orientation)); |
450 | + |
451 | + Q_EMIT orientationChanged(); |
452 | +} |
453 | + |
454 | void MirSurfaceItem::setSession(Session* session) |
455 | { |
456 | m_session = session; |
457 | |
458 | === modified file 'tests/mocks/Unity/Application/MirSurfaceItem.h' |
459 | --- tests/mocks/Unity/Application/MirSurfaceItem.h 2014-09-01 12:24:06 +0000 |
460 | +++ tests/mocks/Unity/Application/MirSurfaceItem.h 2014-09-16 08:46:18 +0000 |
461 | @@ -34,6 +34,7 @@ |
462 | Q_PROPERTY(State state READ state NOTIFY stateChanged) |
463 | Q_PROPERTY(QString name READ name CONSTANT) |
464 | Q_PROPERTY(bool live READ live NOTIFY liveChanged) |
465 | + Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false) |
466 | |
467 | public: |
468 | enum Type { |
469 | @@ -64,6 +65,9 @@ |
470 | State state() const { return m_state; } |
471 | QString name() const { return m_name; } |
472 | bool live() const { return m_live; } |
473 | + Qt::ScreenOrientation orientation() const { return m_orientation; } |
474 | + |
475 | + void setOrientation(const Qt::ScreenOrientation orientation); |
476 | |
477 | void setSession(Session* item); |
478 | void setScreenshot(const QUrl& screenshot); |
479 | @@ -76,6 +80,7 @@ |
480 | void typeChanged(Type); |
481 | void stateChanged(State); |
482 | void liveChanged(bool live); |
483 | + void orientationChanged(); |
484 | |
485 | void inputMethodRequested(); |
486 | void inputMethodDismissed(); |
487 | @@ -104,6 +109,7 @@ |
488 | const Type m_type; |
489 | State m_state; |
490 | bool m_live; |
491 | + Qt::ScreenOrientation m_orientation; |
492 | |
493 | QQmlComponent *m_qmlContentComponent; |
494 | QQuickItem *m_qmlItem; |
495 | @@ -114,5 +120,6 @@ |
496 | |
497 | Q_DECLARE_METATYPE(MirSurfaceItem*) |
498 | Q_DECLARE_METATYPE(QList<MirSurfaceItem*>) |
499 | +Q_DECLARE_METATYPE(Qt::ScreenOrientation) |
500 | |
501 | #endif // MIRSURFACEITEM_H |
502 | |
503 | === modified file 'tests/mocks/Unity/Application/MirSurfaceItem.qml' |
504 | --- tests/mocks/Unity/Application/MirSurfaceItem.qml 2014-08-18 16:59:08 +0000 |
505 | +++ tests/mocks/Unity/Application/MirSurfaceItem.qml 2014-09-16 08:46:18 +0000 |
506 | @@ -21,12 +21,22 @@ |
507 | id: root |
508 | color: "pink" |
509 | |
510 | - anchors.fill: parent |
511 | - |
512 | implicitWidth: units.gu(40) |
513 | implicitHeight: units.gu(70) |
514 | |
515 | + rotation: { |
516 | + if (orientation == Qt.PortraitOrientation) return 0; |
517 | + else if (orientation == Qt.LandscapeOrientation) return 90; |
518 | + else if (orientation == Qt.InvertedPortraitOrientation) return 180; |
519 | + else return 270; |
520 | + } |
521 | + x: parent ? (parent.width - width) / 2 : 0 |
522 | + y: parent ? (parent.height - height) / 2 : 0 |
523 | + width: parent ? (rotation == 0 || rotation == 180 ? parent.width : parent.height) : implicitWidth |
524 | + height: parent ? (rotation == 0 || rotation == 180 ? parent.height : parent.width) : implicitHeight |
525 | + |
526 | property alias screenshotSource: screenshotImage.source |
527 | + property int orientation: Qt.PortraitOrientation |
528 | |
529 | property bool wantInputMethod: false |
530 | |
531 | |
532 | === modified file 'tests/qmltests/Stages/tst_ApplicationWindow.qml' |
533 | --- tests/qmltests/Stages/tst_ApplicationWindow.qml 2014-09-02 23:25:33 +0000 |
534 | +++ tests/qmltests/Stages/tst_ApplicationWindow.qml 2014-09-16 08:46:18 +0000 |
535 | @@ -50,6 +50,7 @@ |
536 | ApplicationWindow { |
537 | anchors.fill: parent |
538 | application: fakeApplication |
539 | + orientation: Qt.PortraitOrientation |
540 | } |
541 | } |
542 | FocusScope { |
543 | @@ -147,6 +148,24 @@ |
544 | } |
545 | } |
546 | |
547 | + Button { |
548 | + anchors { left: parent.left; right: parent.right } |
549 | + text: "Rotate device \u27F3" |
550 | + onClicked: { |
551 | + var orientation = applicationWindowLoader.item.orientation |
552 | + if (orientation == Qt.PortraitOrientation) { |
553 | + orientation = Qt.LandscapeOrientation; |
554 | + } else if (orientation == Qt.LandscapeOrientation) { |
555 | + orientation = Qt.InvertedPortraitOrientation; |
556 | + } else if (orientation == Qt.InvertedPortraitOrientation) { |
557 | + orientation = Qt.InvertedLandscapeOrientation; |
558 | + } else { |
559 | + orientation = Qt.PortraitOrientation; |
560 | + } |
561 | + applicationWindowLoader.item.orientation = orientation; |
562 | + } |
563 | + } |
564 | + |
565 | } |
566 | } |
567 | |
568 | |
569 | === modified file 'tests/qmltests/Stages/tst_PhoneStage.qml' |
570 | --- tests/qmltests/Stages/tst_PhoneStage.qml 2014-08-27 21:39:17 +0000 |
571 | +++ tests/qmltests/Stages/tst_PhoneStage.qml 2014-09-16 08:46:18 +0000 |
572 | @@ -31,6 +31,8 @@ |
573 | anchors { fill: parent; rightMargin: units.gu(30) } |
574 | dragAreaWidth: units.gu(2) |
575 | maximizedAppTopMargin: units.gu(3) + units.dp(2) |
576 | + interactive: true |
577 | + orientation: Qt.PortraitOrientation |
578 | } |
579 | |
580 | Binding { |
581 | @@ -67,6 +69,21 @@ |
582 | ApplicationManager.get(appList.selectedAppIndex).setState(ApplicationInfoInterface.Stopped); |
583 | } |
584 | } |
585 | + Button { |
586 | + anchors { left: parent.left; right: parent.right } |
587 | + text: "Rotate device \u27F3" |
588 | + onClicked: { |
589 | + if (phoneStage.orientation == Qt.PortraitOrientation) { |
590 | + phoneStage.orientation = Qt.LandscapeOrientation; |
591 | + } else if (phoneStage.orientation == Qt.LandscapeOrientation) { |
592 | + phoneStage.orientation = Qt.InvertedPortraitOrientation; |
593 | + } else if (phoneStage.orientation == Qt.InvertedPortraitOrientation) { |
594 | + phoneStage.orientation = Qt.InvertedLandscapeOrientation; |
595 | + } else { |
596 | + phoneStage.orientation = Qt.PortraitOrientation; |
597 | + } |
598 | + } |
599 | + } |
600 | } |
601 | ListView { |
602 | id: appList |
603 | @@ -256,6 +273,46 @@ |
604 | compare(ApplicationManager.focusedApplicationId, selectedApp.appId); |
605 | } |
606 | |
607 | + function test_orientation_change_sent_to_focused_app() { |
608 | + phoneStage.orientation = Qt.PortraitOrientation; |
609 | + addApps(1); |
610 | + |
611 | + var spreadView = findChild(phoneStage, "spreadView"); |
612 | + var app = findChild(spreadView, "appDelegate0"); |
613 | + tryCompare(app, "orientation", Qt.PortraitOrientation); |
614 | + |
615 | + phoneStage.orientation = Qt.LandscapeOrientation; |
616 | + tryCompare(app, "orientation", Qt.LandscapeOrientation); |
617 | + } |
618 | + |
619 | + function test_orientation_change_not_sent_to_apps_while_spread_open() { |
620 | + phoneStage.orientation = Qt.PortraitOrientation; |
621 | + addApps(1); |
622 | + |
623 | + var spreadView = findChild(phoneStage, "spreadView"); |
624 | + var app = findChild(spreadView, "appDelegate0"); |
625 | + tryCompare(app, "orientation", Qt.PortraitOrientation); |
626 | + |
627 | + goToSpread(); |
628 | + phoneStage.orientation = Qt.LandscapeOrientation; |
629 | + tryCompare(app, "orientation", Qt.PortraitOrientation); |
630 | + } |
631 | + |
632 | + function test_orientation_change_not_sent_to_unfocused_app_until_it_focused() { |
633 | + phoneStage.orientation = Qt.PortraitOrientation; |
634 | + addApps(1); |
635 | + |
636 | + var spreadView = findChild(phoneStage, "spreadView"); |
637 | + var app = findChild(spreadView, "appDelegate0"); |
638 | + |
639 | + goToSpread(); |
640 | + phoneStage.orientation = Qt.LandscapeOrientation; |
641 | + tryCompare(app, "orientation", Qt.PortraitOrientation); |
642 | + |
643 | + phoneStage.select(app.application.appId); |
644 | + tryCompare(app, "orientation", Qt.LandscapeOrientation); |
645 | + } |
646 | + |
647 | function cleanup() { |
648 | while (ApplicationManager.count > 1) { |
649 | var oldCount = ApplicationManager.count; |
650 | @@ -263,6 +320,7 @@ |
651 | ApplicationManager.stopApplication(ApplicationManager.get(closingIndex).appId) |
652 | tryCompare(ApplicationManager, "count", oldCount - 1) |
653 | } |
654 | + phoneStage.orientation = Qt.PortraitOrientation; |
655 | } |
656 | } |
657 | } |
658 | |
659 | === modified file 'tests/qmltests/Stages/tst_SessionContainer.qml' |
660 | --- tests/qmltests/Stages/tst_SessionContainer.qml 2014-09-02 15:51:20 +0000 |
661 | +++ tests/qmltests/Stages/tst_SessionContainer.qml 2014-09-16 08:46:18 +0000 |
662 | @@ -41,6 +41,7 @@ |
663 | SessionContainer { |
664 | id: sessionContainer |
665 | anchors.fill: parent |
666 | + orientation: Qt.PortraitOrientation |
667 | } |
668 | } |
669 | |
670 | @@ -112,6 +113,24 @@ |
671 | session: sessionContainerLoader.item ? sessionContainerLoader.item.session : null |
672 | } |
673 | } |
674 | + |
675 | + Button { |
676 | + anchors { left: parent.left; right: parent.right } |
677 | + text: "Rotate device \u27F3" |
678 | + onClicked: { |
679 | + var orientation = sessionContainerLoader.item.orientation |
680 | + if (orientation == Qt.PortraitOrientation) { |
681 | + orientation = Qt.LandscapeOrientation; |
682 | + } else if (orientation == Qt.LandscapeOrientation) { |
683 | + orientation = Qt.InvertedPortraitOrientation; |
684 | + } else if (orientation == Qt.InvertedPortraitOrientation) { |
685 | + orientation = Qt.InvertedLandscapeOrientation; |
686 | + } else { |
687 | + orientation = Qt.PortraitOrientation; |
688 | + } |
689 | + sessionContainerLoader.item.orientation = orientation; |
690 | + } |
691 | + } |
692 | } |
693 | } |
694 | |
695 | @@ -263,5 +282,49 @@ |
696 | // wait for animation to end |
697 | tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false); |
698 | } |
699 | + |
700 | + function test_orientationPropagatedToChildren_data() { |
701 | + return [ { tag: "count=1", count: 1 }, |
702 | + { tag: "count=4", count: 4 } ]; |
703 | + } |
704 | + |
705 | + /* Test orientation changes are propagated to all children immediately */ |
706 | + function test_orientationPropagatedToChildren(data) { |
707 | + sessionCheckbox.checked = true; |
708 | + var rootSessionContainer = sessionContainerLoader.item; |
709 | + compare(rootSessionContainer.childSessions.count(), 0); |
710 | + |
711 | + var i; |
712 | + var sessions = []; |
713 | + for (i = 0; i < data.count; i++) { |
714 | + var session = ApplicationTest.addChildSession(rootSessionContainer.session, |
715 | + "gallery"); |
716 | + session.createSurface(); |
717 | + rootSessionContainer.session.addChildSession(session); |
718 | + |
719 | + // Check child SessionContainer has orientation matching the parent |
720 | + var delegate = findChild(rootSessionContainer, "childDelegate" + i); |
721 | + var childSessionContainer = findChild(delegate, "sessionContainer"); |
722 | + |
723 | + tryCompare(rootSessionContainer, "orientation", childSessionContainer.orientation); |
724 | + |
725 | + sessions.push(session); |
726 | + } |
727 | + |
728 | + // Change orientation and verify all children updated |
729 | + rootSessionContainer.orientation = Qt.LandscapeOrientation; |
730 | + |
731 | + for (i = 0; i < data.count; i++) { |
732 | + var delegate = findChild(rootSessionContainer, "childDelegate" + i); |
733 | + var childSessionContainer = findChild(delegate, "sessionContainer"); |
734 | + |
735 | + tryCompare(rootSessionContainer, "orientation", childSessionContainer.orientation); |
736 | + } |
737 | + |
738 | + // Clean up |
739 | + for (i = data.count-1; i >= 0; i--) { |
740 | + ApplicationTest.removeSession(sessions[i]); |
741 | + } |
742 | + } |
743 | } |
744 | } |
FAILED: Continuous integration, rev:1259 jenkins. qa.ubuntu. com/job/ unity8- ci/4267/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- utopic- touch/4694/ console jenkins. qa.ubuntu. com/job/ unity-phablet- qmluitests- utopic/ 1268 jenkins. qa.ubuntu. com/job/ unity8- utopic- amd64-ci/ 1361 jenkins. qa.ubuntu. com/job/ unity8- utopic- i386-ci/ 1361 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- mako/4470/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/5946 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/5946/ artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 13027
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity8- ci/4267/ rebuild
http://