Skip to content

Commit b0b907e

Browse files
authored
feat: macOS url scheme support (#1603)
1 parent 6886cf1 commit b0b907e

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

extra/Info.plist.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@
2222
<string>@VICINAE_BUNDLE_SHORT_VERSION@</string>
2323
<key>CFBundleVersion</key>
2424
<string>@VICINAE_BUNDLE_VERSION@</string>
25+
<key>CFBundleURLTypes</key>
26+
<array>
27+
<dict>
28+
<key>CFBundleTypeRole</key>
29+
<string>Viewer</string>
30+
<key>CFBundleURLName</key>
31+
<string>@VICINAE_BUNDLE_ID@.deeplink</string>
32+
<key>CFBundleURLSchemes</key>
33+
<array>
34+
<string>vicinae</string>
35+
<string>raycast</string>
36+
<string>com.raycast</string>
37+
</array>
38+
</dict>
39+
</array>
2540
<key>LSMinimumSystemVersion</key>
2641
<string>14.4</string>
2742
<key>LSApplicationCategoryType</key>

src/server/src/server.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,34 @@
9494
#include "server.hpp"
9595

9696
#ifdef Q_OS_MACOS
97+
#include "ipc-command-handler.hpp"
9798
#include "qml/macos-chrome-attached.hpp"
99+
#include <QFileOpenEvent>
100+
#endif
101+
102+
#ifdef Q_OS_MACOS
103+
class UrlSchemeOpenFilter : public QObject {
104+
public:
105+
UrlSchemeOpenFilter(ApplicationContext &ctx) : m_ctx(ctx) {}
106+
107+
protected:
108+
bool eventFilter(QObject *watched, QEvent *event) override {
109+
if (event->type() == QEvent::FileOpen) {
110+
const QUrl url = static_cast<QFileOpenEvent *>(event)->url();
111+
if (Omnicast::APP_SCHEMES.contains(url.scheme())) {
112+
IpcCommandHandler handler(m_ctx);
113+
if (auto res = handler.handleUrl(url); !res) {
114+
qWarning() << "Failed to handle deeplink" << url.toString() << ":" << res.error();
115+
}
116+
return true;
117+
}
118+
}
119+
return QObject::eventFilter(watched, event);
120+
}
121+
122+
private:
123+
ApplicationContext &m_ctx;
124+
};
98125
#endif
99126

100127
static void applyTextRenderingMode(const config::FontConfig &fontConfig) {
@@ -353,6 +380,11 @@ int startServer(const ServerLaunchOptions &launchOpts) {
353380

354381
commandServer.start(Omnicast::commandSocketPath());
355382

383+
#ifdef Q_OS_MACOS
384+
UrlSchemeOpenFilter urlSchemeOpenFilter(ctx);
385+
qApp->installEventFilter(&urlSchemeOpenFilter);
386+
#endif
387+
356388
QObject::connect(
357389
ctx.services->fileService()->indexer(), &AbstractFileIndexer::scanStatusChanged,
358390
ctx.services->toastService(),

0 commit comments

Comments
 (0)