mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
CR fixes
This commit is contained in:
parent
4b182bb3e2
commit
576b8acef3
7 changed files with 38 additions and 88 deletions
|
@ -113,18 +113,18 @@
|
|||
<context>
|
||||
<name>Menu</name>
|
||||
<message>
|
||||
<location filename="src/Menu.cpp" line="429"/>
|
||||
<location filename="src/Menu.cpp" line="437"/>
|
||||
<source>Open .ini config file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/Menu.cpp" line="431"/>
|
||||
<location filename="src/Menu.cpp" line="443"/>
|
||||
<location filename="src/Menu.cpp" line="439"/>
|
||||
<location filename="src/Menu.cpp" line="451"/>
|
||||
<source>Text files (*.ini)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="src/Menu.cpp" line="441"/>
|
||||
<location filename="src/Menu.cpp" line="449"/>
|
||||
<source>Save .ini config file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#include <QLineEdit>
|
||||
#include <QMainWindow>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QShortcut>
|
||||
#include <QSlider>
|
||||
#include <QStandardPaths>
|
||||
#include <QUuid>
|
||||
#include <QWindow>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <AccountManager.h>
|
||||
#include <XmppClient.h>
|
||||
|
@ -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;
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include <EventTypes.h>
|
||||
#include <MenuItemProperties.h>
|
||||
#include <OctreeConstants.h>
|
||||
#include "location/LocationManager.h"
|
||||
|
||||
#include <ui/ChatWindow.h>
|
||||
#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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
#define __hifi__LocationManager__
|
||||
|
||||
#include <QtCore>
|
||||
#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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,8 +26,6 @@ public:
|
|||
_domain = domain;
|
||||
}
|
||||
|
||||
NamedLocation(const QJsonObject jsonData);
|
||||
|
||||
QString toJsonString();
|
||||
|
||||
bool isEmpty() { return _locationName.isNull() || _locationName.isEmpty(); }
|
||||
|
|
Loading…
Reference in a new issue