-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move file open event handling to standalone file
- Loading branch information
Showing
7 changed files
with
63 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-FileCopyrightText: 2024 Gary Wang <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include "fileopeneventhandler.h" | ||
|
||
#include <QFileOpenEvent> | ||
|
||
FileOpenEventHandler::FileOpenEventHandler(QObject *parent) | ||
: QObject(parent) | ||
{ | ||
} | ||
|
||
bool FileOpenEventHandler::eventFilter(QObject *obj, QEvent *event) | ||
{ | ||
if (event->type() == QEvent::FileOpen) { | ||
QFileOpenEvent *fileOpenEvent = static_cast<QFileOpenEvent *>(event); | ||
emit fileOpen(fileOpenEvent->url()); | ||
return true; | ||
} | ||
return QObject::eventFilter(obj, event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-FileCopyrightText: 2024 Gary Wang <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#pragma once | ||
|
||
#include <QObject> | ||
|
||
class FileOpenEventHandler : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit FileOpenEventHandler(QObject *parent = nullptr); | ||
|
||
protected: | ||
bool eventFilter(QObject *obj, QEvent *event) override; | ||
|
||
signals: | ||
void fileOpen(const QUrl &url); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters