summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-09-24 14:50:33 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-09-27 14:02:07 +0000
commit324e92200fc233d3c6c192856422b519814a03a8 (patch)
tree4858138f2e9c50e7a3bd2cafdfdb7d98d2ac8b9b /src
parent706db17d9af2c52e5b3c1c0b01ae52c1650d3c16 (diff)
Make QWindow::transientParent a property
The accessors have existed for a long time, but in Qt Quick it helps to have it available as a property, in case any of the "magic" guesses wrong about the user's intention. [ChangeLog][QtGui][QWindow] QWindow::transientParent is now a property. Task-number: QTBUG-67903 Task-number: QTBUG-52944 Change-Id: Ibf6ed789c4756bd934bdb4620fbcdb5879c3fb17 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qwindow.cpp27
-rw-r--r--src/gui/kernel/qwindow.h3
-rw-r--r--src/gui/kernel/qwindow_p.h2
3 files changed, 24 insertions, 8 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 3d7d22959d..17a18f3c9a 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1328,16 +1328,18 @@ Qt::WindowStates QWindow::windowStates() const
*/
/*!
- Sets the transient \a parent
+ \property QWindow::transientParent
+ \brief the window for which this window is a transient pop-up
+ \since 5.13
This is a hint to the window manager that this window is a dialog or pop-up
- on behalf of the given window.
+ on behalf of the transient parent.
In order to cause the window to be centered above its transient parent by
default, depending on the window manager, it may also be necessary to call
setFlags() with a suitable \l Qt::WindowType (such as \c Qt::Dialog).
- \sa transientParent(), parent()
+ \sa parent()
*/
void QWindow::setTransientParent(QWindow *parent)
{
@@ -1354,19 +1356,28 @@ void QWindow::setTransientParent(QWindow *parent)
d->transientParent = parent;
QGuiApplicationPrivate::updateBlockedStatus(this);
+ emit transientParentChanged(parent);
}
-/*!
- Returns the transient parent of the window.
-
- \sa setTransientParent(), parent()
-*/
QWindow *QWindow::transientParent() const
{
Q_D(const QWindow);
return d->transientParent.data();
}
+/*
+ The setter for the QWindow::transientParent property.
+ The only reason this exists is to set the transientParentPropertySet flag
+ so that Qt Quick knows whether it was set programmatically (because of
+ Window declaration context) or because the user set the property.
+*/
+void QWindowPrivate::setTransientParent(QWindow *parent)
+{
+ Q_Q(QWindow);
+ q->setTransientParent(parent);
+ transientParentPropertySet = true;
+}
+
/*!
\enum QWindow::AncestorMode
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 36d8e7ad0f..1be3c845fe 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -123,6 +123,7 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged REVISION 1)
Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged REVISION 1)
+ Q_PRIVATE_PROPERTY(QWindow::d_func(), QWindow* transientParent MEMBER transientParent WRITE setTransientParent NOTIFY transientParentChanged REVISION 13)
public:
enum Visibility {
@@ -336,6 +337,8 @@ Q_SIGNALS:
Q_REVISION(1) void opacityChanged(qreal opacity);
+ Q_REVISION(13) void transientParentChanged(QWindow *transientParent);
+
protected:
virtual void exposeEvent(QExposeEvent *);
virtual void resizeEvent(QResizeEvent *);
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index bf5e645114..25f9a8a9b2 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -148,6 +148,7 @@ public:
void disconnectFromScreen();
void emitScreenChangedRecursion(QScreen *newScreen);
QScreen *screenForGeometry(const QRect &rect);
+ void setTransientParent(QWindow *parent);
virtual void clearFocusObject();
virtual QRectF closestAcceptableGeometry(const QRectF &rect) const;
@@ -191,6 +192,7 @@ public:
bool blockedByModalWindow;
bool updateRequestPending;
+ bool transientParentPropertySet = false;
QPointer<QWindow> transientParent;
QPointer<QScreen> topLevelScreen;