← Back to team overview

ubuntu-sdk-team team mailing list archive

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

 

Christian Dywan has proposed merging lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/organizedWindow into lp:ubuntu-ui-toolkit/staging with lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/outTheWindow as a prerequisite.

Commit message:
Add organizationName property to MainWindow

Requested reviews:
  Ubuntu SDK team (ubuntu-sdk-team)

For more details, see:
https://code.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/organizedWindow/+merge/314631
-- 
Your team Ubuntu SDK team is requested to review the proposed merge of lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/organizedWindow into lp:ubuntu-ui-toolkit/staging.
=== modified file 'src/UbuntuToolkit/ucapplication.cpp'
--- src/UbuntuToolkit/ucapplication.cpp	2016-09-09 17:49:07 +0000
+++ src/UbuntuToolkit/ucapplication.cpp	2017-01-12 15:33:19 +0000
@@ -39,6 +39,8 @@
 UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0)
                                                                , m_inputMethod(QGuiApplication::inputMethod())
 {
+    // Unset organization by default to skip an extra folder component
+    QCoreApplication::setOrganizationName(QStringLiteral(""));
     // Make sure we receive application name changes from C++ modules
     connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged,
             this, &UCApplication::applicationNameChanged);
@@ -68,8 +70,7 @@
        to how Unity uses it to distinguish running applications.
      */
     QCoreApplication::setApplicationName(applicationName);
-    // Unset organization to skip an extra folder component
-    QCoreApplication::setOrganizationName(QString());
+    QCoreApplication::setOrganizationName(QCoreApplication::organizationName());
     /*
        Ensure that LocalStorage and WebKit use the same location
        Docs are ambiguous: in practise applicationName is ignored by default

=== modified file 'src/UbuntuToolkit/ucmainwindow.cpp'
--- src/UbuntuToolkit/ucmainwindow.cpp	2017-01-12 15:33:18 +0000
+++ src/UbuntuToolkit/ucmainwindow.cpp	2017-01-12 15:33:19 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Canonical Ltd.
+ * Copyright 2016-2017 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -172,6 +172,34 @@
 }
 
 /*!
+  \qmlproperty string MainWindow::organizationName
+
+  The property holds the optional name of the organization. If set, data
+  folders reside in a subfolder of the organizationName. By default no
+  organizationName is set.
+*/
+QString UCMainWindow::organizationName() const
+{
+    return d_func()->m_organizationName;
+}
+
+
+void UCMainWindow::setOrganizationName(QString organizationName)
+{
+    Q_D(UCMainWindow);
+
+    if (d->m_organizationName == organizationName)
+        return;
+
+    d->m_organizationName = organizationName;
+
+    if (organizationName != QStringLiteral("")) {
+        QCoreApplication::setOrganizationName(organizationName);
+    }
+    Q_EMIT organizationNameChanged(organizationName);
+}
+
+/*!
   \qmlproperty Units MainWindow::units
 
   Grid units for this particular window - unlike the global context property

=== modified file 'src/UbuntuToolkit/ucmainwindow_p.h'
--- src/UbuntuToolkit/ucmainwindow_p.h	2017-01-12 15:33:18 +0000
+++ src/UbuntuToolkit/ucmainwindow_p.h	2017-01-12 15:33:19 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Canonical Ltd.
+ * Copyright 2016-2017 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -32,6 +32,7 @@
 {
     Q_OBJECT
     Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName NOTIFY applicationNameChanged)
+    Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName NOTIFY organizationNameChanged)
 #ifndef Q_QDOC
     Q_PROPERTY(UT_PREPEND_NAMESPACE(UCUnits)* units READ units NOTIFY unitsChanged)
     Q_PROPERTY(UT_PREPEND_NAMESPACE(UbuntuI18n)* i18n READ i18n NOTIFY i18nChanged)
@@ -48,6 +49,8 @@
 
     QString applicationName() const;
     void setApplicationName(QString applicationName);
+    QString organizationName() const;
+    void setOrganizationName(QString organizationName);
 
     UCUnits* units();
     UbuntuI18n* i18n() const;
@@ -56,6 +59,7 @@
 
 Q_SIGNALS:
     void applicationNameChanged(QString applicationName);
+    void organizationNameChanged(QString applicationName);
     void i18nChanged();
     void unitsChanged();
 #ifndef Q_QDOC

=== modified file 'src/UbuntuToolkit/ucmainwindow_p_p.h'
--- src/UbuntuToolkit/ucmainwindow_p_p.h	2017-01-12 15:33:18 +0000
+++ src/UbuntuToolkit/ucmainwindow_p_p.h	2017-01-12 15:33:19 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Canonical Ltd.
+ * Copyright 2016-2017 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -37,6 +37,7 @@
     void init();
 
     QString m_applicationName;
+    QString m_organizationName;
     UCPopupContext* m_actionContext = nullptr;
     UCUnits* m_units = nullptr;
 

=== modified file 'tests/unit/mainwindow/AppName.qml'
--- tests/unit/mainwindow/AppName.qml	2017-01-12 15:33:18 +0000
+++ tests/unit/mainwindow/AppName.qml	2017-01-12 15:33:19 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013-2016 Canonical Ltd.
+ * Copyright 2013-2017 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by

=== added file 'tests/unit/mainwindow/OrganizationName.qml'
--- tests/unit/mainwindow/OrganizationName.qml	1970-01-01 00:00:00 +0000
+++ tests/unit/mainwindow/OrganizationName.qml	2017-01-12 15:33:19 +0000
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2013-2017 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.4
+import Ubuntu.Components 1.3
+import Ubuntu.Components.Labs 1.0
+
+MainWindow {
+    objectName: "appName"
+    applicationName: "tv.island.pacific"
+    organizationName: "pacifist"
+
+    Label {
+        text: "Lorem ipsum dolor sit amet"
+    }
+}

=== modified file 'tests/unit/mainwindow/tst_mainwindow.cpp'
--- tests/unit/mainwindow/tst_mainwindow.cpp	2017-01-12 15:33:18 +0000
+++ tests/unit/mainwindow/tst_mainwindow.cpp	2017-01-12 15:33:19 +0000
@@ -109,7 +109,7 @@
     {
     }
 
-    // Note: tests/unit/mainview contains the UCApplication bits
+    // Note: tests/unit/mainview13 contains the UCApplication bits
 
     void testCase_AppName()
     {
@@ -120,6 +120,18 @@
         QCOMPARE(applicationName, QCoreApplication::applicationName());
         QCOMPARE(QString(""), QCoreApplication::organizationName());
     }
+
+    void testCase_OrganizationName()
+    {
+        QString applicationName("tv.island.pacific");
+        QString organizationName("pacifist");
+        QQuickWindow *mainWindow(loadTest("OrganizationName.qml"));
+        QVERIFY(mainWindow);
+        QCOMPARE(applicationName, mainWindow->property("applicationName").toString());
+        QCOMPARE(applicationName, QCoreApplication::applicationName());
+        QCOMPARE(organizationName, mainWindow->property("organizationName").toString());
+        QCOMPARE(organizationName, QCoreApplication::organizationName());
+    }
 };
 
 QTEST_MAIN(tst_MainWindow)


Follow ups