History

Improved hifi:// style URL scheme handling.

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.

James Brotchie committed 12 years ago

Commit 19b8f101 parent 89cb1ad5 files · +51 −29Browse files

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

Unified · Split

interface/src/Menu.cpp+41−2
@@ -912,19 +912,58 @@ bool Menu::goToDestination(QString destination) { · 911 unmodified lines
912912 return LocationManager::getInstance().goToDestination(destination);
913913 }
914914
915+void Menu::goTo(QString destination) {
916+ LocationManager::getInstance().goTo(destination);
917+}
918+
915919 void Menu::goTo() {
916920
917921 QInputDialog gotoDialog(Application::getInstance()->getWindow());
918922 gotoDialog.setWindowTitle("Go to");
919− gotoDialog.setLabelText("Destination:");
923+ gotoDialog.setLabelText("Destination or URL:\n @user, #place, hifi://domain/location/orientation");
920924 QString destination = QString();
925+
921926 gotoDialog.setTextValue(destination);
922927 gotoDialog.setWindowFlags(Qt::Sheet);
923928 gotoDialog.resize(gotoDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, gotoDialog.size().height());
924929
925930 int dialogReturn = gotoDialog.exec();
926931 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+ }
928967 }
929968 sendFakeEnterEvent();
930969 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t