Merge pull request #2652 from AndrewMeadows/inertia

save settings whenever menu items are changed
This commit is contained in:
Andrzej Kapolka 2014-04-11 16:35:01 -07:00
commit 91c21ced5d
8 changed files with 17 additions and 4 deletions

View file

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

View file

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

View file

@ -684,6 +684,7 @@ QAction* Menu::addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu,
QAction::NoRole, menuItemLocation); QAction::NoRole, menuItemLocation);
action->setCheckable(true); action->setCheckable(true);
action->setChecked(checked); action->setChecked(checked);
connect(action, SIGNAL(changed()), Application::getInstance(), SLOT(bumpSettings()));
return action; return action;
} }
@ -917,7 +918,6 @@ void Menu::goToLocation() {
QString currentLocation = QString("%1, %2, %3").arg(QString::number(avatarPos.x), QString currentLocation = QString("%1, %2, %3").arg(QString::number(avatarPos.x),
QString::number(avatarPos.y), QString::number(avatarPos.z)); QString::number(avatarPos.y), QString::number(avatarPos.z));
QInputDialog coordinateDialog(Application::getInstance()->getWindow()); QInputDialog coordinateDialog(Application::getInstance()->getWindow());
coordinateDialog.setWindowTitle("Go to Location"); coordinateDialog.setWindowTitle("Go to Location");
coordinateDialog.setLabelText("Coordinate as x,y,z:"); coordinateDialog.setLabelText("Coordinate as x,y,z:");

View file

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

View file

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

View file

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

View file

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

View file

@ -140,6 +140,7 @@ void PreferencesDialog::savePreferences() {
if (shouldDispatchIdentityPacket) { if (shouldDispatchIdentityPacket) {
myAvatar->sendIdentityPacket(); myAvatar->sendIdentityPacket();
Application::getInstance()->bumpSettings();
} }
myAvatar->getHead()->setPupilDilation(ui.pupilDilationSlider->value() / (float)ui.pupilDilationSlider->maximum()); myAvatar->getHead()->setPupilDilation(ui.pupilDilationSlider->value() / (float)ui.pupilDilationSlider->maximum());