save settings for change in: identity, position

This commit is contained in:
Andrew Meadows 2014-04-10 17:14:51 -07:00
parent e08dfeae2a
commit a436b59971
7 changed files with 16 additions and 4 deletions

View file

@ -250,6 +250,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection);
_settings = new QSettings(this);
_numChangedSettings = 0;
// Check to see if the user passed in a command line option for loading a local
// Voxel File.
@ -406,6 +407,7 @@ void Application::saveSettings() {
_voxelImporter->saveSettings(_settings);
}
_settings->sync();
_numChangedSettings = 0;
}
@ -1271,6 +1273,9 @@ void Application::idle() {
// After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
idleTimer->start(2);
}
if (_numChangedSettings > 0) {
saveSettings();
}
}
}
@ -1617,6 +1622,7 @@ void Application::init() {
connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
connect(_myAvatar, SIGNAL(transformChanged()), this, SLOT(bumpSettings()));
}
void Application::closeMirrorView() {

View file

@ -286,6 +286,8 @@ public slots:
void uploadHead();
void uploadSkeleton();
void bumpSettings() { ++_numChangedSettings; }
private slots:
void timer();
void idle();
@ -376,6 +378,7 @@ private:
QNetworkAccessManager* _networkAccessManager;
QMutex _settingsMutex;
QSettings* _settings;
int _numChangedSettings;
QUndoStack _undoStack;

View file

@ -898,6 +898,7 @@ void Menu::editPreferences() {
if (shouldDispatchIdentityPacket) {
applicationInstance->getAvatar()->sendIdentityPacket();
applicationInstance->bumpSettings();
}
applicationInstance->getAvatar()->getHead()->setPupilDilation(pupilDilation->value() / (float)pupilDilation->maximum());
@ -1063,7 +1064,6 @@ void Menu::goToLocation() {
QString currentLocation = QString("%1, %2, %3").arg(QString::number(avatarPos.x),
QString::number(avatarPos.y), QString::number(avatarPos.z));
QInputDialog coordinateDialog(Application::getInstance()->getWindow());
coordinateDialog.setWindowTitle("Go to Location");
coordinateDialog.setLabelText("Coordinate as x,y,z:");

View file

@ -1175,6 +1175,7 @@ void MyAvatar::goToLocationFromResponse(const QJsonObject& jsonObject) {
glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(),
coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
setPosition(newPosition);
emit transformChanged();
}
}

View file

@ -106,6 +106,9 @@ public slots:
glm::vec3 getThrust() { return _thrust; };
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
signals:
void transformChanged();
private:
bool _mousePressed;
float _bodyPitchDelta; // degrees

View file

@ -118,8 +118,6 @@ void LocationManager::checkForMultipleDestinations() {
Application::getInstance()->getAvatar()->goToLocationFromResponse(_placeData);
return;
}
emit locationChanged();
}
}
@ -178,6 +176,7 @@ void LocationManager::goToOrientation(QString orientation) {
glm::quat avatarOrientation = myAvatar->getOrientation();
if (newAvatarOrientation != avatarOrientation) {
myAvatar->setOrientation(newAvatarOrientation);
emit myAvatar->transformChanged();
}
}
}
@ -211,6 +210,7 @@ bool LocationManager::goToDestination(QString destination) {
qDebug("Going To Location: %f, %f, %f...", x, y, z);
myAvatar->setPosition(newAvatarPos);
emit myAvatar->transformChanged();
}
return true;

View file

@ -48,7 +48,6 @@ private:
signals:
void creationCompleted(LocationManager::NamedLocationCreateResponse response);
void multipleDestinationsFound(const QJsonObject& userData, const QJsonObject& placeData);
void locationChanged();
private slots:
void namedLocationDataReceived(const QJsonObject& data);