mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-15 17:46:47 +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;
|
||||
domainServerSettings.beginGroup(DS_SETTINGS_SESSIONS_GROUP);
|
||||
|
||||
foreach(const QString& uuidKey, domainServerSettings.childKeys()) {
|
||||
_cookieSessionHash.insert(QUuid(uuidKey), domainServerSettings.value(uuidKey).value<DomainServerWebSessionData>());
|
||||
foreach(const QString& uuidKey, domainServerSettings.childKeys())
|
||||
_cookieSessionHash.insert(QUuid(uuidKey),
|
||||
domainServerSettings.value(uuidKey).value<DomainServerWebSessionData>());
|
||||
qDebug() << "Pulled web session from settings - cookie UUID is" << uuidKey;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -469,7 +469,6 @@ Application::~Application() {
|
|||
_entities.getTree()->setSimulation(NULL);
|
||||
qInstallMessageHandler(NULL);
|
||||
|
||||
saveSettings();
|
||||
_window->saveGeometry();
|
||||
|
||||
int DELAY_TIME = 1000;
|
||||
|
@ -507,10 +506,6 @@ Application::~Application() {
|
|||
DependencyManager::destroy<GLCanvas>();
|
||||
}
|
||||
|
||||
void Application::saveSettings() {
|
||||
Menu::getInstance()->saveSettings();
|
||||
}
|
||||
|
||||
void Application::initializeGL() {
|
||||
qDebug( "Created Display Window.");
|
||||
|
||||
|
@ -1635,8 +1630,6 @@ void Application::init() {
|
|||
|
||||
_timerStart.start();
|
||||
_lastTimeUpdated.start();
|
||||
|
||||
Menu::getInstance()->loadSettings();
|
||||
|
||||
// when --url in command line, teleport to location
|
||||
const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
|
||||
|
@ -3657,11 +3650,6 @@ void Application::openUrl(const QUrl& url) {
|
|||
}
|
||||
|
||||
void Application::updateMyAvatarTransform() {
|
||||
<<<<<<< HEAD
|
||||
#ifdef USE_BULLET_PHYSICS
|
||||
=======
|
||||
bumpSettings();
|
||||
>>>>>>> 215e3b732e8aa1f36a6bef9534c77a7bcecacc04
|
||||
const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters
|
||||
glm::vec3 avatarPosition = _myAvatar->getPosition();
|
||||
glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset();
|
||||
|
|
|
@ -219,8 +219,6 @@ public:
|
|||
virtual const Transform& getViewTransform() const { return _viewTransform; }
|
||||
void setViewTransform(const Transform& view);
|
||||
|
||||
void saveSettings();
|
||||
|
||||
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
||||
void lockOctreeSceneStats() { _octreeSceneStatsLock.lockForRead(); }
|
||||
void unlockOctreeSceneStats() { _octreeSceneStatsLock.unlock(); }
|
||||
|
|
|
@ -41,7 +41,6 @@ class LODManager : public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
// TODO: replace bumpSettings()
|
||||
void setAutomaticAvatarLOD(bool automaticAvatarLOD) { _automaticAvatarLOD = automaticAvatarLOD; }
|
||||
bool getAutomaticAvatarLOD() const { return _automaticAvatarLOD; }
|
||||
void setAvatarLODDecreaseFPS(float avatarLODDecreaseFPS) { _avatarLODDecreaseFPS = avatarLODDecreaseFPS; }
|
||||
|
|
|
@ -113,9 +113,6 @@ Menu::Menu() {
|
|||
qApp, SLOT(uploadAttachment()));
|
||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadEntity, 0,
|
||||
qApp, SLOT(uploadEntity()));
|
||||
addDisabledActionAndSeparator(fileMenu, "Settings");
|
||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsImport, 0, this, SLOT(importSettings()));
|
||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsExport, 0, this, SLOT(exportSettings()));
|
||||
|
||||
addActionToQMenuAndActionHash(fileMenu,
|
||||
MenuOption::Quit,
|
||||
|
@ -558,106 +555,33 @@ Menu::Menu() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void Menu::loadSettings(QSettings* settings) {
|
||||
Settings defaultSettings;
|
||||
if (!settings) {
|
||||
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::loadAction(QSettings& settings, QAction& action) {
|
||||
if (action.isChecked() != settings.value(action.text(), action.isChecked()).toBool()) {
|
||||
action.trigger();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::exportSettings() {
|
||||
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
|
||||
QString fileName = QFileDialog::getSaveFileName(qApp->getWindow(),
|
||||
tr("Save .ini config file"),
|
||||
locationDir,
|
||||
tr("Text files (*.ini)"));
|
||||
if (fileName != "") {
|
||||
QSettings tmp(fileName, QSettings::IniFormat);
|
||||
saveSettings(&tmp);
|
||||
tmp.sync();
|
||||
void Menu::saveAction(QSettings& settings, QAction& action) {
|
||||
settings.setValue(action.text(), action.isChecked());
|
||||
}
|
||||
|
||||
void Menu::scanMenuBar(settingsAction modifySetting) {
|
||||
Settings settings;
|
||||
foreach (QMenu* menu, findChildren<QMenu*>()) {
|
||||
scanMenu(*menu, modifySetting, settings);
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::loadAction(QSettings* set, QAction* action) {
|
||||
if (action->isChecked() != set->value(action->text(), action->isChecked()).toBool()) {
|
||||
action->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::saveAction(QSettings* set, QAction* 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);
|
||||
void Menu::scanMenu(QMenu& menu, settingsAction modifySetting, QSettings& settings) {
|
||||
settings.beginGroup(menu.title());
|
||||
foreach (QAction* action, menu.actions()) {
|
||||
if (action->menu()) {
|
||||
scanMenu(*action->menu(), modifySetting, settings);
|
||||
} else (action->isCheckable()) {
|
||||
modifySetting(settings, *action);
|
||||
}
|
||||
}
|
||||
set->endGroup();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName, int menuItemLocation) {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <MenuItemProperties.h>
|
||||
|
||||
class QSettings;
|
||||
class Settings;
|
||||
|
||||
class Menu : public QMenuBar {
|
||||
Q_OBJECT
|
||||
|
@ -49,11 +49,6 @@ public:
|
|||
void removeAction(QMenu* menu, const QString& actionName);
|
||||
|
||||
public slots:
|
||||
void loadSettings(QSettings* settings = NULL);
|
||||
void saveSettings(QSettings* settings = NULL);
|
||||
void importSettings();
|
||||
void exportSettings();
|
||||
|
||||
QMenu* addMenu(const QString& menuName);
|
||||
void removeMenu(const QString& menuName);
|
||||
bool menuExists(const QString& menuName);
|
||||
|
@ -69,11 +64,11 @@ private:
|
|||
static Menu* _instance;
|
||||
Menu();
|
||||
|
||||
typedef void(*settingsAction)(QSettings*, QAction*);
|
||||
static void loadAction(QSettings* set, QAction* action);
|
||||
static void saveAction(QSettings* set, QAction* action);
|
||||
void scanMenuBar(settingsAction modifySetting, QSettings* set);
|
||||
void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set);
|
||||
typedef void(*settingsAction)(Settings&, QAction&);
|
||||
static void loadAction(Settings& settings, QAction& action);
|
||||
static void saveAction(Settings& settings, QAction& action);
|
||||
void scanMenuBar(settingsAction modifySetting);
|
||||
void scanMenu(QMenu& menu, settingsAction modifySetting, Settings& settings);
|
||||
|
||||
/// helper method to have separators with labels that are also compatible with OS X
|
||||
void addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& actionName,
|
||||
|
|
Loading…
Reference in a new issue