|
7 | 7 |
|
8 | 8 | #include <QApplication> |
9 | 9 | #include <QDirIterator> |
10 | | -#include <QFileOpenEvent> |
11 | 10 | #include <QFontDatabase> |
12 | 11 | #include <QImageReader> |
13 | 12 | #include <QLoggingCategory> |
|
22 | 21 | #include <QThread> |
23 | 22 | #include <QTimer> |
24 | 23 |
|
| 24 | +#include <CoreApi/FileOpenEventSource.h> |
25 | 25 | #include <CoreApi/applicationinfo.h> |
26 | 26 | #include <CoreApi/runtimeinterface.h> |
27 | 27 | #include <CoreApi/settingcatalog.h> |
@@ -190,7 +190,6 @@ namespace Core::Internal { |
190 | 190 |
|
191 | 191 | initializeSingletons(); |
192 | 192 | CoreInterface::fileOpenDispatcher()->setReady(false); |
193 | | - qApp->installEventFilter(this); |
194 | 193 | initializeBehaviorPreference(); |
195 | 194 | initializeActions(); |
196 | 195 | initializeSettings(); |
@@ -219,6 +218,18 @@ namespace Core::Internal { |
219 | 218 | checkLastRun(); |
220 | 219 | checkPlugins(); |
221 | 220 | CoreInterface::fileOpenDispatcher()->registerHandler(new ProjectFileOpenHandler(this)); |
| 221 | + |
| 222 | + auto fileOpenEventSource = RuntimeInterface::fileOpenEventSource(); |
| 223 | + const auto openPendingFiles = [fileOpenEventSource] { |
| 224 | + const auto filePaths = fileOpenEventSource->takePendingFiles(); |
| 225 | + if (filePaths.isEmpty()) { |
| 226 | + return; |
| 227 | + } |
| 228 | + auto firstWindow = CoreInterface::windowSystem()->firstWindow(); |
| 229 | + CoreInterface::fileOpenDispatcher()->openFiles(filePaths, firstWindow ? firstWindow->window() : nullptr); |
| 230 | + }; |
| 231 | + connect(fileOpenEventSource, &FileOpenEventSource::filesAvailable, this, openPendingFiles); |
| 232 | + openPendingFiles(); |
222 | 233 | } |
223 | 234 |
|
224 | 235 | bool CorePlugin::delayedInitialize() { |
@@ -257,18 +268,6 @@ namespace Core::Internal { |
257 | 268 | return nullptr; |
258 | 269 | } |
259 | 270 |
|
260 | | - bool CorePlugin::eventFilter(QObject *obj, QEvent *event) { |
261 | | - if (obj == qApp && event->type() == QEvent::FileOpen) { |
262 | | - const auto filePath = static_cast<QFileOpenEvent *>(event)->file(); |
263 | | - if (!filePath.isEmpty()) { |
264 | | - auto firstWindow = CoreInterface::windowSystem()->firstWindow(); |
265 | | - CoreInterface::fileOpenDispatcher()->openFiles({filePath}, firstWindow ? firstWindow->window() : nullptr); |
266 | | - } |
267 | | - return true; |
268 | | - } |
269 | | - return QObject::eventFilter(obj, event); |
270 | | - } |
271 | | - |
272 | 271 | void CorePlugin::initializeSingletons() { |
273 | 272 | new CoreInterface(this); |
274 | 273 | new BehaviorPreference(this); |
|
0 commit comments