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>
This commit is contained in:
Shawn Rutledge 2018-09-24 14:50:33 +02:00
parent 706db17d9a
commit 324e92200f
3 changed files with 24 additions and 8 deletions

View File

@ -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

View File

@ -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 *);

View File

@ -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;