summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp33
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp32
4 files changed, 42 insertions, 41 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index bb686f1..bb07882 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -121,47 +121,38 @@ QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
121 return pix; 121 return pix;
122} 122}
123 123
124 124
125QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { 125QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
126 QPixmap pixmap( pix ); 126 QPixmap pixmap( pix );
127 pixmap.setMask( mask ); 127 pixmap.setMask( mask );
128 return pixmap; 128 return pixmap;
129} 129}
130 130
131}; 131};
132 132
133void AudioWidget::resizeEvent( QResizeEvent * ) { 133void AudioWidget::resizeEvent( QResizeEvent *e ) {
134 int h = height(); 134 int h = height();
135 int w = width(); 135 int w = width();
136 136
137 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 137 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
138 slider.setFixedWidth( w - 110 ); 138 slider.setFixedWidth( w - 110 );
139 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 139 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
140 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 140 slider.setBackgroundOrigin( QWidget::ParentOrigin );
141 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 141 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
142 142
143 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; 143 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2;
144 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; 144 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10;
145 QPoint p = upperLeftOfButtonMask;
146 145
147 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, p ); 146 MediaWidget::resizeEvent( e );
148 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, p );
149
150 for ( uint i = 0; i < buttons.size(); i++ ) {
151 if ( !buttons[i].mask.isNull() ) {
152 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
153 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
154 }
155 }
156} 147}
157 148
158void AudioWidget::sliderPressed() { 149void AudioWidget::sliderPressed() {
159 audioSliderBeingMoved = TRUE; 150 audioSliderBeingMoved = TRUE;
160} 151}
161 152
162 153
163void AudioWidget::sliderReleased() { 154void AudioWidget::sliderReleased() {
164 audioSliderBeingMoved = FALSE; 155 audioSliderBeingMoved = FALSE;
165 if ( slider.width() == 0 ) 156 if ( slider.width() == 0 )
166 return; 157 return;
167 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 158 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index ab23aa8..ab2ec50 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -100,24 +100,41 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
100 QPainter p( &pix ); 100 QPainter p( &pix );
101 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 101 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
102 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 102 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
103 paintAllButtons( p ); 103 paintAllButtons( p );
104 QPainter p2( this ); 104 QPainter p2( this );
105 p2.drawPixmap( pe->rect().topLeft(), pix ); 105 p2.drawPixmap( pe->rect().topLeft(), pix );
106 } else { 106 } else {
107 QPainter p( this ); 107 QPainter p( this );
108 paintAllButtons( p ); 108 paintAllButtons( p );
109 } 109 }
110} 110}
111 111
112void MediaWidget::resizeEvent( QResizeEvent *e )
113{
114 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
115 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
116
117 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
118 Button &button = *it;
119
120 if ( button.mask.isNull() )
121 continue;
122 button.pixUp = addMaskToPixmap( pixUp, button.mask );
123 button.pixDown = addMaskToPixmap( pixDn, button.mask );
124 }
125
126 QWidget::resizeEvent( e );
127}
128
112MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 129MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
113{ 130{
114 if ( position.x() <= 0 || position.y() <= 0 || 131 if ( position.x() <= 0 || position.y() <= 0 ||
115 position.x() >= buttonMask.width() || 132 position.x() >= buttonMask.width() ||
116 position.y() >= buttonMask.height() ) 133 position.y() >= buttonMask.height() )
117 return 0; 134 return 0;
118 135
119 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 136 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
120 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 137 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
121 if ( it->command + 1 == pixelIdx ) 138 if ( it->command + 1 == pixelIdx )
122 return &( *it ); 139 return &( *it );
123 140
@@ -221,14 +238,30 @@ void MediaWidget::setToggleButton( Button &button, bool down )
221{ 238{
222 if ( down != button.isDown ) 239 if ( down != button.isDown )
223 toggleButton( button ); 240 toggleButton( button );
224} 241}
225 242
226void MediaWidget::toggleButton( Button &button ) 243void MediaWidget::toggleButton( Button &button )
227{ 244{
228 button.isDown = !button.isDown; 245 button.isDown = !button.isDown;
229 246
230 paintButton( button ); 247 paintButton( button );
231} 248}
232 249
250QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset )
251{
252 QPixmap pix( image.size() );
253 QPainter p( &pix );
254 p.drawTiledPixmap( pix.rect(), background, offset );
255 p.drawImage( 0, 0, image );
256 return pix;
257}
258
259QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask )
260{
261 QPixmap result( pix );
262 result.setMask( mask );
263 return result;
264}
265
233/* vim: et sw=4 ts=4 266/* vim: et sw=4 ts=4
234 */ 267 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 9f13677..4599637 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -103,24 +103,26 @@ signals:
103protected: 103protected:
104 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 104 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
105 const Skin &skin ); 105 const Skin &skin );
106 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ); 106 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin );
107 107
108 void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null ); 108 void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null );
109 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ); 109 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin );
110 110
111 virtual void closeEvent( QCloseEvent * ); 111 virtual void closeEvent( QCloseEvent * );
112 112
113 virtual void paintEvent( QPaintEvent *pe ); 113 virtual void paintEvent( QPaintEvent *pe );
114 114
115 virtual void resizeEvent( QResizeEvent *e );
116
115 Button *buttonAt( const QPoint &position ); 117 Button *buttonAt( const QPoint &position );
116 118
117 virtual void mousePressEvent( QMouseEvent *event ); 119 virtual void mousePressEvent( QMouseEvent *event );
118 virtual void mouseReleaseEvent( QMouseEvent *event ); 120 virtual void mouseReleaseEvent( QMouseEvent *event );
119 121
120 virtual void makeVisible(); 122 virtual void makeVisible();
121 123
122 void handleCommand( Command command, bool buttonDown ); 124 void handleCommand( Command command, bool buttonDown );
123 125
124 bool isOverButton( const QPoint &position, int buttonId ) const; 126 bool isOverButton( const QPoint &position, int buttonId ) const;
125 127
126 void paintAllButtons( QPainter &p ); 128 void paintAllButtons( QPainter &p );
@@ -134,17 +136,20 @@ protected:
134 MediaPlayerState &mediaPlayerState; 136 MediaPlayerState &mediaPlayerState;
135 PlayListWidget &playList; 137 PlayListWidget &playList;
136 138
137 ButtonVector buttons; 139 ButtonVector buttons;
138 140
139 QImage buttonMask; 141 QImage buttonMask;
140 142
141 QPoint upperLeftOfButtonMask; 143 QPoint upperLeftOfButtonMask;
142 144
143 QPixmap backgroundPixmap; 145 QPixmap backgroundPixmap;
144 QImage buttonUpImage; 146 QImage buttonUpImage;
145 QImage buttonDownImage; 147 QImage buttonDownImage;
148
149 static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset );
150 static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask );
146}; 151};
147 152
148#endif // MEDIAWIDGET_H 153#endif // MEDIAWIDGET_H
149/* vim: et sw=4 ts=4 154/* vim: et sw=4 ts=4
150 */ 155 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index bc47717..a8ff540 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -90,71 +90,43 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
90 90
91 setLength( mediaPlayerState.length() ); 91 setLength( mediaPlayerState.length() );
92 setPosition( mediaPlayerState.position() ); 92 setPosition( mediaPlayerState.position() );
93 setFullscreen( mediaPlayerState.isFullscreen() ); 93 setFullscreen( mediaPlayerState.isFullscreen() );
94 setPlaying( mediaPlayerState.isPlaying() ); 94 setPlaying( mediaPlayerState.isPlaying() );
95} 95}
96 96
97 97
98VideoWidget::~VideoWidget() 98VideoWidget::~VideoWidget()
99{ 99{
100} 100}
101 101
102QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 102void VideoWidget::resizeEvent( QResizeEvent *e ) {
103 QPixmap pix( img.width(), img.height() );
104 QPainter p( &pix );
105 p.drawTiledPixmap( pix.rect(), bg, offset );
106 p.drawImage( 0, 0, img );
107 return new QPixmap( pix );
108}
109
110QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
111 QPixmap pixmap( pix );
112 pixmap.setMask( mask );
113 return pixmap;
114}
115
116void VideoWidget::resizeEvent( QResizeEvent * ) {
117 int h = height(); 103 int h = height();
118 int w = width(); 104 int w = width();
119 //int Vh = 160; 105 //int Vh = 160;
120 //int Vw = 220; 106 //int Vw = 220;
121 107
122 slider->setFixedWidth( w - 20 ); 108 slider->setFixedWidth( w - 20 );
123 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 109 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
124 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 110 slider->setBackgroundOrigin( QWidget::ParentOrigin );
125 slider->setFocusPolicy( QWidget::NoFocus ); 111 slider->setFocusPolicy( QWidget::NoFocus );
126 slider->setBackgroundPixmap( backgroundPixmap ); 112 slider->setBackgroundPixmap( backgroundPixmap );
127 113
128 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 114 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
129 if(w>h) 115 if(w>h)
130 upperLeftOfButtonMask.ry() = 0; 116 upperLeftOfButtonMask.ry() = 0;
131 else 117 else
132 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 118 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
133 QPoint p = upperLeftOfButtonMask;
134
135 QPixmap *pixUp = combineVImageWithBackground( buttonUpImage, backgroundPixmap, p );
136 QPixmap *pixDn = combineVImageWithBackground( buttonDownImage, backgroundPixmap, p );
137
138 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
139 Button &button = *it;
140
141 if ( !button.mask.isNull() ) {
142 button.pixUp = maskVPixToMask( *pixUp, button.mask );
143 button.pixDown = maskVPixToMask( *pixDn, button.mask );
144 }
145 }
146 119
147 delete pixUp; 120 MediaWidget::resizeEvent( e );
148 delete pixDn;
149} 121}
150 122
151void VideoWidget::sliderPressed() { 123void VideoWidget::sliderPressed() {
152 videoSliderBeingMoved = TRUE; 124 videoSliderBeingMoved = TRUE;
153} 125}
154 126
155void VideoWidget::sliderReleased() { 127void VideoWidget::sliderReleased() {
156 videoSliderBeingMoved = FALSE; 128 videoSliderBeingMoved = FALSE;
157 if ( slider->width() == 0 ) { 129 if ( slider->width() == 0 ) {
158 return; 130 return;
159 } 131 }
160 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 132 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());