author | simon <simon> | 2002-12-02 19:46:48 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 19:46:48 (UTC) |
commit | e77f4914311d8a623c084d01a287798440abf01f (patch) (side-by-side diff) | |
tree | 673375b737c4b1435929cdc804641b08d20e62c8 | |
parent | 1706751f05c1d4312beb1ca939a156b090c7b5f6 (diff) | |
download | opie-e77f4914311d8a623c084d01a287798440abf01f.zip opie-e77f4914311d8a623c084d01a287798440abf01f.tar.gz opie-e77f4914311d8a623c084d01a287798440abf01f.tar.bz2 |
- inherit from MediaWidget
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 9 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 6 |
4 files changed, 12 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 1600320..0b7d470 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -45,167 +45,166 @@ #include <qdir.h> #include <stdlib.h> #include <stdio.h> #include "audiowidget.h" #include "mediaplayerstate.h" #include "playlistwidget.h" extern MediaPlayerState *mediaPlayerState; extern PlayListWidget *playList; static const int xo = -2; // movable x offset static const int yo = 22; // movable y offset struct MediaButton { bool isToggle, isHeld, isDown; }; //Layout information for the audioButtons (and if it is a toggle button or not) MediaButton audioButtons[] = { { TRUE, FALSE, FALSE }, // play { FALSE, FALSE, FALSE }, // stop { FALSE, FALSE, FALSE }, // next { FALSE, FALSE, FALSE }, // previous { FALSE, FALSE, FALSE }, // volume up { FALSE, FALSE, FALSE }, // volume down { TRUE, FALSE, FALSE }, // repeat/loop { FALSE, FALSE, FALSE }, // playlist { FALSE, FALSE, FALSE }, // forward { FALSE, FALSE, FALSE } // back }; const char * const skin_mask_file_names[10] = { "play", "stop", "next", "prev", "up", "down", "loop", "playlist", "forward", "back" }; static void changeTextColor( QWidget *w ) { QPalette p = w->palette(); p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); w->setPalette( p ); } static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); -AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : +AudioWidget::AudioWidget(QWidget* parent, const char* name) : - QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { + MediaWidget( parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { setCaption( tr("OpiePlayer") ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency QString skinPath = "opieplayer2/skins/" + skin; pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); imgButtonMask.fill( 0 ); for ( int i = 0; i < 10; i++ ) { QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_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 < 10; i++ ) { buttonPixUp[i] = 0l; buttonPixDown[i] = 0l; } setBackgroundPixmap( pixBg ); songInfo.setFocusPolicy( QWidget::NoFocus ); // changeTextColor( &songInfo ); // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); // songInfo.setFrameStyle( QFrame::NoFrame); songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); // songInfo.setForegroundColor(Qt::white); slider.setFixedHeight( 20 ); slider.setMinValue( 0 ); slider.setMaxValue( 1 ); slider.setFocusPolicy( QWidget::NoFocus ); slider.setBackgroundPixmap( pixBg ); // Config cofg("qpe"); // cofg.setGroup("Appearance"); // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); time.setFocusPolicy( QWidget::NoFocus ); time.setAlignment( Qt::AlignCenter ); // time.setFrame(FALSE); // changeTextColor( &time ); resizeEvent( NULL ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); - connect( mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->isFullscreen() ); // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->isPlaying() ); } AudioWidget::~AudioWidget() { for ( int i = 0; i < 10; i++ ) { delete buttonPixUp[i]; delete buttonPixDown[i]; } for ( int i = 0; i < 10; i++ ) { delete masks[i]; } // mediaPlayerState->setPlaying(false); } namespace { QPixmap combineImageWithBackground( 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 pix; } QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } }; diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 91fcbc5..74c5b0e 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -1,131 +1,132 @@ /* 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 AUDIO_WIDGET_H #define AUDIO_WIDGET_H -#include <qwidget.h> #include <qpainter.h> #include <qdrawutil.h> #include <qpixmap.h> #include <qstring.h> #include <qslider.h> #include <qframe.h> #include <qlineedit.h> #include <qimage.h> #include <opie/oticker.h> -#include "mediaplayerstate.h" +#include "mediawidget.h" class QPixmap; namespace { enum AudioButtons { AudioPlay=0, AudioStop, AudioNext, AudioPrevious, AudioVolumeUp, AudioVolumeDown, AudioLoop, AudioPlayList, AudioForward, AudioBack }; }; -class AudioWidget : public QWidget { +class AudioWidget : public MediaWidget { Q_OBJECT public: - AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); + AudioWidget( QWidget* parent=0, const char* name=0 ); ~AudioWidget(); void setTickerText( const QString &text ) { songInfo.setText( text ); } public slots: void updateSlider( long, long ); void sliderPressed( ); void sliderReleased( ); void setLooping( bool b) { setToggleButton( AudioLoop, b ); } void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } void setPosition( long ); void setLength( long ); void setSeekable( bool ); + +public: void setDisplayType( MediaPlayerState::DisplayType displayType ); signals: void moreClicked(); void lessClicked(); void moreReleased(); void lessReleased(); void forwardClicked(); void backClicked(); void forwardReleased(); void backReleased(); void sliderMoved(long); protected: void doBlank(); void doUnblank(); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void resizeEvent( QResizeEvent *re ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void timerEvent( QTimerEvent *event ); void closeEvent( QCloseEvent *event ); void keyReleaseEvent( QKeyEvent *e); private slots: void skipFor(); void skipBack(); void stopSkip(); private: void toggleButton( int ); void setToggleButton( int, bool ); void paintButton( QPainter *p, int i ); int skipDirection; QString skin; QPixmap pixBg; QImage imgUp; QImage imgDn; QImage imgButtonMask; QBitmap *masks[10]; QPixmap *buttonPixUp[10]; QPixmap *buttonPixDown[10]; QPixmap *pixmaps[4]; OTicker songInfo; QSlider slider; QLineEdit time; int xoff, yoff; diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 9ce2b57..8a0016e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -38,153 +38,152 @@ #include <qwidget.h> #include <qpainter.h> #include <qpixmap.h> #include <qslider.h> #include <qdrawutil.h> #include "videowidget.h" #include "mediaplayerstate.h" #include "playlistwidget.h" #ifdef Q_WS_QWS # define USE_DIRECT_PAINTER # include <qdirectpainter_qws.h> # include <qgfxraster_qws.h> #endif extern MediaPlayerState *mediaPlayerState; extern PlayListWidget *playList; 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 ) { +VideoWidget::VideoWidget(QWidget* parent, const char* name) : +MediaWidget( parent, name ), 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( QPEApplication::qpeDir() + "/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( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); - connect( mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setFullscreen( mediaPlayerState->isFullscreen() ); setPlaying( mediaPlayerState->isPlaying() ); } 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; slider->setFixedWidth( w - 20 ); slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 89af646..8e9dd7e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -1,107 +1,107 @@ /* 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" -#include "mediaplayerstate.h" +#include "mediawidget.h" class QPixmap; class QSlider; enum VideoButtons { VideoStop = 0, VideoPlay, // VideoPause, VideoPrevious, VideoNext, VideoVolUp, VideoVolDown, VideoFullscreen }; -class VideoWidget : public QWidget { +class VideoWidget : public MediaWidget { Q_OBJECT public: - VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); + VideoWidget( QWidget* parent=0, const char* name=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 setDisplayType( MediaPlayerState::DisplayType displayType ); 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; |