diff options
Diffstat (limited to 'src/widgets/dialogs/qdialog.cpp')
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index c9093095a7..e7b526445e 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -422,7 +422,7 @@ QDialog::~QDialog() /*! \internal This function is called by the push button \a pushButton when it - becomes the default button. If \a pushButton is 0, the dialogs + becomes the default button. If \a pushButton is \nullptr, the dialogs default default button becomes the default button. This is what a push button calls when it loses focus. */ @@ -760,12 +760,31 @@ void QDialog::setVisible(bool visible) if (!testAttribute(Qt::WA_DontShowOnScreen) && d->canBeNativeDialog() && d->setNativeDialogVisible(visible)) return; + // We should not block windows by the invisible modal dialog + // if a platform-specific dialog is implemented as an in-process + // Qt window, because in this case it will also be blocked. + const bool dontBlockWindows = testAttribute(Qt::WA_DontShowOnScreen) + && d->styleHint(QPlatformDialogHelper::DialogIsQtWindow).toBool(); + Qt::WindowModality oldModality; + bool wasModalitySet; + + if (dontBlockWindows) { + oldModality = windowModality(); + wasModalitySet = testAttribute(Qt::WA_SetWindowModality); + setWindowModality(Qt::NonModal); + } + if (visible) { if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden)) return; QWidget::setVisible(visible); +#if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED showExtension(d->doShowExtension); +QT_WARNING_POP +#endif QWidget *fw = window()->focusWidget(); if (!fw) fw = this; @@ -826,6 +845,11 @@ void QDialog::setVisible(bool visible) d->eventLoop->exit(); } + if (dontBlockWindows) { + setWindowModality(oldModality); + setAttribute(Qt::WA_SetWindowModality, wasModalitySet); + } + #if QT_CONFIG(pushbutton) const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); if (d->mainDef && isActiveWindow() @@ -927,6 +951,7 @@ void QDialog::adjustPosition(QWidget* w) move(p); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -995,7 +1020,7 @@ void QDialog::setExtension(QWidget* extension) /*! \obsolete - Returns the dialog's extension or 0 if no extension has been + Returns the dialog's extension or \nullptr if no extension has been defined. Instead of using this functionality, we recommend that you simply call @@ -1071,7 +1096,7 @@ void QDialog::showExtension(bool showIt) #endif } } - +#endif /*! \reimp */ QSize QDialog::sizeHint() const |