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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,8 @@ public:
|
||||
|
||||
Layouting::ItemBoxContainer *rootItem() const;
|
||||
|
||||
void onCloseEvent(QCloseEvent *);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DropArea)
|
||||
friend class Controllers::MainWindow;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user