diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 34904542a0..6e6a4aef6e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -592,8 +592,6 @@ void Menu::loadSettings(QSettings* settings) { int bufferSize = settings->value("audioOutputBufferSize", DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES).toInt(); QMetaObject::invokeMethod(audio.data(), "setOutputBufferSize", Q_ARG(int, bufferSize)); - _snapshotsLocation = settings->value("snapshotsLocation", - QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).toString(); setScriptsLocation(settings->value("scriptsLocation", QString()).toString()); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) @@ -635,7 +633,6 @@ void Menu::saveSettings(QSettings* settings) { settings->setValue("audioOutputStarveDetectionPeriod", audio->getOutputStarveDetectionPeriod()); settings->setValue("audioOutputBufferSize", audio->getOutputBufferSize()); - settings->setValue("snapshotsLocation", _snapshotsLocation); settings->setValue("scriptsLocation", _scriptsLocation); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) settings->setValue("speechRecognitionEnabled", _speechRecognizer.getEnabled()); @@ -1155,13 +1152,6 @@ void Menu::runTests() { runTimingTests(); } -QString Menu::getSnapshotsLocation() const { - if (_snapshotsLocation.isNull() || _snapshotsLocation.isEmpty() || QDir(_snapshotsLocation).exists() == false) { - return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - } - return _snapshotsLocation; -} - void Menu::setScriptsLocation(const QString& scriptsLocation) { _scriptsLocation = scriptsLocation; bumpSettings(); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 98445f31a6..e38c476ba1 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -130,8 +130,6 @@ private: /////////////////////////////////////////// TODO: Move to appropriate files //////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public: - QString getSnapshotsLocation() const; - void setSnapshotsLocation(QString snapshotsLocation) { _snapshotsLocation = snapshotsLocation; bumpSettings(); } const QString& getScriptsLocation() const { return _scriptsLocation; } void setScriptsLocation(const QString& scriptsLocation); @@ -160,7 +158,6 @@ private: SpeechRecognizer _speechRecognizer; #endif - QString _snapshotsLocation; QString _scriptsLocation; QByteArray _walletPrivateKey; }; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 08186a7adf..b54c73e83b 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -20,6 +20,7 @@ #include "Menu.h" #include "ModelsBrowser.h" #include "PreferencesDialog.h" +#include "Snapshot.h" #include "UserActivityLogger.h" const int PREFERENCES_HEIGHT_PADDING = 20; @@ -120,7 +121,7 @@ void PreferencesDialog::loadPreferences() { ui.sendDataCheckBox->setChecked(!menuInstance->isOptionChecked(MenuOption::DisableActivityLogger)); - ui.snapshotLocationEdit->setText(menuInstance->getSnapshotsLocation()); + ui.snapshotLocationEdit->setText(Snapshot::getSnapshotsLocation()); ui.scriptsLocationEdit->setText(menuInstance->getScriptsLocation()); @@ -218,7 +219,7 @@ void PreferencesDialog::savePreferences() { } if (!ui.snapshotLocationEdit->text().isEmpty() && QDir(ui.snapshotLocationEdit->text()).exists()) { - Menu::getInstance()->setSnapshotsLocation(ui.snapshotLocationEdit->text()); + Snapshot::setSnapshotsLocation(ui.snapshotLocationEdit->text()); } if (!ui.scriptsLocationEdit->text().isEmpty() && QDir(ui.scriptsLocationEdit->text()).exists()) { diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 3ea2a2fb2b..73a7d31241 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -10,13 +10,15 @@ // #include +#include #include +#include #include +#include #include #include "Snapshot.h" -#include "Menu.h" // filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg // %1 <= username, %2 <= date and time, %3 <= current location @@ -36,6 +38,8 @@ const QString ORIENTATION_W = "orientation-w"; const QString DOMAIN_KEY = "domain"; +QString Snapshot::_snapshotsLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { if (!QFile(snapshotPath).exists()) { @@ -86,7 +90,7 @@ QFile* Snapshot::savedFileForSnapshot(bool isTemporary) { auto glCanvas = DependencyManager::get(); QImage shot = glCanvas->grabFrameBuffer(); - Avatar* avatar = Application::getInstance()->getAvatar(); + Avatar* avatar = qApp->getAvatar(); glm::vec3 location = avatar->getPosition(); glm::quat orientation = avatar->getHead()->getOrientation(); @@ -118,7 +122,7 @@ QFile* Snapshot::savedFileForSnapshot(bool isTemporary) { const int IMAGE_QUALITY = 100; if (!isTemporary) { - QString snapshotFullPath = Menu::getInstance()->getSnapshotsLocation(); + QString snapshotFullPath = getSnapshotsLocation(); if (!snapshotFullPath.endsWith(QDir::separator())) { snapshotFullPath.append(QDir::separator()); @@ -148,4 +152,13 @@ QFile* Snapshot::savedFileForSnapshot(bool isTemporary) { } } +QString Snapshot::getSnapshotsLocation() { + if (_snapshotsLocation.isNull() || + _snapshotsLocation.isEmpty() || + QDir(_snapshotsLocation).exists() == false) { + return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + } + return _snapshotsLocation; +} + diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index c29bdc41ff..ec5abca710 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -41,14 +41,17 @@ private: }; class Snapshot { - public: + static QString getSnapshotsLocation(); + static void setSnapshotsLocation(QString snapshotsLocation) { _snapshotsLocation = snapshotsLocation; } static QString saveSnapshot(); static QTemporaryFile* saveTempSnapshot(); static SnapshotMetaData* parseSnapshotData(QString snapshotPath); private: static QFile* savedFileForSnapshot(bool isTemporary); + + static QString _snapshotsLocation; }; #endif // hifi_Snapshot_h