mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Qt: Allow custom stylesheets
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
@ -73,8 +74,8 @@ static QComboBox* MakeLanguageComboBox()
|
||||
InterfacePane::InterfacePane(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
CreateLayout();
|
||||
ConnectLayout();
|
||||
LoadConfig();
|
||||
ConnectLayout();
|
||||
}
|
||||
|
||||
void InterfacePane::CreateLayout()
|
||||
@ -106,9 +107,9 @@ void InterfacePane::CreateUI()
|
||||
combobox_layout->addRow(tr("&Theme:"), m_combobox_theme);
|
||||
|
||||
// List avalable themes
|
||||
auto file_search_results =
|
||||
auto theme_search_results =
|
||||
Common::DoFileSearch({File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR});
|
||||
for (const std::string& filename : file_search_results)
|
||||
for (const std::string& filename : theme_search_results)
|
||||
{
|
||||
std::string name, ext;
|
||||
SplitPath(filename, nullptr, &name, &ext);
|
||||
@ -117,13 +118,32 @@ void InterfacePane::CreateUI()
|
||||
m_combobox_theme->addItem(qt_name);
|
||||
}
|
||||
|
||||
// User Style Combobox
|
||||
m_combobox_userstyle = new QComboBox;
|
||||
m_label_userstyle = new QLabel(tr("User Style:"));
|
||||
combobox_layout->addRow(m_label_userstyle, m_combobox_userstyle);
|
||||
|
||||
auto userstyle_search_results = Common::DoFileSearch({File::GetUserPath(D_STYLES_IDX)});
|
||||
|
||||
m_combobox_userstyle->addItem(tr("(None)"), QStringLiteral(""));
|
||||
|
||||
for (const std::string& filename : userstyle_search_results)
|
||||
{
|
||||
std::string name, ext;
|
||||
SplitPath(filename, nullptr, &name, &ext);
|
||||
QString qt_name = QString::fromStdString(name);
|
||||
m_combobox_userstyle->addItem(qt_name, QString::fromStdString(filename));
|
||||
}
|
||||
|
||||
// Checkboxes
|
||||
m_checkbox_top_window = new QCheckBox(tr("Keep Window on Top"));
|
||||
m_checkbox_use_builtin_title_database = new QCheckBox(tr("Use Built-In Database of Game Names"));
|
||||
m_checkbox_use_userstyle = new QCheckBox(tr("Use Custom User Style"));
|
||||
m_checkbox_show_debugging_ui = new QCheckBox(tr("Show Debugging UI"));
|
||||
|
||||
groupbox_layout->addWidget(m_checkbox_top_window);
|
||||
groupbox_layout->addWidget(m_checkbox_use_builtin_title_database);
|
||||
groupbox_layout->addWidget(m_checkbox_use_userstyle);
|
||||
groupbox_layout->addWidget(m_checkbox_show_debugging_ui);
|
||||
}
|
||||
|
||||
@ -157,6 +177,9 @@ void InterfacePane::ConnectLayout()
|
||||
connect(m_checkbox_show_debugging_ui, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
||||
connect(m_combobox_theme, static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::activated),
|
||||
&Settings::Instance(), &Settings::SetThemeName);
|
||||
connect(m_combobox_userstyle,
|
||||
static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged), this,
|
||||
&InterfacePane::OnSaveConfig);
|
||||
connect(m_combobox_language, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this,
|
||||
&InterfacePane::OnSaveConfig);
|
||||
connect(m_checkbox_confirm_on_stop, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
||||
@ -165,6 +188,7 @@ void InterfacePane::ConnectLayout()
|
||||
connect(m_checkbox_pause_on_focus_lost, &QCheckBox::clicked, this, &InterfacePane::OnSaveConfig);
|
||||
connect(m_checkbox_hide_mouse, &QCheckBox::clicked, &Settings::Instance(),
|
||||
&Settings::SetHideCursor);
|
||||
connect(m_checkbox_use_userstyle, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig);
|
||||
}
|
||||
|
||||
void InterfacePane::LoadConfig()
|
||||
@ -178,6 +202,20 @@ void InterfacePane::LoadConfig()
|
||||
m_combobox_theme->setCurrentIndex(
|
||||
m_combobox_theme->findText(QString::fromStdString(SConfig::GetInstance().theme_name)));
|
||||
|
||||
const QString userstyle = Settings::Instance().GetCurrentUserStyle();
|
||||
|
||||
if (userstyle.isEmpty())
|
||||
m_combobox_userstyle->setCurrentIndex(0);
|
||||
else
|
||||
m_combobox_userstyle->setCurrentText(userstyle);
|
||||
|
||||
m_checkbox_use_userstyle->setChecked(Settings::Instance().AreUserStylesEnabled());
|
||||
|
||||
const bool visible = m_checkbox_use_userstyle->isChecked();
|
||||
|
||||
m_combobox_userstyle->setVisible(visible);
|
||||
m_label_userstyle->setVisible(visible);
|
||||
|
||||
// In Game Options
|
||||
m_checkbox_confirm_on_stop->setChecked(startup_params.bConfirmStop);
|
||||
m_checkbox_use_panic_handlers->setChecked(startup_params.bUsePanicHandlers);
|
||||
@ -193,6 +231,13 @@ void InterfacePane::OnSaveConfig()
|
||||
Settings::Instance().SetKeepWindowOnTop(m_checkbox_top_window->isChecked());
|
||||
settings.m_use_builtin_title_database = m_checkbox_use_builtin_title_database->isChecked();
|
||||
Settings::Instance().SetDebugModeEnabled(m_checkbox_show_debugging_ui->isChecked());
|
||||
Settings::Instance().SetCurrentUserStyle(m_combobox_userstyle->currentData().toString());
|
||||
Settings::Instance().SetUserStylesEnabled(m_checkbox_use_userstyle->isChecked());
|
||||
|
||||
const bool visible = m_checkbox_use_userstyle->isChecked();
|
||||
|
||||
m_combobox_userstyle->setVisible(visible);
|
||||
m_label_userstyle->setVisible(visible);
|
||||
|
||||
// In Game Options
|
||||
settings.bConfirmStop = m_checkbox_confirm_on_stop->isChecked();
|
||||
|
Reference in New Issue
Block a user