// For license of this file, see /LICENSE.md. #ifndef SKINFACTORY_H #define SKINFACTORY_H #include #include #include #include #include #include class SkinEnums : public QObject { Q_OBJECT public: enum class PaletteColors { // Paint foreground of some interesting items (feeds with new articles, etc.). FgInteresting = 1, // Paint foreground of some interesting items WHEN SELECTED (feeds with new articles, etc.). FgSelectedInteresting = 2, // Paint foreground of some errored items (feeds with error, etc.). FgError = 4, // Paint foreground of some errored items WHEN SELECTED (feeds with error, etc.). FgSelectedError = 8, // OK-ish color (background of list with test results of article filter). Allright = 16 }; static QString palleteColorText(PaletteColors col); Q_ENUM(PaletteColors) }; struct RSSGUARD_DLLSPEC Skin { QString m_baseName; QString m_visibleName; QString m_author; QString m_version; QString m_rawData; QString m_adblocked; QString m_layoutMarkupWrapper; QString m_enclosureImageMarkup; QString m_layoutMarkup; QString m_enclosureMarkup; QHash m_colorPalette; QVariant colorForModel(SkinEnums::PaletteColors type, bool ignore_custom_colors = false) const; }; uint qHash(const SkinEnums::PaletteColors& key); Q_DECLARE_METATYPE(Skin) class RSSGUARD_DLLSPEC SkinFactory : public QObject { Q_OBJECT public: explicit SkinFactory(QObject* parent = nullptr); virtual ~SkinFactory() = default; // Loads skin name from settings and sets it as active. void loadCurrentSkin(); Skin currentSkin() const; bool isStyleGoodForDarkVariant(const QString& style_name) const; // Returns the name of the skin, that should be activated // after application restart. QString selectedSkinName() const; QString adBlockedPage(const QString& url, const QString& filter); // Gets skin about a particular skin. Skin skinInfo(const QString& skin_name, bool* ok = nullptr) const; // Returns list of installed skins. QList installedSkins() const; // Sets the desired skin as the active one if it exists. void setCurrentSkinName(const QString& skin_name); QString customSkinBaseFolder() const; private: // Loads the skin from give skin_data. void loadSkinFromData(const Skin& skin); QString loadSkinFile(const QString& skin_folder, const QString& file_name, const QString& base_folder) const; // Holds name of the current skin. Skin m_currentSkin; }; inline Skin SkinFactory::currentSkin() const { return m_currentSkin; } #endif // SKINFACTORY_H