configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit. Co-Authored-By: LC <lioncash@users.noreply.github.com>
This commit is contained in:
@@ -387,43 +387,31 @@ extern bool configuring_global;
|
||||
template <typename Type>
|
||||
class Setting final {
|
||||
public:
|
||||
Setting() {
|
||||
use_global = true;
|
||||
}
|
||||
Setting(Type val) {
|
||||
use_global = true;
|
||||
global = val;
|
||||
}
|
||||
Setting() = default;
|
||||
explicit Setting(Type val) : global{val} {}
|
||||
~Setting() = default;
|
||||
void SetGlobal(bool to_global) {
|
||||
use_global = to_global;
|
||||
};
|
||||
}
|
||||
bool UsingGlobal() const {
|
||||
return use_global;
|
||||
};
|
||||
}
|
||||
Type GetValue(bool need_global = false) const {
|
||||
if (use_global || need_global) {
|
||||
return global;
|
||||
}
|
||||
return local;
|
||||
};
|
||||
}
|
||||
void SetValue(const Type& value) {
|
||||
if (use_global) {
|
||||
global = value;
|
||||
} else {
|
||||
local = value;
|
||||
}
|
||||
};
|
||||
operator Type() const {
|
||||
return GetValue();
|
||||
};
|
||||
Type operator=(const Type& b) {
|
||||
SetValue(b);
|
||||
return b;
|
||||
};
|
||||
}
|
||||
|
||||
private:
|
||||
bool use_global{};
|
||||
bool use_global = true;
|
||||
Type global{};
|
||||
Type local{};
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ class QSettings;
|
||||
|
||||
class Config {
|
||||
public:
|
||||
Config(const std::string& config_loc = "qt-config.ini", bool is_global = true);
|
||||
explicit Config(const std::string& config_loc = "qt-config.ini", bool is_global = true);
|
||||
~Config();
|
||||
|
||||
void Reload();
|
||||
|
||||
@@ -69,6 +69,7 @@ void ConfigurationShared::SetPerGameSetting(
|
||||
}
|
||||
|
||||
void ConfigurationShared::InsertGlobalItem(QComboBox* combobox) {
|
||||
const QString use_global_text = tr("Use global configuration");
|
||||
combobox->insertItem(ConfigurationShared::USE_GLOBAL_INDEX,
|
||||
ConfigurationShared::use_global_text);
|
||||
combobox->insertSeparator(ConfigurationShared::USE_GLOBAL_SEPARATOR_INDEX);
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace ConfigurationShared {
|
||||
constexpr int USE_GLOBAL_INDEX = 0;
|
||||
constexpr int USE_GLOBAL_SEPARATOR_INDEX = 1;
|
||||
constexpr int USE_GLOBAL_OFFSET = 2;
|
||||
static const QString use_global_text = QString::fromUtf8("Use global configuration");
|
||||
|
||||
// Global-aware apply and set functions
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id(title_id) {
|
||||
game_config = std::make_unique<Config>(fmt::format("{:016X}", title_id) + ".ini", false);
|
||||
game_config = std::make_unique<Config>(fmt::format("{:016X}.ini", title_id), false);
|
||||
|
||||
Settings::configuring_global = false;
|
||||
|
||||
@@ -85,7 +85,7 @@ void ConfigurePerGame::LoadConfiguration() {
|
||||
|
||||
ui->addonsTab->LoadFromFile(file);
|
||||
|
||||
ui->display_title_id->setText(QString::fromStdString(fmt::format("{:016X}", title_id)));
|
||||
ui->display_title_id->setText(QStringLiteral("%1").arg(title_id, 16, 16, 0).toUpper());
|
||||
|
||||
FileSys::PatchManager pm{title_id};
|
||||
const auto control = pm.GetControlMetadata();
|
||||
|
||||
@@ -1045,7 +1045,7 @@ void GMainWindow::BootGame(const QString& filename) {
|
||||
const auto loader = Loader::GetLoader(v_file);
|
||||
if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) {
|
||||
// Load per game settings
|
||||
Config per_game_config(fmt::format("{:016X}", title_id) + ".ini", false);
|
||||
Config per_game_config(fmt::format("{:016X}.ini", title_id), false);
|
||||
}
|
||||
|
||||
Settings::LogSettings();
|
||||
|
||||
Reference in New Issue
Block a user