History

Custom URL handler

stojce committed 12 years ago

Commit b05967a1 parent 7fc66394 files · +57 −49Browse files

Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all

Unified · Split

interface/src/Application.cpp+17−0
@@ -101,6 +101,8 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 100 unmodified lines
101101
102102 const int STATS_PELS_PER_LINE = 20;
103103
104+const QString CUSTOM_URL_SCHEME = "hifi:";
105+
104106 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
105107 if (message.size() > 0) {
106108 QString messageWithNewLine = message + "\n";
@@ -680,6 +682,21 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 573 unmodified lines
680682 }
681683 }
682684
685+bool Application::event(QEvent* event) {
686+
687+ // handle custom URL
688+ if (event->type() == QEvent::FileOpen) {
689+ QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
690+ if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) {
691+ QString destination = fileEvent->url().toLocalFile().remove(QRegExp(CUSTOM_URL_SCHEME + "|/"));
692+ Menu::getInstance()->goToDestination(destination);
693+ }
694+
695+ return false;
696+ }
697+ return QApplication::event(event);
698+}
699+
683700 void Application::keyPressEvent(QKeyEvent* event) {
684701
685702 _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t