author | harlekin <harlekin> | 2002-08-15 20:51:11 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-15 20:51:11 (UTC) |
commit | be99f951c39d19a6e9923103434afdb293741d35 (patch) (side-by-side diff) | |
tree | 4fe4d6cc51eee0bbdd53c9b353624d104929f08b | |
parent | 157b5b1209b656960fc0b27fc077eb36a77b2c3f (diff) | |
download | opie-be99f951c39d19a6e9923103434afdb293741d35.zip opie-be99f951c39d19a6e9923103434afdb293741d35.tar.gz opie-be99f951c39d19a6e9923103434afdb293741d35.tar.bz2 |
click in fullscreen leeds to going back to the normal videowidget now
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 37 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 68 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.h | 15 |
5 files changed, 67 insertions, 56 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 93819f2..22afe19 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -1,170 +1,170 @@ #include <qpe/qpeapplication.h> #include <qpe/qlibrary.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qwidgetstack.h> #include <qfile.h> #include "mediaplayer.h" #include "playlistwidget.h" #include "audiowidget.h" #include "videowidget.h" #include "volumecontrol.h" #include "mediaplayerstate.h" extern AudioWidget *audioUI; extern VideoWidget *videoUI; extern PlayListWidget *playList; extern MediaPlayerState *mediaPlayerState; MediaPlayer::MediaPlayer( QObject *parent, const char *name ) : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { xineControl = new XineControl(); // QPEApplication::grabKeyboard(); // EVIL connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); volControl = new VolumeControl; } MediaPlayer::~MediaPlayer() { delete xineControl; delete volControl; } void MediaPlayer::pauseCheck( bool b ) { if ( b && !mediaPlayerState->playing() ) { mediaPlayerState->setPaused( FALSE ); } } void MediaPlayer::play() { mediaPlayerState->setPlaying( FALSE ); mediaPlayerState->setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { if ( !play ) { - //mediaPlayerState->setPaused( TRUE ); + // mediaPlayerState->setPaused( FALSE ); return; } if ( mediaPlayerState->paused() ) { mediaPlayerState->setPaused( FALSE ); return; } const DocLnk *playListCurrent = playList->current(); if ( playListCurrent != NULL ) { currentFile = playListCurrent; } xineControl->play( currentFile->file() ); xineControl->length(); long seconds = mediaPlayerState->length();// QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); qDebug(time); QString tickerText; if( currentFile->file().left(4) == "http" ) tickerText= tr( " File: " ) + currentFile->name(); else tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; // QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); // if ( !fileInfo.isEmpty() ) // tickerText += ", " + fileInfo; // audioUI->setTickerText( tickerText + "." ); audioUI->setTickerText( currentFile->file( ) ); } void MediaPlayer::prev() { if ( playList->prev() ) { play(); } else if ( mediaPlayerState->looping() ) { if ( playList->last() ) { play(); } } else { mediaPlayerState->setList(); } } void MediaPlayer::next() { if ( playList->next() ) { play(); } else if ( mediaPlayerState->looping() ) { if ( playList->first() ) { play(); } } else { mediaPlayerState->setList(); } } void MediaPlayer::startDecreasingVolume() { volumeDirection = -1; startTimer( 100 ); volControl->decVol(2); } void MediaPlayer::startIncreasingVolume() { volumeDirection = +1; startTimer( 100 ); volControl->incVol(2); } bool drawnOnScreenDisplay = FALSE; unsigned int onScreenDisplayVolume = 0; const int yoff = 110; void MediaPlayer::stopChangingVolume() { killTimers(); // Get rid of the on-screen display stuff drawnOnScreenDisplay = FALSE; onScreenDisplayVolume = 0; int w=0; int h=0; if( !xineControl->hasVideo()) { w = audioUI->width(); h = audioUI->height(); audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); } else { w = videoUI->width(); h = videoUI->height(); videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 238770b..c2080e6 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -1,183 +1,185 @@ /* This file is part of the Opie Project Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> Copyright (c) 2002 L. Potter <ljp@llornkcor.com> Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpe/resource.h> #include <qpe/mediaplayerplugininterface.h> #include <qpe/config.h> #include <qwidget.h> #include <qpainter.h> #include <qpixmap.h> #include <qslider.h> #include <qdrawutil.h> #include "videowidget.h" #include "mediaplayerstate.h" #ifdef Q_WS_QWS # define USE_DIRECT_PAINTER # include <qdirectpainter_qws.h> # include <qgfxraster_qws.h> #endif extern MediaPlayerState *mediaPlayerState; static const int xo = 2; // movable x offset static const int yo = 0; // movable y offset struct MediaButton { bool isToggle, isHeld, isDown; }; MediaButton videoButtons[] = { { FALSE, FALSE, FALSE }, // stop { TRUE, FALSE, FALSE }, // play { FALSE, FALSE, FALSE }, // previous { FALSE, FALSE, FALSE }, // next { FALSE, FALSE, FALSE }, // volUp { FALSE, FALSE, FALSE }, // volDown { TRUE, FALSE, FALSE } // fullscreen }; const char *skinV_mask_file_names[7] = { "stop","play","back","fwd","up","down","full" }; static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { setCaption( tr("OpiePlayer - Video") ); videoFrame = new XineVideoWidget ( this, "Video frame" ); + connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); + connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); QString skinPath = "opieplayer2/skins/" + skin; pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); imgButtonMask->fill( 0 ); for ( int i = 0; i < 7; i++ ) { QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; masks[i] = new QBitmap( filename ); if ( !masks[i]->isNull() ) { QImage imgMask = masks[i]->convertToImage(); uchar **dest = imgButtonMask->jumpTable(); for ( int y = 0; y < imgUp->height(); y++ ) { uchar *line = dest[y]; for ( int x = 0; x < imgUp->width(); x++ ) { if ( !qRed( imgMask.pixel( x, y ) ) ) line[x] = i + 1; } } } } for ( int i = 0; i < 7; i++ ) { buttonPixUp[i] = NULL; buttonPixDown[i] = NULL; } setBackgroundPixmap( *pixBg ); slider = new QSlider( Qt::Horizontal, this ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); slider->setFocusPolicy( QWidget::NoFocus ); resizeEvent( NULL ); connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setFullscreen( mediaPlayerState->fullscreen() ); // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); } VideoWidget::~VideoWidget() { for ( int i = 0; i < 7; i++ ) { delete buttonPixUp[i]; delete buttonPixDown[i]; } delete pixBg; delete imgUp; delete imgDn; delete imgButtonMask; for ( int i = 0; i < 7; i++ ) { delete masks[i]; } } QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); p.drawImage( 0, 0, img ); return new QPixmap( pix ); } QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } void VideoWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); int Vh = 160; int Vw = 220; @@ -250,241 +252,246 @@ void VideoWidget::setView( char view ) { if ( view == 'v' ) { makeVisible(); } else { // Effectively blank the view next time we show it so it looks nicer scaledWidth = 0; scaledHeight = 0; hide(); } } void VideoWidget::updateSlider( long i, long max ) { // Will flicker too much if we don't do this if ( max == 0 ) { return; } int width = slider->width(); int val = int((double)i * width / max); if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { if ( slider->value() != val ) { slider->setValue( val ); } if ( slider->maxValue() != width ) { slider->setMaxValue( width ); } } } void VideoWidget::setToggleButton( int i, bool down ) { if ( down != videoButtons[i].isDown ) { toggleButton( i ); } } void VideoWidget::toggleButton( int i ) { videoButtons[i].isDown = !videoButtons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void VideoWidget::paintButton( QPainter *p, int i ) { if ( videoButtons[i].isDown ) { p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); } else { p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); } } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numVButtons; i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not int x = event->pos().x() - xoff; int y = event->pos().y() - yoff; bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); if ( isOnButton && !videoButtons[i].isHeld ) { videoButtons[i].isHeld = TRUE; toggleButton(i); switch (i) { case VideoVolUp: emit moreClicked(); return; case VideoVolDown: emit lessClicked(); return; } } else if ( !isOnButton && videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; toggleButton(i); } } else { if ( videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; if ( !videoButtons[i].isToggle ) { setToggleButton( i, FALSE ); } switch(i) { case VideoPlay: { if( mediaPlayerState->isPaused ) { setToggleButton( i, FALSE ); mediaPlayerState->setPaused( FALSE ); return; } else if( !mediaPlayerState->isPaused ) { setToggleButton( i, TRUE ); mediaPlayerState->setPaused( TRUE ); return; } else { - // setToggleButton( i, TRUE ); - // mediaPlayerState->setPlaying( videoButtons[i].isDown ); + return; } } case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; case VideoNext: mediaPlayerState->setNext(); return; case VideoPrevious: mediaPlayerState->setPrev(); return; case VideoVolUp: emit moreReleased(); return; case VideoVolDown: emit lessReleased(); return; case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; } } } } } void VideoWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { if ( mediaPlayerState->fullscreen() ) { mediaPlayerState->setFullscreen( FALSE ); makeVisible(); } mouseMoveEvent( event ); } void VideoWidget::showEvent( QShowEvent* ) { QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); mouseMoveEvent( &event ); } + void VideoWidget::backToNormal() { + mediaPlayerState->setFullscreen( FALSE ); + makeVisible(); + } + void VideoWidget::makeVisible() { - if ( mediaPlayerState->fullscreen() ) { - setBackgroundMode( QWidget::NoBackground ); - showFullScreen(); - resize( qApp->desktop()->size() ); - slider->hide(); - videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); - } else { - showNormal(); - showMaximized(); - slider->show(); - videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); - qApp->processEvents(); - } + if ( mediaPlayerState->fullscreen() ) { + setBackgroundMode( QWidget::NoBackground ); + showFullScreen(); + resize( qApp->desktop()->size() ); + slider->hide(); + videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); + + } else { + showNormal(); + showMaximized(); + slider->show(); + videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); + qApp->processEvents(); + } } void VideoWidget::paintEvent( QPaintEvent * pe) { QPainter p( this ); if ( mediaPlayerState->fullscreen() ) { // Clear the background p.setBrush( QBrush( Qt::black ) ); } else { if ( !pe->erased() ) { // Combine with background and double buffer QPixmap pix( pe->rect().size() ); QPainter p( &pix ); p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); for ( int i = 0; i < numVButtons; i++ ) { paintButton( &p, i ); } QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); for ( int i = 0; i < numVButtons; i++ ) paintButton( &p, i ); } slider->repaint( TRUE ); } } void VideoWidget::closeEvent( QCloseEvent* ) { mediaPlayerState->setList(); } void VideoWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity break; case Key_F10: //contacts // hide(); break; case Key_F11: //menu break; case Key_F12: //home break; case Key_F13: //mail break; case Key_Space: { if(mediaPlayerState->playing()) { mediaPlayerState->setPlaying(FALSE); } else { mediaPlayerState->setPlaying(TRUE); } } break; case Key_Down: // toggleButton(6); emit lessClicked(); emit lessReleased(); // toggleButton(6); break; case Key_Up: // toggleButton(5); emit moreClicked(); emit moreReleased(); // toggleButton(5); break; case Key_Right: mediaPlayerState->setNext(); break; case Key_Left: mediaPlayerState->setPrev(); break; case Key_Escape: break; }; } XineVideoWidget* VideoWidget::vidWidget() { return videoFrame; } void VideoWidget::setFullscreen ( bool b ) { setToggleButton( VideoFullscreen, b ); } void VideoWidget::setPlaying( bool b) { diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index b35558b..990fa5f 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -1,122 +1,123 @@ /* This file is part of the Opie Project Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> Copyright (c) 2002 L. Potter <ljp@llornkcor.com> Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef VIDEO_WIDGET_H #define VIDEO_WIDGET_H #include <qwidget.h> #include "xinevideowidget.h" class QPixmap; class QSlider; enum VideoButtons { VideoStop = 0, VideoPlay, // VideoPause, VideoPrevious, VideoNext, VideoVolUp, VideoVolDown, VideoFullscreen }; class VideoWidget : public QWidget { Q_OBJECT public: VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); ~VideoWidget(); XineVideoWidget* vidWidget(); public slots: void updateSlider( long, long ); void sliderPressed( ); void sliderReleased( ); void setPlaying( bool b); void setFullscreen( bool b ); void makeVisible(); + void backToNormal(); void setPosition( long ); void setLength( long ); void setView( char ); signals: void moreClicked(); void lessClicked(); void moreReleased(); void lessReleased(); void sliderMoved( long ); void videoResized ( const QSize &s ); protected: void resizeEvent( QResizeEvent * ); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void closeEvent( QCloseEvent *event ); void keyReleaseEvent( QKeyEvent *e); private: // Ticker songInfo; QPixmap *pixBg; QImage *imgUp; QImage *imgDn; QImage *imgButtonMask; QBitmap *masks[7]; QPixmap *buttonPixUp[7]; QPixmap *buttonPixDown[7]; QString skin; // QPixmap *pixmaps[4]; int xoff, yoff; void paintButton( QPainter *p, int i ); void toggleButton( int ); void setToggleButton( int, bool ); QString backgroundPix; QSlider *slider; QPixmap *pixmaps[3]; QImage *currentFrame; int scaledWidth; int scaledHeight; XineVideoWidget* videoFrame; }; #endif // VIDEO_WIDGET_H diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index d65006b..3e28e54 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp @@ -1,268 +1,270 @@ /* This file is part of the Opie Project - + Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> Copyright (c) 2002 LJP <> Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - + */ #include <qimage.h> #include <qpainter.h> #include <qgfx_qws.h> #include <qdirectpainter_qws.h> #include <qgfx_qws.h> #include <qsize.h> #include <qapplication.h> #include <qpainter.h> #include <qpe/resource.h> #include "xinevideowidget.h" static inline void memcpy_rev ( void *dst, void *src, size_t len ) { ((char *) src ) += len; - len >>= 1; + len >>= 1; while ( len-- ) *((short int *) dst )++ = *--((short int *) src ); } static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) { len >>= 1; while ( len-- ) { *((short int *) dst )++ = *((short int *) src ); ((char *) src ) += step; } } static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) { len >>= 1; - + ((char *) src ) += ( len * step ); - + while ( len-- ) { ((char *) src ) -= step; *((short int *) dst )++ = *((short int *) src ); } } XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) { setBackgroundMode ( NoBackground ); m_image = 0; m_buff = 0; m_bytes_per_line_fb = qt_screen-> linestep ( ); m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; m_rotation = 0; } XineVideoWidget::~XineVideoWidget ( ) { delete m_image; } void XineVideoWidget::clear ( ) { m_buff = 0; repaint ( false ); } void XineVideoWidget::paintEvent ( QPaintEvent * ) { //qWarning( "painting <<<" ); if ( m_buff == 0 ) { QPainter p ( this ); p. fillRect ( rect ( ), black ); if ( m_image ) p. drawImage ( 0, 0, *m_image ); //qWarning ( "logo\n" ); } else { // qWarning ( "paintevent\n" ); - + QArray <QRect> qt_bug_workaround_clip_rects; - + { QDirectPainter dp ( this ); int rot = dp. transformOrientation ( ) + m_rotation; uchar *fb = dp. frameBuffer ( ); uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; - + QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); - + qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { const QRect &clip = dp. rect ( i ); - + qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); - - uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); + + uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); uchar *src = frame; - + switch ( rot ) { case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; } uint leftfill = 0; uint framefill = 0; uint rightfill = 0; uint clipwidth = clip. width ( ) * m_bytes_per_pixel; - + if ( clip. left ( ) < framerect. left ( )) leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; if ( clip. right ( ) > framerect. right ( )) rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; - + framefill = clipwidth - ( leftfill + rightfill ); for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { memset ( dst, 0, clipwidth ); } else { if ( leftfill ) memset ( dst, 0, leftfill ); - + if ( framefill ) { switch ( rot ) { case 0: memcpy ( dst + leftfill, src, framefill ); break; case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; } - } + } if ( rightfill ) memset ( dst + leftfill + framefill, 0, rightfill ); } - + dst += m_bytes_per_line_fb; - + switch ( rot ) { case 0: src += m_bytes_per_line_frame; break; case 1: src -= m_bytes_per_pixel; break; case 2: src -= m_bytes_per_line_frame; break; case 3: src += m_bytes_per_pixel; break; } } } } - //qWarning ( " ||| painting |||" ); + //qWarning ( " ||| painting |||" ); { // QVFB hack by MArtin Jones QPainter p ( this ); - for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { + for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); } } } //qWarning( "painting >>>" ); } void XineVideoWidget::setImage ( QImage* image ) { delete m_image; m_image = image; } void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) { bool rot90 = (( -m_rotation ) & 1 ); if ( rot90 ) { int d = w; w = h; h = d; } m_lastframe = m_thisframe; m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); // qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); m_buff = img; m_bytes_per_line_frame = bpl; repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); } void XineVideoWidget::resizeEvent ( QResizeEvent * ) { QSize s = size ( ); bool fs = ( s == qApp-> desktop ( )-> size ( )); - + m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; - + if ( fs && qt_screen-> isTransformed ( )) { - s = qt_screen-> mapToDevice ( s ); + s = qt_screen-> mapToDevice ( s ); } // qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); - + emit videoResized ( s ); } void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) { QWidget *p = parentWidget ( ); - + if ( p ) { - QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); - - QApplication::sendEvent ( p, &pme ); + // QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); + + // QApplication::sendEvent ( p, &pme ); + // emit clicked(); } } void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) { QWidget *p = parentWidget ( ); - + if ( p ) { - QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); - - QApplication::sendEvent ( p, &pme ); + // QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); + + // QApplication::sendEvent ( p, &pme ); + emit clicked(); } } diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h index 2fc627d..c5101da 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.h +++ b/noncore/multimedia/opieplayer2/xinevideowidget.h @@ -1,72 +1,73 @@ /* This file is part of the Opie Project Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> Copyright (c) 2002 LJP <> Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qwidget.h> #include "lib.h" class QImage; class XineVideoWidget : public QWidget { Q_OBJECT public: XineVideoWidget( QWidget* parent, const char* name ); ~XineVideoWidget(); QImage *image() { return m_image; }; void setImage( QImage* image ); void setImage( uchar* image, int width, int height, int linestep); void clear() ; - + protected: void paintEvent( QPaintEvent* p ); void resizeEvent ( QResizeEvent *r ); - void mousePressEvent ( QMouseEvent *e ); - void mouseReleaseEvent ( QMouseEvent *e ); + void mousePressEvent ( QMouseEvent *e ); + void mouseReleaseEvent ( QMouseEvent *e ); signals: - void videoResized ( const QSize &s ); - + void clicked(); + void videoResized ( const QSize &s ); + private: - QRect m_lastframe; - QRect m_thisframe; + QRect m_lastframe; + QRect m_thisframe; uchar* m_buff; int m_bytes_per_line_fb; int m_bytes_per_line_frame; int m_bytes_per_pixel; QImage* m_image; int m_rotation; }; |