2 Copyright (C) 2007 Jeff Mitchell <kde-dev@emailgoeshere.com>
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.
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.
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
19 #include "StarManager.h"
22 #include "config-amarok.h"
24 #include "metabundle.h"
27 #include <KIconEffect>
28 #include <KStandardDirs> //KGlobal::dirs()
35 StarManager
* StarManager::instance()
37 static StarManager sm
;
42 StarManager::StarManager()
44 /*if( AmarokConfig::customRatingsColors() )
45 AmarokConfig::setCustomRatingsColors( false );
46 m_colors[0] = AmarokConfig::starColorOne();
47 m_colors[1] = AmarokConfig::starColorTwo();
48 m_colors[2] = AmarokConfig::starColorThree();
49 m_colors[3] = AmarokConfig::starColorFour();
50 m_colors[4] = AmarokConfig::starColorFive();
51 m_halfStarColor = AmarokConfig::starColorHalf();*/
57 StarManager::~StarManager() {}
60 StarManager::reinitStars( int height
, int margin
)
67 int hval
= m_height
+ m_margin
* 2 - 4 + ( ( m_height
% 2 ) ? 1 : 0 );
68 QImage star
= QImage( KStandardDirs::locate( "data", "amarok/images/star.png" ) ).scaled( hval
, hval
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
70 m_starPix
= QPixmap::fromImage( star
);
71 m_greyedStar
= star
.copy();
72 KIconEffect::toGray( m_greyedStar
, 1.0 );
73 m_greyedStarPix
= QPixmap::fromImage( m_greyedStar
);
74 QImage half
= QImage( KStandardDirs::locate( "data", "amarok/images/smallstar.png" ) ).scaled( hval
, hval
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
75 m_halfStar
= half
.copy();
76 /*if( AmarokConfig::customRatingsColors() )
77 KIconEffect::colorize( m_halfStar, m_halfStarColor, 1.0 );*/
78 m_halfStarPix
= QPixmap::fromImage( m_halfStar
);
82 for( int i
= 0; i
< 5; i
++ )
84 tempstar
= star
.copy();
85 temphalfstar
= half
.copy();
86 /*if( AmarokConfig::customRatingsColors() )
88 KIconEffect::colorize( tempstar, m_colors[i], 1.0 );
89 if( !AmarokConfig::fixedHalfStarColor() )
90 KIconEffect::colorize( temphalfstar, m_colors[i], 1.0 );
92 m_images
[i
] = tempstar
.copy();
93 m_halfimages
[i
] = temphalfstar
.copy();
94 m_pixmaps
[i
] = QPixmap::fromImage( tempstar
);
95 m_halfpixmaps
[i
] = QPixmap::fromImage( temphalfstar
);
97 temphalfstar
= QImage();
100 // if( Playlist::instance() ) Playlist::instance()->qscrollview()->viewport()->update();
102 if( CollectionView::instance() &&
103 CollectionView::instance()->viewMode() == CollectionView::modeFlatView )
104 CollectionView::instance()->triggerUpdate(); */
105 emit
ratingsColorsChanged();
109 StarManager::getStar( int num
)
111 if( num
< 1 || num
> 5 )
114 return &m_pixmaps
[num
- 1];
118 StarManager::getStarImage( int num
)
120 if( num
< 1 || num
> 5 )
123 return m_images
[num
- 1];
127 StarManager::getHalfStar( int num
)
129 /*if( AmarokConfig::fixedHalfStarColor() || num == -1 )
130 return &m_halfStarPix;
132 return &m_halfpixmaps
[num
- 1];
136 StarManager::getHalfStarImage( int num
)
138 /*if( AmarokConfig::fixedHalfStarColor() || num == -1 )
141 return m_halfimages
[num
- 1];
145 StarManager::setColor( int starNum
, const QColor
&color
)
147 if( starNum
< 1 || starNum
> 5 )
149 m_colors
[starNum
- 1] = color
;
154 StarManager::setHalfColor( const QColor
&color
)
156 m_halfStarColor
= color
;
160 #include "StarManager.moc"