Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/realLayoutDirectionChange into lp:ubuntu-ui-toolkit/staging

Proposed by Cris Dywan
Status: Merged
Approved by: Zsombor Egri
Approved revision: 2181
Merged at revision: 2188
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/realLayoutDirectionChange
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 117 lines (+28/-6)
5 files modified
components.api (+1/-0)
examples/ubuntu-ui-toolkit-gallery/MainPage.qml (+4/-4)
examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml (+1/-2)
src/UbuntuToolkit/ucapplication.cpp (+18/-0)
src/UbuntuToolkit/ucapplication_p.h (+4/-0)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/realLayoutDirectionChange
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Zsombor Egri Approve
Adnane Belmadiaf (community) Approve
Review via email: mp+318359@code.launchpad.net

Commit message

Change layoutDirection from gallery (via UCApplication)

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
2181. By Cris Dywan

Update components.api

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Adnane Belmadiaf (daker) wrote :

LGTM, i still see some issues in RTL mode with APL but they are not related to this MR.

review: Approve
Revision history for this message
Zsombor Egri (zsombi) wrote :

All fine, thanks for having it!

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) 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 'components.api'
2--- components.api 2017-02-21 14:57:05 +0000
3+++ components.api 2017-02-27 15:48:33 +0000
4@@ -1635,6 +1635,7 @@
5 Ubuntu.Components.UCApplication 1.0 0.1: QtObject
6 property string applicationName
7 property QtObject inputMethod
8+ property Qt.LayoutDirection layoutDirection
9 Ubuntu.Components.UCFontUtils 1.0 0.1: QtObject
10 function double sizeToPixels(string size)
11 function double modularScale(string size)
12
13=== modified file 'examples/ubuntu-ui-toolkit-gallery/MainPage.qml'
14--- examples/ubuntu-ui-toolkit-gallery/MainPage.qml 2016-06-17 13:42:23 +0000
15+++ examples/ubuntu-ui-toolkit-gallery/MainPage.qml 2017-02-27 15:48:33 +0000
16@@ -30,14 +30,14 @@
17 Action {
18 text: i18n.tr('Right to Left')
19 iconName: 'flash-on'
20- visible: !gallery.rtl
21- onTriggered: gallery.rtl = !gallery.rtl
22+ visible: UbuntuApplication.layoutDirection == Qt.LeftToRight
23+ onTriggered: UbuntuApplication.layoutDirection = Qt.RightToLeft
24 },
25 Action {
26 text: i18n.tr('Left to Right')
27 iconName: 'flash-off'
28- visible: gallery.rtl
29- onTriggered: gallery.rtl = !gallery.rtl
30+ visible: UbuntuApplication.layoutDirection == Qt.RightToLeft
31+ onTriggered: UbuntuApplication.layoutDirection = Qt.LeftToRight
32 },
33 Action {
34 text: i18n.tr('Use dark theme')
35
36=== modified file 'examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml'
37--- examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml 2016-01-18 12:50:44 +0000
38+++ examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml 2017-02-27 15:48:33 +0000
39@@ -29,9 +29,8 @@
40 width: units.gu(120)
41 height: units.gu(75)
42
43- LayoutMirroring.enabled: rtl
44+ LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
45 LayoutMirroring.childrenInherit: true
46- property bool rtl: Qt.application.layoutDirection == Qt.RightToLeft
47
48 AdaptivePageLayout {
49 id: layout
50
51=== modified file 'src/UbuntuToolkit/ucapplication.cpp'
52--- src/UbuntuToolkit/ucapplication.cpp 2017-02-09 11:00:07 +0000
53+++ src/UbuntuToolkit/ucapplication.cpp 2017-02-27 15:48:33 +0000
54@@ -42,6 +42,10 @@
55 // Make sure we receive application name changes from C++ modules
56 connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged,
57 this, &UCApplication::applicationNameChanged);
58+ // Changes to the default layout direction (RTL, LTR)
59+ QGuiApplication* application = qobject_cast<QGuiApplication*>(QCoreApplication::instance());
60+ connect(application, &QGuiApplication::layoutDirectionChanged,
61+ this, &UCApplication::layoutDirectionChanged);
62 }
63
64 UCApplication::~UCApplication()
65@@ -91,4 +95,18 @@
66 m_inputMethod = inputMethod;
67 }
68
69+/*!
70+ * \internal
71+ * The (default) layout direction. Can be overridden for testing,
72+ * unlike Qt.application.layoutDirection.
73+ */
74+Qt::LayoutDirection UCApplication::layoutDirection() {
75+ return QGuiApplication::layoutDirection();
76+}
77+
78+void UCApplication::setLayoutDirection(Qt::LayoutDirection layoutDirection) {
79+ return QGuiApplication::setLayoutDirection(layoutDirection);
80+}
81+
82+
83 UT_NAMESPACE_END
84
85=== modified file 'src/UbuntuToolkit/ucapplication_p.h'
86--- src/UbuntuToolkit/ucapplication_p.h 2016-09-09 17:49:07 +0000
87+++ src/UbuntuToolkit/ucapplication_p.h 2017-02-27 15:48:33 +0000
88@@ -33,6 +33,7 @@
89 Q_OBJECT
90 Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged)
91 Q_PROPERTY(QObject* inputMethod READ inputMethod WRITE setInputMethod NOTIFY inputMethodChanged)
92+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
93
94 private:
95 Q_DISABLE_COPY(UCApplication)
96@@ -53,11 +54,13 @@
97 // getter
98 QString applicationName();
99 QObject* inputMethod();
100+ Qt::LayoutDirection layoutDirection();
101
102 // setter
103 void setContext(QQmlContext* context);
104 void setApplicationName(const QString& applicationName);
105 void setInputMethod(QObject* inputMethod);
106+ void setLayoutDirection(Qt::LayoutDirection layoutDirection);
107
108 private:
109 QQmlContext* m_context;
110@@ -67,6 +70,7 @@
111 Q_SIGNALS:
112 void applicationNameChanged();
113 void inputMethodChanged();
114+ void layoutDirectionChanged();
115 };
116
117 UT_NAMESPACE_END

Subscribers

People subscribed via source and target branches