1 // Copyright 2005-2019 The Mumble Developers. All rights reserved. 2 // Use of this source code is governed by a BSD-style license 3 // that can be found in the LICENSE file at the root of the 4 // Mumble source tree or at <https://www.mumble.info/LICENSE>. 5 6 #ifndef MUMBLE_MUMBLE_THEMES_H_ 7 #define MUMBLE_MUMBLE_THEMES_H_ 8 9 #include <ThemeInfo.h> 10 #include <Settings.h> 11 #ifndef Q_MOC_RUN 12 #include <boost/optional.hpp> 13 #endif 14 15 class Themes { 16 public: 17 /// Returns the style configured in the given settings structure 18 static boost::optional<ThemeInfo::StyleInfo> getConfiguredStyle(const Settings& settings); 19 20 /// Updates the given settings object to be configured to the given style 21 /// 22 /// @note Does not apply the theme @see apply 23 /// 24 /// @param settings Settings object to update 25 /// @param style Style to set 26 /// @param outChanged Will be set to true if the style in settings actually changed. Will not be changed otherwise. 27 static void setConfiguredStyle(Settings& settings, boost::optional<ThemeInfo::StyleInfo> style, bool& outChanged); 28 29 /// Applies the theme 30 /// 31 /// @note Can only apply a theme before MainWindow etc. is opened 32 static bool apply(); 33 34 /// Return a theme name to theme map 35 static ThemeMap getThemes(); 36 37 /// Returns the per user themes directory 38 static QDir getUserThemesDirectory(); 39 40 private: 41 /// Applies the fallback stylesheet 42 static void applyFallback(); 43 44 /// Tries to apply the configured theme. 45 /// @return True on success. False on failure. 46 static bool applyConfigured(); 47 48 // Sets the theme to a QSS theme 49 static void setTheme(QString &themeQss, QStringList &skinPaths); 50 51 /// Returns list of theme search directories ordered ascending by priorty (lowest first) 52 static QVector<QDir> getSearchDirectories(); 53 54 /// Returns default style-sheet used for fall-backs 55 static QString getDefaultStylesheet(); 56 57 /// userStylesheetPath returns the absolute path to the 58 /// user.qss file. 59 static QString userStylesheetPath(); 60 61 /// readStylesheet fills stylesheetContent with the content 62 /// of the file at stylesheetFn, if available. 63 /// If a the file is is available, the function returns true. 64 /// If no file is available, it returns false. 65 static bool readStylesheet(const QString &stylesheetFn, QString &stylesheetContent); 66 }; 67 68 #endif // MUMBLE_MUMBLE_THEMES_H_ 69