auto dark mode restored, fix merging

This commit is contained in:
Nayla Hanegan 2024-08-23 14:48:50 -04:00
parent 4ced9ad700
commit 2670ec26f6
8 changed files with 61 additions and 223 deletions

View file

@ -91,7 +91,6 @@ InterfacePane::InterfacePane(QWidget* parent) : QWidget(parent)
{
CreateLayout();
UpdateShowDebuggingCheckbox();
LoadUserStyle();
ConnectLayout();
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
@ -138,28 +137,6 @@ void InterfacePane::CreateUI()
m_combobox_theme = new ConfigStringChoice(theme_names, Config::MAIN_THEME_NAME);
combobox_layout->addRow(tr("&Theme:"), m_combobox_theme);
// User Style Combobox
m_combobox_userstyle = new ToolTipComboBox;
m_label_userstyle = new QLabel(tr("Style:"));
combobox_layout->addRow(m_label_userstyle, m_combobox_userstyle);
auto userstyle_search_results = Common::DoFileSearch({File::GetUserPath(D_STYLES_IDX)});
auto current = QOperatingSystemVersionBase::current();
#ifdef _WIN32
if (current <= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10))
{
m_combobox_userstyle->addItem(tr("Windows 11"), static_cast<int>(Settings::StyleType::Light));
m_combobox_userstyle->addItem(tr("Windows 10"), static_cast<int>(Settings::StyleType::Dark));
}
#endif
for (const std::string& path : userstyle_search_results)
{
const QFileInfo file_info(QString::fromStdString(path));
m_combobox_userstyle->addItem(file_info.completeBaseName(), file_info.fileName());
}
// Checkboxes
m_checkbox_use_builtin_title_database = new ConfigBool(tr("Use Built-In Database of Game Names"),
Config::MAIN_USE_BUILT_IN_TITLE_DATABASE);
@ -242,8 +219,6 @@ void InterfacePane::ConnectLayout()
&Settings::SetDebugModeEnabled);
connect(m_combobox_theme, &QComboBox::currentIndexChanged, &Settings::Instance(),
&Settings::ThemeChanged);
connect(m_combobox_userstyle, &QComboBox::currentIndexChanged, this,
&InterfacePane::OnUserStyleChanged);
connect(m_combobox_language, &QComboBox::currentIndexChanged, this,
&InterfacePane::OnLanguageChanged);
connect(m_checkbox_top_window, &QCheckBox::toggled, &Settings::Instance(),
@ -284,31 +259,6 @@ void InterfacePane::UpdateShowDebuggingCheckbox()
}
}
void InterfacePane::LoadUserStyle()
{
const Settings::StyleType style_type = Settings::Instance().GetStyleType();
const QString userstyle = Settings::Instance().GetUserStyleName();
const int index = style_type == Settings::StyleType::User ?
m_combobox_userstyle->findData(userstyle) :
m_combobox_userstyle->findData(static_cast<int>(style_type));
if (index > 0)
SignalBlocking(m_combobox_userstyle)->setCurrentIndex(index);
}
void InterfacePane::OnUserStyleChanged()
{
const auto selected_style = m_combobox_userstyle->currentData();
bool is_builtin_type = false;
const int style_type_int = selected_style.toInt(&is_builtin_type);
Settings::Instance().SetStyleType(is_builtin_type ?
static_cast<Settings::StyleType>(style_type_int) :
Settings::StyleType::User);
if (!is_builtin_type)
Settings::Instance().SetUserStyleName(selected_style.toString());
Settings::Instance().ApplyStyle();
}
void InterfacePane::OnLanguageChanged()
{
ModalMessageBox::information(
@ -414,7 +364,4 @@ void InterfacePane::AddDescriptions()
m_radio_cursor_visible_never->SetDescription(tr(TR_CURSOR_VISIBLE_NEVER_DESCRIPTION));
m_radio_cursor_visible_always->SetDescription(tr(TR_CURSOR_VISIBLE_ALWAYS_DESCRIPTION));
m_combobox_userstyle->SetTitle(tr("Style"));
m_combobox_userstyle->SetDescription(tr(TR_USER_STYLE_DESCRIPTION));
}