summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-08-10 17:41:15 (UTC)
committer llornkcor <llornkcor>2002-08-10 17:41:15 (UTC)
commitb488752cf2149443dcebcc8f7ad21c1ba47070fa (patch) (unidiff)
tree461adc8345f14d495466e5082f36651a844bde67
parentfb46a101bab9348ebfb68094b7c6cf54e56ea774 (diff)
downloadopie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.zip
opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.gz
opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.bz2
added skins to videowidget, fixed fullscreen menu. Still needs work on buttonmask.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp41
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp226
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h15
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp1
7 files changed, 212 insertions, 82 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index dc90a62..2ee9383 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -136,9 +136,9 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
136 skin = cfg.readEntry("Skin","default"); 136 skin = cfg.readEntry("Skin","default");
137 //skin = "scaleTest"; 137 //skin = "scaleTest";
138// color of background, frame, degree of transparency 138// color of background, frame, degree of transparency
139 139
140 QString skinPath = "opieplayer/skins/" + skin; 140 QString skinPath = "opieplayer2/skins/" + skin;
141 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 141 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
142 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 142 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
143 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 143 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
144 144
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 135c67c..57b1c81 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -158,8 +158,11 @@ void MediaPlayerState::setPlaylist( bool b ) {
158 emit playlistToggled(b); 158 emit playlistToggled(b);
159} 159}
160 160
161void MediaPlayerState::setPaused( bool b ) { 161void MediaPlayerState::setPaused( bool b ) {
162if(b) qDebug("setPaused true");
163 else qDebug("setPaused false");
164
162 if ( isPaused == b ) { 165 if ( isPaused == b ) {
163 return; 166 return;
164 } 167 }
165 isPaused = b; 168 isPaused = b;
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index b43d9f7..65458e7 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -9,8 +9,9 @@
9#include <qpe/lnkproperties.h> 9#include <qpe/lnkproperties.h>
10#include <qpe/storage.h> 10#include <qpe/storage.h>
11 11
12#include <qpe/applnk.h> 12#include <qpe/applnk.h>
13#include <qpopupmenu.h>
13#include <qpe/config.h> 14#include <qpe/config.h>
14#include <qpe/global.h> 15#include <qpe/global.h>
15#include <qpe/resource.h> 16#include <qpe/resource.h>
16#include <qaction.h> 17#include <qaction.h>
@@ -157,15 +158,21 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
157 pmPlayList->insertSeparator(-1); 158 pmPlayList->insertSeparator(-1);
158 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 159 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
159 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 160 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
160 161
161 QPopupMenu *pmView = new QPopupMenu( this ); 162
163 pmView = new QPopupMenu( this );
162 menu->insertItem( tr( "View" ), pmView ); 164 menu->insertItem( tr( "View" ), pmView );
165 pmView->isCheckable();
166
167 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), this, SLOT( toggleFull() ) );
168
169 Config cfg( "OpiePlayer" );
170 bool b= cfg.readBoolEntry("FullScreen", 0);
171 mediaPlayerState->setFullscreen( b );
172 pmView->setItemChecked( -16, b );
163 173
164 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 174 pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), this, SLOT(toggleScaled() ) );
165 fullScreenButton->addTo(pmView);
166 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
167 //scaleButton->addTo(pmView);
168 175
169 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 176 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
170 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 177 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
171 178
@@ -241,10 +248,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
241 playLists->setMinimumSize(233,260); 248 playLists->setMinimumSize(233,260);
242 tabWidget->insertTab(LTab,tr("Lists")); 249 tabWidget->insertTab(LTab,tr("Lists"));
243 250
244 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 251 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
245 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 252
246 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 253connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) );
254
255// connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) );
256
247 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 257 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
248 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 258 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
249 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 259 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
250 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 260 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
@@ -265,9 +275,8 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
265 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 275 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
266 276
267 setCentralWidget( vbox5 ); 277 setCentralWidget( vbox5 );
268 278
269 Config cfg( "OpiePlayer" );
270 readConfig( cfg ); 279 readConfig( cfg );
271 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 280 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
272 loadList(DocLnk( currentPlaylist)); 281 loadList(DocLnk( currentPlaylist));
273 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 282 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
@@ -1208,4 +1217,20 @@ void PlayListWidget::readPls(const QString &filename) {
1208 i++; 1217 i++;
1209 } 1218 }
1210} 1219}
1211 1220
1221void PlayListWidget::pmViewActivated(int index) {
1222qDebug("%d", index);
1223switch(index) {
1224 case -16:
1225 {
1226
1227 mediaPlayerState->toggleFullscreen();
1228 bool b=mediaPlayerState->fullscreen();
1229 pmView->setItemChecked( index,b);
1230 Config cfg( "OpiePlayer" );
1231 cfg.writeEntry("FullScreen", b);
1232
1233 }
1234 break;
1235};
1236}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index e44096b..fdfa666 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -6,8 +6,9 @@
6#include <qpe/applnk.h> 6#include <qpe/applnk.h>
7#include <qtabwidget.h> 7#include <qtabwidget.h>
8#include <qpe/fileselector.h> 8#include <qpe/fileselector.h>
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qpopupmenu.h>
10 11
11/* #include <qtimer.h> */ 12/* #include <qtimer.h> */
12 13
13 14
@@ -24,13 +25,15 @@ class PlayListWidget : public QMainWindow {
24public: 25public:
25 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 26 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
26 ~PlayListWidget(); 27 ~PlayListWidget();
27 QTabWidget * tabWidget; 28 QTabWidget * tabWidget;
28 QAction *fullScreenButton, *scaleButton; 29// MenuItem *fullScreenButton, *scaleButton;
30// QAction *fullScreenButton, *scaleButton;
29 DocLnkSet files; 31 DocLnkSet files;
30 DocLnkSet vFiles; 32 DocLnkSet vFiles;
31 QListView *audioView, *videoView, *playlistView; 33 QListView *audioView, *videoView, *playlistView;
32 QLabel *libString; 34 QLabel *libString;
35 QPopupMenu *pmView ;
33 bool fromSetDocument; 36 bool fromSetDocument;
34 bool insanityBool; 37 bool insanityBool;
35 QString setDocFileRef; 38 QString setDocFileRef;
36 // retrieve the current playlist entry (media file link) 39 // retrieve the current playlist entry (media file link)
@@ -66,8 +69,9 @@ private:
66 PlayListWidgetPrivate *d; // Private implementation data 69 PlayListWidgetPrivate *d; // Private implementation data
67 void populateAudioView(); 70 void populateAudioView();
68 void populateVideoView(); 71 void populateVideoView();
69private slots: 72private slots:
73 void pmViewActivated(int);
70 void writem3u(); 74 void writem3u();
71 void scanForAudio(); 75 void scanForAudio();
72 void scanForVideo(); 76 void scanForVideo();
73 void openFile(); 77 void openFile();
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 188b18d..419c3ae 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -31,8 +31,9 @@
31 31
32*/ 32*/
33 33
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/mediaplayerplugininterface.h>
35#include <qpe/config.h> 36#include <qpe/config.h>
36 37
37#include <qwidget.h> 38#include <qwidget.h>
38#include <qpainter.h> 39#include <qpainter.h>
@@ -57,64 +58,79 @@ static const int xo = 2; // movable x offset
57static const int yo = 0; // movable y offset 58static const int yo = 0; // movable y offset
58 59
59 60
60struct MediaButton { 61struct MediaButton {
61 int xPos, yPos;
62 bool isToggle, isHeld, isDown; 62 bool isToggle, isHeld, isDown;
63 int controlType;
64}; 63};
65 64
66
67// Layout information for the videoButtons (and if it is a toggle button or not)
68MediaButton videoButtons[] = { 65MediaButton videoButtons[] = {
69 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 66 { FALSE, FALSE, FALSE }, // previous
70 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 67 { FALSE, FALSE, FALSE }, // stop
71 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 68 { TRUE, FALSE, FALSE }, // play
72 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 69 { TRUE, FALSE, FALSE }, // pause
73 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 70 { FALSE, FALSE, FALSE }, // next
74 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 71 { FALSE, FALSE, FALSE }, // playlist
75 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 72 { TRUE, FALSE, FALSE } // fullscreen
76}; 73};
77 74
75const char *skinV_mask_file_names[7] = {
76"stop","play","back","fwd","up","down","full"
77};
78 78
79static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 79static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
80 80
81 81
82VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 82VideoWidget::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
86 videoFrame = new XineVideoWidget ( this, "Video frame" );
87 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
88
85 Config cfg("OpiePlayer"); 89 Config cfg("OpiePlayer");
86 cfg.setGroup("VideoWidget"); 90 cfg.setGroup("VideoWidget");
91 skin = cfg.readEntry("Skin","default");
87 92
88 QString Button0aPix, Button0bPix, controlsPix; 93 QString skinPath = "opieplayer2/skins/" + skin;
89 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); 94 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
90 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); 95 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
91 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); 96 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
92 97
93 cfg.setGroup("AudioWidget"); 98 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
94 QString skin = cfg.readEntry("Skin","default"); 99 imgButtonMask->fill( 0 );
95 QString skinPath = "opieplayer/skins/" + skin;
96 backgroundPix = QString("%1/background").arg(skinPath) ;
97 100
98 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 101 for ( int i = 0; i < 7; i++ ) {
99 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); 102 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png";
100 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); 103 masks[i] = new QBitmap( filename );
101 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); 104 qDebug(filename);
102 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 105 if ( !masks[i]->isNull() ) {
106 QImage imgMask = masks[i]->convertToImage();
107 uchar **dest = imgButtonMask->jumpTable();
108 for ( int y = 0; y < imgUp->height(); y++ ) {
109 uchar *line = dest[y];
110 for ( int x = 0; x < imgUp->width(); x++ ) {
111 if ( !qRed( imgMask.pixel( x, y ) ) )
112 line[x] = i + 1;
113 }
114 }
115 }
116
117 }
118
119 for ( int i = 0; i < 7; i++ ) {
120 buttonPixUp[i] = NULL;
121 buttonPixDown[i] = NULL;
122 }
123
124 setBackgroundPixmap( *pixBg );
103 125
104 slider = new QSlider( Qt::Horizontal, this ); 126 slider = new QSlider( Qt::Horizontal, this );
105 slider->setMinValue( 0 ); 127 slider->setMinValue( 0 );
106 slider->setMaxValue( 1 ); 128 slider->setMaxValue( 1 );
107 129 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
108 slider->setBackgroundPixmap( *this->backgroundPixmap () ); //Resource::loadPixmap( backgroundPix ) );
109 slider->setBackgroundOrigin( QWidget::ParentOrigin);
110 slider->setFocusPolicy( QWidget::NoFocus ); 130 slider->setFocusPolicy( QWidget::NoFocus );
111 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 131 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
112 132
113 videoFrame = new XineVideoWidget ( this, "Video frame" );
114
115 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
116
117 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 133 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
118 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 134 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
119 135
120 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 136 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
@@ -123,34 +139,87 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
123 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 139 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
124 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 140 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
125 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 141 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
126 142
127 // Intialise state
128 setLength( mediaPlayerState->length() ); 143 setLength( mediaPlayerState->length() );
129 setPosition( mediaPlayerState->position() ); 144 setPosition( mediaPlayerState->position() );
130 setFullscreen( mediaPlayerState->fullscreen() ); 145
146 ////////////////////////// FIXME
147// setFullscreen( mediaPlayerState->fullscreen() );
131 setPaused( mediaPlayerState->paused() ); 148 setPaused( mediaPlayerState->paused() );
132 setPlaying( mediaPlayerState->playing() ); 149 setPlaying( mediaPlayerState->playing() );
133 150 qDebug("finished videowidget");
134} 151}
135 152
136 153
137VideoWidget::~VideoWidget() { 154VideoWidget::~VideoWidget() {
138 for ( int i = 0; i < 3; i++ ) { 155 for ( int i = 0; i < 7; i++ ) {
139 delete pixmaps[i]; 156 delete buttonPixUp[i];
157 delete buttonPixDown[i];
158 }
159
160 delete pixBg;
161 delete imgUp;
162 delete imgDn;
163 delete imgButtonMask;
164 for ( int i = 0; i < 7; i++ ) {
165 delete masks[i];
140 } 166 }
141 delete currentFrame;
142} 167}
143 168
169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
170 QPixmap pix( img.width(), img.height() );
171 QPainter p( &pix );
172 p.drawTiledPixmap( pix.rect(), bg, offset );
173 p.drawImage( 0, 0, img );
174 return new QPixmap( pix );
175}
144 176
145static bool videoSliderBeingMoved = FALSE; 177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
178 QPixmap *pixmap = new QPixmap( pix );
179 pixmap->setMask( mask );
180 return pixmap;
181}
182
183void VideoWidget::resizeEvent( QResizeEvent * ) {
184 int h = height();
185 int w = width();
186 int Vh = 160;
187 //videoFrame->height();
188 int Vw = 220;
189 //videoFrame->width();
190// songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
191
192 slider->setFixedWidth( w - 110 );
193 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
194 slider->setBackgroundOrigin( QWidget::ParentOrigin );
195// time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
196 xoff = 0;// ( imgUp->width() ) / 2;
197 yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10;
198 QPoint p( xoff, yoff );
199
200 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
201 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
202
203 for ( int i = 0; i < 7; i++ ) {
204 if ( !masks[i]->isNull() ) {
205 delete buttonPixUp[i];
206 delete buttonPixDown[i];
207 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
208 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
209 }
210 }
211
212 delete pixUp;
213 delete pixDn;
214}
146 215
216static bool videoSliderBeingMoved = FALSE;
147 217
148void VideoWidget::sliderPressed() { 218void VideoWidget::sliderPressed() {
149 videoSliderBeingMoved = TRUE; 219 videoSliderBeingMoved = TRUE;
150} 220}
151 221
152
153void VideoWidget::sliderReleased() { 222void VideoWidget::sliderReleased() {
154 videoSliderBeingMoved = FALSE; 223 videoSliderBeingMoved = FALSE;
155 if ( slider->width() == 0 ) { 224 if ( slider->width() == 0 ) {
156 return; 225 return;
@@ -158,9 +227,8 @@ void VideoWidget::sliderReleased() {
158 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 227 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
159 mediaPlayerState->setPosition( val ); 228 mediaPlayerState->setPosition( val );
160} 229}
161 230
162
163void VideoWidget::setPosition( long i ) { 231void VideoWidget::setPosition( long i ) {
164 updateSlider( i, mediaPlayerState->length() ); 232 updateSlider( i, mediaPlayerState->length() );
165} 233}
166 234
@@ -168,9 +236,8 @@ void VideoWidget::setPosition( long i ) {
168void VideoWidget::setLength( long max ) { 236void VideoWidget::setLength( long max ) {
169 updateSlider( mediaPlayerState->position(), max ); 237 updateSlider( mediaPlayerState->position(), max );
170} 238}
171 239
172
173void VideoWidget::setView( char view ) { 240void VideoWidget::setView( char view ) {
174 if ( view == 'v' ) { 241 if ( view == 'v' ) {
175 makeVisible(); 242 makeVisible();
176 } else { 243 } else {
@@ -180,9 +247,8 @@ void VideoWidget::setView( char view ) {
180 hide(); 247 hide();
181 } 248 }
182} 249}
183 250
184
185void VideoWidget::updateSlider( long i, long max ) { 251void VideoWidget::updateSlider( long i, long max ) {
186 // Will flicker too much if we don't do this 252 // Will flicker too much if we don't do this
187 if ( max == 0 ) { 253 if ( max == 0 ) {
188 return; 254 return;
@@ -198,44 +264,37 @@ void VideoWidget::updateSlider( long i, long max ) {
198 } 264 }
199 } 265 }
200} 266}
201 267
202
203void VideoWidget::setToggleButton( int i, bool down ) { 268void VideoWidget::setToggleButton( int i, bool down ) {
204 if ( down != videoButtons[i].isDown ) { 269 if ( down != videoButtons[i].isDown ) {
205 toggleButton( i ); 270 toggleButton( i );
206 } 271 }
207} 272}
208 273
209
210void VideoWidget::toggleButton( int i ) { 274void VideoWidget::toggleButton( int i ) {
211 videoButtons[i].isDown = !videoButtons[i].isDown; 275 videoButtons[i].isDown = !videoButtons[i].isDown;
212 QPainter p(this); 276 QPainter p(this);
213 paintButton ( &p, i ); 277 paintButton ( &p, i );
214} 278}
215 279
216
217void VideoWidget::paintButton( QPainter *p, int i ) { 280void VideoWidget::paintButton( QPainter *p, int i ) {
218 int x = videoButtons[i].xPos;
219 int y = videoButtons[i].yPos;
220 int offset = 10 + videoButtons[i].isDown;
221 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
222 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
223}
224 281
282 if ( videoButtons[i].isDown )
283 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
284 else
285 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
286}
225 287
226void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 288void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
227 for ( int i = 0; i < numButtons; i++ ) { 289 for ( int i = 0; i < numButtons; i++ ) {
228 int x = videoButtons[i].xPos;
229 int y = videoButtons[i].yPos;
230 if ( event->state() == QMouseEvent::LeftButton ) { 290 if ( event->state() == QMouseEvent::LeftButton ) {
231 // The test to see if the mouse click is inside the circular button or not 291 // The test to see if the mouse click is inside the button or not
232 // (compared with the radius squared to avoid a square-root of our distance) 292 int x = event->pos().x() - xoff;
233 int radius = 16; 293 int y = event->pos().y() - yoff;
234 QPoint center = QPoint( x + radius, y + radius ); 294
235 QPoint dXY = center - event->pos(); 295 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
236 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 296 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
237 bool isOnButton = dist <= (radius * radius);
238 if ( isOnButton != videoButtons[i].isHeld ) { 297 if ( isOnButton != videoButtons[i].isHeld ) {
239 videoButtons[i].isHeld = isOnButton; 298 videoButtons[i].isHeld = isOnButton;
240 toggleButton(i); 299 toggleButton(i);
241 } 300 }
@@ -243,11 +302,9 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
243 if ( videoButtons[i].isHeld ) { 302 if ( videoButtons[i].isHeld ) {
244 videoButtons[i].isHeld = FALSE; 303 videoButtons[i].isHeld = FALSE;
245 if ( !videoButtons[i].isToggle ) 304 if ( !videoButtons[i].isToggle )
246 setToggleButton( i, FALSE ); 305 setToggleButton( i, FALSE );
247 qDebug("button toggled3 %d",i);
248 } 306 }
249
250 } 307 }
251 switch (i) { 308 switch (i) {
252 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 309 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
253 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 310 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
@@ -260,14 +317,12 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
260 317
261 } 318 }
262} 319}
263 320
264
265void VideoWidget::mousePressEvent( QMouseEvent *event ) { 321void VideoWidget::mousePressEvent( QMouseEvent *event ) {
266 mouseMoveEvent( event ); 322 mouseMoveEvent( event );
267} 323}
268 324
269
270void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 325void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
271 if ( mediaPlayerState->fullscreen() ) { 326 if ( mediaPlayerState->fullscreen() ) {
272 mediaPlayerState->setFullscreen( FALSE ); 327 mediaPlayerState->setFullscreen( FALSE );
273 makeVisible(); 328 makeVisible();
@@ -293,9 +348,9 @@ void VideoWidget::makeVisible() {
293 } 348 }
294} 349}
295 350
296 351
297void VideoWidget::paintEvent( QPaintEvent * ) { 352void VideoWidget::paintEvent( QPaintEvent * pe) {
298 QPainter p( this ); 353 QPainter p( this );
299 354
300 if ( mediaPlayerState->fullscreen() ) { 355 if ( mediaPlayerState->fullscreen() ) {
301 // Clear the background 356 // Clear the background
@@ -306,13 +361,28 @@ void VideoWidget::paintEvent( QPaintEvent * ) {
306 361
307 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); 362 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) );
308 // draw the buttons 363 // draw the buttons
309 364
310 for ( int i = 0; i < numButtons; i++ ) { 365 if ( !pe->erased() ) {
366 // Combine with background and double buffer
367 QPixmap pix( pe->rect().size() );
368 QPainter p( &pix );
369 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
370 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
371 for ( int i = 0; i < numButtons; i++ )
372 paintButton( &p, i );
373 QPainter p2( this );
374 p2.drawPixmap( pe->rect().topLeft(), pix );
375 } else {
376 QPainter p( this );
377 for ( int i = 0; i < numButtons; i++ )
311 paintButton( &p, i ); 378 paintButton( &p, i );
312 } 379 }
313 // draw the slider 380// for ( int i = 0; i < numButtons; i++ ) {
314 slider->repaint( TRUE ); 381// paintButton( &p, i );
382// }
383// // draw the slider
384// slider->repaint( TRUE );
315 } 385 }
316} 386}
317 387
318 388
@@ -320,11 +390,23 @@ void VideoWidget::closeEvent( QCloseEvent* ) {
320 mediaPlayerState->setList(); 390 mediaPlayerState->setList();
321} 391}
322 392
323 393
394bool VideoWidget::playVideo() {
395 bool result = FALSE;
396
397 int stream = 0;
398
399 int sw = 240;
400 int sh = 320;
401 int dd = QPixmap::defaultDepth();
402 int w = height();
403 int h = width();
324 404
325void VideoWidget::keyReleaseEvent( QKeyEvent *e) 405 return true;
326{ 406}
407
408void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
327 switch ( e->key() ) { 409 switch ( e->key() ) {
328////////////////////////////// Zaurus keys 410////////////////////////////// Zaurus keys
329 case Key_Home: 411 case Key_Home:
330 break; 412 break;
@@ -369,13 +451,13 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e)
369 break; 451 break;
370 452
371 }; 453 };
372} 454}
455
373XineVideoWidget* VideoWidget::vidWidget() { 456XineVideoWidget* VideoWidget::vidWidget() {
374 return videoFrame; 457 return videoFrame;
375} 458}
376 459
377 460
378void VideoWidget::setFullscreen ( bool b ) 461void VideoWidget::setFullscreen ( bool b ) {
379{
380 setToggleButton( VideoFullscreen, b ); 462 setToggleButton( VideoFullscreen, b );
381} 463}
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 04e810e..830696e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -55,8 +55,9 @@ class VideoWidget : public QWidget {
55public: 55public:
56 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 56 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
57 ~VideoWidget(); 57 ~VideoWidget();
58 58
59 bool playVideo();
59 XineVideoWidget* vidWidget(); 60 XineVideoWidget* vidWidget();
60public slots: 61public slots:
61 void updateSlider( long, long ); 62 void updateSlider( long, long );
62 void sliderPressed( ); 63 void sliderPressed( );
@@ -73,16 +74,30 @@ signals:
73 void sliderMoved( long ); 74 void sliderMoved( long );
74 void videoResized ( const QSize &s ); 75 void videoResized ( const QSize &s );
75 76
76protected: 77protected:
78 QString skin;
79 void resizeEvent( QResizeEvent * );
77 void paintEvent( QPaintEvent *pe ); 80 void paintEvent( QPaintEvent *pe );
78 void mouseMoveEvent( QMouseEvent *event ); 81 void mouseMoveEvent( QMouseEvent *event );
79 void mousePressEvent( QMouseEvent *event ); 82 void mousePressEvent( QMouseEvent *event );
80 void mouseReleaseEvent( QMouseEvent *event ); 83 void mouseReleaseEvent( QMouseEvent *event );
81 void closeEvent( QCloseEvent *event ); 84 void closeEvent( QCloseEvent *event );
82 void keyReleaseEvent( QKeyEvent *e); 85 void keyReleaseEvent( QKeyEvent *e);
83 86
84private: 87private:
88// Ticker songInfo;
89 QPixmap *pixBg;
90 QImage *imgUp;
91 QImage *imgDn;
92 QImage *imgButtonMask;
93 QBitmap *masks[7];
94 QPixmap *buttonPixUp[7];
95 QPixmap *buttonPixDown[7];
96// QPixmap *pixmaps[4];
97 int xoff, yoff;
98
99
85 void paintButton( QPainter *p, int i ); 100 void paintButton( QPainter *p, int i );
86 void toggleButton( int ); 101 void toggleButton( int );
87 void setToggleButton( int, bool ); 102 void setToggleButton( int, bool );
88 103
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 98446a0..d65006b 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -38,8 +38,9 @@
38#include <qdirectpainter_qws.h> 38#include <qdirectpainter_qws.h>
39#include <qgfx_qws.h> 39#include <qgfx_qws.h>
40#include <qsize.h> 40#include <qsize.h>
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qpainter.h>
42 43
43#include <qpe/resource.h> 44#include <qpe/resource.h>
44 45
45#include "xinevideowidget.h" 46#include "xinevideowidget.h"