mirror of
https://github.com/overte-org/overte.git
synced 2025-07-22 18:13:35 +02:00
Remove load/saveSettings from Menu/Application
Tweaked scanMenuBar too
This commit is contained in:
parent
43597ea29d
commit
c1e195d17b
6 changed files with 28 additions and 123 deletions
|
@ -1947,8 +1947,9 @@ void DomainServer::loadExistingSessionsFromSettings() {
|
||||||
Settings domainServerSettings;
|
Settings domainServerSettings;
|
||||||
domainServerSettings.beginGroup(DS_SETTINGS_SESSIONS_GROUP);
|
domainServerSettings.beginGroup(DS_SETTINGS_SESSIONS_GROUP);
|
||||||
|
|
||||||
foreach(const QString& uuidKey, domainServerSettings.childKeys()) {
|
foreach(const QString& uuidKey, domainServerSettings.childKeys())
|
||||||
_cookieSessionHash.insert(QUuid(uuidKey), domainServerSettings.value(uuidKey).value<DomainServerWebSessionData>());
|
_cookieSessionHash.insert(QUuid(uuidKey),
|
||||||
|
domainServerSettings.value(uuidKey).value<DomainServerWebSessionData>());
|
||||||
qDebug() << "Pulled web session from settings - cookie UUID is" << uuidKey;
|
qDebug() << "Pulled web session from settings - cookie UUID is" << uuidKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -469,7 +469,6 @@ Application::~Application() {
|
||||||
_entities.getTree()->setSimulation(NULL);
|
_entities.getTree()->setSimulation(NULL);
|
||||||
qInstallMessageHandler(NULL);
|
qInstallMessageHandler(NULL);
|
||||||
|
|
||||||
saveSettings();
|
|
||||||
_window->saveGeometry();
|
_window->saveGeometry();
|
||||||
|
|
||||||
int DELAY_TIME = 1000;
|
int DELAY_TIME = 1000;
|
||||||
|
@ -507,10 +506,6 @@ Application::~Application() {
|
||||||
DependencyManager::destroy<GLCanvas>();
|
DependencyManager::destroy<GLCanvas>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::saveSettings() {
|
|
||||||
Menu::getInstance()->saveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::initializeGL() {
|
void Application::initializeGL() {
|
||||||
qDebug( "Created Display Window.");
|
qDebug( "Created Display Window.");
|
||||||
|
|
||||||
|
@ -1635,8 +1630,6 @@ void Application::init() {
|
||||||
|
|
||||||
_timerStart.start();
|
_timerStart.start();
|
||||||
_lastTimeUpdated.start();
|
_lastTimeUpdated.start();
|
||||||
|
|
||||||
Menu::getInstance()->loadSettings();
|
|
||||||
|
|
||||||
// when --url in command line, teleport to location
|
// when --url in command line, teleport to location
|
||||||
const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
|
const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
|
||||||
|
@ -3657,11 +3650,6 @@ void Application::openUrl(const QUrl& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateMyAvatarTransform() {
|
void Application::updateMyAvatarTransform() {
|
||||||
<<<<<<< HEAD
|
|
||||||
#ifdef USE_BULLET_PHYSICS
|
|
||||||
=======
|
|
||||||
bumpSettings();
|
|
||||||
>>>>>>> 215e3b732e8aa1f36a6bef9534c77a7bcecacc04
|
|
||||||
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();
|
||||||
glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset();
|
glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset();
|
||||||
|
|
|
@ -219,8 +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);
|
||||||
|
|
||||||
void saveSettings();
|
|
||||||
|
|
||||||
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
||||||
void lockOctreeSceneStats() { _octreeSceneStatsLock.lockForRead(); }
|
void lockOctreeSceneStats() { _octreeSceneStatsLock.lockForRead(); }
|
||||||
void unlockOctreeSceneStats() { _octreeSceneStatsLock.unlock(); }
|
void unlockOctreeSceneStats() { _octreeSceneStatsLock.unlock(); }
|
||||||
|
|
|
@ -41,7 +41,6 @@ class LODManager : public Dependency {
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// TODO: replace bumpSettings()
|
|
||||||
void setAutomaticAvatarLOD(bool automaticAvatarLOD) { _automaticAvatarLOD = automaticAvatarLOD; }
|
void setAutomaticAvatarLOD(bool automaticAvatarLOD) { _automaticAvatarLOD = automaticAvatarLOD; }
|
||||||
bool getAutomaticAvatarLOD() const { return _automaticAvatarLOD; }
|
bool getAutomaticAvatarLOD() const { return _automaticAvatarLOD; }
|
||||||
void setAvatarLODDecreaseFPS(float avatarLODDecreaseFPS) { _avatarLODDecreaseFPS = avatarLODDecreaseFPS; }
|
void setAvatarLODDecreaseFPS(float avatarLODDecreaseFPS) { _avatarLODDecreaseFPS = avatarLODDecreaseFPS; }
|
||||||
|
|
|
@ -113,9 +113,6 @@ Menu::Menu() {
|
||||||
qApp, SLOT(uploadAttachment()));
|
qApp, SLOT(uploadAttachment()));
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadEntity, 0,
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadEntity, 0,
|
||||||
qApp, SLOT(uploadEntity()));
|
qApp, SLOT(uploadEntity()));
|
||||||
addDisabledActionAndSeparator(fileMenu, "Settings");
|
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsImport, 0, this, SLOT(importSettings()));
|
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsExport, 0, this, SLOT(exportSettings()));
|
|
||||||
|
|
||||||
addActionToQMenuAndActionHash(fileMenu,
|
addActionToQMenuAndActionHash(fileMenu,
|
||||||
MenuOption::Quit,
|
MenuOption::Quit,
|
||||||
|
@ -558,106 +555,33 @@ Menu::Menu() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::loadSettings(QSettings* settings) {
|
void Menu::loadAction(QSettings& settings, QAction& action) {
|
||||||
Settings defaultSettings;
|
if (action.isChecked() != settings.value(action.text(), action.isChecked()).toBool()) {
|
||||||
if (!settings) {
|
action.trigger();
|
||||||
settings = &defaultSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto audio = DependencyManager::get<Audio>();
|
|
||||||
audio->setOutputStarveDetectionEnabled(settings->value("audioOutputStarveDetectionEnabled", DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED).toBool());
|
|
||||||
audio->setOutputStarveDetectionThreshold(settings->value("audioOutputStarveDetectionThreshold", DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD).toInt());
|
|
||||||
audio->setOutputStarveDetectionPeriod(settings->value("audioOutputStarveDetectionPeriod", DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD).toInt());
|
|
||||||
int bufferSize = settings->value("audioOutputBufferSize", DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES).toInt();
|
|
||||||
QMetaObject::invokeMethod(audio.data(), "setOutputBufferSize", Q_ARG(int, bufferSize));
|
|
||||||
|
|
||||||
scanMenuBar(&loadAction, settings);
|
|
||||||
qApp->getAvatar()->loadData(settings);
|
|
||||||
qApp->updateWindowTitle();
|
|
||||||
|
|
||||||
// MyAvatar caches some menu options, so we have to update them whenever we load settings.
|
|
||||||
// TODO: cache more settings in MyAvatar that are checked with very high frequency.
|
|
||||||
setIsOptionChecked(MenuOption::KeyboardMotorControl , true);
|
|
||||||
MyAvatar* myAvatar = qApp->getAvatar();
|
|
||||||
myAvatar->updateCollisionGroups();
|
|
||||||
myAvatar->onToggleRagdoll();
|
|
||||||
myAvatar->updateMotionBehavior();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::saveSettings(QSettings* settings) {
|
|
||||||
Settings defaultSettings;
|
|
||||||
if (!settings) {
|
|
||||||
settings = &defaultSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto audio = DependencyManager::get<Audio>();
|
|
||||||
settings->setValue("audioOutputStarveDetectionEnabled", audio->getOutputStarveDetectionEnabled());
|
|
||||||
settings->setValue("audioOutputStarveDetectionThreshold", audio->getOutputStarveDetectionThreshold());
|
|
||||||
settings->setValue("audioOutputStarveDetectionPeriod", audio->getOutputStarveDetectionPeriod());
|
|
||||||
settings->setValue("audioOutputBufferSize", audio->getOutputBufferSize());
|
|
||||||
|
|
||||||
scanMenuBar(&saveAction, settings);
|
|
||||||
qApp->getAvatar()->saveData(settings);
|
|
||||||
|
|
||||||
DependencyManager::get<AddressManager>()->storeCurrentAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::importSettings() {
|
|
||||||
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(qApp->getWindow(),
|
|
||||||
tr("Open .ini config file"),
|
|
||||||
locationDir,
|
|
||||||
tr("Text files (*.ini)"));
|
|
||||||
if (fileName != "") {
|
|
||||||
QSettings tmp(fileName, QSettings::IniFormat);
|
|
||||||
loadSettings(&tmp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::exportSettings() {
|
void Menu::saveAction(QSettings& settings, QAction& action) {
|
||||||
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
|
settings.setValue(action.text(), action.isChecked());
|
||||||
QString fileName = QFileDialog::getSaveFileName(qApp->getWindow(),
|
}
|
||||||
tr("Save .ini config file"),
|
|
||||||
locationDir,
|
void Menu::scanMenuBar(settingsAction modifySetting) {
|
||||||
tr("Text files (*.ini)"));
|
Settings settings;
|
||||||
if (fileName != "") {
|
foreach (QMenu* menu, findChildren<QMenu*>()) {
|
||||||
QSettings tmp(fileName, QSettings::IniFormat);
|
scanMenu(*menu, modifySetting, settings);
|
||||||
saveSettings(&tmp);
|
|
||||||
tmp.sync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::loadAction(QSettings* set, QAction* action) {
|
void Menu::scanMenu(QMenu& menu, settingsAction modifySetting, QSettings& settings) {
|
||||||
if (action->isChecked() != set->value(action->text(), action->isChecked()).toBool()) {
|
settings.beginGroup(menu.title());
|
||||||
action->trigger();
|
foreach (QAction* action, menu.actions()) {
|
||||||
}
|
if (action->menu()) {
|
||||||
}
|
scanMenu(*action->menu(), modifySetting, settings);
|
||||||
|
} else (action->isCheckable()) {
|
||||||
void Menu::saveAction(QSettings* set, QAction* action) {
|
modifySetting(settings, *action);
|
||||||
set->setValue(action->text(), action->isChecked());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::scanMenuBar(settingsAction modifySetting, QSettings* set) {
|
|
||||||
QList<QMenu*> menus = this->findChildren<QMenu *>();
|
|
||||||
|
|
||||||
for (QList<QMenu *>::const_iterator it = menus.begin(); menus.end() != it; ++it) {
|
|
||||||
scanMenu(*it, modifySetting, set);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set) {
|
|
||||||
QList<QAction*> actions = menu->actions();
|
|
||||||
|
|
||||||
set->beginGroup(menu->title());
|
|
||||||
for (QList<QAction *>::const_iterator it = actions.begin(); actions.end() != it; ++it) {
|
|
||||||
if ((*it)->menu()) {
|
|
||||||
scanMenu((*it)->menu(), modifySetting, set);
|
|
||||||
}
|
|
||||||
if ((*it)->isCheckable()) {
|
|
||||||
modifySetting(set, *it);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set->endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName, int menuItemLocation) {
|
void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName, int menuItemLocation) {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <MenuItemProperties.h>
|
#include <MenuItemProperties.h>
|
||||||
|
|
||||||
class QSettings;
|
class Settings;
|
||||||
|
|
||||||
class Menu : public QMenuBar {
|
class Menu : public QMenuBar {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -49,11 +49,6 @@ public:
|
||||||
void removeAction(QMenu* menu, const QString& actionName);
|
void removeAction(QMenu* menu, const QString& actionName);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadSettings(QSettings* settings = NULL);
|
|
||||||
void saveSettings(QSettings* settings = NULL);
|
|
||||||
void importSettings();
|
|
||||||
void exportSettings();
|
|
||||||
|
|
||||||
QMenu* addMenu(const QString& menuName);
|
QMenu* addMenu(const QString& menuName);
|
||||||
void removeMenu(const QString& menuName);
|
void removeMenu(const QString& menuName);
|
||||||
bool menuExists(const QString& menuName);
|
bool menuExists(const QString& menuName);
|
||||||
|
@ -69,11 +64,11 @@ private:
|
||||||
static Menu* _instance;
|
static Menu* _instance;
|
||||||
Menu();
|
Menu();
|
||||||
|
|
||||||
typedef void(*settingsAction)(QSettings*, QAction*);
|
typedef void(*settingsAction)(Settings&, QAction&);
|
||||||
static void loadAction(QSettings* set, QAction* action);
|
static void loadAction(Settings& settings, QAction& action);
|
||||||
static void saveAction(QSettings* set, QAction* action);
|
static void saveAction(Settings& settings, QAction& action);
|
||||||
void scanMenuBar(settingsAction modifySetting, QSettings* set);
|
void scanMenuBar(settingsAction modifySetting);
|
||||||
void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set);
|
void scanMenu(QMenu& menu, settingsAction modifySetting, Settings& settings);
|
||||||
|
|
||||||
/// helper method to have separators with labels that are also compatible with OS X
|
/// helper method to have separators with labels that are also compatible with OS X
|
||||||
void addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName,
|
void addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName,
|
||||||
|
|
Loading…
Reference in a new issue