History

Add Menu::goToUrl

Ryan Huffman committed 12 years ago

Commit ff51b221 parent 05708492 files · +32 −27Browse files

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

Unified · Split

interface/src/Menu.cpp+31−27
@@ -927,42 +927,46 @@ void Menu::goTo() { · 926 unmodified lines
927927 int dialogReturn = gotoDialog.exec();
928928 if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) {
929929 QString desiredDestination = gotoDialog.textValue();
930+ if (!goToURL(desiredDestination)) {;
931+ goTo(desiredDestination);
932+ }
933+ }
934+ sendFakeEnterEvent();
935+}
930936
931− if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) {
932− QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
937+bool Menu::goToURL(QString location) {
938+ if (location.startsWith(CUSTOM_URL_SCHEME + "//")) {
939+ QStringList urlParts = location.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
933940
934− if (urlParts.count() > 1) {
935− // if url has 2 or more parts, the first one is domain name
936− QString domain = urlParts[0];
941+ if (urlParts.count() > 1) {
942+ // if url has 2 or more parts, the first one is domain name
943+ QString domain = urlParts[0];
937944
938− // second part is either a destination coordinate or
939− // a place name
940− QString destination = urlParts[1];
945+ // second part is either a destination coordinate or
946+ // a place name
947+ QString destination = urlParts[1];
941948
942− // any third part is an avatar orientation.
943− QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
949+ // any third part is an avatar orientation.
950+ QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
944951
945− goToDomain(domain);
946−
947− // goto either @user, #place, or x-xx,y-yy,z-zz
948− // style co-ordinate.
949− goTo(destination);
952+ goToDomain(domain);
950953
951− if (!orientation.isEmpty()) {
952− // location orientation
953− goToOrientation(orientation);
954− }
955− } else if (urlParts.count() == 1) {
956− // location coordinates or place name
957− QString destination = urlParts[0];
958− goTo(destination);
959− }
954+ // goto either @user, #place, or x-xx,y-yy,z-zz
955+ // style co-ordinate.
956+ goTo(destination);
960957
961− } else {
962− goToUser(gotoDialog.textValue());
958+ if (!orientation.isEmpty()) {
959+ // location orientation
960+ goToOrientation(orientation);
961+ }
962+ } else if (urlParts.count() == 1) {
963+ // location coordinates or place name
964+ QString destination = urlParts[0];
965+ goTo(destination);
963966 }
967+ return true;
964968 }
965− sendFakeEnterEvent();
969+ return false;
966970 }
967971
968972 void Menu::goToUser(const QString& user) {