summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-07-08 23:29:49 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-07-08 23:29:49 +0200
commitfa1801471c2708ed8266ec7b99bd4cec886ccc1b (patch)
treeaa56218c2c7e4939aaf11a2046b0f12760326545 /gui
parent90940a774eab876c38d5cef981b4be5bae67a462 (diff)
options: fix 2 issues
1. Calling valueChanged didn't invoke machinery in value<t>, only base_value aka value_. There's a fast path in value<t>::type() despite the pessimization. 2. Split global scope stuff into options::globals from the options::globals stuff 3. Adjust usages
Diffstat (limited to 'gui')
-rw-r--r--gui/init.cpp2
-rw-r--r--gui/process_detector.cpp13
-rw-r--r--gui/settings.cpp9
3 files changed, 13 insertions, 11 deletions
diff --git a/gui/init.cpp b/gui/init.cpp
index 0e9d746a..1a4666b5 100644
--- a/gui/init.cpp
+++ b/gui/init.cpp
@@ -213,7 +213,7 @@ OTR_GUI_EXPORT int otr_main(int argc, char** argv, std::function<QWidget*()> con
qDebug() << "locale:" << forced_locale;
}
- const bool no_i18n = group::with_global_settings_object([](QSettings& s) {
+ const bool no_i18n = options::globals::with_global_settings_object([](QSettings& s) {
return s.value("disable-translation", false).toBool();
});
diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp
index 969b1856..0ff05f93 100644
--- a/gui/process_detector.cpp
+++ b/gui/process_detector.cpp
@@ -24,31 +24,32 @@ static constexpr inline auto RECORD_SEPARATOR = QChar(char(0x1e)); // RS ^]
static constexpr inline auto UNIT_SEPARATOR = QChar(char(0x1f)); // US ^_
using namespace options;
+using namespace options::globals;
void proc_detector_settings::set_game_list(const QString &game_list)
{
- group::with_global_settings_object([&](QSettings& settings) {
+ with_global_settings_object([&](QSettings& settings) {
settings.setValue("executable-list", game_list);
});
}
QString proc_detector_settings::get_game_list()
{
- return group::with_global_settings_object([&](QSettings& settings) {
+ return with_global_settings_object([&](QSettings& settings) {
return settings.value("executable-list").toString();
});
}
bool proc_detector_settings::is_enabled()
{
- return group::with_global_settings_object([&](QSettings& settings) {
+ return with_global_settings_object([&](QSettings& settings) {
return settings.value("executable-detector-enabled", false).toBool();
});
}
void proc_detector_settings::set_is_enabled(bool enabled)
{
- group::with_global_settings_object([&](QSettings& settings) {
+ with_global_settings_object([&](QSettings& settings) {
settings.setValue("executable-detector-enabled", enabled);
});
}
@@ -76,7 +77,7 @@ QHash<QString, QString> proc_detector_settings::split_process_names()
void BrowseButton::browse()
{
- QString dir_path = QFileInfo(group::ini_pathname()).absolutePath();
+ QString dir_path = QFileInfo(ini_pathname()).absolutePath();
QString filename = QFileDialog::getOpenFileName(
this,
tr("Set executable name"),
@@ -96,7 +97,7 @@ int process_detector::add_row(QString const& exe_name, QString const& profile)
QComboBox* cb = new QComboBox();
cb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
cb->addItem("");
- cb->addItems(group::ini_list());
+ cb->addItems(ini_list());
ui.tableWidget->setCellWidget(i, 1, cb);
QTableWidgetItem* twi = new QTableWidgetItem(exe_name);
diff --git a/gui/settings.cpp b/gui/settings.cpp
index 31bbd87b..5ee59260 100644
--- a/gui/settings.cpp
+++ b/gui/settings.cpp
@@ -18,10 +18,11 @@
#include <QFileDialog>
using namespace options;
+using namespace options::globals;
QString options_dialog::kopts_to_string(const key_opts& kopts)
{
- if (static_cast<QString>(kopts.guid) != "")
+ if (!kopts.guid->isEmpty())
{
const int btn = kopts.button & ~Qt::KeyboardModifierMask;
const int mods = kopts.button & Qt::KeyboardModifierMask;
@@ -31,14 +32,14 @@ QString options_dialog::kopts_to_string(const key_opts& kopts)
if (mods & Qt::ShiftModifier) mm += "Shift+";
return mm + tr("Joy button %1").arg(QString::number(btn));
}
- if (static_cast<QString>(kopts.keycode) == "")
+ if (kopts.keycode->isEmpty())
return tr("None");
return kopts.keycode;
}
void options_dialog::set_disable_translation_state(bool value)
{
- group::with_global_settings_object([&](QSettings& s)
+ with_global_settings_object([&](QSettings& s)
{
s.setValue("disable-translation", value);
});
@@ -105,7 +106,7 @@ options_dialog::options_dialog(std::function<void(bool)>&& pause_keybindings) :
tie_setting(main.neck_enable, ui.neck_enable);
- const bool is_translation_disabled = group::with_global_settings_object([] (QSettings& s) {
+ const bool is_translation_disabled = with_global_settings_object([] (QSettings& s) {
return s.value("disable-translation", false).toBool();
});
ui.disable_translation->setChecked(is_translation_disabled);