mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
Totally removed Application's setting memember
This commit is contained in:
parent
92e9df0c74
commit
c2b7ff1b54
11 changed files with 94 additions and 142 deletions
|
@ -356,9 +356,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
|
|
||||||
connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
|
connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
|
||||||
|
|
||||||
_settings = new QSettings(this);
|
|
||||||
_numChangedSettings = 0;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA WsaData;
|
WSADATA WsaData;
|
||||||
int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData);
|
int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData);
|
||||||
|
@ -514,10 +511,6 @@ Application::~Application() {
|
||||||
|
|
||||||
void Application::saveSettings() {
|
void Application::saveSettings() {
|
||||||
Menu::getInstance()->saveSettings();
|
Menu::getInstance()->saveSettings();
|
||||||
_rearMirrorTools->saveSettings(_settings);
|
|
||||||
|
|
||||||
_settings->sync();
|
|
||||||
_numChangedSettings = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::initializeGL() {
|
void Application::initializeGL() {
|
||||||
|
@ -1439,10 +1432,6 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1711,16 +1700,13 @@ void Application::init() {
|
||||||
_metavoxels.init();
|
_metavoxels.init();
|
||||||
|
|
||||||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||||
_rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings);
|
_rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect);
|
||||||
|
|
||||||
connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
|
connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
|
||||||
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()));
|
||||||
|
|
||||||
// save settings when avatar changes
|
|
||||||
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
|
||||||
|
|
||||||
#ifdef USE_BULLET_PHYSICS
|
#ifdef USE_BULLET_PHYSICS
|
||||||
EntityTree* tree = _entities.getTree();
|
EntityTree* tree = _entities.getTree();
|
||||||
_physicsEngine.setEntityTree(tree);
|
_physicsEngine.setEntityTree(tree);
|
||||||
|
@ -3551,7 +3537,6 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser
|
||||||
if (activateMainWindow && !loadScriptFromEditor) {
|
if (activateMainWindow && !loadScriptFromEditor) {
|
||||||
_window->activateWindow();
|
_window->activateWindow();
|
||||||
}
|
}
|
||||||
bumpSettings();
|
|
||||||
|
|
||||||
return scriptEngine;
|
return scriptEngine;
|
||||||
}
|
}
|
||||||
|
@ -3579,7 +3564,6 @@ void Application::scriptFinished(const QString& scriptName) {
|
||||||
_scriptEnginesHash.erase(it);
|
_scriptEnginesHash.erase(it);
|
||||||
_runningScriptsWidget->scriptStopped(scriptName);
|
_runningScriptsWidget->scriptStopped(scriptName);
|
||||||
_runningScriptsWidget->setRunningScripts(getRunningScripts());
|
_runningScriptsWidget->setRunningScripts(getRunningScripts());
|
||||||
bumpSettings();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3675,7 +3659,6 @@ void Application::openUrl(const QUrl& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateMyAvatarTransform() {
|
void Application::updateMyAvatarTransform() {
|
||||||
bumpSettings();
|
|
||||||
#ifdef USE_BULLET_PHYSICS
|
#ifdef USE_BULLET_PHYSICS
|
||||||
const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters
|
const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters
|
||||||
glm::vec3 avatarPosition = _myAvatar->getPosition();
|
glm::vec3 avatarPosition = _myAvatar->getPosition();
|
||||||
|
|
|
@ -219,10 +219,6 @@ public:
|
||||||
virtual const Transform& getViewTransform() const { return _viewTransform; }
|
virtual const Transform& getViewTransform() const { return _viewTransform; }
|
||||||
void setViewTransform(const Transform& view);
|
void setViewTransform(const Transform& view);
|
||||||
|
|
||||||
/// if you need to access the application settings, use lockSettings()/unlockSettings()
|
|
||||||
QSettings* lockSettings() { _settingsMutex.lock(); return _settings; }
|
|
||||||
void unlockSettings() { _settingsMutex.unlock(); }
|
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
||||||
|
@ -361,7 +357,6 @@ public slots:
|
||||||
void openUrl(const QUrl& url);
|
void openUrl(const QUrl& url);
|
||||||
|
|
||||||
void updateMyAvatarTransform();
|
void updateMyAvatarTransform();
|
||||||
void bumpSettings() { ++_numChangedSettings; }
|
|
||||||
|
|
||||||
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
||||||
|
|
||||||
|
@ -455,10 +450,6 @@ private:
|
||||||
QThread* _nodeThread;
|
QThread* _nodeThread;
|
||||||
DatagramProcessor _datagramProcessor;
|
DatagramProcessor _datagramProcessor;
|
||||||
|
|
||||||
QMutex _settingsMutex;
|
|
||||||
QSettings* _settings;
|
|
||||||
int _numChangedSettings;
|
|
||||||
|
|
||||||
QUndoStack _undoStack;
|
QUndoStack _undoStack;
|
||||||
UndoStackScriptingInterface _undoStackScriptingInterface;
|
UndoStackScriptingInterface _undoStackScriptingInterface;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <GlowEffect.h>
|
#include <GlowEffect.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
#include <Settings.h>
|
||||||
#include <UserActivityLogger.h>
|
#include <UserActivityLogger.h>
|
||||||
#include <XmppClient.h>
|
#include <XmppClient.h>
|
||||||
|
|
||||||
|
@ -544,10 +545,9 @@ Menu::Menu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::loadSettings(QSettings* settings) {
|
void Menu::loadSettings(QSettings* settings) {
|
||||||
bool lockedSettings = false;
|
Settings defaultSettings;
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
settings = qApp->lockSettings();
|
settings = &defaultSettings;
|
||||||
lockedSettings = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto audio = DependencyManager::get<Audio>();
|
auto audio = DependencyManager::get<Audio>();
|
||||||
|
@ -568,17 +568,12 @@ void Menu::loadSettings(QSettings* settings) {
|
||||||
myAvatar->updateCollisionGroups();
|
myAvatar->updateCollisionGroups();
|
||||||
myAvatar->onToggleRagdoll();
|
myAvatar->onToggleRagdoll();
|
||||||
myAvatar->updateMotionBehavior();
|
myAvatar->updateMotionBehavior();
|
||||||
|
|
||||||
if (lockedSettings) {
|
|
||||||
qApp->unlockSettings();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::saveSettings(QSettings* settings) {
|
void Menu::saveSettings(QSettings* settings) {
|
||||||
bool lockedSettings = false;
|
Settings defaultSettings;
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
settings = qApp->lockSettings();
|
settings = &defaultSettings;
|
||||||
lockedSettings = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto audio = DependencyManager::get<Audio>();
|
auto audio = DependencyManager::get<Audio>();
|
||||||
|
@ -591,10 +586,6 @@ void Menu::saveSettings(QSettings* settings) {
|
||||||
qApp->getAvatar()->saveData(settings);
|
qApp->getAvatar()->saveData(settings);
|
||||||
|
|
||||||
DependencyManager::get<AddressManager>()->storeCurrentAddress();
|
DependencyManager::get<AddressManager>()->storeCurrentAddress();
|
||||||
|
|
||||||
if (lockedSettings) {
|
|
||||||
qApp->unlockSettings();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::importSettings() {
|
void Menu::importSettings() {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <QBuffer>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QHttpMultiPart>
|
#include <QHttpMultiPart>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QJsonDocument>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
|
@ -28,12 +30,17 @@
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QThread>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
|
#include <GeometryCache.h>
|
||||||
|
#include <GLMHelpers.h>
|
||||||
|
#include <ResourceCache.h>
|
||||||
|
#include <Settings.h>
|
||||||
|
#include <TextureCache.h>
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "ModelUploader.h"
|
#include "ModelUploader.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,8 +114,8 @@ ModelUploader::~ModelUploader() {
|
||||||
|
|
||||||
bool ModelUploader::zip() {
|
bool ModelUploader::zip() {
|
||||||
// File Dialog
|
// File Dialog
|
||||||
QSettings* settings = Application::getInstance()->lockSettings();
|
Settings settings;
|
||||||
QString lastLocation = settings->value(SETTING_NAME).toString();
|
QString lastLocation = settings.value(SETTING_NAME).toString();
|
||||||
|
|
||||||
if (lastLocation.isEmpty()) {
|
if (lastLocation.isEmpty()) {
|
||||||
lastLocation = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
lastLocation = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||||
|
@ -123,11 +130,9 @@ bool ModelUploader::zip() {
|
||||||
lastLocation, "Model files (*.fst *.fbx)");
|
lastLocation, "Model files (*.fst *.fbx)");
|
||||||
if (filename == "") {
|
if (filename == "") {
|
||||||
// If the user canceled we return.
|
// If the user canceled we return.
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
settings->setValue(SETTING_NAME, filename);
|
settings.setValue(SETTING_NAME, filename);
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
|
|
||||||
// First we check the FST file (if any)
|
// First we check the FST file (if any)
|
||||||
QFile* fst;
|
QFile* fst;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
|
#include <Settings.h>
|
||||||
#include <ShapeCollider.h>
|
#include <ShapeCollider.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <TextRenderer.h>
|
#include <TextRenderer.h>
|
||||||
|
@ -795,62 +796,60 @@ void MyAvatar::loadData(QSettings* settings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::saveAttachmentData(const AttachmentData& attachment) const {
|
void MyAvatar::saveAttachmentData(const AttachmentData& attachment) const {
|
||||||
QSettings* settings = Application::getInstance()->lockSettings();
|
Settings settings;
|
||||||
settings->beginGroup("savedAttachmentData");
|
settings.beginGroup("savedAttachmentData");
|
||||||
settings->beginGroup(_skeletonModel.getURL().toString());
|
settings.beginGroup(_skeletonModel.getURL().toString());
|
||||||
settings->beginGroup(attachment.modelURL.toString());
|
settings.beginGroup(attachment.modelURL.toString());
|
||||||
settings->setValue("jointName", attachment.jointName);
|
settings.setValue("jointName", attachment.jointName);
|
||||||
|
|
||||||
settings->beginGroup(attachment.jointName);
|
settings.beginGroup(attachment.jointName);
|
||||||
settings->setValue("translation_x", attachment.translation.x);
|
settings.setValue("translation_x", attachment.translation.x);
|
||||||
settings->setValue("translation_y", attachment.translation.y);
|
settings.setValue("translation_y", attachment.translation.y);
|
||||||
settings->setValue("translation_z", attachment.translation.z);
|
settings.setValue("translation_z", attachment.translation.z);
|
||||||
glm::vec3 eulers = safeEulerAngles(attachment.rotation);
|
glm::vec3 eulers = safeEulerAngles(attachment.rotation);
|
||||||
settings->setValue("rotation_x", eulers.x);
|
settings.setValue("rotation_x", eulers.x);
|
||||||
settings->setValue("rotation_y", eulers.y);
|
settings.setValue("rotation_y", eulers.y);
|
||||||
settings->setValue("rotation_z", eulers.z);
|
settings.setValue("rotation_z", eulers.z);
|
||||||
settings->setValue("scale", attachment.scale);
|
settings.setValue("scale", attachment.scale);
|
||||||
|
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AttachmentData MyAvatar::loadAttachmentData(const QUrl& modelURL, const QString& jointName) const {
|
AttachmentData MyAvatar::loadAttachmentData(const QUrl& modelURL, const QString& jointName) const {
|
||||||
QSettings* settings = Application::getInstance()->lockSettings();
|
Settings settings;
|
||||||
settings->beginGroup("savedAttachmentData");
|
settings.beginGroup("savedAttachmentData");
|
||||||
settings->beginGroup(_skeletonModel.getURL().toString());
|
settings.beginGroup(_skeletonModel.getURL().toString());
|
||||||
settings->beginGroup(modelURL.toString());
|
settings.beginGroup(modelURL.toString());
|
||||||
|
|
||||||
AttachmentData attachment;
|
AttachmentData attachment;
|
||||||
attachment.modelURL = modelURL;
|
attachment.modelURL = modelURL;
|
||||||
if (jointName.isEmpty()) {
|
if (jointName.isEmpty()) {
|
||||||
attachment.jointName = settings->value("jointName").toString();
|
attachment.jointName = settings.value("jointName").toString();
|
||||||
} else {
|
} else {
|
||||||
attachment.jointName = jointName;
|
attachment.jointName = jointName;
|
||||||
}
|
}
|
||||||
settings->beginGroup(attachment.jointName);
|
settings.beginGroup(attachment.jointName);
|
||||||
if (settings->contains("translation_x")) {
|
if (settings.contains("translation_x")) {
|
||||||
attachment.translation.x = loadSetting(settings, "translation_x", 0.0f);
|
attachment.translation.x = loadSetting(&settings, "translation_x", 0.0f);
|
||||||
attachment.translation.y = loadSetting(settings, "translation_y", 0.0f);
|
attachment.translation.y = loadSetting(&settings, "translation_y", 0.0f);
|
||||||
attachment.translation.z = loadSetting(settings, "translation_z", 0.0f);
|
attachment.translation.z = loadSetting(&settings, "translation_z", 0.0f);
|
||||||
glm::vec3 eulers;
|
glm::vec3 eulers;
|
||||||
eulers.x = loadSetting(settings, "rotation_x", 0.0f);
|
eulers.x = loadSetting(&settings, "rotation_x", 0.0f);
|
||||||
eulers.y = loadSetting(settings, "rotation_y", 0.0f);
|
eulers.y = loadSetting(&settings, "rotation_y", 0.0f);
|
||||||
eulers.z = loadSetting(settings, "rotation_z", 0.0f);
|
eulers.z = loadSetting(&settings, "rotation_z", 0.0f);
|
||||||
attachment.rotation = glm::quat(eulers);
|
attachment.rotation = glm::quat(eulers);
|
||||||
attachment.scale = loadSetting(settings, "scale", 1.0f);
|
attachment.scale = loadSetting(&settings, "scale", 1.0f);
|
||||||
} else {
|
} else {
|
||||||
attachment = AttachmentData();
|
attachment = AttachmentData();
|
||||||
}
|
}
|
||||||
|
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
settings->endGroup();
|
settings.endGroup();
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
|
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Application.h"
|
#include <Settings.h>
|
||||||
|
|
||||||
#include "SettingsScriptingInterface.h"
|
#include "SettingsScriptingInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,9 +20,7 @@ SettingsScriptingInterface* SettingsScriptingInterface::getInstance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant SettingsScriptingInterface::getValue(const QString& setting) {
|
QVariant SettingsScriptingInterface::getValue(const QString& setting) {
|
||||||
QSettings* settings = Application::getInstance()->lockSettings();
|
QVariant value = Settings().value(setting);
|
||||||
QVariant value = settings->value(setting);
|
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
if (!value.isValid()) {
|
if (!value.isValid()) {
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
|
@ -29,9 +28,7 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVariant& defaultValue) {
|
QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVariant& defaultValue) {
|
||||||
QSettings* settings = Application::getInstance()->lockSettings();
|
QVariant value = Settings().value(setting, defaultValue);
|
||||||
QVariant value = settings->value(setting, defaultValue);
|
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
if (!value.isValid()) {
|
if (!value.isValid()) {
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
|
@ -39,7 +36,5 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVar
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsScriptingInterface::setValue(const QString& setting, const QVariant& value) {
|
void SettingsScriptingInterface::setValue(const QString& setting, const QVariant& value) {
|
||||||
QSettings* settings = Application::getInstance()->lockSettings();
|
Settings().setValue(setting, value);
|
||||||
settings->setValue(setting, value);
|
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
#include <Settings.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "ChatMessageArea.h"
|
#include "ChatMessageArea.h"
|
||||||
|
@ -377,12 +378,11 @@ void ChatWindow::messageReceived(const QXmppMessage& message) {
|
||||||
if (message.body().contains(usernameMention)) {
|
if (message.body().contains(usernameMention)) {
|
||||||
|
|
||||||
// Don't show messages already seen in icon tray at start-up.
|
// Don't show messages already seen in icon tray at start-up.
|
||||||
QSettings* settings = Application::getInstance()->lockSettings();
|
Settings settings;
|
||||||
bool showMessage = settings->value("usernameMentionTimestamp").toDateTime() < _lastMessageStamp;
|
bool showMessage = settings.value("usernameMentionTimestamp").toDateTime() < _lastMessageStamp;
|
||||||
if (showMessage) {
|
if (showMessage) {
|
||||||
settings->setValue("usernameMentionTimestamp", _lastMessageStamp);
|
settings.setValue("usernameMentionTimestamp", _lastMessageStamp);
|
||||||
}
|
}
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
|
|
||||||
if (isHidden() && showMessage) {
|
if (isHidden() && showMessage) {
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QtWebKitWidgets/QWebFrame>
|
#include <QtWebKitWidgets/QWebFrame>
|
||||||
#include <QtWebKit/QWebElement>
|
#include <QtWebKit/QWebElement>
|
||||||
#include <QDesktopWidget>
|
|
||||||
|
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
#include <Settings.h>
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "InfoView.h"
|
#include "InfoView.h"
|
||||||
|
|
||||||
#define SETTINGS_VERSION_KEY "info-version"
|
#define SETTINGS_VERSION_KEY "info-version"
|
||||||
|
@ -49,20 +49,19 @@ bool InfoView::shouldShow() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings* settings = Application::getInstance()->lockSettings();
|
Settings settings;
|
||||||
|
|
||||||
QString lastVersion = settings->value(SETTINGS_VERSION_KEY).toString();
|
QString lastVersion = settings.value(SETTINGS_VERSION_KEY).toString();
|
||||||
|
|
||||||
QWebElement versionTag = page()->mainFrame()->findFirstElement("#version");
|
QWebElement versionTag = page()->mainFrame()->findFirstElement("#version");
|
||||||
QString version = versionTag.attribute("value");
|
QString version = versionTag.attribute("value");
|
||||||
|
|
||||||
if (version != QString::null && (lastVersion == QString::null || lastVersion != version)) {
|
if (version != QString::null && (lastVersion == QString::null || lastVersion != version)) {
|
||||||
settings->setValue(SETTINGS_VERSION_KEY, version);
|
settings.setValue(SETTINGS_VERSION_KEY, version);
|
||||||
shouldShow = true;
|
shouldShow = true;
|
||||||
} else {
|
} else {
|
||||||
shouldShow = false;
|
shouldShow = false;
|
||||||
}
|
}
|
||||||
Application::getInstance()->unlockSettings();
|
|
||||||
return shouldShow;
|
return shouldShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ void InfoView::loaded(bool ok) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDesktopWidget* desktop = Application::getInstance()->desktop();
|
QDesktopWidget* desktop = qApp->desktop();
|
||||||
QWebFrame* mainFrame = page()->mainFrame();
|
QWebFrame* mainFrame = page()->mainFrame();
|
||||||
|
|
||||||
int height = mainFrame->contentsSize().height() > desktop->height() ?
|
int height = mainFrame->contentsSize().height() > desktop->height() ?
|
||||||
|
|
|
@ -270,6 +270,4 @@ void PreferencesDialog::savePreferences() {
|
||||||
audio->setOutputStarveDetectionPeriod(ui.outputStarveDetectionPeriodSpinner->value());
|
audio->setOutputStarveDetectionPeriod(ui.outputStarveDetectionPeriodSpinner->value());
|
||||||
|
|
||||||
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
||||||
|
|
||||||
Application::getInstance()->bumpSettings();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
#include <Settings.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
@ -26,18 +27,14 @@ const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel";
|
||||||
const int ICON_SIZE = 24;
|
const int ICON_SIZE = 24;
|
||||||
const int ICON_PADDING = 5;
|
const int ICON_PADDING = 5;
|
||||||
|
|
||||||
RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* settings) :
|
RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) :
|
||||||
_parent(parent),
|
_parent(parent),
|
||||||
_bounds(bounds),
|
_bounds(bounds),
|
||||||
_windowed(false),
|
_windowed(false),
|
||||||
_fullScreen(false)
|
_fullScreen(false)
|
||||||
{
|
{
|
||||||
_zoomLevel = HEAD;
|
|
||||||
_closeTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/close.svg"));
|
_closeTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/close.svg"));
|
||||||
|
|
||||||
// Disabled for now https://worklist.net/19548
|
|
||||||
// _resetTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/reset.png"));
|
|
||||||
|
|
||||||
_zoomHeadTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/plus.svg"));
|
_zoomHeadTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/plus.svg"));
|
||||||
_zoomBodyTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/minus.svg"));
|
_zoomBodyTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/minus.svg"));
|
||||||
|
|
||||||
|
@ -46,11 +43,7 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* se
|
||||||
_resetIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE);
|
_resetIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE);
|
||||||
_bodyZoomIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE);
|
_bodyZoomIconRect = QRect(_bounds.width() - ICON_SIZE - ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE);
|
||||||
_headZoomIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE);
|
_headZoomIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.bottom() - ICON_PADDING - ICON_SIZE, ICON_SIZE, ICON_SIZE);
|
||||||
|
}
|
||||||
settings->beginGroup(SETTINGS_GROUP_NAME);
|
|
||||||
_zoomLevel = loadSetting(settings, ZOOM_LEVEL_SETTINGS, 0) == HEAD ? HEAD : BODY;
|
|
||||||
settings->endGroup();
|
|
||||||
};
|
|
||||||
|
|
||||||
void RearMirrorTools::render(bool fullScreen) {
|
void RearMirrorTools::render(bool fullScreen) {
|
||||||
if (fullScreen) {
|
if (fullScreen) {
|
||||||
|
@ -63,11 +56,8 @@ void RearMirrorTools::render(bool fullScreen) {
|
||||||
if (_windowed) {
|
if (_windowed) {
|
||||||
displayIcon(_bounds, _closeIconRect, _closeTextureId);
|
displayIcon(_bounds, _closeIconRect, _closeTextureId);
|
||||||
|
|
||||||
// Disabled for now https://worklist.net/19548
|
displayIcon(_bounds, _headZoomIconRect, _zoomHeadTextureId, getZoomLevel() == HEAD);
|
||||||
// displayIcon(_bounds, _resetIconRect, _resetTextureId);
|
displayIcon(_bounds, _bodyZoomIconRect, _zoomBodyTextureId, getZoomLevel() == BODY);
|
||||||
|
|
||||||
displayIcon(_bounds, _headZoomIconRect, _zoomHeadTextureId, _zoomLevel == HEAD);
|
|
||||||
displayIcon(_bounds, _bodyZoomIconRect, _zoomBodyTextureId, _zoomLevel == BODY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,23 +69,14 @@ bool RearMirrorTools::mousePressEvent(int x, int y) {
|
||||||
emit closeView();
|
emit closeView();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disabled for now https://worklist.net/19548
|
|
||||||
if (_resetIconRect.contains(x, y)) {
|
|
||||||
emit resetView();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (_headZoomIconRect.contains(x, y)) {
|
if (_headZoomIconRect.contains(x, y)) {
|
||||||
_zoomLevel = HEAD;
|
setZoomLevel(HEAD);
|
||||||
Application::getInstance()->bumpSettings();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_bodyZoomIconRect.contains(x, y)) {
|
if (_bodyZoomIconRect.contains(x, y)) {
|
||||||
_zoomLevel = BODY;
|
setZoomLevel(BODY);
|
||||||
Application::getInstance()->bumpSettings();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,10 +97,20 @@ bool RearMirrorTools::mousePressEvent(int x, int y) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RearMirrorTools::saveSettings(QSettings* settings) {
|
ZoomLevel RearMirrorTools::getZoomLevel() {
|
||||||
settings->beginGroup(SETTINGS_GROUP_NAME);
|
Settings settings;
|
||||||
settings->setValue(ZOOM_LEVEL_SETTINGS, _zoomLevel);
|
settings.beginGroup(SETTINGS_GROUP_NAME);
|
||||||
settings->endGroup();
|
ZoomLevel zoomLevel = (ZoomLevel)settings.value(ZOOM_LEVEL_SETTINGS, HEAD).toInt();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
return zoomLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RearMirrorTools::setZoomLevel(ZoomLevel zoomLevel) {
|
||||||
|
Settings settings;
|
||||||
|
settings.beginGroup(SETTINGS_GROUP_NAME);
|
||||||
|
settings.setValue(ZOOM_LEVEL_SETTINGS, zoomLevel);
|
||||||
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint textureId, bool selected) {
|
void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint textureId, bool selected) {
|
||||||
|
|
|
@ -25,11 +25,12 @@ enum ZoomLevel {
|
||||||
class RearMirrorTools : public QObject {
|
class RearMirrorTools : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* settings);
|
RearMirrorTools(QGLWidget* parent, QRect& bounds);
|
||||||
void render(bool fullScreen);
|
void render(bool fullScreen);
|
||||||
bool mousePressEvent(int x, int y);
|
bool mousePressEvent(int x, int y);
|
||||||
ZoomLevel getZoomLevel() { return _zoomLevel; }
|
|
||||||
void saveSettings(QSettings* settings);
|
ZoomLevel getZoomLevel();
|
||||||
|
void setZoomLevel(ZoomLevel zoomLevel);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void closeView();
|
void closeView();
|
||||||
|
@ -44,7 +45,6 @@ private:
|
||||||
GLuint _resetTextureId;
|
GLuint _resetTextureId;
|
||||||
GLuint _zoomBodyTextureId;
|
GLuint _zoomBodyTextureId;
|
||||||
GLuint _zoomHeadTextureId;
|
GLuint _zoomHeadTextureId;
|
||||||
ZoomLevel _zoomLevel;
|
|
||||||
|
|
||||||
QRect _closeIconRect;
|
QRect _closeIconRect;
|
||||||
QRect _resetIconRect;
|
QRect _resetIconRect;
|
||||||
|
|
Loading…
Reference in a new issue