aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-02-08 16:25:12 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-02-11 12:12:38 +0000
commitf145f33d529c2b59ace7a3cdfd5463e68787f40b (patch)
treee52efc0d5750e84bbf68d7501bba94c726cec673
parent705a2780743a01cb9a1032fca8c1f942b50e5a0a (diff)
Rename Window.targetScreen to screen, and pick up changes to the screen
The screen property can be used for both setting the initital screen, and for reading out the current screen, so 'targetScreen' was not an ideal name for this property. Change-Id: I1b617085b1e8e0e437355740be5d3cee9379c47f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/qml/qml/qqmlengine.cpp4
-rw-r--r--src/quick/items/qquickscreen.cpp6
-rw-r--r--src/quick/items/qquickscreen_p.h2
-rw-r--r--src/quick/items/qquickwindow.cpp26
-rw-r--r--src/quick/items/qquickwindowmodule.cpp22
-rw-r--r--src/quick/items/qquickwindowmodule_p.h8
-rw-r--r--tests/auto/quick/qquickwindow/data/windowWithScreen.qml2
7 files changed, 30 insertions, 40 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 7fb94da9ce..9e6d046485 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -565,7 +565,7 @@ The following functions are also on the Qt object.
\l{Screen} attached object. In practice the array corresponds to the screen
list returned by QGuiApplication::screens(). In addition to examining
properties like name, width, height, etc., the array elements can also be
- assigned to the targetScreen property of Window items, thus serving as an
+ assigned to the screen property of Window items, thus serving as an
alternative to the C++ side's QWindow::setScreen(). This property has been
added in Qt 5.9.
@@ -586,7 +586,7 @@ The following functions are also on the Qt object.
\li application.font
\endlist
- \sa Screen, Window, Window.targetScreen
+ \sa Screen, Window, Window.screen
*/
/*!
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index 9347b55c70..20c6973ee1 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -207,9 +207,9 @@ QT_BEGIN_NAMESPACE
By default it is set to the value of the QScreen that the window uses.
*/
-QQuickScreenInfo::QQuickScreenInfo(QObject *parent)
- : QObject(parent),
- m_screen(nullptr)
+QQuickScreenInfo::QQuickScreenInfo(QObject *parent, QScreen *wrappedScreen)
+ : QObject(parent)
+ , m_screen(wrappedScreen)
{
}
diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h
index 06efb3ab45..99e1466631 100644
--- a/src/quick/items/qquickscreen_p.h
+++ b/src/quick/items/qquickscreen_p.h
@@ -84,7 +84,7 @@ class Q_AUTOTEST_EXPORT QQuickScreenInfo : public QObject
Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION 1)
public:
- QQuickScreenInfo(QObject *parent = nullptr);
+ QQuickScreenInfo(QObject *parent = nullptr, QScreen *wrappedScreen = nullptr);
QString name() const;
int width() const;
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 0e7c50ffcf..0ebd644d69 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -4172,25 +4172,25 @@ void QQuickWindow::resetOpenGLState()
*/
/*!
- \qmlproperty variant Window::targetScreen
+ \qmlproperty variant Window::screen
- Specifies the screen the window should be placed on. Equivalent to
- QWindow::setScreen().
+ The screen with which the window is associated.
- The value must be an element from the Qt.application.screens array.
+ If specified before showing a window, will result in the window being shown
+ on that screen, unless an explicit window position has been set. The value
+ must be an element from the Qt.application.screens array.
- By default the value is null which leads to using the primary screen.
-
- \note To ensure that the window is associated with the desired screen right
- upon the underlying native window's initial creation, make sure this
- property is set as early as possible and that the setting of its value is
- not deferred. This can be particularly important on embedded platforms
- without a windowing system, where only one window per screen is allowed at a
- time.
+ \note To ensure that the window is associated with the desired screen when
+ the underlying native window is created, make sure this property is set as
+ early as possible and that the setting of its value is not deferred. This
+ can be particularly important on embedded platforms without a windowing system,
+ where only one window per screen is allowed at a time. Setting the screen after
+ a window has been created does not move the window if the new screen is part of
+ the same virtual desktop as the old screen.
\since 5.9
- \sa QWindow::setScreen(), QScreen, Qt.application
+ \sa QWindow::setScreen(), QWindow::screen(), QScreen, Qt.application
*/
/*!
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index 42313e4584..6211b7802f 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -59,7 +59,6 @@ public:
: complete(false)
, visible(false)
, visibility(QQuickWindow::AutomaticVisibility)
- , targetScreen(nullptr)
{
}
@@ -67,7 +66,6 @@ public:
bool visible;
QQuickWindow::Visibility visibility;
QV4::PersistentValue rootItemMarker;
- QObject *targetScreen;
};
QQuickWindowQmlImpl::QQuickWindowQmlImpl(QWindow *parent)
@@ -75,6 +73,7 @@ QQuickWindowQmlImpl::QQuickWindowQmlImpl(QWindow *parent)
{
connect(this, &QWindow::visibleChanged, this, &QQuickWindowQmlImpl::visibleChanged);
connect(this, &QWindow::visibilityChanged, this, &QQuickWindowQmlImpl::visibilityChanged);
+ connect(this, &QWindow::screenChanged, this, &QQuickWindowQmlImpl::screenChanged);
}
void QQuickWindowQmlImpl::setVisible(bool visible)
@@ -175,24 +174,15 @@ void QQuickWindowQmlImpl::setWindowVisibility()
}
}
-QObject *QQuickWindowQmlImpl::targetScreen() const
+QObject *QQuickWindowQmlImpl::screen() const
{
- Q_D(const QQuickWindowQmlImpl);
- return d->targetScreen;
+ return new QQuickScreenInfo(const_cast<QQuickWindowQmlImpl *>(this), QWindow::screen());
}
-void QQuickWindowQmlImpl::setTargetScreen(QObject *screen)
+void QQuickWindowQmlImpl::setScreen(QObject *screen)
{
- Q_D(QQuickWindowQmlImpl);
- if (d->targetScreen != screen) {
- d->targetScreen = screen;
- emit targetScreenChanged();
- QQuickScreenInfo *screenWrapper = qobject_cast<QQuickScreenInfo *>(screen);
- if (screenWrapper)
- setScreen(screenWrapper->wrappedScreen());
- else
- setScreen(nullptr);
- }
+ QQuickScreenInfo *screenWrapper = qobject_cast<QQuickScreenInfo *>(screen);
+ QWindow::setScreen(screenWrapper ? screenWrapper->wrappedScreen() : nullptr);
}
void QQuickWindowModule::defineModule()
diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h
index 7ca29880ea..16130bc8a0 100644
--- a/src/quick/items/qquickwindowmodule_p.h
+++ b/src/quick/items/qquickwindowmodule_p.h
@@ -67,7 +67,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWindowQmlImpl : public QQuickWindow, public Q
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
- Q_PROPERTY(QObject *targetScreen READ targetScreen WRITE setTargetScreen NOTIFY targetScreenChanged REVISION 2)
+ Q_PROPERTY(QObject *screen READ screen WRITE setScreen NOTIFY screenChanged REVISION 2)
public:
QQuickWindowQmlImpl(QWindow *parent = Q_NULLPTR);
@@ -75,15 +75,15 @@ public:
void setVisible(bool visible);
void setVisibility(Visibility visibility);
- QObject *targetScreen() const;
- void setTargetScreen(QObject *screen);
+ QObject *screen() const;
+ void setScreen(QObject *screen);
static QQuickWindowAttached *qmlAttachedProperties(QObject *object);
Q_SIGNALS:
void visibleChanged(bool arg);
void visibilityChanged(QWindow::Visibility visibility);
- Q_REVISION(2) void targetScreenChanged();
+ Q_REVISION(2) void screenChanged();
protected:
void classBegin() Q_DECL_OVERRIDE;
diff --git a/tests/auto/quick/qquickwindow/data/windowWithScreen.qml b/tests/auto/quick/qquickwindow/data/windowWithScreen.qml
index fdc0be3388..2a5a7b7b76 100644
--- a/tests/auto/quick/qquickwindow/data/windowWithScreen.qml
+++ b/tests/auto/quick/qquickwindow/data/windowWithScreen.qml
@@ -3,7 +3,7 @@ import QtQuick.Window 2.3 as Window
Window.Window {
color: "#00FF00"
- targetScreen: Qt.application.screens[0]
+ screen: Qt.application.screens[0]
Item {
objectName: "item"
}