Skip to content
Permalink
Browse files

Merge PR #3595: Refactor themes.cpp and themes.h

  • Loading branch information...
davidebeatrici committed Feb 9, 2019
2 parents 1fb1e9c + bdfda03 commit ba087869df8416117584bac666a6dd619e2c838a
Showing with 12 additions and 15 deletions.
  1. +9 −15 src/mumble/Themes.cpp
  2. +3 −0 src/mumble/Themes.h
@@ -51,19 +51,9 @@ void Themes::applyFallback() {

QStringList skinPaths;
skinPaths << QLatin1String(":/themes/Mumble");
QDir::setSearchPaths(QLatin1String("skin"), skinPaths);

QString userStylesheetFn = userStylesheetPath();
QString userStylesheetContent;
if (readStylesheet(userStylesheetFn, userStylesheetContent)) {
qWarning("Themes: allowing user stylesheet at '%s' to override fallback stylesheet", qPrintable(userStylesheetFn));
}
QString defaultTheme = getDefaultStylesheet();
setTheme(defaultTheme, skinPaths);

qApp->setStyleSheet(
getDefaultStylesheet() +
QLatin1String("\n") +
userStylesheetContent
);
}

bool Themes::applyConfigured() {
@@ -87,14 +77,19 @@ bool Themes::applyConfigured() {
QStringList skinPaths;
skinPaths << qssFile.path();
skinPaths << QLatin1String(":/themes/Mumble"); // Some skins might want to fall-back on our built-in resources
QDir::setSearchPaths(QLatin1String("skin"), skinPaths);

QString themeQss = QString::fromUtf8(file.readAll());
setTheme(themeQss, skinPaths);
return true;
}

void Themes::setTheme(QString &themeQss, QStringList &skinPaths) {
QDir::setSearchPaths(QLatin1String("skin"), skinPaths);

QString userStylesheetFn = userStylesheetPath();
QString userStylesheetContent;
if (readStylesheet(userStylesheetFn, userStylesheetContent)) {
qWarning("Themes: allowing user stylesheet at '%s' to override the chosen theme", qPrintable(userStylesheetFn));
qWarning("Themes: allowing user stylesheet at '%s' to override the stylesheet", qPrintable(userStylesheetFn));
}

qApp->setStyleSheet(
@@ -103,7 +98,6 @@ bool Themes::applyConfigured() {
userStylesheetContent
);

return true;
}

bool Themes::apply() {
@@ -45,6 +45,9 @@ class Themes {
/// @return True on success. False on failure.
static bool applyConfigured();

// Sets the theme to a QSS theme
static void setTheme(QString &themeQss, QStringList &skinPaths);

/// Returns list of theme search directories ordered ascending by priorty (lowest first)
static QVector<QDir> getSearchDirectories();

0 comments on commit ba08786

Please sign in to comment.
You can’t perform that action at this time.