mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 17:35:45 +02:00
Fixes asked by ZappoMan on QSettings' commit.
This commit is contained in:
parent
dccc44a6f5
commit
c199190666
4 changed files with 37 additions and 39 deletions
|
@ -33,6 +33,7 @@
|
|||
#include <QTimer>
|
||||
#include <QtDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QDesktopServices>
|
||||
#include <PairingHandler.h>
|
||||
|
||||
#include <AgentTypes.h>
|
||||
|
@ -2201,38 +2202,38 @@ void* Application::networkReceive(void* args) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void Application::scanMenuBar(settingsAction f, QSettings *set) {
|
||||
if (NULL == _window->menuBar()) {
|
||||
void Application::scanMenuBar(settingsAction modifySetting, QSettings* set) {
|
||||
if (!_window->menuBar()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QMenu *> menus = _window->menuBar()->findChildren<QMenu *>();
|
||||
QList<QMenu*> menus = _window->menuBar()->findChildren<QMenu *>();
|
||||
|
||||
for (QList<QMenu *>::const_iterator it = menus.begin(); menus.end() != it; ++it) {
|
||||
scanMenu(*it, f, set);
|
||||
scanMenu(*it, modifySetting, set);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::scanMenu(QMenu *menu, settingsAction f, QSettings *set) {
|
||||
QList<QAction *> actions = menu->actions();
|
||||
void Application::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(), f, set);
|
||||
scanMenu((*it)->menu(), modifySetting, set);
|
||||
}
|
||||
if ((*it)->isCheckable()) {
|
||||
f(set, *it);
|
||||
modifySetting(set, *it);
|
||||
}
|
||||
}
|
||||
set->endGroup();
|
||||
}
|
||||
|
||||
void Application::loadAction(QSettings *set, QAction *action) {
|
||||
void Application::loadAction(QSettings* set, QAction* action) {
|
||||
action->setChecked(set->value(action->text(), action->isChecked()).toBool());
|
||||
}
|
||||
}
|
||||
|
||||
void Application::saveAction(QSettings *set, QAction *action) {
|
||||
void Application::saveAction(QSettings* set, QAction* action) {
|
||||
set->setValue(action->text(), action->isChecked());
|
||||
}
|
||||
|
||||
|
@ -2240,44 +2241,41 @@ void Application::setAutosave(bool wantsAutosave) {
|
|||
_autosave = wantsAutosave;
|
||||
}
|
||||
|
||||
void Application::loadSettings(QSettings *set) {
|
||||
if (!set) set = this->getSettings();
|
||||
void Application::loadSettings(QSettings* set) {
|
||||
if (!set) set = getSettings();
|
||||
|
||||
scanMenuBar(&Application::loadAction, set);
|
||||
getAvatar()->getData(set);
|
||||
getAvatar()->loadData(set);
|
||||
}
|
||||
|
||||
void Application::saveSettings(QSettings *set) {
|
||||
if (!set) set = this->getSettings();
|
||||
void Application::saveSettings(QSettings* set) {
|
||||
if (!set) set = getSettings();
|
||||
|
||||
scanMenuBar(&Application::saveAction, set);
|
||||
getAvatar()->setData(set);
|
||||
getAvatar()->saveData(set);
|
||||
}
|
||||
|
||||
void Application::importSettings() {
|
||||
QString fileName = QFileDialog::getOpenFileName(this->_window,
|
||||
QString locationDir(QDesktopServices::displayName(QDesktopServices::DesktopLocation));
|
||||
QString fileName = QFileDialog::getOpenFileName(_window,
|
||||
tr("Open .ini config file"),
|
||||
"",
|
||||
locationDir,
|
||||
tr("Text files (*.ini)"));
|
||||
|
||||
if (fileName != "") {
|
||||
QSettings tmp(fileName, QSettings::IniFormat);
|
||||
|
||||
loadSettings(&tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::exportSettings() {
|
||||
QString fileName = QFileDialog::getSaveFileName(this->_window,
|
||||
QString locationDir(QDesktopServices::displayName(QDesktopServices::DesktopLocation));
|
||||
QString fileName = QFileDialog::getSaveFileName(_window,
|
||||
tr("Save .ini config file"),
|
||||
"",
|
||||
locationDir,
|
||||
tr("Text files (*.ini)"));
|
||||
|
||||
if (fileName != "") {
|
||||
QSettings tmp(fileName, QSettings::IniFormat);
|
||||
|
||||
saveSettings(&tmp);
|
||||
|
||||
tmp.sync();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,8 @@ private slots:
|
|||
void chooseVoxelPaintColor();
|
||||
|
||||
void setAutosave(bool wantsAutosave);
|
||||
void loadSettings(QSettings *set = NULL);
|
||||
void saveSettings(QSettings *set = NULL);
|
||||
void loadSettings(QSettings* set = NULL);
|
||||
void saveSettings(QSettings* set = NULL);
|
||||
void importSettings();
|
||||
void exportSettings();
|
||||
|
||||
|
@ -148,11 +148,11 @@ private:
|
|||
static void* networkReceive(void* args);
|
||||
|
||||
// methodes handling menu settings
|
||||
typedef void(*settingsAction)(QSettings *, QAction *);
|
||||
static void loadAction(QSettings *set, QAction *action);
|
||||
static void saveAction(QSettings *set, QAction *action);
|
||||
void scanMenuBar(settingsAction, QSettings *set);
|
||||
void scanMenu(QMenu *menu, settingsAction f, QSettings *set);
|
||||
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);
|
||||
|
||||
QMainWindow* _window;
|
||||
QGLWidget* _glWidget;
|
||||
|
|
|
@ -1114,10 +1114,10 @@ void Avatar::setHeadFromGyros(glm::vec3* eulerAngles, glm::vec3* angularVelocity
|
|||
}
|
||||
}
|
||||
|
||||
void Avatar::getData(QSettings *set) {
|
||||
void Avatar::loadData(QSettings* set) {
|
||||
set->beginGroup("Avatar");
|
||||
|
||||
_bodyYaw = set->value("bodyYawn", _bodyYaw).toFloat();
|
||||
_bodyYaw = set->value("bodyYaw", _bodyYaw).toFloat();
|
||||
_bodyPitch = set->value("bodyPitch", _bodyPitch).toFloat();
|
||||
_bodyRoll = set->value("bodyRoll", _bodyRoll).toFloat();
|
||||
|
||||
|
@ -1128,10 +1128,10 @@ void Avatar::getData(QSettings *set) {
|
|||
set->endGroup();
|
||||
}
|
||||
|
||||
void Avatar::setData(QSettings *set) {
|
||||
void Avatar::saveData(QSettings* set) {
|
||||
set->beginGroup("Avatar");
|
||||
|
||||
set->setValue("bodyYawn", _bodyYaw);
|
||||
set->setValue("bodyYaw", _bodyYaw);
|
||||
set->setValue("bodyPitch", _bodyPitch);
|
||||
set->setValue("bodyRoll", _bodyRoll);
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ public:
|
|||
glm::vec3 getThrust() { return _thrust; };
|
||||
|
||||
// get/set avatar data
|
||||
void setData(QSettings *set);
|
||||
void getData(QSettings *set);
|
||||
void saveData(QSettings* set);
|
||||
void loadData(QSettings* set);
|
||||
|
||||
private:
|
||||
// privatize copy constructor and assignment operator to avoid copying
|
||||
|
|
Loading…
Reference in a new issue