Changeset View
Changeset View
Standalone View
Standalone View
src/SvgHandler.h
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 49 | public: | |||
---|---|---|---|---|---|
61 | * @param element The theme element to render ( if none the entire svg is rendered ) | 61 | * @param element The theme element to render ( if none the entire svg is rendered ) | ||
62 | * @param skipCache If true, the pixmap will always get rendered and never fetched from the cache. | 62 | * @param skipCache If true, the pixmap will always get rendered and never fetched from the cache. | ||
63 | * @param opacity The opacity used for rendering. Range 0.0 to 1.0. | 63 | * @param opacity The opacity used for rendering. Range 0.0 to 1.0. | ||
64 | * @return The svg element/file rendered into a pixmap | 64 | * @return The svg element/file rendered into a pixmap | ||
65 | */ | 65 | */ | ||
66 | QPixmap renderSvg( const QString& keyname, int width, int height, const QString& element = QString(), bool skipCache = false, const qreal opacity = 1.0 ); | 66 | QPixmap renderSvg( const QString& keyname, int width, int height, const QString& element = QString(), bool skipCache = false, const qreal opacity = 1.0 ); | ||
67 | 67 | | |||
68 | /** | 68 | /** | ||
69 | * Another overloaded function that loads a svg file from an url. This function is usable from QML. | ||||
70 | * @param keyname the name of the key to save in the cache | ||||
71 | * @param width Width of the resulting pixmap | ||||
72 | * @param height Height of the resulting pixmap | ||||
73 | * @param element The theme element to render ( if none the entire svg is rendered ) | ||||
74 | * @param skipCache If true, the pixmap will always get rendered and never fetched from the cache. | ||||
75 | * @param opacity The opacity used for rendering. Range 0.0 to 1.0. | ||||
76 | * @return The svg element/file rendered into a pixmap | ||||
77 | */ | ||||
78 | Q_INVOKABLE QPixmap renderSvg( const QUrl& url, const QString& keyname, int width, int height, const QString& element = QString(), bool skipCache = false, const qreal opacity = 1.0 ); | ||||
79 | | ||||
80 | /** | ||||
69 | * Yet another overloaded function. This one renders the svg element and adds half a divider element to the top and the bottom | 81 | * Yet another overloaded function. This one renders the svg element and adds half a divider element to the top and the bottom | ||
70 | * so it looks sane when multiple elements with the same width are stacked. | 82 | * so it looks sane when multiple elements with the same width are stacked. | ||
71 | * | 83 | * | ||
72 | * @param keyname the name of the key to save in the cache. | 84 | * @param keyname the name of the key to save in the cache. | ||
73 | * @param width Width of the resulting pixmap. | 85 | * @param width Width of the resulting pixmap. | ||
74 | * @param height Height of the resulting pixmap. | 86 | * @param height Height of the resulting pixmap. | ||
75 | * @param element The theme element to render ( if none the entire svg is rendered ) | 87 | * @param element The theme element to render ( if none the entire svg is rendered ) | ||
76 | * @return The svg element/file rendered into a pixmap. | 88 | * @return The svg element/file rendered into a pixmap. | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 149 | Q_SIGNALS: | |||
138 | void retinted(); | 150 | void retinted(); | ||
139 | 151 | | |||
140 | private Q_SLOTS: | 152 | private Q_SLOTS: | ||
141 | void discardCache(); | 153 | void discardCache(); | ||
142 | 154 | | |||
143 | private: | 155 | private: | ||
144 | SvgHandler( QObject* parent = 0 ); | 156 | SvgHandler( QObject* parent = 0 ); | ||
145 | 157 | | |||
146 | bool loadSvg( const QString& name ); | 158 | bool loadSvg( const QString& name, bool forceCustomTheme = false ); | ||
147 | 159 | | |||
148 | QPixmap sliderHandle( const QColor &color, bool pressed, int size ); | 160 | QPixmap sliderHandle( const QColor &color, bool pressed, int size ); | ||
149 | QColor calcLightColor(const QColor &color) const; | 161 | QColor calcLightColor(const QColor &color) const; | ||
150 | QColor calcDarkColor(const QColor &color) const; | 162 | QColor calcDarkColor(const QColor &color) const; | ||
151 | bool lowThreshold(const QColor &color) const; | 163 | bool lowThreshold(const QColor &color) const; | ||
152 | 164 | | |||
153 | KImageCache * m_cache; | 165 | KImageCache * m_cache; | ||
154 | 166 | | |||
155 | QHash<QString,QSvgRenderer*> m_renderers; | 167 | QHash<QString,QSvgRenderer*> m_renderers; | ||
156 | QReadWriteLock m_lock; | 168 | QReadWriteLock m_lock; | ||
157 | 169 | | |||
158 | QString m_themeFile; | 170 | QString m_themeFile; | ||
159 | bool m_customTheme; | 171 | bool m_customTheme; | ||
160 | }; | 172 | }; | ||
161 | 173 | | |||
162 | #endif | 174 | #endif |