diff --git a/interface/interface_en.ts b/interface/interface_en.ts index c52ec91671..786a76530c 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -113,18 +113,18 @@ Menu - + Open .ini config file - - + + Text files (*.ini) - + Save .ini config file diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index b322e6567c..98a00e05c9 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -19,12 +19,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include @@ -940,7 +940,7 @@ void Menu::goToLocation() { sendFakeEnterEvent(); } -void Menu::namedLocationCreated(LocationManager::NamedLocationCreateResponse response, NamedLocation* location) { +void Menu::namedLocationCreated(LocationManager::NamedLocationCreateResponse response) { if (response == LocationManager::Created) { return; diff --git a/interface/src/Menu.h b/interface/src/Menu.h index b124315cbb..df622be6ac 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -17,9 +17,9 @@ #include #include #include -#include "location/LocationManager.h" -#include +#include "location/LocationManager.h" +#include "ui/ChatWindow.h" const float ADJUST_LOD_DOWN_FPS = 40.0; const float ADJUST_LOD_UP_FPS = 55.0; @@ -149,7 +149,7 @@ private slots: void showChat(); void toggleChat(); void audioMuteToggled(); - void namedLocationCreated(LocationManager::NamedLocationCreateResponse response, NamedLocation* location); + void namedLocationCreated(LocationManager::NamedLocationCreateResponse response); void multipleDestinationsDecision(const QJsonObject& userData, const QJsonObject& placeData); private: diff --git a/interface/src/location/LocationManager.cpp b/interface/src/location/LocationManager.cpp index 986371ac88..b83094ba4c 100644 --- a/interface/src/location/LocationManager.cpp +++ b/interface/src/location/LocationManager.cpp @@ -6,8 +6,8 @@ // // -#include "LocationManager.h" #include "Application.h" +#include "LocationManager.h" const QString GET_USER_ADDRESS = "/api/v1/users/%1/address"; const QString GET_PLACE_ADDRESS = "/api/v1/places/%1/address"; @@ -29,15 +29,14 @@ void LocationManager::namedLocationDataReceived(const QJsonObject& data) { } if (data.contains("status") && data["status"].toString() == "success") { - NamedLocation* location = new NamedLocation(data["data"].toObject()); - emit creationCompleted(LocationManager::Created, location); + emit creationCompleted(LocationManager::Created); } else { - emit creationCompleted(LocationManager::AlreadyExists, NULL); + emit creationCompleted(LocationManager::AlreadyExists); } } void LocationManager::errorDataReceived(QNetworkReply::NetworkError error, const QString& message) { - emit creationCompleted(LocationManager::SystemError, NULL); + emit creationCompleted(LocationManager::SystemError); } void LocationManager::createNamedLocation(NamedLocation* namedLocation) { @@ -149,7 +148,7 @@ void LocationManager::goToOrientation(QString orientation) { return; } - QStringList orientationItems = orientation.split(QRegExp("_|,"), QString::SkipEmptyParts); + QStringList orientationItems = orientation.remove(' ').split(QRegExp("_|,"), QString::SkipEmptyParts); const int NUMBER_OF_ORIENTATION_ITEMS = 4; const int W_ITEM = 0; @@ -159,10 +158,16 @@ void LocationManager::goToOrientation(QString orientation) { if (orientationItems.size() == NUMBER_OF_ORIENTATION_ITEMS) { - double w = replaceLastOccurrence('-', '.', orientationItems[W_ITEM].trimmed()).toDouble(); - double x = replaceLastOccurrence('-', '.', orientationItems[X_ITEM].trimmed()).toDouble(); - double y = replaceLastOccurrence('-', '.', orientationItems[Y_ITEM].trimmed()).toDouble(); - double z = replaceLastOccurrence('-', '.', orientationItems[Z_ITEM].trimmed()).toDouble(); + // replace last occurrence of '_' with decimal point + replaceLastOccurrence('-', '.', orientationItems[W_ITEM]); + replaceLastOccurrence('-', '.', orientationItems[X_ITEM]); + replaceLastOccurrence('-', '.', orientationItems[Y_ITEM]); + replaceLastOccurrence('-', '.', orientationItems[Z_ITEM]); + + double w = orientationItems[W_ITEM].toDouble(); + double x = orientationItems[X_ITEM].toDouble(); + double y = orientationItems[Y_ITEM].toDouble(); + double z = orientationItems[Z_ITEM].toDouble(); glm::quat newAvatarOrientation(w, x, y, z); @@ -176,7 +181,7 @@ void LocationManager::goToOrientation(QString orientation) { bool LocationManager::goToDestination(QString destination) { - QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts); + QStringList coordinateItems = destination.remove(' ').split(QRegExp("_|,"), QString::SkipEmptyParts); const int NUMBER_OF_COORDINATE_ITEMS = 3; const int X_ITEM = 0; @@ -184,9 +189,14 @@ bool LocationManager::goToDestination(QString destination) { const int Z_ITEM = 2; if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { - double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble(); - double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble(); - double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble(); + // replace last occurrence of '_' with decimal point + replaceLastOccurrence('-', '.', coordinateItems[X_ITEM]); + replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM]); + replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM]); + + double x = coordinateItems[X_ITEM].toDouble(); + double y = coordinateItems[Y_ITEM].toDouble(); + double z = coordinateItems[Z_ITEM].toDouble(); glm::vec3 newAvatarPos(x, y, z); @@ -207,14 +217,11 @@ bool LocationManager::goToDestination(QString destination) { return false; } -QString LocationManager::replaceLastOccurrence(QChar search, QChar replace, QString string) { +void LocationManager::replaceLastOccurrence(const QChar search, const QChar replace, QString& string) { int lastIndex; lastIndex = string.lastIndexOf(search); if (lastIndex > 0) { lastIndex = string.lastIndexOf(search); string.replace(lastIndex, 1, replace); } - - return string; } - diff --git a/interface/src/location/LocationManager.h b/interface/src/location/LocationManager.h index 6d5beacae5..a6bdaf66b4 100644 --- a/interface/src/location/LocationManager.h +++ b/interface/src/location/LocationManager.h @@ -10,8 +10,9 @@ #define __hifi__LocationManager__ #include -#include "NamedLocation.h" + #include "AccountManager.h" +#include "NamedLocation.h" class LocationManager : public QObject { Q_OBJECT @@ -35,14 +36,14 @@ public: bool goToDestination(QString destination); private: - QString replaceLastOccurrence(QChar search, QChar replace, QString string); QJsonObject _userData; QJsonObject _placeData; + void replaceLastOccurrence(const QChar search, const QChar replace, QString& string); void checkForMultipleDestinations(); signals: - void creationCompleted(LocationManager::NamedLocationCreateResponse response, NamedLocation* location); + void creationCompleted(LocationManager::NamedLocationCreateResponse response); void multipleDestinationsFound(const QJsonObject& userData, const QJsonObject& placeData); void locationChanged(); diff --git a/interface/src/location/NamedLocation.cpp b/interface/src/location/NamedLocation.cpp index af96794fd0..c6daef4961 100644 --- a/interface/src/location/NamedLocation.cpp +++ b/interface/src/location/NamedLocation.cpp @@ -22,59 +22,3 @@ QString NamedLocation::toJsonString() { _domain, _locationName); } - -NamedLocation::NamedLocation(const QJsonObject jsonData) { - - bool hasProperties; - - if (jsonData.contains("name")) { - hasProperties = true; - _locationName = jsonData["name"].toString(); - } - - if (jsonData.contains("username")) { - hasProperties = true; - _createdBy = jsonData["username"].toString(); - } - - if (jsonData.contains("domain")) { - hasProperties = true; - _domain = jsonData["domain"].toString(); - } - - // parse position - if (jsonData.contains("position")) { - hasProperties = true; - const int NUMBER_OF_POSITION_ITEMS = 3; - const int X_ITEM = 0; - const int Y_ITEM = 1; - const int Z_ITEM = 2; - - QStringList coordinateItems = jsonData["position"].toString().split(",", QString::SkipEmptyParts); - if (coordinateItems.size() == NUMBER_OF_POSITION_ITEMS) { - double x = coordinateItems[X_ITEM].trimmed().toDouble(); - double y = coordinateItems[Y_ITEM].trimmed().toDouble(); - double z = coordinateItems[Z_ITEM].trimmed().toDouble(); - _location = glm::vec3(x, y, z); - } - } - - // parse orientation - if (jsonData.contains("orientation")) { - hasProperties = true; - QStringList orientationItems = jsonData["orientation"] .toString().split(",", QString::SkipEmptyParts); - const int NUMBER_OF_ORIENTATION_ITEMS = 4; - const int W_ITEM = 0; - const int X_ITEM = 1; - const int Y_ITEM = 2; - const int Z_ITEM = 3; - - if (orientationItems.size() == NUMBER_OF_ORIENTATION_ITEMS) { - double w = orientationItems[W_ITEM].trimmed().toDouble(); - double x = orientationItems[X_ITEM].trimmed().toDouble(); - double y = orientationItems[Y_ITEM].trimmed().toDouble(); - double z = orientationItems[Z_ITEM].trimmed().toDouble(); - _orientation = glm::quat(w, x, y, z); - } - } -} \ No newline at end of file diff --git a/interface/src/location/NamedLocation.h b/interface/src/location/NamedLocation.h index 4bc8c2e2ad..81af03b45e 100644 --- a/interface/src/location/NamedLocation.h +++ b/interface/src/location/NamedLocation.h @@ -26,8 +26,6 @@ public: _domain = domain; } - NamedLocation(const QJsonObject jsonData); - QString toJsonString(); bool isEmpty() { return _locationName.isNull() || _locationName.isEmpty(); }