From 8120700787b354ed4bfba0993c6d4ca988a8d9e6 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 17 Apr 2014 00:03:11 +0200 Subject: [PATCH 1/6] Added urlGoTo --- interface/src/Application.cpp | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1fabca3711..a7a00bf7c7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -356,6 +356,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : QMutexLocker locker(&_settingsMutex); _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); } + //When -url in command line, teleport to location + urlGoTo(argc, constArgv); } Application::~Application() { @@ -3548,3 +3550,40 @@ void Application::takeSnapshot() { Snapshot::saveSnapshot(_glWidget, _myAvatar); } + +void Application::urlGoTo(int argc, const char * constArgv[]) { + //Gets the url (hifi://domain/destination/orientation) + QString customUrl = getCmdOption(argc, constArgv, "-url"); + + if (customUrl.startsWith("hifi://")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + + if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; + + // second part is either a destination coordinate or + // a place name + QString destination = urlParts[1]; + + // any third part is an avatar orientation. + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); + + Menu::goToDomain(domain); + + // goto either @user, #place, or x-xx,y-yy,z-zz + // style co-ordinate. + Menu::goTo(destination); + + if (!orientation.isEmpty()) { + // location orientation + Menu::goToOrientation(orientation); + } + } else if (urlParts.count() == 1) { + // location coordinates or place name + QString destination = urlParts[0]; + Menu::goTo(destination); + } + + } +} From d55fb60862a1fdc237a20db3d2a942fba50e6be4 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 17 Apr 2014 00:03:33 +0200 Subject: [PATCH 2/6] Added urlGoTo --- interface/src/Application.h | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/Application.h b/interface/src/Application.h index 6a14788caa..de5f1fe113 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -509,6 +509,7 @@ private: void displayUpdateDialog(); bool shouldSkipVersion(QString latestVersion); void takeSnapshot(); + void urlGoTo(int argc, const char * constArgv[]); TouchEvent _lastTouchEvent; From b3ce36f1309140f9cf4e84c113bff670d0455b39 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 17 Apr 2014 00:04:27 +0200 Subject: [PATCH 3/6] Changed goTo's to statics --- interface/src/Menu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 40ed8efdc7..c2aac5672b 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -135,10 +135,10 @@ public: void removeAction(QMenu* menu, const QString& actionName); - bool goToDestination(QString destination); - void goToOrientation(QString orientation); - void goToDomain(const QString newDomain); - void goTo(QString destination); + bool static goToDestination(QString destination); + void static goToOrientation(QString orientation); + void static goToDomain(const QString newDomain); + void static goTo(QString destination); public slots: From fca4e2abba27f4676fe7bdacbb6c1531763444c8 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 17 Apr 2014 00:09:58 +0200 Subject: [PATCH 4/6] Update Application.h --- interface/src/Application.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index de5f1fe113..a09483a1ba 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -128,6 +128,7 @@ public: void initializeGL(); void paintGL(); void resizeGL(int width, int height); + void urlGoTo(int argc, const char * constArgv[]); void keyPressEvent(QKeyEvent* event); void keyReleaseEvent(QKeyEvent* event); @@ -509,7 +510,6 @@ private: void displayUpdateDialog(); bool shouldSkipVersion(QString latestVersion); void takeSnapshot(); - void urlGoTo(int argc, const char * constArgv[]); TouchEvent _lastTouchEvent; From 6d1f4ed9420f2c238a2afb9834e189d0651be913 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 18 Apr 2014 01:13:06 +0200 Subject: [PATCH 5/6] Fix format --- interface/src/Application.cpp | 47 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a7a00bf7c7..592370705a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3555,35 +3555,34 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { //Gets the url (hifi://domain/destination/orientation) QString customUrl = getCmdOption(argc, constArgv, "-url"); - if (customUrl.startsWith("hifi://")) { - QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (customUrl.startsWith("hifi://")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; - if (urlParts.count() > 1) { - // if url has 2 or more parts, the first one is domain name - QString domain = urlParts[0]; + // second part is either a destination coordinate or + // a place name + QString destination = urlParts[1]; - // second part is either a destination coordinate or - // a place name - QString destination = urlParts[1]; + // any third part is an avatar orientation. + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - // any third part is an avatar orientation. - QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - - Menu::goToDomain(domain); + Menu::goToDomain(domain); - // goto either @user, #place, or x-xx,y-yy,z-zz - // style co-ordinate. - Menu::goTo(destination); + // goto either @user, #place, or x-xx,y-yy,z-zz + // style co-ordinate. + Menu::goTo(destination); - if (!orientation.isEmpty()) { - // location orientation - Menu::goToOrientation(orientation); - } - } else if (urlParts.count() == 1) { - // location coordinates or place name - QString destination = urlParts[0]; - Menu::goTo(destination); + if (!orientation.isEmpty()) { + // location orientation + Menu::goToOrientation(orientation); } - + } else if (urlParts.count() == 1) { + // location coordinates or place name + QString destination = urlParts[0]; + Menu::goTo(destination); } + + } } From d489e9dcd403114263c6d360b00e4aba75c3fca3 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 18 Apr 2014 23:55:45 +0200 Subject: [PATCH 6/6] Fix format --- interface/src/Application.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 592370705a..0abcd9d1af 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3552,11 +3552,11 @@ void Application::takeSnapshot() { } void Application::urlGoTo(int argc, const char * constArgv[]) { - //Gets the url (hifi://domain/destination/orientation) - QString customUrl = getCmdOption(argc, constArgv, "-url"); + //Gets the url (hifi://domain/destination/orientation) + QString customUrl = getCmdOption(argc, constArgv, "-url"); - if (customUrl.startsWith("hifi://")) { - QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (customUrl.startsWith("hifi://")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name QString domain = urlParts[0]; @@ -3583,6 +3583,5 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { QString destination = urlParts[0]; Menu::goTo(destination); } - } }