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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
ff835a5030
commit
f05cc4144e
@ -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();
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
{}
|
||||
~QDialogPrivate();
|
||||
|
||||
QWindow *parentWindow() const;
|
||||
QWindow *transientParentWindow() const;
|
||||
bool setNativeDialogVisible(bool visible);
|
||||
QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const;
|
||||
void deletePlatformHelper();
|
||||
|
Loading…
x
Reference in New Issue
Block a user