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
1=== modified file 'modules/Ubuntu/Components/OrientationHelper.qml'
2--- modules/Ubuntu/Components/OrientationHelper.qml 2013-07-27 12:11:45 +0000
3+++ modules/Ubuntu/Components/OrientationHelper.qml 2013-07-29 11:41:22 +0000
4@@ -91,6 +91,14 @@
5
6 Component.onCompleted: orientationTransition.enabled = transitionEnabled
7
8+ /*!
9+ \internal
10+
11+ Report the current orientation of the application via QWindow::contentOrientation.
12+ http://qt-project.org/doc/qt-5.0/qtgui/qwindow.html#contentOrientation-prop
13+ */
14+ onOrientationAngleChanged: window.contentOrientation = Screen.orientation
15+
16 Item {
17 id: stateWrapper
18
19
20=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
21--- modules/Ubuntu/Components/plugin/plugin.cpp 2013-07-27 12:11:45 +0000
22+++ modules/Ubuntu/Components/plugin/plugin.cpp 2013-07-29 11:41:22 +0000
23@@ -100,6 +100,31 @@
24 }
25 }
26
27+void UbuntuComponentsPlugin::registerWindowContextProperty()
28+{
29+ setWindowContextProperty(QGuiApplication::focusWindow());
30+
31+ // listen to QGuiApplication::focusWindowChanged
32+ /* Ensure that setWindowContextProperty is called in the same thread (the
33+ main thread) otherwise it segfaults. Reference:
34+ https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205556
35+ */
36+ QGuiApplication* application = static_cast<QGuiApplication*>(QCoreApplication::instance());
37+ QObject::connect(application, SIGNAL(focusWindowChanged(QWindow*)),
38+ this, SLOT(setWindowContextProperty(QWindow*)),
39+ Qt::DirectConnection);
40+
41+}
42+
43+void UbuntuComponentsPlugin::setWindowContextProperty(QWindow* focusWindow)
44+{
45+ QQuickView* view = qobject_cast<QQuickView*>(focusWindow);
46+
47+ if (view != NULL) {
48+ view->rootContext()->setContextProperty("window", view);
49+ }
50+}
51+
52 void UbuntuComponentsPlugin::registerTypes(const char *uri)
53 {
54 Q_ASSERT(uri == QLatin1String("Ubuntu.Components"));
55@@ -164,4 +189,6 @@
56 Qt::LandscapeOrientation |
57 Qt::InvertedPortraitOrientation |
58 Qt::InvertedLandscapeOrientation);
59+
60+ registerWindowContextProperty();
61 }
62
63=== modified file 'modules/Ubuntu/Components/plugin/plugin.h'
64--- modules/Ubuntu/Components/plugin/plugin.h 2013-07-27 12:11:45 +0000
65+++ modules/Ubuntu/Components/plugin/plugin.h 2013-07-29 11:41:22 +0000
66@@ -22,6 +22,8 @@
67 #include <QtQml/QQmlEngine>
68 #include <QtQml/QQmlExtensionPlugin>
69
70+class QWindow;
71+
72 class UbuntuComponentsPlugin : public QQmlExtensionPlugin
73 {
74 Q_OBJECT
75@@ -32,6 +34,10 @@
76 void initializeEngine(QQmlEngine *engine, const char *uri);
77 QUrl baseUrl(QStringList importPathList, const char* uri);
78 void registerQmlSingletonType(QQmlEngine *engine, const char* uri, const char* typeName, const char* qmlFile);
79+
80+private Q_SLOTS:
81+ void registerWindowContextProperty();
82+ void setWindowContextProperty(QWindow* focusWindow);
83 };
84 #endif // UBUNTU_COMPONENTS_PLUGIN_H
85

Subscribers

People subscribed via source and target branches

to status/vote changes: