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();
99 if( Playlist::instance() ) Playlist::instance()->qscrollview()->viewport()->update();
101 if( CollectionView::instance() &&
102 CollectionView::instance()->viewMode() == CollectionView::modeFlatView )
103 CollectionView::instance()->triggerUpdate(); */
104 emit
ratingsColorsChanged();
108 StarManager::getStar( int num
)
110 if( num
< 1 || num
> 5 )
113 return &m_pixmaps
[num
- 1];
117 StarManager::getStarImage( int num
)
119 if( num
< 1 || num
> 5 )
122 return m_images
[num
- 1];
126 StarManager::getHalfStar( int num
)
128 /*if( AmarokConfig::fixedHalfStarColor() || num == -1 )
129 return &m_halfStarPix;
131 return &m_halfpixmaps
[num
- 1];
135 StarManager::getHalfStarImage( int num
)
137 /*if( AmarokConfig::fixedHalfStarColor() || num == -1 )
140 return m_halfimages
[num
- 1];
144 StarManager::setColor( int starNum
, const QColor
&color
)
146 if( starNum
< 1 || starNum
> 5 )
148 m_colors
[starNum
- 1] = color
;
153 StarManager::setHalfColor( const QColor
&color
)
155 m_halfStarColor
= color
;
159 #include "StarManager.moc"