Skip to content

Commit 6aa5554

Browse files
committed
Update close callback
1 parent 4b38ba3 commit 6aa5554

File tree

3 files changed

+2
-27
lines changed

3 files changed

+2
-27
lines changed

src/plugins/coreplugin/windows/ProjectWindowInterface.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ namespace Core {
4343
ProjectTimeline *projectTimeline;
4444
EditActionsHandlerRegistry *mainEditActionsHandlerRegistry;
4545
ProjectDocumentContext *projectDocumentContext;
46-
QList<std::function<bool()>> closeCallbacks;
4746

4847
void init() {
4948
Q_Q(ProjectWindowInterface);
@@ -188,11 +187,6 @@ namespace Core {
188187
return d->projectDocumentContext->saveCopy(path);
189188
}
190189

191-
void ProjectWindowInterface::addCloseCallback(const std::function<bool()> &callback) {
192-
Q_D(ProjectWindowInterface);
193-
d->closeCallbacks.append(callback);
194-
}
195-
196190
QWindow *ProjectWindowInterface::createWindow(QObject *parent) const {
197191
Q_D(const ProjectWindowInterface);
198192
QQmlComponent component(RuntimeInterface::qmlEngine(), "DiffScope.Core", "ProjectWindow");
@@ -220,25 +214,9 @@ namespace Core {
220214
path = tr("Untitled") + ".dspx";
221215
}
222216
win->setFilePath(path);
223-
win->installEventFilter(const_cast<ProjectWindowInterface *>(this));
224217
return win;
225218
}
226219

227-
bool ProjectWindowInterface::eventFilter(QObject *watched, QEvent *event) {
228-
Q_D(ProjectWindowInterface);
229-
if (watched == window()) {
230-
if (event->type() == QEvent::Close) {
231-
for (const auto &callback : d->closeCallbacks) {
232-
if (!callback()) {
233-
event->ignore();
234-
return true;
235-
}
236-
}
237-
}
238-
}
239-
return ActionWindowInterfaceBase::eventFilter(watched, event);
240-
}
241-
242220
ProjectWindowInterface::ProjectWindowInterface(ProjectDocumentContext *projectDocumentContext, QObject *parent) : ProjectWindowInterface(*new ProjectWindowInterfacePrivate, parent) {
243221
Q_D(ProjectWindowInterface);
244222
d->projectDocumentContext = projectDocumentContext;

src/plugins/coreplugin/windows/ProjectWindowInterface.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef DIFFSCOPE_COREPLUGIN_PROJECTWINDOWINTERFACE_H
22
#define DIFFSCOPE_COREPLUGIN_PROJECTWINDOWINTERFACE_H
33

4-
#include <functional>
5-
64
#include <qqmlintegration.h>
75

86
#include <SVSCraftCore/SVSCraftNamespace.h>
@@ -60,11 +58,10 @@ namespace Core {
6058
Q_INVOKABLE bool saveAs();
6159
Q_INVOKABLE bool saveCopy();
6260

63-
void addCloseCallback(const std::function<bool()> &callback);
61+
6462

6563
protected:
6664
QWindow *createWindow(QObject *parent) const override;
67-
bool eventFilter(QObject *watched, QEvent *event) override;
6865

6966
explicit ProjectWindowInterface(ProjectDocumentContext *projectDocumentContext, QObject *parent = nullptr);
7067
explicit ProjectWindowInterface(ProjectWindowInterfacePrivate &d, QObject *parent = nullptr);

0 commit comments

Comments
 (0)