1 // For license of this file, see <project-root-folder>/LICENSE.md. 2 3 #ifndef SKINFACTORY_H 4 #define SKINFACTORY_H 5 6 #include <QObject> 7 8 #include <QColor> 9 #include <QHash> 10 #include <QMetaType> 11 #include <QStringList> 12 13 struct RSSGUARD_DLLSPEC Skin { 14 enum class PaletteColors { 15 Highlight = 1, 16 Error = 2, 17 Allright = 3 18 }; 19 20 QString m_baseName; 21 QString m_visibleName; 22 QString m_author; 23 QString m_version; 24 QString m_rawData; 25 QString m_adblocked; 26 QString m_layoutMarkupWrapper; 27 QString m_enclosureImageMarkup; 28 QString m_layoutMarkup; 29 QString m_enclosureMarkup; 30 QHash<Skin::PaletteColors, QColor> m_colorPalette; 31 }; 32 33 uint qHash(const Skin::PaletteColors& key); 34 Q_DECLARE_METATYPE(Skin)35Q_DECLARE_METATYPE(Skin) 36 37 class RSSGUARD_DLLSPEC SkinFactory : public QObject { 38 Q_OBJECT 39 40 public: 41 explicit SkinFactory(QObject* parent = nullptr); 42 virtual ~SkinFactory() = default; 43 44 // Loads skin name from settings and sets it as active. 45 void loadCurrentSkin(); 46 Skin currentSkin() const; 47 48 // Returns the name of the skin, that should be activated 49 // after application restart. 50 QString selectedSkinName() const; 51 52 QString adBlockedPage(const QString& url, const QString& filter); 53 54 // Gets skin about a particular skin. 55 Skin skinInfo(const QString& skin_name, bool* ok = nullptr) const; 56 57 // Returns list of installed skins. 58 QList<Skin> installedSkins() const; 59 60 // Sets the desired skin as the active one if it exists. 61 void setCurrentSkinName(const QString& skin_name); 62 63 QString customSkinBaseFolder() const; 64 65 private: 66 67 // Loads the skin from give skin_data. 68 void loadSkinFromData(const Skin& skin); 69 70 // Holds name of the current skin. 71 Skin m_currentSkin; 72 }; 73 currentSkin()74inline Skin SkinFactory::currentSkin() const { 75 return m_currentSkin; 76 } 77 78 #endif // SKINFACTORY_H 79