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/Menu.cpp (1 of 5 files). Show all
Unified · Split
| @@ -912,19 +912,58 @@ bool Menu::goToDestination(QString destination) { · 911 unmodified lines | ||
| 912 | 912 | return LocationManager::getInstance().goToDestination(destination); |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | +void Menu::goTo(QString destination) { | |
| 916 | + LocationManager::getInstance().goTo(destination); | |
| 917 | +} | |
| 918 | + | |
| 915 | 919 | void Menu::goTo() { |
| 916 | 920 | |
| 917 | 921 | QInputDialog gotoDialog(Application::getInstance()->getWindow()); |
| 918 | 922 | gotoDialog.setWindowTitle("Go to"); |
| 919 | − gotoDialog.setLabelText("Destination:"); | |
| 923 | + gotoDialog.setLabelText("Destination or URL:\n @user, #place, hifi://domain/location/orientation"); | |
| 920 | 924 | QString destination = QString(); |
| 925 | + | |
| 921 | 926 | gotoDialog.setTextValue(destination); |
| 922 | 927 | gotoDialog.setWindowFlags(Qt::Sheet); |
| 923 | 928 | gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height()); |
| 924 | 929 | |
| 925 | 930 | int dialogReturn = gotoDialog.exec(); |
| 926 | 931 | if (dialogReturn == QDialog::Accepted && !gotoDialog.textValue().isEmpty()) { |
| 927 | − goToUser(gotoDialog.textValue()); | |
| 932 | + QString desiredDestination = gotoDialog.textValue(); | |
| 933 | + | |
| 934 | + if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) { | |
| 935 | + QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); | |
| 936 | + | |
| 937 | + if (urlParts.count() > 1) { | |
| 938 | + // if url has 2 or more parts, the first one is domain name | |
| 939 | + QString domain = urlParts[0]; | |
| 940 | + | |
| 941 | + // second part is either a destination coordinate or | |
| 942 | + // a place name | |
| 943 | + QString destination = urlParts[1]; | |
| 944 | + | |
| 945 | + // any third part is an avatar orientation. | |
| 946 | + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); | |
| 947 | + | |
| 948 | + goToDomain(domain); | |
| 949 | + | |
| 950 | + // goto either @user, #place, or x-xx,y-yy,z-zz | |
| 951 | + // style co-ordinate. | |
| 952 | + goTo(destination); | |
| 953 | + | |
| 954 | + if (!orientation.isEmpty()) { | |
| 955 | + // location orientation | |
| 956 | + goToOrientation(orientation); | |
| 957 | + } | |
| 958 | + } else if (urlParts.count() == 1) { | |
| 959 | + // location coordinates or place name | |
| 960 | + QString destination = urlParts[0]; | |
| 961 | + goTo(destination); | |
| 962 | + } | |
| 963 | + | |
| 964 | + } else { | |
| 965 | + goToUser(gotoDialog.textValue()); | |
| 966 | + } | |
| 928 | 967 | } |
| 929 | 968 | sendFakeEnterEvent(); |
| 930 | 969 | } |