ubuntu-sdk-team team mailing list archive
-
ubuntu-sdk-team team
-
Mailing list archive
-
Message #00283
[Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
Christian Dywan has proposed merging lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging with lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/outTheWindow as a prerequisite.
Commit message:
Add visualRoot 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/visualRoot/+merge/314684
--
Your team Ubuntu SDK team is requested to review the proposed merge of lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging.
=== modified file 'src/UbuntuToolkit/quickutils.cpp'
--- src/UbuntuToolkit/quickutils.cpp 2016-11-11 06:57:56 +0000
+++ src/UbuntuToolkit/quickutils.cpp 2017-01-16 14:21:29 +0000
@@ -29,6 +29,8 @@
#include <QtQuick/private/qquicktextedit_p.h>
#include <QtSystemInfo/QInputInfoManager>
+#include <UbuntuToolkit/private/ucmainwindow_p.h>
+
UT_NAMESPACE_BEGIN
QuickUtils *QuickUtils::m_instance = nullptr;
@@ -175,6 +177,12 @@
{
// make sure we have the m_rootView updated
lookupQuickView();
+
+ UCMainWindow *mainWindow(qobject_cast<UCMainWindow*>(m_rootWindow));
+ if (mainWindow && mainWindow->visualRoot()) {
+ return mainWindow->visualRoot();
+ }
+
if (!object) {
return m_rootView ? m_rootView->rootObject() : (m_rootWindow ? m_rootWindow->contentItem() : 0);
}
=== modified file 'src/UbuntuToolkit/ucmainwindow.cpp'
--- src/UbuntuToolkit/ucmainwindow.cpp 2017-01-12 15:20:31 +0000
+++ src/UbuntuToolkit/ucmainwindow.cpp 2017-01-16 14:21:29 +0000
@@ -238,6 +238,29 @@
return d_func()->m_actionContext;
}
+/*!
+ \qmlproperty Item MainWindow::visualRoot
+
+ The property holds the window's visual root, as opposed to the root item.
+ If set, popups (popovers, dialogs, menus) will reparent to it when opened via
+ popupUtils.open().
+*/
+QQuickItem *UCMainWindow::visualRoot() const
+{
+ return d_func()->m_visualRoot;
+}
+
+void UCMainWindow::setVisualRoot(QQuickItem *visualRoot)
+{
+ Q_D(UCMainWindow);
+
+ if (d->m_visualRoot == visualRoot)
+ return;
+
+ d->m_visualRoot = visualRoot;
+ Q_EMIT visualRootChanged(visualRoot);
+}
+
UT_NAMESPACE_END
#include "moc_ucmainwindow_p.cpp"
=== modified file 'src/UbuntuToolkit/ucmainwindow_p.h'
--- src/UbuntuToolkit/ucmainwindow_p.h 2017-01-12 15:20:31 +0000
+++ src/UbuntuToolkit/ucmainwindow_p.h 2017-01-16 14:21:29 +0000
@@ -37,10 +37,12 @@
Q_PROPERTY(UT_PREPEND_NAMESPACE(UCUnits)* units READ units NOTIFY unitsChanged)
Q_PROPERTY(UT_PREPEND_NAMESPACE(UbuntuI18n)* i18n READ i18n NOTIFY i18nChanged)
Q_PROPERTY(UT_PREPEND_NAMESPACE(UCPopupContext)* actionContext READ actionContext NOTIFY actionContextChanged)
+ Q_PROPERTY(UT_PREPEND_NAMESPACE(QQuickItem)* visualRoot READ visualRoot WRITE setVisualRoot NOTIFY visualRootChanged)
#else
Q_PROPERTY(UCUnits* units READ units NOTIFY unitsChanged)
Q_PROPERTY(UbuntuI18n* i18n READ i18n NOTIFY i18nChanged)
Q_PROPERTY(UCPopupContext* actionContext READ actionContext NOTIFY actionContextChanged)
+ Q_PROPERTY(QQuickItem* visualRoot READ visualRoot WRITE setVisualRoot NOTIFY visualRootChanged)
#endif
public:
@@ -57,6 +59,9 @@
UCPopupContext* actionContext() const;
+ QQuickItem* visualRoot() const;
+ void setVisualRoot(QQuickItem*);
+
Q_SIGNALS:
void applicationNameChanged(QString applicationName);
void organizationNameChanged(QString applicationName);
@@ -64,8 +69,10 @@
void unitsChanged();
#ifndef Q_QDOC
void actionContextChanged(UT_PREPEND_NAMESPACE(UCPopupContext)* actionContext);
+ void visualRootChanged(UT_PREPEND_NAMESPACE(QQuickItem)* visualRoot);
#else
void actionContextChanged(UCPopupContext* actionContext);
+ void visualRootChanged(QQuickItem* visualRoot);
#endif
private:
=== modified file 'src/UbuntuToolkit/ucmainwindow_p_p.h'
--- src/UbuntuToolkit/ucmainwindow_p_p.h 2017-01-12 15:20:31 +0000
+++ src/UbuntuToolkit/ucmainwindow_p_p.h 2017-01-16 14:21:29 +0000
@@ -40,6 +40,7 @@
QString m_organizationName;
UCPopupContext* m_actionContext = nullptr;
UCUnits* m_units = nullptr;
+ QQuickItem* m_visualRoot = nullptr;
};
=== added file 'tests/unit/mainwindow/VisualRoot.qml'
--- tests/unit/mainwindow/VisualRoot.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/mainwindow/VisualRoot.qml 2017-01-16 14:21:29 +0000
@@ -0,0 +1,36 @@
+/*
+ * 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: "visualRoot"
+ applicationName: "org.gnu.wildebeest"
+ visualRoot: myRoot
+
+ Rectangle {
+ id: myRoot
+ objectName: "myRoot"
+ anchors.fill: parent
+
+ Label {
+ objectName: "myLabel"
+ text: "Lorem ipsum dolor sit amet"
+ }
+ }
+}
=== modified file 'tests/unit/mainwindow/tst_mainwindow.cpp'
--- tests/unit/mainwindow/tst_mainwindow.cpp 2017-01-12 15:20:31 +0000
+++ tests/unit/mainwindow/tst_mainwindow.cpp 2017-01-16 14:21:29 +0000
@@ -41,7 +41,9 @@
#include <QtQml/QQmlComponent>
#include <UbuntuToolkit/ubuntutoolkitmodule.h>
+#include <UbuntuToolkit/quickutils.h>
#include <UbuntuToolkit/private/ucapplication_p.h>
+#include <UbuntuToolkit/private/ucmainwindow_p.h>
#include <UbuntuToolkit/private/ucunits_p.h>
UT_USE_NAMESPACE
@@ -90,7 +92,7 @@
return window;
}
- QQuickItem *testItem(QQuickItem *that, const QString &identifier)
+ QQuickItem *testItem(QObject *that, const QString &identifier)
{
if (that->property(identifier.toLocal8Bit()).isValid())
return that->property(identifier.toLocal8Bit()).value<QQuickItem*>();
@@ -120,6 +122,7 @@
QCOMPARE(applicationName, QCoreApplication::applicationName());
QCOMPARE(QString(""), QCoreApplication::organizationName());
}
+<<<<<<< TREE
void testCase_OrganizationName()
{
@@ -132,6 +135,18 @@
QCOMPARE(organizationName, mainWindow->property("organizationName").toString());
QCOMPARE(organizationName, QCoreApplication::organizationName());
}
+=======
+
+ void testCase_VisualRoot()
+ {
+ QQuickWindow *mainWindow(loadTest("VisualRoot.qml"));
+ QVERIFY(mainWindow);
+ QQuickItem* myLabel(testItem(mainWindow, "myLabel"));
+ QQuickItem* visualRoot(QuickUtils::instance()->rootItem(myLabel));
+ QQuickItem* myRoot(testItem(mainWindow, "myRoot"));
+ QCOMPARE(visualRoot, myRoot);
+ }
+>>>>>>> MERGE-SOURCE
};
QTEST_MAIN(tst_MainWindow)
Follow ups
-
[Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: noreply, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
[Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: Tim Peeters, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: Tim Peeters, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: Zsombor Egri, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: Christian Dywan, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: Tim Peeters, 2017-01-18
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: Tim Peeters, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16
-
Re: [Merge] lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/visualRoot into lp:ubuntu-ui-toolkit/staging
From: ubuntu-sdk-build-bot, 2017-01-16