diff options
| author | Alexander Volkov <[email protected]> | 2018-12-18 16:49:20 +0300 |
|---|---|---|
| committer | Alexander Volkov <[email protected]> | 2018-12-24 16:51:14 +0000 |
| commit | f05cc4144e06fd06eed12a3e427eb49e7ad1cf85 (patch) | |
| tree | 6f2e346e2aa581777f517cf888ecd897a9ec2e21 /src/widgets/dialogs/qdialog.cpp | |
| parent | ff835a5030f3ec0aaa91ad0332739ca3259804e8 (diff) | |
QDialog: Pass transient parent as a parent to native dialogs
Sometimes it's needed to show a native dialog for another process,
for example in xdg-desktop-portal-kde. In this case we have WId
of a parent window which can be used for calling
QWindow::setTransientParent(QWindow::fromWinId(...)).
Pass this transient parent to a native dialog so it could use
it as a transient parent for itself. Rename
QDialogPrivate::parentWindow() for clarity.
Change-Id: I68974ddea35f9366a0ddffe602d9d028f45e26fa
Reviewed-by: Tor Arne Vestbø <[email protected]>
Diffstat (limited to 'src/widgets/dialogs/qdialog.cpp')
| -rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 06f0393b4ca..6f96018f3ef 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -145,10 +145,13 @@ bool QDialogPrivate::canBeNativeDialog() const return false; } -QWindow *QDialogPrivate::parentWindow() const +QWindow *QDialogPrivate::transientParentWindow() const { - if (const QWidget *parent = q_func()->nativeParentWidget()) + Q_Q(const QDialog); + if (const QWidget *parent = q->nativeParentWidget()) return parent->windowHandle(); + else if (q->windowHandle()) + return q->windowHandle()->transientParent(); return 0; } @@ -158,7 +161,7 @@ bool QDialogPrivate::setNativeDialogVisible(bool visible) if (visible) { Q_Q(QDialog); helperPrepareShow(helper); - nativeDialogInUse = helper->show(q->windowFlags(), q->windowModality(), parentWindow()); + nativeDialogInUse = helper->show(q->windowFlags(), q->windowModality(), transientParentWindow()); } else if (nativeDialogInUse) { helper->hide(); } |
