mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-02 03:49:44 -06:00
merge doublemelon (#2067)
non-exhaustive (but exhausting) list of changes: * base laid for multiple window support, but will likely require more work to work correctly * encapsulation of frontend state for proper multi-instance support * (JIT still needs a fix for the NDS::Current workaround but we can get there later) * new, more flexible configuration system
This commit is contained in:
@ -31,21 +31,26 @@ InterfaceSettingsDialog::InterfaceSettingsDialog(QWidget* parent) : QDialog(pare
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
ui->cbMouseHide->setChecked(Config::MouseHide != 0);
|
||||
ui->spinMouseHideSeconds->setEnabled(Config::MouseHide != 0);
|
||||
ui->spinMouseHideSeconds->setValue(Config::MouseHideSeconds);
|
||||
ui->cbPauseLostFocus->setChecked(Config::PauseLostFocus != 0);
|
||||
ui->spinMaxFPS->setValue(Config::MaxFPS);
|
||||
emuInstance = ((MainWindow*)parent)->getEmuInstance();
|
||||
|
||||
auto& cfg = emuInstance->getGlobalConfig();
|
||||
|
||||
ui->cbMouseHide->setChecked(cfg.GetBool("MouseHide"));
|
||||
ui->spinMouseHideSeconds->setEnabled(ui->cbMouseHide->isChecked());
|
||||
ui->spinMouseHideSeconds->setValue(cfg.GetInt("MouseHideSeconds"));
|
||||
ui->cbPauseLostFocus->setChecked(cfg.GetBool("PauseLostFocus"));
|
||||
ui->spinMaxFPS->setValue(cfg.GetInt("MaxFPS"));
|
||||
|
||||
const QList<QString> themeKeys = QStyleFactory::keys();
|
||||
const QString currentTheme = qApp->style()->objectName();
|
||||
QString cfgTheme = cfg.GetQString("UITheme");
|
||||
|
||||
ui->cbxUITheme->addItem("System default", "");
|
||||
|
||||
for (int i = 0; i < themeKeys.length(); i++)
|
||||
{
|
||||
ui->cbxUITheme->addItem(themeKeys[i], themeKeys[i]);
|
||||
if (!Config::UITheme.empty() && themeKeys[i].compare(currentTheme, Qt::CaseInsensitive) == 0)
|
||||
if (!cfgTheme.isEmpty() && themeKeys[i].compare(currentTheme, Qt::CaseInsensitive) == 0)
|
||||
ui->cbxUITheme->setCurrentIndex(i + 1);
|
||||
}
|
||||
}
|
||||
@ -57,36 +62,31 @@ InterfaceSettingsDialog::~InterfaceSettingsDialog()
|
||||
|
||||
void InterfaceSettingsDialog::on_cbMouseHide_clicked()
|
||||
{
|
||||
if (ui->spinMouseHideSeconds->isEnabled())
|
||||
{
|
||||
ui->spinMouseHideSeconds->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->spinMouseHideSeconds->setEnabled(true);
|
||||
}
|
||||
ui->spinMouseHideSeconds->setEnabled(ui->cbMouseHide->isChecked());
|
||||
}
|
||||
|
||||
void InterfaceSettingsDialog::done(int r)
|
||||
{
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
Config::MouseHide = ui->cbMouseHide->isChecked() ? 1:0;
|
||||
Config::MouseHideSeconds = ui->spinMouseHideSeconds->value();
|
||||
Config::PauseLostFocus = ui->cbPauseLostFocus->isChecked() ? 1:0;
|
||||
Config::MaxFPS = ui->spinMaxFPS->value();
|
||||
auto& cfg = emuInstance->getGlobalConfig();
|
||||
|
||||
cfg.SetBool("MouseHide", ui->cbMouseHide->isChecked());
|
||||
cfg.SetInt("MouseHideSeconds", ui->spinMouseHideSeconds->value());
|
||||
cfg.SetBool("PauseLostFocus", ui->cbPauseLostFocus->isChecked());
|
||||
cfg.SetInt("MaxFPS", ui->spinMaxFPS->value());
|
||||
|
||||
QString themeName = ui->cbxUITheme->currentData().toString();
|
||||
Config::UITheme = themeName.toStdString();
|
||||
cfg.SetQString("UITheme", themeName);
|
||||
|
||||
Config::Save();
|
||||
|
||||
if (!Config::UITheme.empty())
|
||||
if (!themeName.isEmpty())
|
||||
qApp->setStyle(themeName);
|
||||
else
|
||||
qApp->setStyle(*systemThemeName);
|
||||
|
||||
emit updateMouseTimer();
|
||||
emit updateInterfaceSettings();
|
||||
}
|
||||
|
||||
QDialog::done(r);
|
||||
|
Reference in New Issue
Block a user