Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationManual into lp:ubuntu-ui-toolkit/staging
- orientationManual
- Merge into staging
Status: | Superseded | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationManual | ||||||||||||
Merge into: | lp:ubuntu-ui-toolkit/staging | ||||||||||||
Diff against target: |
535 lines (+210/-37) 15 files modified
examples/ubuntu-ui-toolkit-gallery/po/es.po (+7/-7) modules/Ubuntu/Components/MainViewBase.qml (+14/-0) modules/Ubuntu/Components/OrientationHelper.qml (+6/-10) modules/Ubuntu/Components/Popups/PopupBase.qml (+0/-5) modules/Ubuntu/Components/TextCursor.qml (+6/-1) modules/Ubuntu/Components/plugin/plugin.cpp (+0/-7) modules/Ubuntu/Components/plugin/ucapplication.cpp (+39/-1) modules/Ubuntu/Components/plugin/ucapplication.h (+5/-0) tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py (+13/-0) tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py (+34/-0) tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml (+52/-4) tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py (+20/-0) tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml (+2/-0) tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml (+10/-2) tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml (+2/-0) |
||||||||||||
To merge this branch: | bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationManual | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu SDK team | Pending | ||
Review via email: mp+252270@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-03-31.
Commit message
Allow manual orientation changes through OrientationHelp
Description of the change
Autopilot tests for orientation issues in both text input and popovers/ dialogs:
env APP_ID=uitl LANGUAGE=en ./run_tests.sh ubuntuuitoolkit
env APP_ID=uitl LANGUAGE=en ./run_tests.sh ubuntuuitoolkit
- 1167. By Launchpad Translations on behalf of ubuntu-sdk-team
-
Launchpad automatic translations update.
- 1168. By Timo Jyrinki
-
No-change rebuild against Qt 5.4.1.
- 1169. By Florian Boucault
-
Bugfixes for the fresh 1.2 UITK
- 1170. By CI Train Bot Account
-
Releasing 1.2.1450+
15.04.20150318- 0ubuntu1 - 1171. By Launchpad Translations on behalf of ubuntu-sdk-team
-
Launchpad automatic translations update.
- 1172. By Leo Arias
-
The very last bugfix landing for Vivid
- 1173. By CI Train Bot Account
-
Releasing 1.2.1458+
15.04.20150327- 0ubuntu1 - 1174. By Launchpad Translations on behalf of ubuntu-sdk-team
-
Launchpad automatic translations update.
- 1175. By Daniel d'Andrada
-
merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationManual
- 1176. By Daniel d'Andrada
-
fix code and improve fake orientation logic
- 1177. By Cris Dywan
-
Add automaticOrient
ation to textinput AP tests and check rotation instead of rotationAngle - 1178. By Cris Dywan
-
Fix erroneous changes from branch merge
- 1179. By Cris Dywan
-
Set rotation on PopupBase directly with no transition
- 1180. By Cris Dywan
-
Fix components.api
- 1181. By Cris Dywan
-
Revise AP tests for consistency and comments for clarity
- 1182. By Cris Dywan
-
Wait for OrientationHelper to finnish animating
- 1183. By Cris Dywan
-
Verify that orientation really was changed
- 1184. By Cris Dywan
-
Split up orientation test functions and use lower case
- 1185. By Cris Dywan
-
Split up orientation test functions and use lower case
- 1186. By Cris Dywan
-
Use parent OrientationHelper as fakeCursor parent
- 1187. By Cris Dywan
-
Use objectName to select OrientationHelper in MainView CPO
- 1188. By Cris Dywan
-
Correctly use hasOwnProperty to check for automaticOrient
ation - 1189. By Cris Dywan
-
Wait on internal flipDimensions after rotation
- 1190. By Cris Dywan
-
Drop now redundant wait on rotating
- 1191. By Cris Dywan
-
Fix nonsensical typo fix so it says FOLLOW_
SCREEN_ ORIENTATION as intended - 1192. By Cris Dywan
-
Add license header to test_main_
view.orientatio n.qml - 1193. By Cris Dywan
-
Only test non-default orientation for clear results
Otherwise some properties may not change if nothing did rotate.
- 1194. By Cris Dywan
- 1195. By Cris Dywan
-
Take Component-based popover rootItem from the caller
- 1196. By Cris Dywan
-
FakeCursor parent should fallback to toplevel
- 1197. By Cris Dywan
- 1198. By Cris Dywan
-
Put back accidentally removed "import os"
- 1199. By Cris Dywan
- 1200. By Cris Dywan
-
Empty commit
- 1201. By Cris Dywan
- 1202. By Cris Dywan
-
Update components.api
- 1203. By Cris Dywan
-
Undo accidental changes
- 1204. By Cris Dywan
-
Move all orientation tests to 1.3
- 1205. By Cris Dywan
-
Revert bogus components.api changes
- 1206. By Cris Dywan
-
Normalize rotation angle in tests
- 1207. By Cris Dywan
- 1208. By Cris Dywan
-
Use Popups 1.3 in test_popover.qml
- 1209. By Cris Dywan
-
Assert focus after tapping TextField in popover tests
- 1210. By Cris Dywan
-
Anchor Column in test_textinput.
textfield. qml to the top - 1211. By Cris Dywan
- 1212. By Cris Dywan
- 1213. By Cris Dywan
-
Use Eventually and wait_ instead of time.sleep
- 1214. By Cris Dywan
- 1215. By Cris Dywan
-
Make flake8 happy once again
- 1216. By Cris Dywan
Unmerged revisions
- 1216. By Cris Dywan
- 1215. By Cris Dywan
-
Make flake8 happy once again
- 1214. By Cris Dywan
- 1213. By Cris Dywan
-
Use Eventually and wait_ instead of time.sleep
- 1212. By Cris Dywan
- 1211. By Cris Dywan
- 1210. By Cris Dywan
-
Anchor Column in test_textinput.
textfield. qml to the top - 1209. By Cris Dywan
-
Assert focus after tapping TextField in popover tests
- 1208. By Cris Dywan
-
Use Popups 1.3 in test_popover.qml
- 1207. By Cris Dywan
Preview Diff
1 | === modified file 'examples/ubuntu-ui-toolkit-gallery/po/es.po' | |||
2 | --- examples/ubuntu-ui-toolkit-gallery/po/es.po 2015-03-14 05:29:12 +0000 | |||
3 | +++ examples/ubuntu-ui-toolkit-gallery/po/es.po 2015-03-31 12:57:21 +0000 | |||
4 | @@ -8,14 +8,14 @@ | |||
5 | 8 | "Project-Id-Version: ubuntu-ui-toolkit\n" | 8 | "Project-Id-Version: ubuntu-ui-toolkit\n" |
6 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
7 | 10 | "POT-Creation-Date: 2014-11-11 11:21+0100\n" | 10 | "POT-Creation-Date: 2014-11-11 11:21+0100\n" |
9 | 11 | "PO-Revision-Date: 2015-01-16 03:32+0000\n" | 11 | "PO-Revision-Date: 2015-03-28 06:18+0000\n" |
10 | 12 | "Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n" | 12 | "Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n" |
11 | 13 | "Language-Team: Spanish <es@li.org>\n" | 13 | "Language-Team: Spanish <es@li.org>\n" |
12 | 14 | "MIME-Version: 1.0\n" | 14 | "MIME-Version: 1.0\n" |
13 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 15 | "Content-Type: text/plain; charset=UTF-8\n" |
14 | 16 | "Content-Transfer-Encoding: 8bit\n" | 16 | "Content-Transfer-Encoding: 8bit\n" |
17 | 17 | "X-Launchpad-Export-Date: 2015-03-14 05:29+0000\n" | 17 | "X-Launchpad-Export-Date: 2015-03-29 05:42+0000\n" |
18 | 18 | "X-Generator: Launchpad (build 17389)\n" | 18 | "X-Generator: Launchpad (build 17413)\n" |
19 | 19 | 19 | ||
20 | 20 | #: Animations.qml:24 | 20 | #: Animations.qml:24 |
21 | 21 | msgid "NumberAnimation" | 21 | msgid "NumberAnimation" |
22 | @@ -349,7 +349,7 @@ | |||
23 | 349 | 349 | ||
24 | 350 | #: Styles.qml:40 | 350 | #: Styles.qml:40 |
25 | 351 | msgid "Switch between themes" | 351 | msgid "Switch between themes" |
27 | 352 | msgstr "" | 352 | msgstr "Cambiar de tema" |
28 | 353 | 353 | ||
29 | 354 | #: TextInputs.qml:49 | 354 | #: TextInputs.qml:49 |
30 | 355 | msgid "Type me in..." | 355 | msgid "Type me in..." |
31 | @@ -401,12 +401,12 @@ | |||
32 | 401 | 401 | ||
33 | 402 | #: UbuntuShape.qml:49 | 402 | #: UbuntuShape.qml:49 |
34 | 403 | msgid "Image" | 403 | msgid "Image" |
36 | 404 | msgstr "" | 404 | msgstr "Imagen" |
37 | 405 | 405 | ||
38 | 406 | #: UbuntuShape.qml:64 | 406 | #: UbuntuShape.qml:64 |
39 | 407 | msgid "Radius" | 407 | msgid "Radius" |
41 | 408 | msgstr "" | 408 | msgstr "Radio" |
42 | 409 | 409 | ||
43 | 410 | #: UbuntuShape.qml:97 | 410 | #: UbuntuShape.qml:97 |
44 | 411 | msgid "Sizes" | 411 | msgid "Sizes" |
46 | 412 | msgstr "" | 412 | msgstr "Tamaños" |
47 | 413 | 413 | ||
48 | === modified file 'modules/Ubuntu/Components/MainViewBase.qml' | |||
49 | --- modules/Ubuntu/Components/MainViewBase.qml 2015-03-03 13:47:48 +0000 | |||
50 | +++ modules/Ubuntu/Components/MainViewBase.qml 2015-03-31 12:57:21 +0000 | |||
51 | @@ -56,6 +56,20 @@ | |||
52 | 56 | Theme.name = "Ubuntu.Components.Themes.%1".arg(theme); | 56 | Theme.name = "Ubuntu.Components.Themes.%1".arg(theme); |
53 | 57 | } | 57 | } |
54 | 58 | } | 58 | } |
55 | 59 | |||
56 | 60 | // Functions to allow Autopilot to handle orientation | ||
57 | 61 | objectName: "MainViewBaseStyledItem" | ||
58 | 62 | function setOrientation(newOrientation) { | ||
59 | 63 | if (newOrientation == 'Landscape') | ||
60 | 64 | UbuntuApplication.orientation = Qt.LandscapeOrientation | ||
61 | 65 | else if (newOrientation == 'Portrait') | ||
62 | 66 | UbuntuApplication.orientation = Qt.PortraitOrientation | ||
63 | 67 | else | ||
64 | 68 | UbuntuApplication.orientation = newOrientation | ||
65 | 69 | } | ||
66 | 70 | function getOrientation() { | ||
67 | 71 | return UbuntuApplication.orientation | ||
68 | 72 | } | ||
69 | 59 | } | 73 | } |
70 | 60 | 74 | ||
71 | 61 | active: true | 75 | active: true |
72 | 62 | 76 | ||
73 | === modified file 'modules/Ubuntu/Components/OrientationHelper.qml' | |||
74 | --- modules/Ubuntu/Components/OrientationHelper.qml 2015-03-06 07:55:23 +0000 | |||
75 | +++ modules/Ubuntu/Components/OrientationHelper.qml 2015-03-31 12:57:21 +0000 | |||
76 | @@ -83,11 +83,14 @@ | |||
77 | 83 | 83 | ||
78 | 84 | Calculates the current orientation angle. | 84 | Calculates the current orientation angle. |
79 | 85 | */ | 85 | */ |
81 | 86 | property int orientationAngle: automaticOrientation ? Screen.angleBetween(Screen.primaryOrientation, Screen.orientation) : 0 | 86 | readonly property int orientationAngle: automaticOrientation |
82 | 87 | ? Screen.angleBetween(Screen.primaryOrientation, UbuntuApplication.orientation) | ||
83 | 88 | : 0 | ||
84 | 87 | // Screen.primaryOrientation and Screen.orientation can change one right after the other, | 89 | // Screen.primaryOrientation and Screen.orientation can change one right after the other, |
85 | 88 | // causing orientationAngle to momentarily change. To avoid responding to such | 90 | // causing orientationAngle to momentarily change. To avoid responding to such |
86 | 89 | // intermediate states, wait for its value to stabilize before rotating to it. | 91 | // intermediate states, wait for its value to stabilize before rotating to it. |
88 | 90 | onOrientationAngleChanged: { automaticOrientation ? stableOrientationAngleTimer.restart() : d.tryUpdateState(); } | 92 | onOrientationAngleChanged: automaticOrientation ? stableOrientationAngleTimer.restart() |
89 | 93 | : d.tryUpdateState(); | ||
90 | 91 | 94 | ||
91 | 92 | /*! | 95 | /*! |
92 | 93 | The property holds if the OrientationHelper should automatically resize the | 96 | The property holds if the OrientationHelper should automatically resize the |
93 | @@ -102,13 +105,6 @@ | |||
94 | 102 | width: parent ? (d.flipDimensions ? d.availableParentHeight : parent.width) : 0 | 105 | width: parent ? (d.flipDimensions ? d.availableParentHeight : parent.width) : 0 |
95 | 103 | height: parent ? (d.flipDimensions ? parent.width : d.availableParentHeight) : 0 | 106 | height: parent ? (d.flipDimensions ? parent.width : d.availableParentHeight) : 0 |
96 | 104 | 107 | ||
97 | 105 | /* | ||
98 | 106 | The attached property Screen.orientation is only valid inside Item or | ||
99 | 107 | derived components. Inside Object it evaluates to 0 with no error. | ||
100 | 108 | Also be aware that some apps eg. webbrowser-app set window.contentOrientation | ||
101 | 109 | and thus can hide failure to update it from this code. | ||
102 | 110 | See http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick-window2-screen.html | ||
103 | 111 | */ | ||
104 | 112 | Item { | 108 | Item { |
105 | 113 | id: d | 109 | id: d |
106 | 114 | 110 | ||
107 | @@ -138,7 +134,7 @@ | |||
108 | 138 | */ | 134 | */ |
109 | 139 | function applyOrientation() { | 135 | function applyOrientation() { |
110 | 140 | if (windowActive && window) | 136 | if (windowActive && window) |
112 | 141 | window.contentOrientation = Screen.orientation | 137 | window.contentOrientation = UbuntuApplication.orientation |
113 | 142 | } | 138 | } |
114 | 143 | 139 | ||
115 | 144 | onWindowActiveChanged: { | 140 | onWindowActiveChanged: { |
116 | 145 | 141 | ||
117 | === modified file 'modules/Ubuntu/Components/Popups/PopupBase.qml' | |||
118 | --- modules/Ubuntu/Components/Popups/PopupBase.qml 2015-03-03 13:47:48 +0000 | |||
119 | +++ modules/Ubuntu/Components/Popups/PopupBase.qml 2015-03-31 12:57:21 +0000 | |||
120 | @@ -47,11 +47,6 @@ | |||
121 | 47 | */ | 47 | */ |
122 | 48 | property PropertyAnimation fadingAnimation: PropertyAnimation{duration: 0} | 48 | property PropertyAnimation fadingAnimation: PropertyAnimation{duration: 0} |
123 | 49 | 49 | ||
124 | 50 | // without specifying width and height below, some width calculations go wrong in Sheet. | ||
125 | 51 | // I guess popupBase.width is not correctly set initially | ||
126 | 52 | width: parent ? parent.width : undefined | ||
127 | 53 | height: parent ? parent.height : undefined | ||
128 | 54 | |||
129 | 55 | // copy value of automaticOrientation from root object (typically a MainView) | 50 | // copy value of automaticOrientation from root object (typically a MainView) |
130 | 56 | automaticOrientation: stateWrapper.rootItem && stateWrapper.rootItem.automaticOrientation ? | 51 | automaticOrientation: stateWrapper.rootItem && stateWrapper.rootItem.automaticOrientation ? |
131 | 57 | stateWrapper.rootItem.automaticOrientation : false | 52 | stateWrapper.rootItem.automaticOrientation : false |
132 | 58 | 53 | ||
133 | === modified file 'modules/Ubuntu/Components/TextCursor.qml' | |||
134 | --- modules/Ubuntu/Components/TextCursor.qml 2015-03-18 15:51:07 +0000 | |||
135 | +++ modules/Ubuntu/Components/TextCursor.qml 2015-03-31 12:57:21 +0000 | |||
136 | @@ -293,7 +293,12 @@ | |||
137 | 293 | Item { | 293 | Item { |
138 | 294 | id: fakeCursor | 294 | id: fakeCursor |
139 | 295 | objectName: positionProperty + "FakeCursor" | 295 | objectName: positionProperty + "FakeCursor" |
141 | 296 | parent: QuickUtils.rootItem(handler.main) | 296 | // Parent to the contentsItem to be able to inherit rotation |
142 | 297 | parent: { | ||
143 | 298 | var mainView = QuickUtils.rootItem(handler.main); | ||
144 | 299 | // Check in case the root isn't a MainView | ||
145 | 300 | return mainView.contentsItem ? mainView.contentsItem[0] : mainView; | ||
146 | 301 | } | ||
147 | 297 | width: cursorItem.width | 302 | width: cursorItem.width |
148 | 298 | height: cursorItem.height | 303 | height: cursorItem.height |
149 | 299 | Component.onCompleted: caret.parent = fakeCursor | 304 | Component.onCompleted: caret.parent = fakeCursor |
150 | 300 | 305 | ||
151 | === modified file 'modules/Ubuntu/Components/plugin/plugin.cpp' | |||
152 | --- modules/Ubuntu/Components/plugin/plugin.cpp 2015-03-04 19:07:58 +0000 | |||
153 | +++ modules/Ubuntu/Components/plugin/plugin.cpp 2015-03-31 12:57:21 +0000 | |||
154 | @@ -244,12 +244,5 @@ | |||
155 | 244 | // register icon provider | 244 | // register icon provider |
156 | 245 | engine->addImageProvider(QLatin1String("theme"), new UnityThemeIconProvider); | 245 | engine->addImageProvider(QLatin1String("theme"), new UnityThemeIconProvider); |
157 | 246 | 246 | ||
158 | 247 | // Necessary for Screen.orientation (from import QtQuick.Window 2.0) to work | ||
159 | 248 | QGuiApplication::primaryScreen()->setOrientationUpdateMask( | ||
160 | 249 | Qt::PortraitOrientation | | ||
161 | 250 | Qt::LandscapeOrientation | | ||
162 | 251 | Qt::InvertedPortraitOrientation | | ||
163 | 252 | Qt::InvertedLandscapeOrientation); | ||
164 | 253 | |||
165 | 254 | registerWindowContextProperty(); | 247 | registerWindowContextProperty(); |
166 | 255 | } | 248 | } |
167 | 256 | 249 | ||
168 | === modified file 'modules/Ubuntu/Components/plugin/ucapplication.cpp' | |||
169 | --- modules/Ubuntu/Components/plugin/ucapplication.cpp 2014-10-02 10:14:51 +0000 | |||
170 | +++ modules/Ubuntu/Components/plugin/ucapplication.cpp 2015-03-31 12:57:21 +0000 | |||
171 | @@ -19,10 +19,13 @@ | |||
172 | 19 | #include "ucapplication.h" | 19 | #include "ucapplication.h" |
173 | 20 | 20 | ||
174 | 21 | #include <QtCore/QCoreApplication> | 21 | #include <QtCore/QCoreApplication> |
175 | 22 | #include <QtGui/QGuiApplication> | ||
176 | 23 | #include <QWindow> | ||
177 | 22 | #include <QDebug> | 24 | #include <QDebug> |
178 | 23 | #include <QtQml/QQmlContext> | 25 | #include <QtQml/QQmlContext> |
179 | 24 | #include <QtQml/QQmlEngine> | 26 | #include <QtQml/QQmlEngine> |
180 | 25 | #include <QtCore/QStandardPaths> | 27 | #include <QtCore/QStandardPaths> |
181 | 28 | #include <QScreen> | ||
182 | 26 | 29 | ||
183 | 27 | /*! | 30 | /*! |
184 | 28 | * \qmltype UbuntuApplication | 31 | * \qmltype UbuntuApplication |
185 | @@ -33,11 +36,20 @@ | |||
186 | 33 | * | 36 | * |
187 | 34 | * UbuntuApplication is a context property in QML. | 37 | * UbuntuApplication is a context property in QML. |
188 | 35 | */ | 38 | */ |
190 | 36 | UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0) | 39 | UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0), m_orientation(-1) |
191 | 37 | { | 40 | { |
192 | 38 | // Make sure we receive application name changes from C++ modules | 41 | // Make sure we receive application name changes from C++ modules |
193 | 39 | connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged, | 42 | connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged, |
194 | 40 | this, &UCApplication::applicationNameChanged); | 43 | this, &UCApplication::applicationNameChanged); |
195 | 44 | |||
196 | 45 | // Follow primary screen orientation changes | ||
197 | 46 | QGuiApplication::primaryScreen()->setOrientationUpdateMask( | ||
198 | 47 | Qt::PortraitOrientation | | ||
199 | 48 | Qt::LandscapeOrientation | | ||
200 | 49 | Qt::InvertedPortraitOrientation | | ||
201 | 50 | Qt::InvertedLandscapeOrientation); | ||
202 | 51 | connect(QGuiApplication::primaryScreen(), &QScreen::orientationChanged, | ||
203 | 52 | this, &UCApplication::orientationChanged); | ||
204 | 41 | } | 53 | } |
205 | 42 | 54 | ||
206 | 43 | void UCApplication::setContext(QQmlContext* context) { | 55 | void UCApplication::setContext(QQmlContext* context) { |
207 | @@ -73,3 +85,29 @@ | |||
208 | 73 | QCoreApplication::setOrganizationDomain(applicationName); | 85 | QCoreApplication::setOrganizationDomain(applicationName); |
209 | 74 | } | 86 | } |
210 | 75 | 87 | ||
211 | 88 | /*! | ||
212 | 89 | * \qmlproperty Qt.ScreenOrientation Application::orientation | ||
213 | 90 | * \internal | ||
214 | 91 | * The current orientation of the application - can be overridden manually for testing. | ||
215 | 92 | */ | ||
216 | 93 | Qt::ScreenOrientation UCApplication::orientation() { | ||
217 | 94 | if (m_orientation == -1) { | ||
218 | 95 | return QGuiApplication::primaryScreen()->orientation(); | ||
219 | 96 | } else { | ||
220 | 97 | return static_cast<Qt::ScreenOrientation>(m_orientation); | ||
221 | 98 | } | ||
222 | 99 | } | ||
223 | 100 | |||
224 | 101 | void UCApplication::setOrientation(Qt::ScreenOrientation orientation) { | ||
225 | 102 | if (m_orientation == -1) { | ||
226 | 103 | // we're now in manual override mode | ||
227 | 104 | disconnect(QGuiApplication::primaryScreen(), &QScreen::orientationChanged, | ||
228 | 105 | this, &UCApplication::orientationChanged); | ||
229 | 106 | } | ||
230 | 107 | |||
231 | 108 | if (m_orientation != orientation) { | ||
232 | 109 | m_orientation = orientation; | ||
233 | 110 | Q_EMIT orientationChanged(orientation); | ||
234 | 111 | } | ||
235 | 112 | } | ||
236 | 113 | |||
237 | 76 | 114 | ||
238 | === modified file 'modules/Ubuntu/Components/plugin/ucapplication.h' | |||
239 | --- modules/Ubuntu/Components/plugin/ucapplication.h 2013-10-18 08:56:39 +0000 | |||
240 | +++ modules/Ubuntu/Components/plugin/ucapplication.h 2015-03-31 12:57:21 +0000 | |||
241 | @@ -28,6 +28,7 @@ | |||
242 | 28 | { | 28 | { |
243 | 29 | Q_OBJECT | 29 | Q_OBJECT |
244 | 30 | Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged) | 30 | Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged) |
245 | 31 | Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) | ||
246 | 31 | 32 | ||
247 | 32 | private: | 33 | private: |
248 | 33 | Q_DISABLE_COPY(UCApplication) | 34 | Q_DISABLE_COPY(UCApplication) |
249 | @@ -42,16 +43,20 @@ | |||
250 | 42 | 43 | ||
251 | 43 | // getter | 44 | // getter |
252 | 44 | QString applicationName(); | 45 | QString applicationName(); |
253 | 46 | Qt::ScreenOrientation orientation(); | ||
254 | 45 | 47 | ||
255 | 46 | // setter | 48 | // setter |
256 | 47 | void setContext(QQmlContext* context); | 49 | void setContext(QQmlContext* context); |
257 | 48 | void setApplicationName(const QString& applicationName); | 50 | void setApplicationName(const QString& applicationName); |
258 | 51 | void setOrientation(Qt::ScreenOrientation orientation); | ||
259 | 49 | 52 | ||
260 | 50 | private: | 53 | private: |
261 | 51 | QQmlContext* m_context; | 54 | QQmlContext* m_context; |
262 | 55 | int m_orientation; | ||
263 | 52 | 56 | ||
264 | 53 | Q_SIGNALS: | 57 | Q_SIGNALS: |
265 | 54 | void applicationNameChanged(); | 58 | void applicationNameChanged(); |
266 | 59 | void orientationChanged(Qt::ScreenOrientation orientation); | ||
267 | 55 | }; | 60 | }; |
268 | 56 | 61 | ||
269 | 57 | #endif // UBUNTU_COMPONENTS_I18N_H | 62 | #endif // UBUNTU_COMPONENTS_I18N_H |
270 | 58 | 63 | ||
271 | === modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py' | |||
272 | --- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py 2015-02-11 23:37:40 +0000 | |||
273 | +++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_mainview.py 2015-03-31 12:57:21 +0000 | |||
274 | @@ -17,6 +17,7 @@ | |||
275 | 17 | """Ubuntu UI Toolkit Autopilot custom proxy objects.""" | 17 | """Ubuntu UI Toolkit Autopilot custom proxy objects.""" |
276 | 18 | 18 | ||
277 | 19 | import logging | 19 | import logging |
278 | 20 | import time | ||
279 | 20 | 21 | ||
280 | 21 | from autopilot import logging as autopilot_logging | 22 | from autopilot import logging as autopilot_logging |
281 | 22 | from autopilot.introspection import dbus | 23 | from autopilot.introspection import dbus |
282 | @@ -56,6 +57,18 @@ | |||
283 | 56 | 57 | ||
284 | 57 | return False | 58 | return False |
285 | 58 | 59 | ||
286 | 60 | def _set_orientation(self, orientation): | ||
287 | 61 | self.select_single( | ||
288 | 62 | objectName='MainViewBaseStyledItem').slots.setOrientation( | ||
289 | 63 | orientation) | ||
290 | 64 | # Short delay to ensure introspection is uptodate | ||
291 | 65 | time.sleep(1) | ||
292 | 66 | |||
293 | 67 | @property | ||
294 | 68 | def _orientation(self): | ||
295 | 69 | return self.select_single( | ||
296 | 70 | objectName='MainViewBaseStyledItem').orientation | ||
297 | 71 | |||
298 | 59 | def get_header(self): | 72 | def get_header(self): |
299 | 60 | """Return the AppHeader custom proxy object of the MainView.""" | 73 | """Return the AppHeader custom proxy object of the MainView.""" |
300 | 61 | try: | 74 | try: |
301 | 62 | 75 | ||
302 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py' | |||
303 | --- tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py 2014-10-06 10:44:31 +0000 | |||
304 | +++ tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.py 2015-03-31 12:57:21 +0000 | |||
305 | @@ -17,10 +17,44 @@ | |||
306 | 17 | """Tests for the Ubuntu UI Toolkit Header component.""" | 17 | """Tests for the Ubuntu UI Toolkit Header component.""" |
307 | 18 | 18 | ||
308 | 19 | import os | 19 | import os |
309 | 20 | import time | ||
310 | 20 | 21 | ||
311 | 21 | from ubuntuuitoolkit import tests | 22 | from ubuntuuitoolkit import tests |
312 | 22 | 23 | ||
313 | 23 | 24 | ||
314 | 25 | class PopoverOpenTestCase(tests.QMLFileAppTestCase): | ||
315 | 26 | |||
316 | 27 | path = os.path.abspath(__file__) | ||
317 | 28 | dir_path = os.path.dirname(path) | ||
318 | 29 | test_qml_file_path = os.path.join( | ||
319 | 30 | dir_path, 'test_popover.qml') | ||
320 | 31 | |||
321 | 32 | scenarios = [ | ||
322 | 33 | ('Popover', dict(button='button', popover='popover')), | ||
323 | 34 | ('Small dialog', dict(button='button_small', popover='dialog_small')), | ||
324 | 35 | ('Huge dialog', dict(button='button_huge', popover='dialog_huge')), | ||
325 | 36 | ] | ||
326 | 37 | |||
327 | 38 | def setUp(self): | ||
328 | 39 | super(PopoverOpenTestCase, self).setUp() | ||
329 | 40 | |||
330 | 41 | def _rotate(self, orientation): | ||
331 | 42 | self.main_view._set_orientation(orientation) | ||
332 | 43 | button = self.main_view.select_single(objectName=self.button) | ||
333 | 44 | self.pointing_device.click_object(button) | ||
334 | 45 | # Give rendering a chance to finish | ||
335 | 46 | time.sleep(2) | ||
336 | 47 | popover = self.main_view.select_single(objectName=self.popover) | ||
337 | 48 | self.assertEqual(popover.rotationAngle, self.main_view.select_single( | ||
338 | 49 | 'OrientationHelper').rotation) | ||
339 | 50 | |||
340 | 51 | def test_popover_rotate_landscape(self): | ||
341 | 52 | self._rotate('Landscape') | ||
342 | 53 | |||
343 | 54 | def test_popover_rotate_portrait(self): | ||
344 | 55 | self._rotate('Portrait') | ||
345 | 56 | |||
346 | 57 | |||
347 | 24 | class DialogScrollTestCase(tests.QMLFileAppTestCase): | 58 | class DialogScrollTestCase(tests.QMLFileAppTestCase): |
348 | 25 | 59 | ||
349 | 26 | path = os.path.abspath(__file__) | 60 | path = os.path.abspath(__file__) |
350 | 27 | 61 | ||
351 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml' | |||
352 | --- tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml 2015-03-03 13:20:06 +0000 | |||
353 | +++ tests/autopilot/ubuntuuitoolkit/tests/components/test_popover.qml 2015-03-31 12:57:21 +0000 | |||
354 | @@ -15,19 +15,28 @@ | |||
355 | 15 | */ | 15 | */ |
356 | 16 | 16 | ||
357 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.0 |
359 | 18 | import Ubuntu.Components 1.1 | 18 | import Ubuntu.Components 1.2 |
360 | 19 | import Ubuntu.Components.Popups 1.0 | 19 | import Ubuntu.Components.Popups 1.0 |
361 | 20 | import Ubuntu.Test 1.0 | ||
362 | 20 | 21 | ||
363 | 21 | MainView { | 22 | MainView { |
366 | 22 | width: units.gu(48) | 23 | id: root |
367 | 23 | height: units.gu(60) | 24 | width: units.gu(60) |
368 | 25 | height: units.gu(40) | ||
369 | 24 | objectName: "mainView" | 26 | objectName: "mainView" |
370 | 25 | 27 | ||
371 | 28 | automaticOrientation: true | ||
372 | 29 | |||
373 | 26 | Page { | 30 | Page { |
374 | 27 | title: "Popover" | 31 | title: "Popover" |
375 | 28 | 32 | ||
376 | 29 | Column { | 33 | Column { |
377 | 30 | Button { | 34 | Button { |
378 | 35 | objectName: "button" | ||
379 | 36 | text: "Pop over" | ||
380 | 37 | onClicked: PopupUtils.open(popoverComponent) | ||
381 | 38 | } | ||
382 | 39 | Button { | ||
383 | 31 | objectName: "button_small" | 40 | objectName: "button_small" |
384 | 32 | text: "Small" | 41 | text: "Small" |
385 | 33 | onClicked: PopupUtils.open(smallDialogComponent) | 42 | onClicked: PopupUtils.open(smallDialogComponent) |
386 | @@ -37,15 +46,54 @@ | |||
387 | 37 | text: "Huge" | 46 | text: "Huge" |
388 | 38 | onClicked: PopupUtils.open(hugeDialogComponent) | 47 | onClicked: PopupUtils.open(hugeDialogComponent) |
389 | 39 | } | 48 | } |
390 | 49 | Button { | ||
391 | 50 | text: "Landscape" | ||
392 | 51 | onClicked: UbuntuApplication.orientation = Qt.LandscapeOrientation; | ||
393 | 52 | } | ||
394 | 53 | Button { | ||
395 | 54 | text: "Portrait" | ||
396 | 55 | onClicked: UbuntuApplication.orientation = Qt.PortraitOrientation; | ||
397 | 56 | } | ||
398 | 57 | } | ||
399 | 58 | |||
400 | 59 | Component { | ||
401 | 60 | id: popoverComponent | ||
402 | 61 | Popover { | ||
403 | 62 | objectName: "popover" | ||
404 | 63 | Column { | ||
405 | 64 | Button { | ||
406 | 65 | text: "Just a button" | ||
407 | 66 | onClicked: { | ||
408 | 67 | if (UbuntuApplication.orientation === Qt.LandscapeOrientation) { | ||
409 | 68 | UbuntuApplication.orientation = Qt.PortraitOrientation; | ||
410 | 69 | } else { | ||
411 | 70 | UbuntuApplication.orientation = Qt.LandscapeOrientation | ||
412 | 71 | } | ||
413 | 72 | } | ||
414 | 73 | } | ||
415 | 74 | } | ||
416 | 75 | } | ||
417 | 40 | } | 76 | } |
418 | 41 | 77 | ||
419 | 42 | Component { | 78 | Component { |
420 | 43 | id: smallDialogComponent | 79 | id: smallDialogComponent |
421 | 44 | Dialog { | 80 | Dialog { |
422 | 81 | id: smallDialog | ||
423 | 45 | objectName: "dialog_small" | 82 | objectName: "dialog_small" |
425 | 46 | Column { | 83 | Row { |
426 | 47 | Button { | 84 | Button { |
427 | 48 | text: "Just a button" | 85 | text: "Just a button" |
428 | 86 | onClicked: { | ||
429 | 87 | if (UbuntuApplication.orientation === Qt.LandscapeOrientation) { | ||
430 | 88 | UbuntuApplication.orientation = Qt.PortraitOrientation; | ||
431 | 89 | } else { | ||
432 | 90 | UbuntuApplication.orientation = Qt.LandscapeOrientation | ||
433 | 91 | } | ||
434 | 92 | } | ||
435 | 93 | } | ||
436 | 94 | Button { | ||
437 | 95 | text: "close" | ||
438 | 96 | onClicked: PopupUtils.close(smallDialog) | ||
439 | 49 | } | 97 | } |
440 | 50 | } | 98 | } |
441 | 51 | } | 99 | } |
442 | 52 | 100 | ||
443 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py' | |||
444 | --- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py 2015-03-16 10:01:09 +0000 | |||
445 | +++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.py 2015-03-31 12:57:21 +0000 | |||
446 | @@ -166,6 +166,26 @@ | |||
447 | 166 | self.assertTrue(popover.globalRect.y > 0, | 166 | self.assertTrue(popover.globalRect.y > 0, |
448 | 167 | '%s <= 0' % popover.globalRect.y) | 167 | '%s <= 0' % popover.globalRect.y) |
449 | 168 | 168 | ||
450 | 169 | def _rotate(self, orientation): | ||
451 | 170 | if self.test_qml_file_path != self.textfield_qml_file_path: | ||
452 | 171 | self.skipTest('FIXME: Header behavior breaks some rotation cases') | ||
453 | 172 | self.main_view._set_orientation(orientation) | ||
454 | 173 | self.pointing_device.click_object(self.textfield) | ||
455 | 174 | cursor = self.select_cursor('cursorPosition') | ||
456 | 175 | self.pointing_device.click_object(cursor) | ||
457 | 176 | # Give rendering a chance to finish | ||
458 | 177 | sleep(2) | ||
459 | 178 | popover = self.main_view.get_text_input_context_menu( | ||
460 | 179 | 'text_input_contextmenu') | ||
461 | 180 | self.assertEqual(popover.rotation, self.main_view.select_single( | ||
462 | 181 | 'OrientationHelper').rotation) | ||
463 | 182 | |||
464 | 183 | def test_rotate_landscape(self): | ||
465 | 184 | self._rotate('Landscape') | ||
466 | 185 | |||
467 | 186 | def test_rotate_portrait(self): | ||
468 | 187 | self._rotate('Portrait') | ||
469 | 188 | |||
470 | 169 | def test_header_undisturbed_by_text_handlers(self): | 189 | def test_header_undisturbed_by_text_handlers(self): |
471 | 170 | # Verify that handlers aren't accidentally placed at absolute 0/0 | 190 | # Verify that handlers aren't accidentally placed at absolute 0/0 |
472 | 171 | self.pointing_device.click_object(self.textfield) | 191 | self.pointing_device.click_object(self.textfield) |
473 | 172 | 192 | ||
474 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml' | |||
475 | --- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml 2015-03-10 16:29:24 +0000 | |||
476 | +++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textarea.qml 2015-03-31 12:57:21 +0000 | |||
477 | @@ -22,6 +22,8 @@ | |||
478 | 22 | height: units.gu(60) | 22 | height: units.gu(60) |
479 | 23 | objectName: "mainView" | 23 | objectName: "mainView" |
480 | 24 | 24 | ||
481 | 25 | automaticOrientation: true | ||
482 | 26 | |||
483 | 25 | Page { | 27 | Page { |
484 | 26 | title: "Textarea" | 28 | title: "Textarea" |
485 | 27 | head.backAction: Action { | 29 | head.backAction: Action { |
486 | 28 | 30 | ||
487 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml' | |||
488 | --- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml 2015-03-10 16:29:24 +0000 | |||
489 | +++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield.qml 2015-03-31 12:57:21 +0000 | |||
490 | @@ -18,10 +18,12 @@ | |||
491 | 18 | import Ubuntu.Components 1.2 | 18 | import Ubuntu.Components 1.2 |
492 | 19 | 19 | ||
493 | 20 | MainView { | 20 | MainView { |
496 | 21 | width: units.gu(48) | 21 | width: units.gu(60) |
497 | 22 | height: units.gu(60) | 22 | height: units.gu(40) |
498 | 23 | objectName: "mainView" | 23 | objectName: "mainView" |
499 | 24 | 24 | ||
500 | 25 | automaticOrientation: true | ||
501 | 26 | |||
502 | 25 | Page { | 27 | Page { |
503 | 26 | title: "Textfield" | 28 | title: "Textfield" |
504 | 27 | head.backAction: Action { | 29 | head.backAction: Action { |
505 | @@ -31,11 +33,17 @@ | |||
506 | 31 | } | 33 | } |
507 | 32 | 34 | ||
508 | 33 | Column { | 35 | Column { |
509 | 36 | anchors.bottom: parent.bottom | ||
510 | 37 | spacing: units.gu(2) | ||
511 | 38 | |||
512 | 34 | TextField { | 39 | TextField { |
513 | 35 | objectName: "textfield" | 40 | objectName: "textfield" |
514 | 36 | placeholderText: "Type here" | 41 | placeholderText: "Type here" |
515 | 37 | width: units.gu(35) | 42 | width: units.gu(35) |
516 | 38 | } | 43 | } |
517 | 44 | Label { | ||
518 | 45 | text: i18n.tr("Text fields are awesome") | ||
519 | 46 | } | ||
520 | 39 | } | 47 | } |
521 | 40 | } | 48 | } |
522 | 41 | } | 49 | } |
523 | 42 | 50 | ||
524 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml' | |||
525 | --- tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml 2015-03-10 16:29:24 +0000 | |||
526 | +++ tests/autopilot/ubuntuuitoolkit/tests/components/test_textinput.textfield_custom.qml 2015-03-31 12:57:21 +0000 | |||
527 | @@ -23,6 +23,8 @@ | |||
528 | 23 | height: units.gu(60) | 23 | height: units.gu(60) |
529 | 24 | objectName: "mainView" | 24 | objectName: "mainView" |
530 | 25 | 25 | ||
531 | 26 | automaticOrientation: true | ||
532 | 27 | |||
533 | 26 | Page { | 28 | Page { |
534 | 27 | title: "Textfield" | 29 | title: "Textfield" |
535 | 28 | head.backAction: Action { | 30 | head.backAction: Action { |