From da4ac99b12b8ebb2d0dafe09f24cc93f76afc89b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 26 Oct 2020 14:37:53 +0100 Subject: Expunge WA_GroupLeader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's been deprecated since Qt 4.1. Task-number: QTBUG-85816 Change-Id: Iafc6340716556f54fc5472c60035bb57461b842f Reviewed-by: Volker Hilsheimer Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qapplication.cpp | 35 ++++------------------------------- src/widgets/kernel/qwidget.cpp | 16 ++-------------- 2 files changed, 6 insertions(+), 45 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ed6414b16f..7d10e700e9 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2184,46 +2184,19 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin } Qt::WindowModality windowModality = modalWindow->modality(); - QWidgetWindow *modalWidgetWindow = qobject_cast(modalWindow); if (windowModality == Qt::NonModal) { - // determine the modality type if it hasn't been set on the - // modalWindow's widget, this normally happens when waiting for a - // native dialog. use WindowModal if we are the child of a group - // leader; otherwise use ApplicationModal. - QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : nullptr; - while (m && !m->testAttribute(Qt::WA_GroupLeader)) { - m = m->parentWidget(); - if (m) - m = m->window(); - } - windowModality = (m && m->testAttribute(Qt::WA_GroupLeader)) - ? Qt::WindowModal - : Qt::ApplicationModal; + // If modality type hasn't been set on the modalWindow's widget, as + // when waiting for a native dialog, use ApplicationModal. + windowModality = Qt::ApplicationModal; } switch (windowModality) { case Qt::ApplicationModal: - { - QWidgetWindow *widgetWindow = qobject_cast(window); - QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : nullptr; - while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader)) - groupLeaderForWidget = groupLeaderForWidget->parentWidget(); - - if (groupLeaderForWidget) { - // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children - QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : nullptr; - while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader)) - m = m->parentWidget(); - if (m == groupLeaderForWidget) { - *blockingWindow = m->windowHandle(); - return true; - } - } else if (modalWindow != window) { + if (modalWindow != window) { *blockingWindow = modalWindow; return true; } break; - } case Qt::WindowModal: { QWindow *w = window; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 4bcc0f5df0..183d47b5b2 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -10953,21 +10953,9 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) // reset modality type to NonModal when clearing WA_ShowModal data->window_modality = Qt::NonModal; } else if (data->window_modality == Qt::NonModal) { - // determine the modality type if it hasn't been set prior - // to setting WA_ShowModal. set the default to WindowModal - // if we are the child of a group leader; otherwise use + // If modality hasn't been set prior to setting WA_ShowModal, use // ApplicationModal. - QWidget *w = parentWidget(); - if (w) - w = w->window(); - while (w && !w->testAttribute(Qt::WA_GroupLeader)) { - w = w->parentWidget(); - if (w) - w = w->window(); - } - data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader)) - ? Qt::WindowModal - : Qt::ApplicationModal; + data->window_modality = Qt::ApplicationModal; // Some window managers do not allow us to enter modality after the // window is visible.The window must be hidden before changing the // windowModality property and then reshown. -- cgit v1.2.3