mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 15:06:41 +00:00
Move SettingsPage settings related functions to anonymous namespace
This commit is contained in:
parent
c39083ba7e
commit
121b75212f
2 changed files with 44 additions and 47 deletions
|
@ -10,8 +10,52 @@
|
||||||
|
|
||||||
#include <components/config/gamesettings.hpp>
|
#include <components/config/gamesettings.hpp>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
#include "utils/openalutil.hpp"
|
#include "utils/openalutil.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
void loadSettingBool(QCheckBox* checkbox, const std::string& setting, const std::string& group)
|
||||||
|
{
|
||||||
|
if (Settings::Manager::getBool(setting, group))
|
||||||
|
checkbox->setCheckState(Qt::Checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveSettingBool(QCheckBox* checkbox, const std::string& setting, const std::string& group)
|
||||||
|
{
|
||||||
|
const bool cValue = checkbox->checkState();
|
||||||
|
if (cValue != Settings::Manager::getBool(setting, group))
|
||||||
|
Settings::Manager::setBool(setting, group, cValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadSettingInt(QComboBox* comboBox, const std::string& setting, const std::string& group)
|
||||||
|
{
|
||||||
|
const int currentIndex = Settings::Manager::getInt(setting, group);
|
||||||
|
comboBox->setCurrentIndex(currentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveSettingInt(QComboBox* comboBox, const std::string& setting, const std::string& group)
|
||||||
|
{
|
||||||
|
const int currentIndex = comboBox->currentIndex();
|
||||||
|
if (currentIndex != Settings::Manager::getInt(setting, group))
|
||||||
|
Settings::Manager::setInt(setting, group, currentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadSettingInt(QSpinBox* spinBox, const std::string& setting, const std::string& group)
|
||||||
|
{
|
||||||
|
const int value = Settings::Manager::getInt(setting, group);
|
||||||
|
spinBox->setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveSettingInt(QSpinBox* spinBox, const std::string& setting, const std::string& group)
|
||||||
|
{
|
||||||
|
const int value = spinBox->value();
|
||||||
|
if (value != Settings::Manager::getInt(setting, group))
|
||||||
|
Settings::Manager::setInt(setting, group, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Launcher::SettingsPage::SettingsPage(Config::GameSettings& gameSettings, QWidget* parent)
|
Launcher::SettingsPage::SettingsPage(Config::GameSettings& gameSettings, QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, mGameSettings(gameSettings)
|
, mGameSettings(gameSettings)
|
||||||
|
@ -421,45 +465,6 @@ void Launcher::SettingsPage::saveSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::SettingsPage::loadSettingBool(QCheckBox* checkbox, const std::string& setting, const std::string& group)
|
|
||||||
{
|
|
||||||
if (Settings::Manager::getBool(setting, group))
|
|
||||||
checkbox->setCheckState(Qt::Checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::SettingsPage::saveSettingBool(QCheckBox* checkbox, const std::string& setting, const std::string& group)
|
|
||||||
{
|
|
||||||
bool cValue = checkbox->checkState();
|
|
||||||
if (cValue != Settings::Manager::getBool(setting, group))
|
|
||||||
Settings::Manager::setBool(setting, group, cValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::SettingsPage::loadSettingInt(QComboBox* comboBox, const std::string& setting, const std::string& group)
|
|
||||||
{
|
|
||||||
int currentIndex = Settings::Manager::getInt(setting, group);
|
|
||||||
comboBox->setCurrentIndex(currentIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::SettingsPage::saveSettingInt(QComboBox* comboBox, const std::string& setting, const std::string& group)
|
|
||||||
{
|
|
||||||
int currentIndex = comboBox->currentIndex();
|
|
||||||
if (currentIndex != Settings::Manager::getInt(setting, group))
|
|
||||||
Settings::Manager::setInt(setting, group, currentIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::SettingsPage::loadSettingInt(QSpinBox* spinBox, const std::string& setting, const std::string& group)
|
|
||||||
{
|
|
||||||
int value = Settings::Manager::getInt(setting, group);
|
|
||||||
spinBox->setValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::SettingsPage::saveSettingInt(QSpinBox* spinBox, const std::string& setting, const std::string& group)
|
|
||||||
{
|
|
||||||
int value = spinBox->value();
|
|
||||||
if (value != Settings::Manager::getInt(setting, group))
|
|
||||||
Settings::Manager::setInt(setting, group, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launcher::SettingsPage::slotLoadedCellsChanged(QStringList cellNames)
|
void Launcher::SettingsPage::slotLoadedCellsChanged(QStringList cellNames)
|
||||||
{
|
{
|
||||||
loadCellsForAutocomplete(cellNames);
|
loadCellsForAutocomplete(cellNames);
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
#include "ui_settingspage.h"
|
#include "ui_settingspage.h"
|
||||||
|
|
||||||
#include <components/settings/settings.hpp>
|
|
||||||
|
|
||||||
namespace Config
|
namespace Config
|
||||||
{
|
{
|
||||||
class GameSettings;
|
class GameSettings;
|
||||||
|
@ -45,12 +43,6 @@ namespace Launcher
|
||||||
* @param filePaths the file paths of the content files to be examined
|
* @param filePaths the file paths of the content files to be examined
|
||||||
*/
|
*/
|
||||||
void loadCellsForAutocomplete(QStringList filePaths);
|
void loadCellsForAutocomplete(QStringList filePaths);
|
||||||
static void loadSettingBool(QCheckBox* checkbox, const std::string& setting, const std::string& group);
|
|
||||||
static void saveSettingBool(QCheckBox* checkbox, const std::string& setting, const std::string& group);
|
|
||||||
static void loadSettingInt(QComboBox* comboBox, const std::string& setting, const std::string& group);
|
|
||||||
static void saveSettingInt(QComboBox* comboBox, const std::string& setting, const std::string& group);
|
|
||||||
static void loadSettingInt(QSpinBox* spinBox, const std::string& setting, const std::string& group);
|
|
||||||
static void saveSettingInt(QSpinBox* spinBox, const std::string& setting, const std::string& group);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue