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
927 int dialogReturn = gotoDialog.exec();927 int dialogReturn = gotoDialog.exec();
928 if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) {928 if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) {
929 QString desiredDestination = gotoDialog.textValue();929 QString desiredDestination = gotoDialog.textValue();
930 if (!goToURL(desiredDestination)) {;
931 goTo(desiredDestination);
932 }
933 }
934 sendFakeEnterEvent();
935}
930 936
931 if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) {937bool Menu::goToURL(QString location) {
932 QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);938 if (location.startsWith(CUSTOM_URL_SCHEME + "//")) {
939 QStringList urlParts = location.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
933 940
934 if (urlParts.count() > 1) {941 if (urlParts.count() > 1) {
935 // if url has 2 or more parts, the first one is domain name942 // if url has 2 or more parts, the first one is domain name
936 QString domain = urlParts[0];943 QString domain = urlParts[0];
937 944
938 // second part is either a destination coordinate or945 // second part is either a destination coordinate or
939 // a place name946 // a place name
940 QString destination = urlParts[1];947 QString destination = urlParts[1];
941 948
942 // any third part is an avatar orientation.949 // any third part is an avatar orientation.
943 QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();950 QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
944 951
945 goToDomain(domain);952 goToDomain(domain);
946
947 // goto either @user, #place, or x-xx,y-yy,z-zz
948 // style co-ordinate.
949 goTo(destination);
950 953
951 if (!orientation.isEmpty()) {954 // goto either @user, #place, or x-xx,y-yy,z-zz
952 // location orientation955 // style co-ordinate.
953 goToOrientation(orientation);956 goTo(destination);
954 }
955 } else if (urlParts.count() == 1) {
956 // location coordinates or place name
957 QString destination = urlParts[0];
958 goTo(destination);
959 }
960 957
961 } else {958 if (!orientation.isEmpty()) {
962 goToUser(gotoDialog.textValue());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);
963 }966 }
967 return true;
964 }968 }
965 sendFakeEnterEvent();969 return false;
966}970}
967 971
968void Menu::goToUser(const QString& user) {972void Menu::goToUser(const QString& user) {