Fix MainWindow not propagating close events to docked widgets
Nested FloatingWindows already supported it, so make it consistent. Personal take: In a non-docking world, users can override their main window close event and prevent a close, to save a document or such. However, in a docking world, the main window developer won't know which widgets are docked, so forwarding needs to happen, as some might have documents to save.
This commit is contained in:
@@ -156,3 +156,8 @@ QRect MainWindow::centralAreaGeometry() const
|
||||
{
|
||||
return centralWidget()->geometry();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *ev)
|
||||
{
|
||||
onCloseEvent(ev);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
void setCenterWidgetMargins(const QMargins &margins);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *) override;
|
||||
void resizeEvent(QResizeEvent *) override;
|
||||
QRect centralAreaGeometry() const override;
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
# include "DockWidget.h"
|
||||
#endif
|
||||
|
||||
#include <QCloseEvent>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
static LayoutWidget *createLayoutWidget(MainWindowBase *mainWindow, MainWindowOptions options)
|
||||
@@ -791,3 +793,8 @@ QWidgetOrQuick *MainWindowBase::persistentCentralWidget() const
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MainWindowBase::onCloseEvent(QCloseEvent *e)
|
||||
{
|
||||
d->m_layoutWidget->onCloseEvent(e);
|
||||
}
|
||||
|
||||
@@ -223,6 +223,7 @@ public:
|
||||
QRect windowGeometry() const;
|
||||
|
||||
protected:
|
||||
void onCloseEvent(QCloseEvent *);
|
||||
void setUniqueName(const QString &uniqueName);
|
||||
void onResized(QResizeEvent *); // Because QtQuick doesn't have resizeEvent()
|
||||
virtual QMargins centerWidgetMargins() const = 0;
|
||||
|
||||
Reference in New Issue
Block a user