mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-08 05:33:31 +01:00
84a937ae65
Creates a layer outside the game config layer system and passes it to the created gfx widows, so as to not interfere with the global config system. Supports multiple game properties being open at once. Supports editing while a game is playing, but the options only save and update the active game when the window is closed. Right-clicking will remove a property from the game ini.
74 lines
2.2 KiB
C++
74 lines
2.2 KiB
C++
// Copyright 2017 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
|
|
|
|
#include <QSignalBlocker>
|
|
|
|
ConfigChoice::ConfigChoice(const QStringList& options, const Config::Info<int>& setting,
|
|
Config::Layer* layer)
|
|
: ConfigControl(setting.GetLocation(), layer), m_setting(setting)
|
|
{
|
|
addItems(options);
|
|
setCurrentIndex(ReadValue(setting));
|
|
|
|
connect(this, &QComboBox::currentIndexChanged, this, &ConfigChoice::Update);
|
|
}
|
|
|
|
void ConfigChoice::Update(int choice)
|
|
{
|
|
SaveValue(m_setting, choice);
|
|
}
|
|
|
|
void ConfigChoice::OnConfigChanged()
|
|
{
|
|
setCurrentIndex(ReadValue(m_setting));
|
|
}
|
|
|
|
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
|
|
const Config::Info<std::string>& setting,
|
|
Config::Layer* layer)
|
|
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(true)
|
|
{
|
|
for (const auto& op : options)
|
|
addItem(QString::fromStdString(op));
|
|
|
|
Load();
|
|
connect(this, &QComboBox::currentIndexChanged, this, &ConfigStringChoice::Update);
|
|
}
|
|
|
|
ConfigStringChoice::ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
|
|
const Config::Info<std::string>& setting,
|
|
Config::Layer* layer)
|
|
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(false)
|
|
{
|
|
for (const auto& [option_text, option_data] : options)
|
|
addItem(option_text, option_data);
|
|
|
|
connect(this, &QComboBox::currentIndexChanged, this, &ConfigStringChoice::Update);
|
|
Load();
|
|
}
|
|
|
|
void ConfigStringChoice::Update(int index)
|
|
{
|
|
if (m_text_is_data)
|
|
SaveValue(m_setting, itemText(index).toStdString());
|
|
else
|
|
SaveValue(m_setting, itemData(index).toString().toStdString());
|
|
}
|
|
|
|
void ConfigStringChoice::Load()
|
|
{
|
|
const QString setting_value = QString::fromStdString(ReadValue(m_setting));
|
|
const int index = m_text_is_data ? findText(setting_value) : findData(setting_value);
|
|
|
|
// This can be called publicly.
|
|
const QSignalBlocker block(this);
|
|
setCurrentIndex(index);
|
|
}
|
|
|
|
void ConfigStringChoice::OnConfigChanged()
|
|
{
|
|
Load();
|
|
}
|