History

Improved hifi:// style URL scheme handling.

First steps towards implementing #1463. - Moved url parsing code from Application::event to Menu::goTo(QString). - Handle destination component of URL as either a @username, #place, or x-xx,y-yy,z-zz style coordinate. - Added support for entering hifi:// style URL into @ invoked goto menu option.

James Brotchie committed 12 years ago

Commit 19b8f101 parent 89cb1ad5 files · +51 −29Browse files

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

Unified · Split

interface/src/Application.cpp+4−23
@@ -112,8 +112,6 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 111 unmodified lines
112112
113113 const int STATS_PELS_PER_LINE = 20;
114114
115−const QString CUSTOM_URL_SCHEME = "hifi:";
116−
117115 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
118116 if (message.size() > 0) {
119117 QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);
@@ -676,30 +674,13 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 556 unmodified lines
676674 }
677675
678676 bool Application::event(QEvent* event) {
679−
677+
680678 // handle custom URL
681679 if (event->type() == QEvent::FileOpen) {
682680 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
683− if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) {
684− QString destination = fileEvent->url().toLocalFile().remove(CUSTOM_URL_SCHEME);
685− QStringList urlParts = destination.split('/', QString::SkipEmptyParts);
686−
687− if (urlParts.count() > 1) {
688− // if url has 2 or more parts, the first one is domain name
689− Menu::getInstance()->goToDomain(urlParts[0]);
690−
691− // location coordinates
692− Menu::getInstance()->goToDestination(urlParts[1]);
693− if (urlParts.count() > 2) {
694−
695− // location orientation
696− Menu::getInstance()->goToOrientation(urlParts[2]);
697− }
698− } else if (urlParts.count() == 1) {
699−
700− // location coordinates
701− Menu::getInstance()->goToDestination(urlParts[0]);
702− }
681+ bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME);
682+ if (isHifiSchemeURL) {
683+ Menu::getInstance()->goTo(fileEvent->url().toString());
703684 }
704685
705686 return false;

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