History

Custom URL handler

stojce committed 12 years ago

Commit b05967a1 parent 7fc66394 files · +57 −49Browse files

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

Unified · Split

interface/src/Menu.cpp+36−48
@@ -913,6 +913,39 @@ void Menu::goToDomain() { · 912 unmodified lines
913 sendFakeEnterEvent();913 sendFakeEnterEvent();
914}914}
915 915
916bool Menu::goToDestination(QString destination) {
917
918 QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts);
919
920 const int NUMBER_OF_COORDINATE_ITEMS = 3;
921 const int X_ITEM = 0;
922 const int Y_ITEM = 1;
923 const int Z_ITEM = 2;
924 if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) {
925
926 double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble();
927 double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble();
928 double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble();
929
930 glm::vec3 newAvatarPos(x, y, z);
931
932 MyAvatar* myAvatar = Application::getInstance()->getAvatar();
933 glm::vec3 avatarPos = myAvatar->getPosition();
934 if (newAvatarPos != avatarPos) {
935 // send a node kill request, indicating to other clients that they should play the "disappeared" effect
936 MyAvatar::sendKillAvatar();
937
938 qDebug("Going To Location: %f, %f, %f...", x, y, z);
939 myAvatar->setPosition(newAvatarPos);
940 }
941
942 return true;
943 }
944
945 // no coordinates were parsed
946 return false;
947}
948
916void Menu::goTo() {949void Menu::goTo() {
917 950
918 QInputDialog gotoDialog(Application::getInstance()->getWindow());951 QInputDialog gotoDialog(Application::getInstance()->getWindow());
@@ -928,31 +961,8 @@ void Menu::goTo() { · 9 unmodified lines
928 961
929 destination = gotoDialog.textValue();962 destination = gotoDialog.textValue();
930 963
931 QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts);964 // go to coordinate destination or to Username
932 965 if (!goToDestination(destination)) {
933 const int NUMBER_OF_COORDINATE_ITEMS = 3;
934 const int X_ITEM = 0;
935 const int Y_ITEM = 1;
936 const int Z_ITEM = 2;
937 if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) {
938
939 double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble();
940 double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble();
941 double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble();
942
943 glm::vec3 newAvatarPos(x, y, z);
944
945 MyAvatar* myAvatar = Application::getInstance()->getAvatar();
946 glm::vec3 avatarPos = myAvatar->getPosition();
947 if (newAvatarPos != avatarPos) {
948 // send a node kill request, indicating to other clients that they should play the "disappeared" effect
949 MyAvatar::sendKillAvatar();
950
951 qDebug("Going To Location: %f, %f, %f...", x, y, z);
952 myAvatar->setPosition(newAvatarPos);
953 }
954
955 } else {
956 // there's a username entered by the user, make a request to the data-server966 // there's a username entered by the user, make a request to the data-server
957 DataServerClient::getValuesForKeysAndUserString(967 DataServerClient::getValuesForKeysAndUserString(
958 QStringList()968 QStringList()
@@ -983,29 +993,7 @@ void Menu::goToLocation() { · 24 unmodified lines
983 993
984 int dialogReturn = coordinateDialog.exec();994 int dialogReturn = coordinateDialog.exec();
985 if (dialogReturn == QDialog::Accepted && !coordinateDialog.textValue().isEmpty()) {995 if (dialogReturn == QDialog::Accepted && !coordinateDialog.textValue().isEmpty()) {
986 QByteArray newCoordinates;996 goToDestination(coordinateDialog.textValue());
987
988 QString delimiterPattern(",");
989 QStringList coordinateItems = coordinateDialog.textValue().split(delimiterPattern);
990
991 const int NUMBER_OF_COORDINATE_ITEMS = 3;
992 const int X_ITEM = 0;
993 const int Y_ITEM = 1;
994 const int Z_ITEM = 2;
995 if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) {
996 double x = coordinateItems[X_ITEM].toDouble();
997 double y = coordinateItems[Y_ITEM].toDouble();
998 double z = coordinateItems[Z_ITEM].toDouble();
999 glm::vec3 newAvatarPos(x, y, z);
1000
1001 if (newAvatarPos != avatarPos) {
1002 // send a node kill request, indicating to other clients that they should play the "disappeared" effect
1003 MyAvatar::sendKillAvatar();
1004
1005 qDebug("Going To Location: %f, %f, %f...", x, y, z);
1006 myAvatar->setPosition(newAvatarPos);
1007 }
1008 }
1009 }997 }
1010 998
1011 sendFakeEnterEvent();999 sendFakeEnterEvent();