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
112 112
113const int STATS_PELS_PER_LINE = 20;113const int STATS_PELS_PER_LINE = 20;
114 114
115const QString CUSTOM_URL_SCHEME = "hifi:";
116
117void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {115void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
118 if (message.size() > 0) {116 if (message.size() > 0) {
119 QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);117 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
676}674}
677 675
678bool Application::event(QEvent* event) {676bool Application::event(QEvent* event) {
679 677
680 // handle custom URL678 // handle custom URL
681 if (event->type() == QEvent::FileOpen) {679 if (event->type() == QEvent::FileOpen) {
682 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);680 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
683 if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) {681 bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME);
684 QString destination = fileEvent->url().toLocalFile().remove(CUSTOM_URL_SCHEME);682 if (isHifiSchemeURL) {
685 QStringList urlParts = destination.split('/', QString::SkipEmptyParts);683 Menu::getInstance()->goTo(fileEvent->url().toString());
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 }
703 }684 }
704 685
705 return false;686 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