aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickapplication_p.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-09-22 14:22:26 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2016-10-10 11:48:57 +0000
commitd6dfbe8fd5d09388fc624d85c4aefa0269c20db9 (patch)
tree981dd2ab5444b5d83a3538fb7ca444e327f76d8a /src/quick/util/qquickapplication_p.h
parente91bd092f26a9a90ea6df57b84d8c1678c76ba4d (diff)
Enable making window-screen associations from QML
Qt Quick provides a Screen attached property to query information about the screen an item's window belongs to. This is a good start, but has two problems: it lacks some virtual desktop related info (e.g. the position in the virtual desktop) and it cannot be used in combination with the Window element in order to achieve a QML equivalent of QWindow::setScreen(). Therefore add the missing virtualX and virtualY properties and introduce Qt.application.screens. The latter is an equivalent to QGuiApplication::screens() and is a JS array the elements of which can be set as the value of the new Window.targetScreen property. This means that a call like window->setScreen(QGuiApplication::screens()[0]) translates to Window { targetScreen: Qt.application.screens[0]; ... } when using the Window type from QML. Screen addition or removal can be acted upon via onScreensChanged. QQuickScreenAttached has been split into two in order to allow reusing the QScreen wrapping queries for other purposes as well. Task-number: QTBUG-56115 Change-Id: I4b2fbd873315b40d0afe878da2fc50966c00e2e0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/util/qquickapplication_p.h')
-rw-r--r--src/quick/util/qquickapplication_p.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h
index 091cb094ed..70381553b4 100644
--- a/src/quick/util/qquickapplication_p.h
+++ b/src/quick/util/qquickapplication_p.h
@@ -56,10 +56,10 @@
#include <qqml.h>
#include <QtQml/private/qqmlglobal_p.h>
#include <private/qtquickglobal_p.h>
+#include "../items/qquickscreen_p.h"
QT_BEGIN_NAMESPACE
-
class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication
{
Q_OBJECT
@@ -68,6 +68,7 @@ class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication
Q_PROPERTY(bool supportsMultipleWindows READ supportsMultipleWindows CONSTANT)
Q_PROPERTY(Qt::ApplicationState state READ state NOTIFY stateChanged)
Q_PROPERTY(QFont font READ font CONSTANT)
+ Q_PROPERTY(QQmlListProperty<QQuickScreenInfo> screens READ screens NOTIFY screensChanged)
public:
explicit QQuickApplication(QObject *parent = 0);
@@ -77,14 +78,20 @@ public:
bool supportsMultipleWindows() const;
Qt::ApplicationState state() const;
QFont font() const;
+ QQmlListProperty<QQuickScreenInfo> screens();
Q_SIGNALS:
void activeChanged();
void layoutDirectionChanged();
void stateChanged(Qt::ApplicationState state);
+ void screensChanged();
+
+private Q_SLOTS:
+ void updateScreens();
private:
Q_DISABLE_COPY(QQuickApplication)
+ QVector<QQuickScreenInfo *> m_screens;
};
QT_END_NAMESPACE