Merge lp:~fboucault/ubuntu-ui-toolkit/content_orientation_bis into lp:ubuntu-ui-toolkit

Proposed by Florian Boucault
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 664
Merged at revision: 663
Proposed branch: lp:~fboucault/ubuntu-ui-toolkit/content_orientation_bis
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 84 lines (+41/-0)
3 files modified
modules/Ubuntu/Components/OrientationHelper.qml (+8/-0)
modules/Ubuntu/Components/plugin/plugin.cpp (+27/-0)
modules/Ubuntu/Components/plugin/plugin.h (+6/-0)
To merge this branch: bzr merge lp:~fboucault/ubuntu-ui-toolkit/content_orientation_bis
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu SDK team Pending
Review via email: mp+177367@code.launchpad.net

Commit message

OrientationHelper: report the current orientation of the application via QWindow::contentOrientation.
This is a remerge of a previous merge that was reverted because of a segfault. The segfault has been fixed by ensuring that setWindowContextProperty is called in the same thread (the main thread).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'modules/Ubuntu/Components/OrientationHelper.qml'
--- modules/Ubuntu/Components/OrientationHelper.qml 2013-07-27 12:11:45 +0000
+++ modules/Ubuntu/Components/OrientationHelper.qml 2013-07-29 11:41:22 +0000
@@ -91,6 +91,14 @@
9191
92 Component.onCompleted: orientationTransition.enabled = transitionEnabled92 Component.onCompleted: orientationTransition.enabled = transitionEnabled
9393
94 /*!
95 \internal
96
97 Report the current orientation of the application via QWindow::contentOrientation.
98 http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop
99 */
100 onOrientationAngleChanged: window.contentOrientation = Screen.orientation
101
94 Item {102 Item {
95 id: stateWrapper103 id: stateWrapper
96104
97105
=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
--- modules/Ubuntu/Components/plugin/plugin.cpp 2013-07-27 12:11:45 +0000
+++ modules/Ubuntu/Components/plugin/plugin.cpp 2013-07-29 11:41:22 +0000
@@ -100,6 +100,31 @@
100 }100 }
101}101}
102102
103void UbuntuComponentsPlugin::registerWindowContextProperty()
104{
105 setWindowContextProperty(QGuiApplication::focusWindow());
106
107 // listen to QGuiApplication::focusWindowChanged
108 /* Ensure that setWindowContextProperty is called in the same thread (the
109 main thread) otherwise it segfaults. Reference:
110 https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205556
111 */
112 QGuiApplication* application = static_cast<QGuiApplication*>(QCoreApplication::instance());
113 QObject::connect(application, SIGNAL(focusWindowChanged(QWindow*)),
114 this, SLOT(setWindowContextProperty(QWindow*)),
115 Qt::DirectConnection);
116
117}
118
119void UbuntuComponentsPlugin::setWindowContextProperty(QWindow* focusWindow)
120{
121 QQuickView* view = qobject_cast<QQuickView*>(focusWindow);
122
123 if (view != NULL) {
124 view->rootContext()->setContextProperty("window", view);
125 }
126}
127
103void UbuntuComponentsPlugin::registerTypes(const char *uri)128void UbuntuComponentsPlugin::registerTypes(const char *uri)
104{129{
105 Q_ASSERT(uri == QLatin1String("Ubuntu.Components"));130 Q_ASSERT(uri == QLatin1String("Ubuntu.Components"));
@@ -164,4 +189,6 @@
164 Qt::LandscapeOrientation |189 Qt::LandscapeOrientation |
165 Qt::InvertedPortraitOrientation |190 Qt::InvertedPortraitOrientation |
166 Qt::InvertedLandscapeOrientation);191 Qt::InvertedLandscapeOrientation);
192
193 registerWindowContextProperty();
167}194}
168195
=== modified file 'modules/Ubuntu/Components/plugin/plugin.h'
--- modules/Ubuntu/Components/plugin/plugin.h 2013-07-27 12:11:45 +0000
+++ modules/Ubuntu/Components/plugin/plugin.h 2013-07-29 11:41:22 +0000
@@ -22,6 +22,8 @@
22#include <QtQml/QQmlEngine>22#include <QtQml/QQmlEngine>
23#include <QtQml/QQmlExtensionPlugin>23#include <QtQml/QQmlExtensionPlugin>
2424
25class QWindow;
26
25class UbuntuComponentsPlugin : public QQmlExtensionPlugin27class UbuntuComponentsPlugin : public QQmlExtensionPlugin
26{28{
27 Q_OBJECT29 Q_OBJECT
@@ -32,6 +34,10 @@
32 void initializeEngine(QQmlEngine *engine, const char *uri);34 void initializeEngine(QQmlEngine *engine, const char *uri);
33 QUrl baseUrl(QStringList importPathList, const char* uri);35 QUrl baseUrl(QStringList importPathList, const char* uri);
34 void registerQmlSingletonType(QQmlEngine *engine, const char* uri, const char* typeName, const char* qmlFile);36 void registerQmlSingletonType(QQmlEngine *engine, const char* uri, const char* typeName, const char* qmlFile);
37
38private Q_SLOTS:
39 void registerWindowContextProperty();
40 void setWindowContextProperty(QWindow* focusWindow);
35};41};
36#endif // UBUNTU_COMPONENTS_PLUGIN_H42#endif // UBUNTU_COMPONENTS_PLUGIN_H
3743

Subscribers

People subscribed via source and target branches

to status/vote changes: