mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-02 12:00:01 -06:00
Allow the user to choose the UI theme
Mainly useful for those who want dark mode on Windows.
This commit is contained in:
@ -16,15 +16,16 @@
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <QStyleFactory>
|
||||
#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);
|
||||
@ -35,6 +36,18 @@ InterfaceSettingsDialog::InterfaceSettingsDialog(QWidget* parent) : QDialog(pare
|
||||
ui->spinMouseHideSeconds->setValue(Config::MouseHideSeconds);
|
||||
ui->cbPauseLostFocus->setChecked(Config::PauseLostFocus != 0);
|
||||
ui->spinMaxFPS->setValue(Config::MaxFPS);
|
||||
|
||||
const QList<QString> themeKeys = QStyleFactory::keys();
|
||||
const QString currentTheme = qApp->style()->objectName();
|
||||
|
||||
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)
|
||||
ui->cbxUITheme->setCurrentIndex(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
InterfaceSettingsDialog::~InterfaceSettingsDialog()
|
||||
@ -63,8 +76,16 @@ void InterfaceSettingsDialog::done(int r)
|
||||
Config::PauseLostFocus = ui->cbPauseLostFocus->isChecked() ? 1:0;
|
||||
Config::MaxFPS = ui->spinMaxFPS->value();
|
||||
|
||||
QString themeName = ui->cbxUITheme->currentData().toString();
|
||||
Config::UITheme = themeName.toStdString();
|
||||
|
||||
Config::Save();
|
||||
|
||||
if (!Config::UITheme.empty())
|
||||
qApp->setStyle(themeName);
|
||||
else
|
||||
qApp->setStyle(*systemThemeName);
|
||||
|
||||
emit updateMouseTimer();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user