summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidgetwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qwidgetwindow.cpp')
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 846300100ba..ba1230301e1 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -119,8 +119,7 @@ public:
QWidgetPrivate::get(widget)->updateContentsRect();
}
- bool shouldTriggerQuitOnClose() const override;
- bool shouldCancelQuitOnClose() const override;
+ bool participatesInLastWindowClosed() const override;
};
QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const
@@ -847,35 +846,18 @@ void QWidgetWindow::handleCloseEvent(QCloseEvent *event)
event->setAccepted(accepted);
}
-bool QWidgetWindowPrivate::shouldTriggerQuitOnClose() const
+bool QWidgetWindowPrivate::participatesInLastWindowClosed() const
{
Q_Q(const QWidgetWindow);
- QWidget *widget = q->widget();
- // Closing a window without WA_QuitOnClose should stop us from even
- // looking at the other windows. Otherwise we might find that all the
- // other windows miss WA_QuitOnClose as well, and end up quitting,
- // but that's not what the user intended.
- if (!widget->testAttribute(Qt::WA_QuitOnClose))
+ // For historical reasons WA_QuitOnClose has been closely tied
+ // to the lastWindowClosed signal, since the default behavior
+ // is to quit the application after emitting lastWindowClosed.
+ // ### Qt 7: Rename this attribute, or decouple behavior.
+ if (!q->widget()->testAttribute(Qt::WA_QuitOnClose))
return false;
- // Qt::Tool windows do not have WA_QuitOnClose set by default, which
- // means that if you open a dialog from one, and the tool window is
- // the only remaining window, then closing the dialog would result
- // in quitting the application. To prevent this we check if the
- // closed widget has a visible parent (the Qt:Tool window in this
- // case), and if so bail out.
- if (widget->parentWidget() && widget->parentWidget()->isVisible())
- return false;
-
- return true;
-}
-
-bool QWidgetWindowPrivate::shouldCancelQuitOnClose() const
-{
- Q_Q(const QWidgetWindow);
- QWidget *w = q->widget();
- return w->isVisible() && !w->parentWidget() & w->testAttribute(Qt::WA_QuitOnClose);
+ return QWindowPrivate::participatesInLastWindowClosed();
}
#if QT_CONFIG(wheelevent)