Refactor: Move close event logic from FloatingWindow to DropArea

So main window can use it too

(cherry-picked from commit 3454b67a45)
This commit is contained in:
Sergio Martins
2022-06-19 00:29:46 +01:00
parent d47130f0c8
commit bd4aed18c9
3 changed files with 16 additions and 8 deletions

View File

@@ -13,6 +13,7 @@
#include "Config.h"
#include "kddockwidgets/ViewFactory.h"
#include "DockRegistry.h"
#include "Platform.h"
#include "private/Draggable_p.h"
#include "private/Logging_p.h"
#include "private/Utils_p.h"
@@ -651,3 +652,15 @@ bool DropArea::deserialize(const LayoutSaver::MultiSplitter &l)
setRootItem(new Layouting::ItemBoxContainer(view()));
return Layout::deserialize(l);
}
void DropArea::onCloseEvent(QCloseEvent *e)
{
e->accept(); // Accepted by default (will close unless ignored)
const Controllers::Frame::List frames = this->frames();
for (Controllers::Frame *frame : frames) {
Platform::instance()->sendEvent(frame->view(), e);
if (!e->isAccepted())
break; // Stop when the first frame prevents closing
}
}

View File

@@ -133,6 +133,8 @@ public:
Layouting::ItemBoxContainer *rootItem() const;
void onCloseEvent(QCloseEvent *);
private:
Q_DISABLE_COPY(DropArea)
friend class Controllers::MainWindow;

View File

@@ -512,14 +512,7 @@ void FloatingWindow::onCloseEvent(QCloseEvent *e)
return;
}
e->accept(); // Accepted by default (will close unless ignored)
const Controllers::Frame::List frames = this->frames();
for (Controllers::Frame *frame : frames) {
Platform::instance()->sendEvent(frame->view(), e);
if (!e->isAccepted())
break; // Stop when the first frame prevents closing
}
m_dropArea->onCloseEvent(e);
}
bool FloatingWindow::deserialize(const LayoutSaver::FloatingWindow &fw)