summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 21:29:21 (UTC)
committer simon <simon>2002-12-09 21:29:21 (UTC)
commita9015ff25ddec67983f78f2a75346f21b7d062c5 (patch) (unidiff)
treea7f4e0e536f4394bf0392079484ca96592b62183
parente95602de0209b1add5f394ce8b87d5f67213643d (diff)
downloadopie-a9015ff25ddec67983f78f2a75346f21b7d062c5.zip
opie-a9015ff25ddec67983f78f2a75346f21b7d062c5.tar.gz
opie-a9015ff25ddec67983f78f2a75346f21b7d062c5.tar.bz2
- the skin loading code is now centralized. no more duplicated code :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp43
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp25
4 files changed, 50 insertions, 48 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 23d12ec..fd18dbb 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -78,72 +78,49 @@ void changeTextColor( QWidget * w) {
78 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 78 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
79 w->setPalette( p ); 79 w->setPalette( p );
80} 80}
81 81
82} 82}
83 83
84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
85 85
86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
87 audioSliderBeingMoved( false ) 87 audioSliderBeingMoved( false )
88{ 88{
89 setCaption( tr("OpiePlayer") ); 89 setCaption( tr("OpiePlayer") );
90 90
91 Config cfg("OpiePlayer"); 91 Config cfg("OpiePlayer");
92 cfg.setGroup("Options"); 92 cfg.setGroup("Options");
93 skin = cfg.readEntry("Skin","default"); 93 skin = cfg.readEntry("Skin","default");
94 //skin = "scaleTest"; 94 //skin = "scaleTest";
95 // color of background, frame, degree of transparency 95 // color of background, frame, degree of transparency
96 96
97 QString skinPath = "opieplayer2/skins/" + skin; 97 QString skinPath = "opieplayer2/skins/" + skin;
98 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 98 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
99 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 99 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
100 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 100 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
101 101
102 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 102 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() );
103 buttonMask.fill( 0 );
104
105 for ( uint i = 0; i < buttonCount; i++ ) {
106 Button button;
107 button.command = skinInfo[ i ].command;
108 button.type = skinInfo[ i ].type;
109
110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" );
111 button.mask =QBitmap( filename );
112
113 if ( !button.mask.isNull() ) {
114 QImage imgMask = button.mask.convertToImage();
115 uchar **dest = buttonMask.jumpTable();
116 for ( int y = 0; y < imgUp.height(); y++ ) {
117 uchar *line = dest[y];
118 for ( int x = 0; x < imgUp.width(); x++ )
119 if ( !qRed( imgMask.pixel( x, y ) ) )
120 line[x] = button.command + 1;
121 }
122 }
123
124 buttons.push_back( button );
125 }
126 103
127 setBackgroundPixmap( backgroundPixmap ); 104 setBackgroundPixmap( backgroundPixmap );
128 105
129 songInfo.setFocusPolicy( QWidget::NoFocus ); 106 songInfo.setFocusPolicy( QWidget::NoFocus );
130// changeTextColor( &songInfo ); 107// changeTextColor( &songInfo );
131// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 108// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
132// songInfo.setFrameStyle( QFrame::NoFrame); 109// songInfo.setFrameStyle( QFrame::NoFrame);
133 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 110 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
134// songInfo.setForegroundColor(Qt::white); 111// songInfo.setForegroundColor(Qt::white);
135 112
136 slider.setFixedHeight( 20 ); 113 slider.setFixedHeight( 20 );
137 slider.setMinValue( 0 ); 114 slider.setMinValue( 0 );
138 slider.setMaxValue( 1 ); 115 slider.setMaxValue( 1 );
139 slider.setFocusPolicy( QWidget::NoFocus ); 116 slider.setFocusPolicy( QWidget::NoFocus );
140 slider.setBackgroundPixmap( backgroundPixmap ); 117 slider.setBackgroundPixmap( backgroundPixmap );
141 118
142// Config cofg("qpe"); 119// Config cofg("qpe");
143// cofg.setGroup("Appearance"); 120// cofg.setGroup("Appearance");
144// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 121// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
145 122
146 time.setFocusPolicy( QWidget::NoFocus ); 123 time.setFocusPolicy( QWidget::NoFocus );
147 time.setAlignment( Qt::AlignCenter ); 124 time.setAlignment( Qt::AlignCenter );
148 125
149// time.setFrame(FALSE); 126// time.setFrame(FALSE);
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 4c4cead..db16b44 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -18,48 +18,91 @@
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23 23
24#include "mediawidget.h" 24#include "mediawidget.h"
25#include "playlistwidget.h" 25#include "playlistwidget.h"
26 26
27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
29{ 29{
30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
33 this, SLOT( setLength( long ) ) ); 33 this, SLOT( setLength( long ) ) );
34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
35 this, SLOT( setPlaying( bool ) ) ); 35 this, SLOT( setPlaying( bool ) ) );
36} 36}
37 37
38MediaWidget::~MediaWidget() 38MediaWidget::~MediaWidget()
39{ 39{
40} 40}
41 41
42void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
43 const QString &imagePrefix, const QSize &buttonAreaSize )
44{
45 buttonMask = QImage( buttonAreaSize, 8, 255 );
46 buttonMask.fill( 0 );
47
48 for ( uint i = 0; i < buttonCount; ++i ) {
49 Button button = setupButton( skinInfo[ i ], imagePrefix );
50 buttons.push_back( button );
51 }
52}
53
54MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix )
55{
56 Button button;
57 button.command = buttonInfo.command;
58 button.type = buttonInfo.type;
59
60 QString fileName = imagePrefix + buttonInfo.fileName + ".png";
61
62 button.mask = setupButtonMask( button.command, fileName );
63
64 return button;
65}
66
67QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName )
68{
69 QBitmap mask( fileName );
70 if ( mask.isNull() )
71 return mask;
72
73 QImage imgMask = mask.convertToImage();
74 uchar **dest = buttonMask.jumpTable();
75 for ( int y = 0; y < buttonMask.height(); y++ ) {
76 uchar *line = dest[y];
77 for ( int x = 0; x < buttonMask.width(); x++ )
78 if ( !qRed( imgMask.pixel( x, y ) ) )
79 line[x] = command + 1;
80 }
81
82 return mask;
83}
84
42void MediaWidget::closeEvent( QCloseEvent * ) 85void MediaWidget::closeEvent( QCloseEvent * )
43{ 86{
44 mediaPlayerState.setList(); 87 mediaPlayerState.setList();
45} 88}
46 89
47void MediaWidget::paintEvent( QPaintEvent *pe ) 90void MediaWidget::paintEvent( QPaintEvent *pe )
48{ 91{
49 QPainter p( this ); 92 QPainter p( this );
50 93
51 if ( mediaPlayerState.isFullscreen() ) { 94 if ( mediaPlayerState.isFullscreen() ) {
52 // Clear the background 95 // Clear the background
53 p.setBrush( QBrush( Qt::black ) ); 96 p.setBrush( QBrush( Qt::black ) );
54 return; 97 return;
55 } 98 }
56 99
57 if ( !pe->erased() ) { 100 if ( !pe->erased() ) {
58 // Combine with background and double buffer 101 // Combine with background and double buffer
59 QPixmap pix( pe->rect().size() ); 102 QPixmap pix( pe->rect().size() );
60 QPainter p( &pix ); 103 QPainter p( &pix );
61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 104 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 105 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
63 paintAllButtons( p ); 106 paintAllButtons( p );
64 QPainter p2( this ); 107 QPainter p2( this );
65 p2.drawPixmap( pe->rect().topLeft(), pix ); 108 p2.drawPixmap( pe->rect().topLeft(), pix );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 8031371..148948a 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -62,48 +62,53 @@ public:
62 }; 62 };
63 63
64 typedef std::vector<QBitmap> MaskVector; 64 typedef std::vector<QBitmap> MaskVector;
65 typedef std::vector<QPixmap> PixmapVector; 65 typedef std::vector<QPixmap> PixmapVector;
66 66
67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
68 virtual ~MediaWidget(); 68 virtual ~MediaWidget();
69 69
70public slots: 70public slots:
71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
72 virtual void setLength( long length ) = 0; 72 virtual void setLength( long length ) = 0;
73 virtual void setPlaying( bool playing ) = 0; 73 virtual void setPlaying( bool playing ) = 0;
74 74
75signals: 75signals:
76 void moreReleased(); 76 void moreReleased();
77 void lessReleased(); 77 void lessReleased();
78 void forwardReleased(); 78 void forwardReleased();
79 void backReleased(); 79 void backReleased();
80 void forwardClicked(); 80 void forwardClicked();
81 void backClicked(); 81 void backClicked();
82 void moreClicked(); 82 void moreClicked();
83 void lessClicked(); 83 void lessClicked();
84 84
85protected: 85protected:
86 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
87 const QString &imagePrefix, const QSize &buttonAreaSize );
88 Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix );
89 QBitmap setupButtonMask( const Command &command, const QString &fileName );
90
86 virtual void closeEvent( QCloseEvent * ); 91 virtual void closeEvent( QCloseEvent * );
87 92
88 virtual void paintEvent( QPaintEvent *pe ); 93 virtual void paintEvent( QPaintEvent *pe );
89 94
90 Button *buttonAt( const QPoint &position ); 95 Button *buttonAt( const QPoint &position );
91 96
92 virtual void mousePressEvent( QMouseEvent *event ); 97 virtual void mousePressEvent( QMouseEvent *event );
93 virtual void mouseReleaseEvent( QMouseEvent *event ); 98 virtual void mouseReleaseEvent( QMouseEvent *event );
94 99
95 virtual void makeVisible(); 100 virtual void makeVisible();
96 101
97 void handleCommand( Command command, bool buttonDown ); 102 void handleCommand( Command command, bool buttonDown );
98 103
99 bool isOverButton( const QPoint &position, int buttonId ) const; 104 bool isOverButton( const QPoint &position, int buttonId ) const;
100 105
101 void paintAllButtons( QPainter &p ); 106 void paintAllButtons( QPainter &p );
102 void paintButton( const Button &button ); 107 void paintButton( const Button &button );
103 void paintButton( QPainter &p, const Button &button ); 108 void paintButton( QPainter &p, const Button &button );
104 109
105 void setToggleButton( Button &button, bool down ); 110 void setToggleButton( Button &button, bool down );
106 void setToggleButton( Command command, bool down ); 111 void setToggleButton( Command command, bool down );
107 void toggleButton( Button &button ); 112 void toggleButton( Button &button );
108 113
109 MediaPlayerState &mediaPlayerState; 114 MediaPlayerState &mediaPlayerState;
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 4901e47..d1efaad 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -73,72 +73,49 @@ const MediaWidget::SkinButtonInfo skinInfo[] =
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 74
75} 75}
76 76
77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) 78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
79{ 79{
80 setCaption( tr("OpiePlayer - Video") ); 80 setCaption( tr("OpiePlayer - Video") );
81 81
82 82
83 videoFrame = new XineVideoWidget ( this, "Video frame" ); 83 videoFrame = new XineVideoWidget ( this, "Video frame" );
84 84
85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
87 87
88 Config cfg("OpiePlayer"); 88 Config cfg("OpiePlayer");
89 cfg.setGroup("Options"); 89 cfg.setGroup("Options");
90 skin = cfg.readEntry("Skin","default"); 90 skin = cfg.readEntry("Skin","default");
91 91
92 QString skinPath = "opieplayer2/skins/" + skin; 92 QString skinPath = "opieplayer2/skins/" + skin;
93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96 96
97 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 97 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() );
98 buttonMask.fill( 0 );
99
100 for ( uint i = 0; i < buttonCount; i++ ) {
101 Button button;
102 button.command = skinInfo[ i ].command;
103 button.type = skinInfo[ i ].type;
104
105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" );
106 button.mask =QBitmap( filename );
107
108 if ( !button.mask.isNull() ) {
109 QImage imgMask = button.mask.convertToImage();
110 uchar **dest = buttonMask.jumpTable();
111 for ( int y = 0; y < imgUp.height(); y++ ) {
112 uchar *line = dest[y];
113 for ( int x = 0; x < imgUp.width(); x++ )
114 if ( !qRed( imgMask.pixel( x, y ) ) )
115 line[x] = button.command + 1;
116 }
117 }
118
119 buttons.push_back( button );
120 }
121 98
122 setBackgroundPixmap( backgroundPixmap ); 99 setBackgroundPixmap( backgroundPixmap );
123 100
124 slider = new QSlider( Qt::Horizontal, this ); 101 slider = new QSlider( Qt::Horizontal, this );
125 slider->setMinValue( 0 ); 102 slider->setMinValue( 0 );
126 slider->setMaxValue( 1 ); 103 slider->setMaxValue( 1 );
127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 104 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
128 //slider->setFocusPolicy( QWidget::NoFocus ); 105 //slider->setFocusPolicy( QWidget::NoFocus );
129 106
130 resizeEvent( NULL ); 107 resizeEvent( NULL );
131 108
132 setLength( mediaPlayerState.length() ); 109 setLength( mediaPlayerState.length() );
133 setPosition( mediaPlayerState.position() ); 110 setPosition( mediaPlayerState.position() );
134 setFullscreen( mediaPlayerState.isFullscreen() ); 111 setFullscreen( mediaPlayerState.isFullscreen() );
135 setPlaying( mediaPlayerState.isPlaying() ); 112 setPlaying( mediaPlayerState.isPlaying() );
136} 113}
137 114
138 115
139VideoWidget::~VideoWidget() 116VideoWidget::~VideoWidget()
140{ 117{
141} 118}
142 119
143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 120QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
144 QPixmap pix( img.width(), img.height() ); 121 QPixmap pix( img.width(), img.height() );