1
/****************************************************************************************
2
 * Copyright (c) 2007 Jeff Mitchell <kde-dev@emailgoeshere.com>                         *
3
 *                                                                                      *
4
 * This program is free software; you can redistribute it and/or modify it under        *
5
 * the terms of the GNU General Public License as published by the Free Software        *
6
 * Foundation; either version 2 of the License, or (at your option) any later           *
7
 * version.                                                                             *
8
 *                                                                                      *
9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12
 *                                                                                      *
13
 * You should have received a copy of the GNU General Public License along with         *
14
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15
 ****************************************************************************************/
16
17
#ifndef AMAROK_STAR_MANAGER_H
18
#define AMAROK_STAR_MANAGER_H
19
20
#include <QImage>
21
#include <QPixmap>
22
23
class StarManager : public QObject
24
{
25
    Q_OBJECT
26
27
    public:
28
        static StarManager *instance();
29
30
        QPixmap* getStar( int num );
31
        QPixmap* getGreyStar() { return &m_greyedStarPix; }
32
        QPixmap* getHalfStar( int num = -1 );
33
        QImage& getStarImage( int num );
34
        QImage& getGreyStarImage() { return m_greyedStar; }
35
        QImage& getHalfStarImage( int num = -1 );
36
37
        bool setColor( int starNum, const QColor &color );
38
        bool setHalfColor( const QColor &color );
39
40
        void reinitStars( int height = -1, int margin = -1 );
41
42
    signals:
43
        void ratingsColorsChanged();
44
45
    private:
46
        StarManager( QObject* parent );
47
        ~StarManager();
48
49
        static StarManager* s_instance;
50
51
        int m_height;
52
        int m_margin;
53
54
        //cached stars...why both?  For faster conversion when drawing context browser
55
        QPixmap m_starPix;
56
        QImage m_star;
57
        QPixmap m_greyedStarPix;
58
        QImage m_greyedStar;
59
        QPixmap m_halfStarPix;
60
        QImage m_halfStar;
61
62
        QImage m_images[5];
63
        QImage m_halfimages[5];
64
        QPixmap m_pixmaps[5];
65
        QPixmap m_halfpixmaps[5];
66
67
        QColor m_colors[5];
68
        QColor m_halfStarColor;
69
};
70
71
#endif