/* Copyright 2016-2023 melonDS team This file is part of melonDS. melonDS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. melonDS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with melonDS. If not, see http://www.gnu.org/licenses/. */ #include #include "InterfaceSettingsDialog.h" #include "ui_InterfaceSettingsDialog.h" #include "types.h" #include "Platform.h" #include "Config.h" #include "main.h" InterfaceSettingsDialog* InterfaceSettingsDialog::currentDlg = nullptr; InterfaceSettingsDialog::InterfaceSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::InterfaceSettingsDialog) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); 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 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 (!cfgTheme.isEmpty() && themeKeys[i].compare(currentTheme, Qt::CaseInsensitive) == 0) ui->cbxUITheme->setCurrentIndex(i + 1); } } InterfaceSettingsDialog::~InterfaceSettingsDialog() { delete ui; } void InterfaceSettingsDialog::on_cbMouseHide_clicked() { ui->spinMouseHideSeconds->setEnabled(ui->cbMouseHide->isChecked()); } void InterfaceSettingsDialog::done(int r) { if (r == QDialog::Accepted) { 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(); cfg.SetQString("UITheme", themeName); Config::Save(); if (!themeName.isEmpty()) qApp->setStyle(themeName); else qApp->setStyle(*systemThemeName); emit updateInterfaceSettings(); } QDialog::done(r); closeDlg(); }