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