mirror of https://git.suyu.dev/suyu/suyu.git
Compare commits
4 Commits
5624391445
...
f87425e3d9
Author | SHA1 | Date |
---|---|---|
flodavid | f87425e3d9 | |
flodavid | e08c432a94 | |
flodavid | 743279c466 | |
flodavid | 740247b757 |
|
@ -220,9 +220,9 @@ void ConfigureUi::UpdateDarkModeOptions() {
|
|||
QString selected_theme = ui->theme_combobox->currentData().toString();
|
||||
|
||||
/* Dark mode option are added according to the modes the current style supports */
|
||||
bool has_common_style = QFile::exists(selected_theme + QStringLiteral("style.qss"));
|
||||
bool has_light_style = QFile::exists(selected_theme + QStringLiteral("light.qss"));
|
||||
bool has_dark_style = QFile::exists(selected_theme + QStringLiteral("dark.qss"));
|
||||
bool has_common_style = QFile::exists(selected_theme + QStringLiteral("/style.qss"));
|
||||
bool has_light_style = QFile::exists(selected_theme + QStringLiteral("/light.qss"));
|
||||
bool has_dark_style = QFile::exists(selected_theme + QStringLiteral("/dark.qss"));
|
||||
#ifdef _WIN32
|
||||
// Indicate which option needs a restart to be applied, depending on current environment
|
||||
// variable
|
||||
|
|
|
@ -4810,7 +4810,7 @@ void GMainWindow::UpdateUITheme() {
|
|||
LOG_ERROR(Frontend, "Unable to open style \"{}\", fallback to the default theme",
|
||||
current_theme.toStdString());
|
||||
|
||||
if (TryLoadStylesheet(QStringLiteral(":/%1/").arg(default_theme))) {
|
||||
if (TryLoadStylesheet(QStringLiteral(":/%1").arg(default_theme))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4821,14 +4821,18 @@ void GMainWindow::UpdateUITheme() {
|
|||
setStyleSheet({});
|
||||
}
|
||||
|
||||
void GMainWindow::UpdateIcons(const QString& theme_used) {
|
||||
void GMainWindow::UpdateIcons(const QString& theme_path) {
|
||||
// Get the theme directory from its path
|
||||
std::size_t last_slash = theme_path.toStdString().find_last_of("/");
|
||||
QString theme_dir = QString::fromStdString(theme_path.toStdString().substr(last_slash + 1));
|
||||
|
||||
// Append _dark to the theme name to use dark variant icons
|
||||
if (CheckDarkMode()) {
|
||||
LOG_DEBUG(Frontend, "Using icons from: {}", theme_used.toStdString() + "_dark");
|
||||
QIcon::setThemeName(theme_used + QStringLiteral("_dark"));
|
||||
LOG_DEBUG(Frontend, "Using icons from: {}", theme_dir.toStdString() + "_dark");
|
||||
QIcon::setThemeName(theme_dir + QStringLiteral("_dark"));
|
||||
} else {
|
||||
LOG_DEBUG(Frontend, "Using icons from: {}", theme_used.toStdString());
|
||||
QIcon::setThemeName(theme_used);
|
||||
LOG_DEBUG(Frontend, "Using icons from: {}", theme_dir.toStdString());
|
||||
QIcon::setThemeName(theme_dir);
|
||||
}
|
||||
|
||||
const QString theme_directory{
|
||||
|
@ -4840,7 +4844,7 @@ void GMainWindow::UpdateIcons(const QString& theme_used) {
|
|||
theme_paths << QString::fromStdString(":/icons") << QStringLiteral("%1").arg(theme_directory);
|
||||
QIcon::setThemeSearchPaths(theme_paths);
|
||||
|
||||
// Change current directory, to allow user themes to use their own icons
|
||||
// Change current directory, to allow user themes to add their own icons
|
||||
QDir::setCurrent(QStringLiteral("%1/%2").arg(theme_directory, UISettings::values.theme));
|
||||
|
||||
emit UpdateThemedIcons();
|
||||
|
@ -4851,14 +4855,14 @@ bool GMainWindow::TryLoadStylesheet(const QString& theme_uri) {
|
|||
|
||||
// Use themed stylesheet if it exists
|
||||
if (CheckDarkMode()) {
|
||||
style_path = theme_uri + QStringLiteral("dark.qss");
|
||||
style_path = theme_uri + QStringLiteral("/dark.qss");
|
||||
} else {
|
||||
style_path = theme_uri + QStringLiteral("light.qss");
|
||||
style_path = theme_uri + QStringLiteral("/light.qss");
|
||||
}
|
||||
if (!QFile::exists(style_path)) {
|
||||
LOG_DEBUG(Frontend, "No themed (light/dark) stylesheet, using default one");
|
||||
// Use common stylesheet if themed one does not exist
|
||||
style_path = theme_uri + QStringLiteral("style.qss");
|
||||
style_path = theme_uri + QStringLiteral("/style.qss");
|
||||
}
|
||||
|
||||
// Loading stylesheet
|
||||
|
|
|
@ -23,12 +23,12 @@ namespace FS = Common::FS;
|
|||
namespace UISettings {
|
||||
|
||||
const Themes included_themes{{
|
||||
{"Default", ":/default/"},
|
||||
{"Default monochrome", ":/monochrome/"},
|
||||
{"Mine Shaft", ":/qdarkstyle/"},
|
||||
{"Mine Shaft monochrome", ":/qdarkstyle_monochrome/"},
|
||||
{"Midnight Blue", ":/qdarkstyle_midnight_blue/"},
|
||||
{"Midnight Blue monochrome", ":/qdarkstyle_midnight_blue_monochrome/"},
|
||||
{"Default", ":/default"},
|
||||
{"Default monochrome", ":/monochrome"},
|
||||
{"Mine Shaft", ":/qdarkstyle"},
|
||||
{"Mine Shaft monochrome", ":/qdarkstyle_monochrome"},
|
||||
{"Midnight Blue", ":/qdarkstyle_midnight_blue"},
|
||||
{"Midnight Blue monochrome", ":/qdarkstyle_midnight_blue_monochrome"},
|
||||
}};
|
||||
|
||||
Values values = {};
|
||||
|
|
|
@ -49,7 +49,7 @@ struct Shortcut {
|
|||
ContextualShortcut shortcut;
|
||||
};
|
||||
|
||||
static constexpr std::string_view default_theme{"default"};
|
||||
static constexpr std::string_view default_theme{":/default"};
|
||||
|
||||
using Themes = std::array<std::pair<const char*, const char*>, 6>;
|
||||
extern const Themes included_themes;
|
||||
|
|
Loading…
Reference in New Issue