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
101 101
102const int STATS_PELS_PER_LINE = 20;102const int STATS_PELS_PER_LINE = 20;
103 103
104const QString CUSTOM_URL_SCHEME = "hifi:";
105
104void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {106void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
105 if (message.size() > 0) {107 if (message.size() > 0) {
106 QString messageWithNewLine = message + "\n";108 QString messageWithNewLine = message + "\n";
@@ -680,6 +682,21 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 573 unmodified lines
680 }682 }
681}683}
682 684
685bool 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
683void Application::keyPressEvent(QKeyEvent* event) {700void Application::keyPressEvent(QKeyEvent* event) {
684 701
685 _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts702 _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