2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
1 |
/****************************************************************************************
|
2 |
* Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> *
|
|
3 |
* Copyright (c) 2008 Jeff Mitchell <kde-dev@emailgoeshere.com> *
|
|
4 |
* Copyright (c) 2009 Mark Kretschmann <kretschmann@kde.org> *
|
|
5 |
* *
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under *
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software *
|
|
8 |
* Foundation; either version 2 of the License, or (at your option) any later *
|
|
9 |
* version. *
|
|
10 |
* *
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
|
|
12 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
|
|
13 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
|
|
14 |
* *
|
|
15 |
* You should have received a copy of the GNU General Public License along with *
|
|
16 |
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
17 |
****************************************************************************************/
|
|
18 |
||
19 |
#ifndef SVGHANDLER_H
|
|
20 |
#define SVGHANDLER_H
|
|
21 |
||
22 |
class QStyleOptionSlider; |
|
23 |
||
2220
by Michael Pyne
juk: Remove KPixmapCache, more simplification. |
24 |
#include <QMap> |
2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
25 |
#include <QReadWriteLock> |
26 |
||
27 |
#include <QPixmap> |
|
28 |
#include <QString> |
|
29 |
||
30 |
class SvgHandler; |
|
2219
by Michael Pyne
juk: Dead code removal, Simplification of SVG Handler. |
31 |
class QSvgRenderer; |
2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
32 |
|
33 |
namespace The { |
|
34 |
SvgHandler* svgHandler(); |
|
35 |
}
|
|
36 |
||
37 |
/**
|
|
38 |
A class to abstract out some common operations of users of tinted svgs
|
|
39 |
*/
|
|
40 |
class SvgHandler : public QObject |
|
41 |
{
|
|
42 |
Q_OBJECT
|
|
43 |
||
44 |
friend SvgHandler* The::svgHandler(); |
|
45 |
||
46 |
public: |
|
47 |
~SvgHandler(); |
|
48 |
||
49 |
QSvgRenderer* getRenderer(); |
|
2215
by Scott Wheeler
Apparently my low-fat version of this broke things when not-cached. Reverting for now. |
50 |
|
2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
51 |
/**
|
52 |
* Overloaded function that uses the current theme
|
|
53 |
* @param keyname the name of the key to save in the cache
|
|
54 |
* @param width Width of the resulting pixmap
|
|
55 |
* @param height Height of the resulting pixmap
|
|
56 |
* @param element The theme element to render ( if none the entire svg is rendered )
|
|
57 |
* @return The svg element/file rendered into a pixmap
|
|
58 |
*/
|
|
2220
by Michael Pyne
juk: Remove KPixmapCache, more simplification. |
59 |
QPixmap renderSvg( const QString& keyname, int width, int height, const QString& element = QString() ); |
2215
by Scott Wheeler
Apparently my low-fat version of this broke things when not-cached. Reverting for now. |
60 |
|
61 |
/**
|
|
2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
62 |
* Paint a custom slider using the specified painter. The slider consists
|
63 |
* of a background part, a "knob" that moves along it to show the current
|
|
64 |
* position, and 2 end markers to clearly mark the ends of the slider.
|
|
65 |
* The background part before the knob, is painted in a different color than the
|
|
66 |
* part after (and under) the knob.
|
|
67 |
* @param p The painter to use.
|
|
68 |
* @param x The x position to begin painting at.
|
|
69 |
* @param y The y position to begin painting at.
|
|
70 |
* @param width The width of the slider to paint.
|
|
71 |
* @param height The height of the slider. The background part does not scale in height, it will always be a relatively thin line, but the knob and end markers do.
|
|
72 |
* @param percentage The percentange of the slider that the knob is positioned at.
|
|
73 |
* @param active Specifies whether the slider should be painted "active" using the current palettes active colors, to specify that it currently has mouse focus or hover.
|
|
74 |
*/
|
|
75 |
void paintCustomSlider( QPainter *p, QStyleOptionSlider *slider, qreal percentage ); |
|
76 |
||
77 |
/**
|
|
78 |
* Calculate the visual slider knob rect from its value, use it instead the QStyle functions
|
|
79 |
* QStyle::sliderPositionFromValue() and QStyle::subControlRect();
|
|
80 |
*/
|
|
81 |
QRect sliderKnobRect( const QRect &slider, qreal percent, bool inverse ) const; |
|
82 |
||
2215
by Scott Wheeler
Apparently my low-fat version of this broke things when not-cached. Reverting for now. |
83 |
/**
|
84 |
* Get the path of the currently used svg theme file.
|
|
85 |
*
|
|
86 |
* @return the path of the currently used theme file.
|
|
87 |
*/
|
|
88 |
QString themeFile(); |
|
89 |
||
90 |
public slots: |
|
91 |
void reTint(); |
|
92 |
||
93 |
signals: |
|
94 |
void retinted(); |
|
95 |
||
2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
96 |
private: |
97 |
SvgHandler( QObject* parent = 0 ); |
|
98 |
||
99 |
bool loadSvg( const QString& name ); |
|
100 |
||
101 |
QPixmap sliderHandle( const QColor &color, bool pressed, int size ); |
|
102 |
||
2220
by Michael Pyne
juk: Remove KPixmapCache, more simplification. |
103 |
QMap<QString, QPixmap> m_cache; |
2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
104 |
|
2219
by Michael Pyne
juk: Dead code removal, Simplification of SVG Handler. |
105 |
QSvgRenderer *m_renderer; |
2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
106 |
QReadWriteLock m_lock; |
2215
by Scott Wheeler
Apparently my low-fat version of this broke things when not-cached. Reverting for now. |
107 |
|
108 |
QString m_themeFile; |
|
2210
by Scott Wheeler
Switch to Amarok's volume / track polition sliders. |
109 |
};
|
110 |
||
111 |
#endif
|