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.
Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -112,8 +112,6 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 111 unmodified lines | ||
| 112 | 112 | |
| 113 | 113 | const int STATS_PELS_PER_LINE = 20; |
| 114 | 114 | |
| 115 | −const QString CUSTOM_URL_SCHEME = "hifi:"; | |
| 116 | − | |
| 117 | 115 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { |
| 118 | 116 | if (message.size() > 0) { |
| 119 | 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 | |
| 678 | 676 | bool Application::event(QEvent* event) { |
| 679 | − | |
| 677 | + | |
| 680 | 678 | // handle custom URL |
| 681 | 679 | if (event->type() == QEvent::FileOpen) { |
| 682 | 680 | 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()); | |
| 703 | 684 | } |
| 704 | 685 | |
| 705 | 686 | return false; |