mirror of
https://github.com/overte-org/overte.git
synced 2025-04-24 05:53:29 +02:00
Moved Snapshot location out of Menu
Moved into Snapshot
This commit is contained in:
parent
488d8a03d5
commit
5930e06849
5 changed files with 23 additions and 19 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -10,13 +10,15 @@
|
|||
//
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <AccountManager.h>
|
||||
#include <Application.h>
|
||||
#include <FileUtils.h>
|
||||
|
||||
#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<GLCanvas>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue