-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 8fe572f..238770b 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -80,49 +80,49 @@ static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | |||
80 | 80 | ||
81 | 81 | ||
82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
84 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
85 | 85 | ||
86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
88 | 88 | ||
89 | Config cfg("OpiePlayer"); | 89 | Config cfg("OpiePlayer"); |
90 | cfg.setGroup("Options"); | 90 | cfg.setGroup("Options"); |
91 | skin = cfg.readEntry("Skin","default"); | 91 | skin = cfg.readEntry("Skin","default"); |
92 | 92 | ||
93 | QString skinPath = "opieplayer2/skins/" + skin; | 93 | QString skinPath = "opieplayer2/skins/" + skin; |
94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
97 | 97 | ||
98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
99 | imgButtonMask->fill( 0 ); | 99 | imgButtonMask->fill( 0 ); |
100 | 100 | ||
101 | for ( int i = 0; i < 7; i++ ) { | 101 | for ( int i = 0; i < 7; i++ ) { |
102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; | 102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; |
103 | masks[i] = new QBitmap( filename ); | 103 | masks[i] = new QBitmap( filename ); |
104 | qDebug(filename); | 104 | |
105 | if ( !masks[i]->isNull() ) { | 105 | if ( !masks[i]->isNull() ) { |
106 | QImage imgMask = masks[i]->convertToImage(); | 106 | QImage imgMask = masks[i]->convertToImage(); |
107 | uchar **dest = imgButtonMask->jumpTable(); | 107 | uchar **dest = imgButtonMask->jumpTable(); |
108 | for ( int y = 0; y < imgUp->height(); y++ ) { | 108 | for ( int y = 0; y < imgUp->height(); y++ ) { |
109 | uchar *line = dest[y]; | 109 | uchar *line = dest[y]; |
110 | for ( int x = 0; x < imgUp->width(); x++ ) { | 110 | for ( int x = 0; x < imgUp->width(); x++ ) { |
111 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 111 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
112 | line[x] = i + 1; | 112 | line[x] = i + 1; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | for ( int i = 0; i < 7; i++ ) { | 118 | for ( int i = 0; i < 7; i++ ) { |
119 | buttonPixUp[i] = NULL; | 119 | buttonPixUp[i] = NULL; |
120 | buttonPixDown[i] = NULL; | 120 | buttonPixDown[i] = NULL; |
121 | } | 121 | } |
122 | 122 | ||
123 | setBackgroundPixmap( *pixBg ); | 123 | setBackgroundPixmap( *pixBg ); |
124 | 124 | ||
125 | slider = new QSlider( Qt::Horizontal, this ); | 125 | slider = new QSlider( Qt::Horizontal, this ); |
126 | slider->setMinValue( 0 ); | 126 | slider->setMinValue( 0 ); |
127 | slider->setMaxValue( 1 ); | 127 | slider->setMaxValue( 1 ); |
128 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 128 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
@@ -158,64 +158,60 @@ VideoWidget::~VideoWidget() { | |||
158 | for ( int i = 0; i < 7; i++ ) { | 158 | for ( int i = 0; i < 7; i++ ) { |
159 | delete masks[i]; | 159 | delete masks[i]; |
160 | } | 160 | } |
161 | 161 | ||
162 | } | 162 | } |
163 | 163 | ||
164 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 164 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
165 | QPixmap pix( img.width(), img.height() ); | 165 | QPixmap pix( img.width(), img.height() ); |
166 | QPainter p( &pix ); | 166 | QPainter p( &pix ); |
167 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 167 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
168 | p.drawImage( 0, 0, img ); | 168 | p.drawImage( 0, 0, img ); |
169 | return new QPixmap( pix ); | 169 | return new QPixmap( pix ); |
170 | } | 170 | } |
171 | 171 | ||
172 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 172 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
173 | QPixmap *pixmap = new QPixmap( pix ); | 173 | QPixmap *pixmap = new QPixmap( pix ); |
174 | pixmap->setMask( mask ); | 174 | pixmap->setMask( mask ); |
175 | return pixmap; | 175 | return pixmap; |
176 | } | 176 | } |
177 | 177 | ||
178 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 178 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
179 | int h = height(); | 179 | int h = height(); |
180 | int w = width(); | 180 | int w = width(); |
181 | int Vh = 160; | 181 | int Vh = 160; |
182 | //videoFrame->height(); | ||
183 | int Vw = 220; | 182 | int Vw = 220; |
184 | //videoFrame->width(); | ||
185 | |||
186 | 183 | ||
187 | slider->setFixedWidth( w - 20 ); | 184 | slider->setFixedWidth( w - 20 ); |
188 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 185 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
189 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 186 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
190 | slider->setFocusPolicy( QWidget::NoFocus ); | 187 | slider->setFocusPolicy( QWidget::NoFocus ); |
191 | slider->setBackgroundPixmap( *pixBg ); | 188 | slider->setBackgroundPixmap( *pixBg ); |
192 | 189 | ||
193 | xoff = 0;// ( imgUp->width() ) / 2; | 190 | xoff = 0;// ( imgUp->width() ) / 2; |
194 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; | 191 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
195 | QPoint p( xoff, yoff ); | 192 | QPoint p( xoff, yoff ); |
196 | 193 | ||
197 | |||
198 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 194 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
199 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 195 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
200 | 196 | ||
201 | for ( int i = 0; i < 7; i++ ) { | 197 | for ( int i = 0; i < 7; i++ ) { |
202 | if ( !masks[i]->isNull() ) { | 198 | if ( !masks[i]->isNull() ) { |
203 | delete buttonPixUp[i]; | 199 | delete buttonPixUp[i]; |
204 | delete buttonPixDown[i]; | 200 | delete buttonPixDown[i]; |
205 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 201 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
206 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 202 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
207 | } | 203 | } |
208 | } | 204 | } |
209 | 205 | ||
210 | delete pixUp; | 206 | delete pixUp; |
211 | delete pixDn; | 207 | delete pixDn; |
212 | } | 208 | } |
213 | 209 | ||
214 | static bool videoSliderBeingMoved = FALSE; | 210 | static bool videoSliderBeingMoved = FALSE; |
215 | 211 | ||
216 | void VideoWidget::sliderPressed() { | 212 | void VideoWidget::sliderPressed() { |
217 | videoSliderBeingMoved = TRUE; | 213 | videoSliderBeingMoved = TRUE; |
218 | } | 214 | } |
219 | 215 | ||
220 | void VideoWidget::sliderReleased() { | 216 | void VideoWidget::sliderReleased() { |
221 | videoSliderBeingMoved = FALSE; | 217 | videoSliderBeingMoved = FALSE; |
@@ -438,56 +434,56 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | |||
438 | ////////////////////////////// Zaurus keys | 434 | ////////////////////////////// Zaurus keys |
439 | case Key_Home: | 435 | case Key_Home: |
440 | break; | 436 | break; |
441 | case Key_F9: //activity | 437 | case Key_F9: //activity |
442 | break; | 438 | break; |
443 | case Key_F10: //contacts | 439 | case Key_F10: //contacts |
444 | // hide(); | 440 | // hide(); |
445 | break; | 441 | break; |
446 | case Key_F11: //menu | 442 | case Key_F11: //menu |
447 | break; | 443 | break; |
448 | case Key_F12: //home | 444 | case Key_F12: //home |
449 | break; | 445 | break; |
450 | case Key_F13: //mail | 446 | case Key_F13: //mail |
451 | break; | 447 | break; |
452 | case Key_Space: { | 448 | case Key_Space: { |
453 | if(mediaPlayerState->playing()) { | 449 | if(mediaPlayerState->playing()) { |
454 | mediaPlayerState->setPlaying(FALSE); | 450 | mediaPlayerState->setPlaying(FALSE); |
455 | } else { | 451 | } else { |
456 | mediaPlayerState->setPlaying(TRUE); | 452 | mediaPlayerState->setPlaying(TRUE); |
457 | } | 453 | } |
458 | } | 454 | } |
459 | break; | 455 | break; |
460 | case Key_Down: | 456 | case Key_Down: |
461 | // toggleButton(6); | 457 | // toggleButton(6); |
462 | // emit lessClicked(); | 458 | emit lessClicked(); |
463 | // emit lessReleased(); | 459 | emit lessReleased(); |
464 | // toggleButton(6); | 460 | // toggleButton(6); |
465 | break; | 461 | break; |
466 | case Key_Up: | 462 | case Key_Up: |
467 | // toggleButton(5); | 463 | // toggleButton(5); |
468 | // emit moreClicked(); | 464 | emit moreClicked(); |
469 | // emit moreReleased(); | 465 | emit moreReleased(); |
470 | // toggleButton(5); | 466 | // toggleButton(5); |
471 | break; | 467 | break; |
472 | case Key_Right: | 468 | case Key_Right: |
473 | mediaPlayerState->setNext(); | 469 | mediaPlayerState->setNext(); |
474 | break; | 470 | break; |
475 | case Key_Left: | 471 | case Key_Left: |
476 | mediaPlayerState->setPrev(); | 472 | mediaPlayerState->setPrev(); |
477 | break; | 473 | break; |
478 | case Key_Escape: | 474 | case Key_Escape: |
479 | break; | 475 | break; |
480 | 476 | ||
481 | }; | 477 | }; |
482 | } | 478 | } |
483 | 479 | ||
484 | XineVideoWidget* VideoWidget::vidWidget() { | 480 | XineVideoWidget* VideoWidget::vidWidget() { |
485 | return videoFrame; | 481 | return videoFrame; |
486 | } | 482 | } |
487 | 483 | ||
488 | 484 | ||
489 | void VideoWidget::setFullscreen ( bool b ) { | 485 | void VideoWidget::setFullscreen ( bool b ) { |
490 | setToggleButton( VideoFullscreen, b ); | 486 | setToggleButton( VideoFullscreen, b ); |
491 | } | 487 | } |
492 | 488 | ||
493 | 489 | ||