Skip to content

Commit

Permalink
Satisfy CI; fix lint & compile on non-Windows/Android
Browse files Browse the repository at this point in the history
  • Loading branch information
ewancg committed Sep 17, 2023
1 parent ce5633d commit da20bd2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
4 changes: 1 addition & 3 deletions Source/Core/DolphinQt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,

#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged, this,
[](Qt::ColorScheme colorScheme) {
Settings::Instance().UpdateStyle();
});
[](Qt::ColorScheme colorScheme) { Settings::Instance().UpdateStyle(); });
#endif

connect(m_cheats_manager, &CheatsManager::OpenGeneralSettings, this,
Expand Down
34 changes: 22 additions & 12 deletions Source/Core/DolphinQt/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ void Settings::UpdateStyle()
qApp->setStyleSheet(QStringLiteral(""));
};

#ifdef Q_OS_WIN
auto LoadDarkStyle = [] {
#ifdef _WIN32
QFile file(QStringLiteral(":/dolphin_dark_win/dark.qss"));
if (file.open(QFile::ReadOnly)) {
if (file.open(QFile::ReadOnly))
{
QString stylesheet_contents;
stylesheet_contents = QString::fromUtf8(file.readAll().data());

Expand All @@ -225,21 +226,27 @@ void Settings::UpdateStyle()
qApp->setPalette(palette);
qApp->setStyleSheet(stylesheet_contents);
}
};
#elif Q_OS_MAC
// Something else should be done on macOS
auto LoadDarkStyle = [&LoadLightStyle] { LoadLightStyle(); };
#else
LoadLightStyle();
// Something else should be done for other platforms.
// Don't try for Linux or BSD because on those platforms, dark theme is defined by a
// user-chosen style
auto LoadDarkStyle = [&LoadLightStyle] { LoadLightStyle(); };
#endif
};

auto LoadSystemStyle = [this, &LoadLightStyle, &LoadDarkStyle] {
if(IsSystemDark()) LoadDarkStyle();
else LoadLightStyle();
if (IsSystemDark())
LoadDarkStyle();
else
LoadLightStyle();
};

auto LoadUserStyle = [this, &LoadSystemStyle] {
// If we haven't found one, we continue with an empty (default) style
QString stylesheet_name = GetUserStyle();
if (stylesheet_name.isEmpty()) {
if (stylesheet_name.isEmpty())
{
LoadSystemStyle();
return;
}
Expand All @@ -251,8 +258,10 @@ void Settings::UpdateStyle()
if (stylesheet.open(QFile::ReadOnly))
stylesheet_contents = QString::fromUtf8(stylesheet.readAll().data());

// We also continue with the default style if it's empty or unreadable (can't check for invalid unfortunately)
if(stylesheet_contents.isEmpty()) {
// We also continue with the default style if it's empty or unreadable (can't check for invalid
// unfortunately)
if (stylesheet_contents.isEmpty())
{
LoadSystemStyle();
return;
}
Expand Down Expand Up @@ -282,7 +291,8 @@ void Settings::UpdateStyle()
GetQSettings().setValue(QStringLiteral("userstyle/name"), stylesheet_name);
};

switch(GetStyleType()) {
switch (GetStyleType())
{
case StyleType::System:
[[fallthrough]];
default:
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/DolphinQt/Settings/InterfacePane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ void InterfacePane::LoadConfig()
if (index > 0)
SignalBlocking(m_combobox_userstyle)->setCurrentIndex(index);

SignalBlocking(m_combobox_style)->setCurrentIndex(static_cast<int>(Settings::Instance().GetStyleType()));
SignalBlocking(m_combobox_style)
->setCurrentIndex(static_cast<int>(Settings::Instance().GetStyleType()));
SignalBlocking(m_combobox_userstyle)->setCurrentText(Settings::Instance().GetUserStyle());

bool combobox_userstyle_visible =
Expand Down Expand Up @@ -298,7 +299,8 @@ void InterfacePane::OnSaveConfig()
Config::SetBase(Config::MAIN_USE_BUILT_IN_TITLE_DATABASE,
m_checkbox_use_builtin_title_database->isChecked());
Settings::Instance().SetDebugModeEnabled(m_checkbox_show_debugging_ui->isChecked());
Settings::Instance().SetStyleType(static_cast<Settings::StyleType>(m_combobox_style->currentIndex()));
Settings::Instance().SetStyleType(
static_cast<Settings::StyleType>(m_combobox_style->currentIndex()));
Settings::Instance().SetUserStyle(m_combobox_userstyle->currentData().toString());
Settings::Instance().UpdateStyle();

Expand Down

0 comments on commit da20bd2

Please sign in to comment.