|
38 | 38 | #include <QSystemTrayIcon>
|
39 | 39 | #include <QMessageBox>
|
40 | 40 | #include <QtGlobal>
|
| 41 | +#include <QtSystemDetection> |
41 | 42 | #if defined(_WIN32)
|
42 | 43 | #if QT_VERSION_MAJOR >= 6
|
43 | 44 | #include <private/qguiapplication_p.h>
|
|
55 | 56 | #include "filedialog.h"
|
56 | 57 | #include "libserver.h"
|
57 | 58 | #include "webclass.h"
|
| 59 | +#include "urlhandler.h" |
58 | 60 |
|
59 | 61 | #define APPNAME "BitBoxApp"
|
60 | 62 |
|
@@ -85,25 +87,6 @@ class BitBoxApp : public SingleApplication
|
85 | 87 | Mode::User | Mode::SecondaryNotification | Mode::ExcludeAppVersion | Mode::ExcludeAppPath)
|
86 | 88 | {
|
87 | 89 | }
|
88 |
| - |
89 |
| -#if defined(Q_OS_MACOS) |
90 |
| - bool event(QEvent *event) override |
91 |
| - { |
92 |
| - if (event->type() == QEvent::FileOpen) { |
93 |
| - QFileOpenEvent* openEvent = static_cast<QFileOpenEvent*>(event); |
94 |
| - if (!openEvent->url().isEmpty()) { |
95 |
| - // This is only supported on macOS and is used to handle URIs that are opened with |
96 |
| - // the BitBoxApp, such as "aopp:..." links. The event is received and handled both |
97 |
| - // if the BitBoxApp is launched and also when it is already running, in which case |
98 |
| - // it is brought to the foreground automatically. |
99 |
| - |
100 |
| - handleURI(openEvent->url().toString().toUtf8().constData()); |
101 |
| - } |
102 |
| - } |
103 |
| - |
104 |
| - return QApplication::event(event); |
105 |
| - } |
106 |
| -#endif |
107 | 90 | };
|
108 | 91 |
|
109 | 92 | class WebEnginePage : public QWebEnginePage {
|
@@ -318,6 +301,12 @@ int main(int argc, char *argv[])
|
318 | 301 | }
|
319 | 302 |
|
320 | 303 | BitBoxApp a(argc, argv);
|
| 304 | + // The URI scheme handler for aopp is handled via OS events on macOS. The other platforms invoke |
| 305 | + // the process with the uri as a command line param. |
| 306 | +#if defined(Q_OS_MACOS) |
| 307 | + UrlHandler url_handler; |
| 308 | + url_handler.setup(); |
| 309 | +#endif |
321 | 310 | // These three are part of the SingleApplication instance ID - if changed, the user should close
|
322 | 311 | // th existing app before launching the new one.
|
323 | 312 | // See https://github.com/BitBoxSwiss/SingleApplication/blob/c557da5d0cb63b8002c1ba99ec18f257620009b1/singleapplication_p.cpp#L135-L137
|
|
0 commit comments