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

Proposed by Cris Dywan
Status: Merged
Approved by: Zsombor Egri
Approved revision: 2064
Merged at revision: 2156
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/organizedWindow
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/outTheWindow
Diff against target: 200 lines (+82/-7)
7 files modified
src/UbuntuToolkit/ucapplication.cpp (+3/-2)
src/UbuntuToolkit/ucmainwindow.cpp (+29/-1)
src/UbuntuToolkit/ucmainwindow_p.h (+5/-1)
src/UbuntuToolkit/ucmainwindow_p_p.h (+2/-1)
tests/unit/mainwindow/AppName.qml (+1/-1)
tests/unit/mainwindow/OrganizationName.qml (+29/-0)
tests/unit/mainwindow/tst_mainwindow.cpp (+13/-1)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/organizedWindow
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Zsombor Egri Approve
Review via email: mp+314631@code.launchpad.net

Commit message

Add organizationName property to MainWindow

To post a comment you must log in.
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
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
Zsombor Egri (zsombi) wrote :

All clear, approved.

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)
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
Tiago Salem Herrmann (tiagosh) wrote :

We noticed that this MR breaks messaging-app and maybe other apps.
organizationName is used by QSettings to build the configuration file path.

In messaging-app we set the organizationName in the cpp code even before the MainView is loaded.
That makes the app create directories like $HOME/.config/Unknown Organization/MessagingApp, which didn't happen before.

We are probably hitting this case:
https://github.com/qt/qtbase/blob/dev/src/corelib/io/qsettings.cpp#L1138

We can certainly set that property on the MainView from now on to avoid running into this problem, but I wonder if other apps that also depend on QSettings (or Settings qml component from qt-labs-settings) wont break.

Revision history for this message
Cris Dywan (kalikiana) wrote :

Tracking investigation of the regression as bug 1662868.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/UbuntuToolkit/ucapplication.cpp'
2--- src/UbuntuToolkit/ucapplication.cpp 2016-09-09 17:49:07 +0000
3+++ src/UbuntuToolkit/ucapplication.cpp 2017-01-12 15:35:42 +0000
4@@ -39,6 +39,8 @@
5 UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0)
6 , m_inputMethod(QGuiApplication::inputMethod())
7 {
8+ // Unset organization by default to skip an extra folder component
9+ QCoreApplication::setOrganizationName(QStringLiteral(""));
10 // Make sure we receive application name changes from C++ modules
11 connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged,
12 this, &UCApplication::applicationNameChanged);
13@@ -68,8 +70,7 @@
14 to how Unity uses it to distinguish running applications.
15 */
16 QCoreApplication::setApplicationName(applicationName);
17- // Unset organization to skip an extra folder component
18- QCoreApplication::setOrganizationName(QString());
19+ QCoreApplication::setOrganizationName(QCoreApplication::organizationName());
20 /*
21 Ensure that LocalStorage and WebKit use the same location
22 Docs are ambiguous: in practise applicationName is ignored by default
23
24=== modified file 'src/UbuntuToolkit/ucmainwindow.cpp'
25--- src/UbuntuToolkit/ucmainwindow.cpp 2017-01-12 15:35:42 +0000
26+++ src/UbuntuToolkit/ucmainwindow.cpp 2017-01-12 15:35:42 +0000
27@@ -1,5 +1,5 @@
28 /*
29- * Copyright 2016 Canonical Ltd.
30+ * Copyright 2016-2017 Canonical Ltd.
31 *
32 * This program is free software; you can redistribute it and/or modify
33 * it under the terms of the GNU Lesser General Public License as published by
34@@ -172,6 +172,34 @@
35 }
36
37 /*!
38+ \qmlproperty string MainWindow::organizationName
39+
40+ The property holds the optional name of the organization. If set, data
41+ folders reside in a subfolder of the organizationName. By default no
42+ organizationName is set.
43+*/
44+QString UCMainWindow::organizationName() const
45+{
46+ return d_func()->m_organizationName;
47+}
48+
49+
50+void UCMainWindow::setOrganizationName(QString organizationName)
51+{
52+ Q_D(UCMainWindow);
53+
54+ if (d->m_organizationName == organizationName)
55+ return;
56+
57+ d->m_organizationName = organizationName;
58+
59+ if (organizationName != QStringLiteral("")) {
60+ QCoreApplication::setOrganizationName(organizationName);
61+ }
62+ Q_EMIT organizationNameChanged(organizationName);
63+}
64+
65+/*!
66 \qmlproperty Units MainWindow::units
67
68 Grid units for this particular window - unlike the global context property
69
70=== modified file 'src/UbuntuToolkit/ucmainwindow_p.h'
71--- src/UbuntuToolkit/ucmainwindow_p.h 2017-01-12 15:35:42 +0000
72+++ src/UbuntuToolkit/ucmainwindow_p.h 2017-01-12 15:35:42 +0000
73@@ -1,5 +1,5 @@
74 /*
75- * Copyright 2016 Canonical Ltd.
76+ * Copyright 2016-2017 Canonical Ltd.
77 *
78 * This program is free software; you can redistribute it and/or modify
79 * it under the terms of the GNU Lesser General Public License as published by
80@@ -32,6 +32,7 @@
81 {
82 Q_OBJECT
83 Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged)
84+ Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName NOTIFY organizationNameChanged)
85 #ifndef Q_QDOC
86 Q_PROPERTY(UT_PREPEND_NAMESPACE(UCUnits)* units READ units NOTIFY unitsChanged)
87 Q_PROPERTY(UT_PREPEND_NAMESPACE(UbuntuI18n)* i18n READ i18n NOTIFY i18nChanged)
88@@ -48,6 +49,8 @@
89
90 QString applicationName() const;
91 void setApplicationName(QString applicationName);
92+ QString organizationName() const;
93+ void setOrganizationName(QString organizationName);
94
95 UCUnits* units();
96 UbuntuI18n* i18n() const;
97@@ -56,6 +59,7 @@
98
99 Q_SIGNALS:
100 void applicationNameChanged(QString applicationName);
101+ void organizationNameChanged(QString applicationName);
102 void i18nChanged();
103 void unitsChanged();
104 #ifndef Q_QDOC
105
106=== modified file 'src/UbuntuToolkit/ucmainwindow_p_p.h'
107--- src/UbuntuToolkit/ucmainwindow_p_p.h 2017-01-12 15:35:42 +0000
108+++ src/UbuntuToolkit/ucmainwindow_p_p.h 2017-01-12 15:35:42 +0000
109@@ -1,5 +1,5 @@
110 /*
111- * Copyright 2016 Canonical Ltd.
112+ * Copyright 2016-2017 Canonical Ltd.
113 *
114 * This program is free software; you can redistribute it and/or modify
115 * it under the terms of the GNU Lesser General Public License as published by
116@@ -37,6 +37,7 @@
117 void init();
118
119 QString m_applicationName;
120+ QString m_organizationName;
121 UCPopupContext* m_actionContext = nullptr;
122 UCUnits* m_units = nullptr;
123
124
125=== modified file 'tests/unit/mainwindow/AppName.qml'
126--- tests/unit/mainwindow/AppName.qml 2017-01-12 15:35:42 +0000
127+++ tests/unit/mainwindow/AppName.qml 2017-01-12 15:35:42 +0000
128@@ -1,5 +1,5 @@
129 /*
130- * Copyright 2013-2016 Canonical Ltd.
131+ * Copyright 2013-2017 Canonical Ltd.
132 *
133 * This program is free software; you can redistribute it and/or modify
134 * it under the terms of the GNU Lesser General Public License as published by
135
136=== added file 'tests/unit/mainwindow/OrganizationName.qml'
137--- tests/unit/mainwindow/OrganizationName.qml 1970-01-01 00:00:00 +0000
138+++ tests/unit/mainwindow/OrganizationName.qml 2017-01-12 15:35:42 +0000
139@@ -0,0 +1,29 @@
140+/*
141+ * Copyright 2013-2017 Canonical Ltd.
142+ *
143+ * This program is free software; you can redistribute it and/or modify
144+ * it under the terms of the GNU Lesser General Public License as published by
145+ * the Free Software Foundation; version 3.
146+ *
147+ * This program is distributed in the hope that it will be useful,
148+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
149+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
150+ * GNU Lesser General Public License for more details.
151+ *
152+ * You should have received a copy of the GNU Lesser General Public License
153+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
154+ */
155+
156+import QtQuick 2.4
157+import Ubuntu.Components 1.3
158+import Ubuntu.Components.Labs 1.0
159+
160+MainWindow {
161+ objectName: "appName"
162+ applicationName: "tv.island.pacific"
163+ organizationName: "pacifist"
164+
165+ Label {
166+ text: "Lorem ipsum dolor sit amet"
167+ }
168+}
169
170=== modified file 'tests/unit/mainwindow/tst_mainwindow.cpp'
171--- tests/unit/mainwindow/tst_mainwindow.cpp 2017-01-12 15:35:42 +0000
172+++ tests/unit/mainwindow/tst_mainwindow.cpp 2017-01-12 15:35:42 +0000
173@@ -109,7 +109,7 @@
174 {
175 }
176
177- // Note: tests/unit/mainview contains the UCApplication bits
178+ // Note: tests/unit/mainview13 contains the UCApplication bits
179
180 void testCase_AppName()
181 {
182@@ -120,6 +120,18 @@
183 QCOMPARE(applicationName, QCoreApplication::applicationName());
184 QCOMPARE(QString(""), QCoreApplication::organizationName());
185 }
186+
187+ void testCase_OrganizationName()
188+ {
189+ QString applicationName("tv.island.pacific");
190+ QString organizationName("pacifist");
191+ QQuickWindow *mainWindow(loadTest("OrganizationName.qml"));
192+ QVERIFY(mainWindow);
193+ QCOMPARE(applicationName, mainWindow->property("applicationName").toString());
194+ QCOMPARE(applicationName, QCoreApplication::applicationName());
195+ QCOMPARE(organizationName, mainWindow->property("organizationName").toString());
196+ QCOMPARE(organizationName, QCoreApplication::organizationName());
197+ }
198 };
199
200 QTEST_MAIN(tst_MainWindow)

Subscribers

People subscribed via source and target branches