History

Allow drag-and-drop of snapshots into Interface

stojce committed 12 years ago

Commit 68584c61 parent 803d0fd9 files · +190 −73Browse files

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

Unified · Split

interface/src/Menu.cpp+51−56
@@ -109,7 +109,7 @@ Menu::Menu() : · 108 unmodified lines
109109 MenuOption::GoToDomain,
110110 Qt::CTRL | Qt::Key_D,
111111 this,
112− SLOT(goToDomain()));
112+ SLOT(goToDomainDialog()));
113113 addActionToQMenuAndActionHash(fileMenu,
114114 MenuOption::GoToLocation,
115115 Qt::CTRL | Qt::SHIFT | Qt::Key_L,
@@ -889,7 +889,18 @@ void Menu::editPreferences() { · 773 unmodified lines
889889 sendFakeEnterEvent();
890890 }
891891
892−void Menu::goToDomain() {
892+void Menu::goToDomain(const QString newDomain) {
893+ if (NodeList::getInstance()->getDomainHostname() != newDomain) {
894+
895+ // send a node kill request, indicating to other clients that they should play the "disappeared" effect
896+ Application::getInstance()->getAvatar()->sendKillAvatar();
897+
898+ // give our nodeList the new domain-server hostname
899+ NodeList::getInstance()->setDomainHostname(newDomain);
900+ }
901+}
902+
903+void Menu::goToDomainDialog() {
893904
894905 QString currentDomainHostname = NodeList::getInstance()->getDomainHostname();
895906
@@ -913,17 +924,46 @@ void Menu::goToDomain() { · 17 unmodified lines
913924 // the user input a new hostname, use that
914925 newHostname = domainDialog.textValue();
915926 }
916−
917− // send a node kill request, indicating to other clients that they should play the "disappeared" effect
918− Application::getInstance()->getAvatar()->sendKillAvatar();
919−
920− // give our nodeList the new domain-server hostname
921− NodeList::getInstance()->setDomainHostname(domainDialog.textValue());
927+
928+ goToDomain(newHostname);
922929 }
923930
924931 sendFakeEnterEvent();
925932 }
926933
934+bool Menu::goToDestination(QString destination) {
935+
936+ QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts);
937+
938+ const int NUMBER_OF_COORDINATE_ITEMS = 3;
939+ const int X_ITEM = 0;
940+ const int Y_ITEM = 1;
941+ const int Z_ITEM = 2;
942+ if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) {
943+
944+ double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble();
945+ double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble();
946+ double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble();
947+
948+ glm::vec3 newAvatarPos(x, y, z);
949+
950+ MyAvatar* myAvatar = Application::getInstance()->getAvatar();
951+ glm::vec3 avatarPos = myAvatar->getPosition();
952+ if (newAvatarPos != avatarPos) {
953+ // send a node kill request, indicating to other clients that they should play the "disappeared" effect
954+ MyAvatar::sendKillAvatar();
955+
956+ qDebug("Going To Location: %f, %f, %f...", x, y, z);
957+ myAvatar->setPosition(newAvatarPos);
958+ }
959+
960+ return true;
961+ }
962+
963+ // no coordinates were parsed
964+ return false;
965+}
966+
927967 void Menu::goTo() {
928968
929969 QInputDialog gotoDialog(Application::getInstance()->getWindow());
@@ -939,31 +979,8 @@ void Menu::goTo() { · 9 unmodified lines
939979
940980 destination = gotoDialog.textValue();
941981
942− QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts);
943−
944− const int NUMBER_OF_COORDINATE_ITEMS = 3;
945− const int X_ITEM = 0;
946− const int Y_ITEM = 1;
947− const int Z_ITEM = 2;
948− if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) {
949−
950− double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble();
951− double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble();
952− double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble();
953−
954− glm::vec3 newAvatarPos(x, y, z);
955−
956− MyAvatar* myAvatar = Application::getInstance()->getAvatar();
957− glm::vec3 avatarPos = myAvatar->getPosition();
958− if (newAvatarPos != avatarPos) {
959− // send a node kill request, indicating to other clients that they should play the "disappeared" effect
960− MyAvatar::sendKillAvatar();
961−
962− qDebug("Going To Location: %f, %f, %f...", x, y, z);
963− myAvatar->setPosition(newAvatarPos);
964− }
965−
966− } else {
982+ // go to coordinate destination or to Username
983+ if (!goToDestination(destination)) {
967984 // there's a username entered by the user, make a request to the data-server
968985 DataServerClient::getValuesForKeysAndUserString(
969986 QStringList()
@@ -994,29 +1011,7 @@ void Menu::goToLocation() { · 24 unmodified lines
9941011
9951012 int dialogReturn = coordinateDialog.exec();
9961013 if (dialogReturn == QDialog::Accepted && !coordinateDialog.textValue().isEmpty()) {
997− QByteArray newCoordinates;
998−
999− QString delimiterPattern(",");
1000− QStringList coordinateItems = coordinateDialog.textValue().split(delimiterPattern);
1001−
1002− const int NUMBER_OF_COORDINATE_ITEMS = 3;
1003− const int X_ITEM = 0;
1004− const int Y_ITEM = 1;
1005− const int Z_ITEM = 2;
1006− if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) {
1007− double x = coordinateItems[X_ITEM].toDouble();
1008− double y = coordinateItems[Y_ITEM].toDouble();
1009− double z = coordinateItems[Z_ITEM].toDouble();
1010− glm::vec3 newAvatarPos(x, y, z);
1011−
1012− if (newAvatarPos != avatarPos) {
1013− // send a node kill request, indicating to other clients that they should play the "disappeared" effect
1014− MyAvatar::sendKillAvatar();
1015−
1016− qDebug("Going To Location: %f, %f, %f...", x, y, z);
1017− myAvatar->setPosition(newAvatarPos);
1018− }
1019− }
1014+ goToDestination(coordinateDialog.textValue());
10201015 }
10211016
10221017 sendFakeEnterEvent();