-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 4 |
2 files changed, 12 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index adef247..fe7ddc1 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -107,18 +107,20 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye | |||
107 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 107 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
108 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 108 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
109 | 109 | ||
110 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 110 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
111 | buttonMask.fill( 0 ); | 111 | buttonMask.fill( 0 ); |
112 | 112 | ||
113 | for ( int i = 0; i < 10; i++ ) { | 113 | masks.reserve( 10 ); |
114 | |||
115 | for ( uint i = 0; i < masks.capacity(); i++ ) { | ||
114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 116 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
115 | masks[i] = new QBitmap( filename ); | 117 | masks.push_back( QBitmap( filename ) ); |
116 | 118 | ||
117 | if ( !masks[i]->isNull() ) { | 119 | if ( !masks[i].isNull() ) { |
118 | QImage imgMask = masks[i]->convertToImage(); | 120 | QImage imgMask = masks[i].convertToImage(); |
119 | uchar **dest = buttonMask.jumpTable(); | 121 | uchar **dest = buttonMask.jumpTable(); |
120 | for ( int y = 0; y < imgUp.height(); y++ ) { | 122 | for ( int y = 0; y < imgUp.height(); y++ ) { |
121 | uchar *line = dest[y]; | 123 | uchar *line = dest[y]; |
122 | for ( int x = 0; x < imgUp.width(); x++ ) | 124 | for ( int x = 0; x < imgUp.width(); x++ ) |
123 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 125 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
124 | line[x] = i + 1; | 126 | line[x] = i + 1; |
@@ -179,15 +181,12 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye | |||
179 | AudioWidget::~AudioWidget() { | 181 | AudioWidget::~AudioWidget() { |
180 | 182 | ||
181 | for ( int i = 0; i < 10; i++ ) { | 183 | for ( int i = 0; i < 10; i++ ) { |
182 | delete buttonPixUp[i]; | 184 | delete buttonPixUp[i]; |
183 | delete buttonPixDown[i]; | 185 | delete buttonPixDown[i]; |
184 | } | 186 | } |
185 | for ( int i = 0; i < 10; i++ ) { | ||
186 | delete masks[i]; | ||
187 | } | ||
188 | // mediaPlayerState->setPlaying(false); | 187 | // mediaPlayerState->setPlaying(false); |
189 | } | 188 | } |
190 | 189 | ||
191 | namespace { | 190 | namespace { |
192 | 191 | ||
193 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 192 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
@@ -222,17 +221,17 @@ void AudioWidget::resizeEvent( QResizeEvent * ) { | |||
222 | QPoint p = upperLeftOfButtonMask; | 221 | QPoint p = upperLeftOfButtonMask; |
223 | 222 | ||
224 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); | 223 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); |
225 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); | 224 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); |
226 | 225 | ||
227 | for ( int i = 0; i < 10; i++ ) { | 226 | for ( int i = 0; i < 10; i++ ) { |
228 | if ( !masks[i]->isNull() ) { | 227 | if ( !masks[i].isNull() ) { |
229 | delete buttonPixUp[i]; | 228 | delete buttonPixUp[i]; |
230 | delete buttonPixDown[i]; | 229 | delete buttonPixDown[i]; |
231 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); | 230 | buttonPixUp[i] = maskPixToMask( pixUp, masks[i] ); |
232 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); | 231 | buttonPixDown[i] = maskPixToMask( pixDn, masks[i] ); |
233 | } | 232 | } |
234 | } | 233 | } |
235 | } | 234 | } |
236 | 235 | ||
237 | void AudioWidget::sliderPressed() { | 236 | void AudioWidget::sliderPressed() { |
238 | audioSliderBeingMoved = TRUE; | 237 | audioSliderBeingMoved = TRUE; |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 8426490..bc7262c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -88,20 +88,22 @@ protected: | |||
88 | void keyReleaseEvent( QKeyEvent *e); | 88 | void keyReleaseEvent( QKeyEvent *e); |
89 | private slots: | 89 | private slots: |
90 | void skipFor(); | 90 | void skipFor(); |
91 | void skipBack(); | 91 | void skipBack(); |
92 | void stopSkip(); | 92 | void stopSkip(); |
93 | private: | 93 | private: |
94 | typedef std::vector<QBitmap> MaskVector; | ||
95 | |||
94 | void setToggleButton( int, bool ); | 96 | void setToggleButton( int, bool ); |
95 | virtual void paintButton( QPainter &p, int i ); | 97 | virtual void paintButton( QPainter &p, int i ); |
96 | int skipDirection; | 98 | int skipDirection; |
97 | QString skin; | 99 | QString skin; |
98 | QPixmap pixBg; | 100 | QPixmap pixBg; |
99 | QImage imgUp; | 101 | QImage imgUp; |
100 | QImage imgDn; | 102 | QImage imgDn; |
101 | QBitmap *masks[10]; | 103 | MaskVector masks; |
102 | QPixmap *buttonPixUp[10]; | 104 | QPixmap *buttonPixUp[10]; |
103 | QPixmap *buttonPixDown[10]; | 105 | QPixmap *buttonPixDown[10]; |
104 | 106 | ||
105 | QPixmap *pixmaps[4]; | 107 | QPixmap *pixmaps[4]; |
106 | OTicker songInfo; | 108 | OTicker songInfo; |
107 | QSlider slider; | 109 | QSlider slider; |