author | llornkcor <llornkcor> | 2002-08-10 17:41:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-10 17:41:15 (UTC) |
commit | b488752cf2149443dcebcc8f7ad21c1ba47070fa (patch) (unidiff) | |
tree | 461adc8345f14d495466e5082f36651a844bde67 | |
parent | fb46a101bab9348ebfb68094b7c6cf54e56ea774 (diff) | |
download | opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.zip opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.gz opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.bz2 |
added skins to videowidget, fixed fullscreen menu. Still needs work on buttonmask.
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 41 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 246 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 17 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 323 |
7 files changed, 384 insertions, 254 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 | |||
@@ -124,33 +124,33 @@ static void changeTextColor( QWidget *w ) { | |||
124 | w->setPalette( p ); | 124 | w->setPalette( p ); |
125 | } | 125 | } |
126 | 126 | ||
127 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 127 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
128 | 128 | ||
129 | 129 | ||
130 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 130 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
131 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 131 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
132 | setCaption( tr("OpiePlayer") ); | 132 | setCaption( tr("OpiePlayer") ); |
133 | 133 | ||
134 | Config cfg("OpiePlayer"); | 134 | Config cfg("OpiePlayer"); |
135 | cfg.setGroup("AudioWidget"); | 135 | cfg.setGroup("AudioWidget"); |
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 | ||
145 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 145 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
146 | imgButtonMask->fill( 0 ); | 146 | imgButtonMask->fill( 0 ); |
147 | 147 | ||
148 | for ( int i = 0; i < 11; i++ ) { | 148 | for ( int i = 0; i < 11; i++ ) { |
149 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 149 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
150 | masks[i] = new QBitmap( filename ); | 150 | masks[i] = new QBitmap( filename ); |
151 | 151 | ||
152 | if ( !masks[i]->isNull() ) { | 152 | if ( !masks[i]->isNull() ) { |
153 | QImage imgMask = masks[i]->convertToImage(); | 153 | QImage imgMask = masks[i]->convertToImage(); |
154 | uchar **dest = imgButtonMask->jumpTable(); | 154 | uchar **dest = imgButtonMask->jumpTable(); |
155 | for ( int y = 0; y < imgUp->height(); y++ ) { | 155 | for ( int y = 0; y < imgUp->height(); y++ ) { |
156 | uchar *line = dest[y]; | 156 | uchar *line = dest[y]; |
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 | |||
@@ -146,32 +146,35 @@ void MediaPlayerState::setShuffled( bool b ) { | |||
146 | if ( isShuffled == b ) { | 146 | if ( isShuffled == b ) { |
147 | return; | 147 | return; |
148 | } | 148 | } |
149 | isShuffled = b; | 149 | isShuffled = b; |
150 | emit shuffledToggled(b); | 150 | emit shuffledToggled(b); |
151 | } | 151 | } |
152 | 152 | ||
153 | void MediaPlayerState::setPlaylist( bool b ) { | 153 | void MediaPlayerState::setPlaylist( bool b ) { |
154 | if ( usePlaylist == b ) { | 154 | if ( usePlaylist == b ) { |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | usePlaylist = b; | 157 | usePlaylist = b; |
158 | emit playlistToggled(b); | 158 | emit playlistToggled(b); |
159 | } | 159 | } |
160 | 160 | ||
161 | void MediaPlayerState::setPaused( bool b ) { | 161 | void MediaPlayerState::setPaused( bool b ) { |
162 | if(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; |
166 | emit pausedToggled(b); | 169 | emit pausedToggled(b); |
167 | } | 170 | } |
168 | 171 | ||
169 | void MediaPlayerState::setPlaying( bool b ) { | 172 | void MediaPlayerState::setPlaying( bool b ) { |
170 | if ( isPlaying == b ) { | 173 | if ( isPlaying == b ) { |
171 | return; | 174 | return; |
172 | } | 175 | } |
173 | isPlaying = b; | 176 | isPlaying = b; |
174 | isStoped = !b; | 177 | isStoped = !b; |
175 | emit playingToggled(b); | 178 | emit playingToggled(b); |
176 | } | 179 | } |
177 | 180 | ||
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 | |||
@@ -1,28 +1,29 @@ | |||
1 | 1 | ||
2 | #define QTOPIA_INTERNAL_FSLP | 2 | #define QTOPIA_INTERNAL_FSLP |
3 | #include <qpe/qcopenvelope_qws.h> | 3 | #include <qpe/qcopenvelope_qws.h> |
4 | 4 | ||
5 | #include <qpe/qpemenubar.h> | 5 | #include <qpe/qpemenubar.h> |
6 | #include <qpe/qpetoolbar.h> | 6 | #include <qpe/qpetoolbar.h> |
7 | #include <qpe/fileselector.h> | 7 | #include <qpe/fileselector.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
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> |
17 | #include <qcursor.h> | 18 | #include <qcursor.h> |
18 | #include <qimage.h> | 19 | #include <qimage.h> |
19 | #include <qfile.h> | 20 | #include <qfile.h> |
20 | #include <qdir.h> | 21 | #include <qdir.h> |
21 | #include <qlayout.h> | 22 | #include <qlayout.h> |
22 | #include <qlabel.h> | 23 | #include <qlabel.h> |
23 | #include <qlist.h> | 24 | #include <qlist.h> |
24 | #include <qlistbox.h> | 25 | #include <qlistbox.h> |
25 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
26 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
27 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
28 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
@@ -145,39 +146,45 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
145 | 146 | ||
146 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 147 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
147 | menu->insertItem( tr( "File" ), pmPlayList ); | 148 | menu->insertItem( tr( "File" ), pmPlayList ); |
148 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 149 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
149 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 150 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
150 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 151 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
151 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 152 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
152 | pmPlayList->insertSeparator(-1); | 153 | pmPlayList->insertSeparator(-1); |
153 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 154 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
154 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
155 | pmPlayList->insertSeparator(-1); | 156 | pmPlayList->insertSeparator(-1); |
156 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
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() ) ); | ||
163 | 168 | ||
164 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 169 | Config cfg( "OpiePlayer" ); |
165 | fullScreenButton->addTo(pmView); | 170 | bool b= cfg.readBoolEntry("FullScreen", 0); |
166 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 171 | mediaPlayerState->setFullscreen( b ); |
167 | //scaleButton->addTo(pmView); | 172 | pmView->setItemChecked( -16, b ); |
173 | |||
174 | pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), this, SLOT(toggleScaled() ) ); | ||
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 | ||
172 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 179 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
173 | 180 | ||
174 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 181 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
175 | // tabWidget->setTabShape(QTabWidget::Triangular); | 182 | // tabWidget->setTabShape(QTabWidget::Triangular); |
176 | 183 | ||
177 | QWidget *pTab; | 184 | QWidget *pTab; |
178 | pTab = new QWidget( tabWidget, "pTab" ); | 185 | pTab = new QWidget( tabWidget, "pTab" ); |
179 | tabWidget->insertTab( pTab,"Playlist"); | 186 | tabWidget->insertTab( pTab,"Playlist"); |
180 | 187 | ||
181 | 188 | ||
182 | // Add the playlist area | 189 | // Add the playlist area |
183 | 190 | ||
@@ -229,57 +236,59 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
229 | videoView->setAllColumnsShowFocus(TRUE); | 236 | videoView->setAllColumnsShowFocus(TRUE); |
230 | videoView->setMultiSelection( TRUE ); | 237 | videoView->setMultiSelection( TRUE ); |
231 | videoView->setSelectionMode( QListView::Extended); | 238 | videoView->setSelectionMode( QListView::Extended); |
232 | 239 | ||
233 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 240 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
234 | 241 | ||
235 | tabWidget->insertTab( vTab,tr("Video")); | 242 | tabWidget->insertTab( vTab,tr("Video")); |
236 | 243 | ||
237 | //playlists list | 244 | //playlists list |
238 | QWidget *LTab; | 245 | QWidget *LTab; |
239 | LTab = new QWidget( tabWidget, "LTab" ); | 246 | LTab = new QWidget( tabWidget, "LTab" ); |
240 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 247 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
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()) ); | 253 | connect( 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)) ); |
251 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 261 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
252 | this,SLOT( playIt( QListViewItem *)) ); | 262 | this,SLOT( playIt( QListViewItem *)) ); |
253 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 263 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
254 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 264 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
255 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 265 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
256 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 266 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
257 | this,SLOT( playIt( QListViewItem *)) ); | 267 | this,SLOT( playIt( QListViewItem *)) ); |
258 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 268 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 269 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
260 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 270 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
261 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 271 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
262 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 272 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
263 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 273 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
264 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 274 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
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 ); |
274 | 283 | ||
275 | initializeStates(); | 284 | initializeStates(); |
276 | } | 285 | } |
277 | 286 | ||
278 | 287 | ||
279 | PlayListWidget::~PlayListWidget() { | 288 | PlayListWidget::~PlayListWidget() { |
280 | Config cfg( "OpiePlayer" ); | 289 | Config cfg( "OpiePlayer" ); |
281 | writeConfig( cfg ); | 290 | writeConfig( cfg ); |
282 | 291 | ||
283 | if ( d->current ) { | 292 | if ( d->current ) { |
284 | delete d->current; | 293 | delete d->current; |
285 | } | 294 | } |
@@ -1196,16 +1205,32 @@ void PlayListWidget::readPls(const QString &filename) { | |||
1196 | lnk.setFile( s); | 1205 | lnk.setFile( s); |
1197 | else { //if its a url | 1206 | else { //if its a url |
1198 | if( name.right(1).find('/') == -1) | 1207 | if( name.right(1).find('/') == -1) |
1199 | s+="/"; | 1208 | s+="/"; |
1200 | lnk.setFile( s); | 1209 | lnk.setFile( s); |
1201 | } | 1210 | } |
1202 | lnk.setType("audio/x-mpegurl"); | 1211 | lnk.setType("audio/x-mpegurl"); |
1203 | 1212 | ||
1204 | qDebug("DocLnk add "+name); | 1213 | qDebug("DocLnk add "+name); |
1205 | d->selectedFiles->addToSelection( lnk); | 1214 | d->selectedFiles->addToSelection( lnk); |
1206 | } | 1215 | } |
1207 | } | 1216 | } |
1208 | i++; | 1217 | i++; |
1209 | } | 1218 | } |
1210 | } | 1219 | } |
1211 | 1220 | ||
1221 | void PlayListWidget::pmViewActivated(int index) { | ||
1222 | qDebug("%d", index); | ||
1223 | switch(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 | |||
@@ -1,48 +1,51 @@ | |||
1 | 1 | ||
2 | #ifndef PLAY_LIST_WIDGET_H | 2 | #ifndef PLAY_LIST_WIDGET_H |
3 | #define PLAY_LIST_WIDGET_H | 3 | #define PLAY_LIST_WIDGET_H |
4 | 4 | ||
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
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 | ||
14 | class PlayListWidgetPrivate; | 15 | class PlayListWidgetPrivate; |
15 | class Config; | 16 | class Config; |
16 | class QListViewItem; | 17 | class QListViewItem; |
17 | class QListView; | 18 | class QListView; |
18 | class QPoint; | 19 | class QPoint; |
19 | class QAction; | 20 | class QAction; |
20 | class QLabel; | 21 | class QLabel; |
21 | 22 | ||
22 | class PlayListWidget : public QMainWindow { | 23 | class PlayListWidget : public QMainWindow { |
23 | Q_OBJECT | 24 | Q_OBJECT |
24 | public: | 25 | public: |
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) |
37 | const DocLnk *current(); | 40 | const DocLnk *current(); |
38 | void useSelectedDocument(); | 41 | void useSelectedDocument(); |
39 | /* QTimer * menuTimer; */ | 42 | /* QTimer * menuTimer; */ |
40 | FileSelector* playLists; | 43 | FileSelector* playLists; |
41 | QPushButton *tbDeletePlaylist; | 44 | QPushButton *tbDeletePlaylist; |
42 | int fd, selected; | 45 | int fd, selected; |
43 | public slots: | 46 | public slots: |
44 | bool first(); | 47 | bool first(); |
45 | bool last(); | 48 | bool last(); |
46 | bool next(); | 49 | bool next(); |
47 | bool prev(); | 50 | bool prev(); |
48 | /* void setFullScreen(); */ | 51 | /* void setFullScreen(); */ |
@@ -54,32 +57,33 @@ void keyReleaseEvent( QKeyEvent *e); | |||
54 | void keyPressEvent( QKeyEvent *e); | 57 | void keyPressEvent( QKeyEvent *e); |
55 | private: | 58 | private: |
56 | bool audioScan, videoScan; | 59 | bool audioScan, videoScan; |
57 | void doBlank(); | 60 | void doBlank(); |
58 | void doUnblank(); | 61 | void doUnblank(); |
59 | void readm3u(const QString &); | 62 | void readm3u(const QString &); |
60 | void readPls(const QString &); | 63 | void readPls(const QString &); |
61 | 64 | ||
62 | 65 | ||
63 | void initializeStates(); | 66 | void initializeStates(); |
64 | void readConfig( Config& cfg ); | 67 | void readConfig( Config& cfg ); |
65 | void writeConfig( Config& cfg ) const; | 68 | void writeConfig( Config& cfg ) const; |
66 | PlayListWidgetPrivate *d; // Private implementation data | 69 | PlayListWidgetPrivate *d; // Private implementation data |
67 | void populateAudioView(); | 70 | void populateAudioView(); |
68 | void populateVideoView(); | 71 | void populateVideoView(); |
69 | private slots: | 72 | private 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(); |
74 | void setDocument( const QString& fileref ); | 78 | void setDocument( const QString& fileref ); |
75 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 79 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
76 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 80 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
77 | void setActiveWindow(); // need to handle this to show the right view | 81 | void setActiveWindow(); // need to handle this to show the right view |
78 | void setPlaylist( bool ); // Show/Hide the playlist | 82 | void setPlaylist( bool ); // Show/Hide the playlist |
79 | void setView( char ); | 83 | void setView( char ); |
80 | void clearList(); | 84 | void clearList(); |
81 | void addAllToList(); | 85 | void addAllToList(); |
82 | void addAllMusicToList(); | 86 | void addAllMusicToList(); |
83 | void addAllVideoToList(); | 87 | void addAllVideoToList(); |
84 | void saveList(); // Save the playlist | 88 | void saveList(); // Save the playlist |
85 | void loadList( const DocLnk &); // Load a playlist | 89 | void loadList( const DocLnk &); // Load a playlist |
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 | |||
@@ -19,324 +19,406 @@ | |||
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
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> |
39 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
40 | #include <qslider.h> | 41 | #include <qslider.h> |
41 | #include <qdrawutil.h> | 42 | #include <qdrawutil.h> |
42 | #include "videowidget.h" | 43 | #include "videowidget.h" |
43 | #include "mediaplayerstate.h" | 44 | #include "mediaplayerstate.h" |
44 | 45 | ||
45 | 46 | ||
46 | #ifdef Q_WS_QWS | 47 | #ifdef Q_WS_QWS |
47 | # define USE_DIRECT_PAINTER | 48 | # define USE_DIRECT_PAINTER |
48 | # include <qdirectpainter_qws.h> | 49 | # include <qdirectpainter_qws.h> |
49 | # include <qgfxraster_qws.h> | 50 | # include <qgfxraster_qws.h> |
50 | #endif | 51 | #endif |
51 | 52 | ||
52 | 53 | ||
53 | extern MediaPlayerState *mediaPlayerState; | 54 | extern MediaPlayerState *mediaPlayerState; |
54 | 55 | ||
55 | 56 | ||
56 | static const int xo = 2; // movable x offset | 57 | static const int xo = 2; // movable x offset |
57 | static const int yo = 0; // movable y offset | 58 | static const int yo = 0; // movable y offset |
58 | 59 | ||
59 | 60 | ||
60 | struct MediaButton { | 61 | struct 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) | ||
68 | MediaButton videoButtons[] = { | 65 | MediaButton 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 | ||
75 | const char *skinV_mask_file_names[7] = { | ||
76 | "stop","play","back","fwd","up","down","full" | ||
77 | }; | ||
78 | 78 | ||
79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
80 | 80 | ||
81 | 81 | ||
82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
84 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
85 | |||
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"); | ||
92 | |||
93 | QString skinPath = "opieplayer2/skins/" + skin; | ||
94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | ||
95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | ||
96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | ||
97 | |||
98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | ||
99 | imgButtonMask->fill( 0 ); | ||
100 | |||
101 | for ( int i = 0; i < 7; i++ ) { | ||
102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; | ||
103 | masks[i] = new QBitmap( filename ); | ||
104 | qDebug(filename); | ||
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 | } | ||
87 | 116 | ||
88 | QString Button0aPix, Button0bPix, controlsPix; | 117 | } |
89 | Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); | ||
90 | Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); | ||
91 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); | ||
92 | 118 | ||
93 | cfg.setGroup("AudioWidget"); | 119 | for ( int i = 0; i < 7; i++ ) { |
94 | QString skin = cfg.readEntry("Skin","default"); | 120 | buttonPixUp[i] = NULL; |
95 | QString skinPath = "opieplayer/skins/" + skin; | 121 | buttonPixDown[i] = NULL; |
96 | backgroundPix = QString("%1/background").arg(skinPath) ; | 122 | } |
97 | 123 | ||
98 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); | 124 | setBackgroundPixmap( *pixBg ); |
99 | pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); | ||
100 | pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); | ||
101 | pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); | ||
102 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | ||
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) ) ); |
121 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
122 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
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 | ||
137 | VideoWidget::~VideoWidget() { | 154 | VideoWidget::~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 | ||
169 | QPixmap *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 | ||
145 | static bool videoSliderBeingMoved = FALSE; | 177 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
178 | QPixmap *pixmap = new QPixmap( pix ); | ||
179 | pixmap->setMask( mask ); | ||
180 | return pixmap; | ||
181 | } | ||
182 | |||
183 | void 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 | } | ||
146 | 211 | ||
212 | delete pixUp; | ||
213 | delete pixDn; | ||
214 | } | ||
215 | |||
216 | static bool videoSliderBeingMoved = FALSE; | ||
147 | 217 | ||
148 | void VideoWidget::sliderPressed() { | 218 | void VideoWidget::sliderPressed() { |
149 | videoSliderBeingMoved = TRUE; | 219 | videoSliderBeingMoved = TRUE; |
150 | } | 220 | } |
151 | 221 | ||
152 | |||
153 | void VideoWidget::sliderReleased() { | 222 | void VideoWidget::sliderReleased() { |
154 | videoSliderBeingMoved = FALSE; | 223 | videoSliderBeingMoved = FALSE; |
155 | if ( slider->width() == 0 ) { | 224 | if ( slider->width() == 0 ) { |
156 | return; | 225 | return; |
157 | } | 226 | } |
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 | |||
163 | void VideoWidget::setPosition( long i ) { | 231 | void VideoWidget::setPosition( long i ) { |
164 | updateSlider( i, mediaPlayerState->length() ); | 232 | updateSlider( i, mediaPlayerState->length() ); |
165 | } | 233 | } |
166 | 234 | ||
167 | 235 | ||
168 | void VideoWidget::setLength( long max ) { | 236 | void VideoWidget::setLength( long max ) { |
169 | updateSlider( mediaPlayerState->position(), max ); | 237 | updateSlider( mediaPlayerState->position(), max ); |
170 | } | 238 | } |
171 | 239 | ||
172 | |||
173 | void VideoWidget::setView( char view ) { | 240 | void VideoWidget::setView( char view ) { |
174 | if ( view == 'v' ) { | 241 | if ( view == 'v' ) { |
175 | makeVisible(); | 242 | makeVisible(); |
176 | } else { | 243 | } else { |
177 | // Effectively blank the view next time we show it so it looks nicer | 244 | // Effectively blank the view next time we show it so it looks nicer |
178 | scaledWidth = 0; | 245 | scaledWidth = 0; |
179 | scaledHeight = 0; | 246 | scaledHeight = 0; |
180 | hide(); | 247 | hide(); |
181 | } | 248 | } |
182 | } | 249 | } |
183 | 250 | ||
184 | |||
185 | void VideoWidget::updateSlider( long i, long max ) { | 251 | void 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; |
189 | } | 255 | } |
190 | int width = slider->width(); | 256 | int width = slider->width(); |
191 | int val = int((double)i * width / max); | 257 | int val = int((double)i * width / max); |
192 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 258 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
193 | if ( slider->value() != val ) { | 259 | if ( slider->value() != val ) { |
194 | slider->setValue( val ); | 260 | slider->setValue( val ); |
195 | } | 261 | } |
196 | if ( slider->maxValue() != width ) { | 262 | if ( slider->maxValue() != width ) { |
197 | slider->setMaxValue( width ); | 263 | slider->setMaxValue( width ); |
198 | } | 264 | } |
199 | } | 265 | } |
200 | } | 266 | } |
201 | 267 | ||
202 | |||
203 | void VideoWidget::setToggleButton( int i, bool down ) { | 268 | void 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 | |||
210 | void VideoWidget::toggleButton( int i ) { | 274 | void 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 | |||
217 | void VideoWidget::paintButton( QPainter *p, int i ) { | 280 | void 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 | ||
226 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 288 | void 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 | } |
242 | } else { | 301 | } else { |
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; |
254 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 311 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
255 | case VideoNext: mediaPlayerState->setNext(); return; | 312 | case VideoNext: mediaPlayerState->setNext(); return; |
256 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 313 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
257 | case VideoPlayList: mediaPlayerState->setList(); return; | 314 | case VideoPlayList: mediaPlayerState->setList(); return; |
258 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 315 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
259 | } | 316 | } |
260 | 317 | ||
261 | } | 318 | } |
262 | } | 319 | } |
263 | 320 | ||
264 | |||
265 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 321 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
266 | mouseMoveEvent( event ); | 322 | mouseMoveEvent( event ); |
267 | } | 323 | } |
268 | 324 | ||
269 | |||
270 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 325 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
271 | if ( mediaPlayerState->fullscreen() ) { | 326 | if ( mediaPlayerState->fullscreen() ) { |
272 | mediaPlayerState->setFullscreen( FALSE ); | 327 | mediaPlayerState->setFullscreen( FALSE ); |
273 | makeVisible(); | 328 | makeVisible(); |
274 | 329 | ||
275 | mouseMoveEvent( event ); | 330 | mouseMoveEvent( event ); |
276 | } | 331 | } |
277 | } | 332 | } |
278 | 333 | ||
279 | 334 | ||
280 | void VideoWidget::makeVisible() { | 335 | void VideoWidget::makeVisible() { |
281 | if ( mediaPlayerState->fullscreen() ) { | 336 | if ( mediaPlayerState->fullscreen() ) { |
282 | setBackgroundMode( QWidget::NoBackground ); | 337 | setBackgroundMode( QWidget::NoBackground ); |
283 | showFullScreen(); | 338 | showFullScreen(); |
284 | resize( qApp->desktop()->size() ); | 339 | resize( qApp->desktop()->size() ); |
285 | slider->hide(); | 340 | slider->hide(); |
286 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 341 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
287 | } else { | 342 | } else { |
288 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 343 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
289 | showNormal(); | 344 | showNormal(); |
290 | showMaximized(); | 345 | showMaximized(); |
291 | slider->show(); | 346 | slider->show(); |
292 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); | 347 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); |
293 | } | 348 | } |
294 | } | 349 | } |
295 | 350 | ||
296 | 351 | ||
297 | void VideoWidget::paintEvent( QPaintEvent * ) { | 352 | void 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 |
302 | p.setBrush( QBrush( Qt::black ) ); | 357 | p.setBrush( QBrush( Qt::black ) ); |
303 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); | 358 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); |
304 | 359 | ||
305 | } else { | 360 | } else { |
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() ) { |
311 | paintButton( &p, i ); | 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++ ) | ||
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 ); |
315 | } | 382 | // } |
383 | // // draw the slider | ||
384 | // slider->repaint( TRUE ); | ||
385 | } | ||
316 | } | 386 | } |
317 | 387 | ||
318 | 388 | ||
319 | void VideoWidget::closeEvent( QCloseEvent* ) { | 389 | void VideoWidget::closeEvent( QCloseEvent* ) { |
320 | mediaPlayerState->setList(); | 390 | mediaPlayerState->setList(); |
321 | } | 391 | } |
322 | 392 | ||
323 | 393 | ||
394 | bool 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 | ||
325 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | 405 | return true; |
326 | { | 406 | } |
407 | |||
408 | void 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; |
331 | case Key_F9: //activity | 413 | case Key_F9: //activity |
332 | break; | 414 | break; |
333 | case Key_F10: //contacts | 415 | case Key_F10: //contacts |
334 | // hide(); | 416 | // hide(); |
335 | break; | 417 | break; |
336 | case Key_F11: //menu | 418 | case Key_F11: //menu |
337 | break; | 419 | break; |
338 | case Key_F12: //home | 420 | case Key_F12: //home |
339 | break; | 421 | break; |
340 | case Key_F13: //mail | 422 | case Key_F13: //mail |
341 | break; | 423 | break; |
342 | case Key_Space: { | 424 | case Key_Space: { |
@@ -357,25 +439,25 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) | |||
357 | // toggleButton(5); | 439 | // toggleButton(5); |
358 | // emit moreClicked(); | 440 | // emit moreClicked(); |
359 | // emit moreReleased(); | 441 | // emit moreReleased(); |
360 | // toggleButton(5); | 442 | // toggleButton(5); |
361 | break; | 443 | break; |
362 | case Key_Right: | 444 | case Key_Right: |
363 | mediaPlayerState->setNext(); | 445 | mediaPlayerState->setNext(); |
364 | break; | 446 | break; |
365 | case Key_Left: | 447 | case Key_Left: |
366 | mediaPlayerState->setPrev(); | 448 | mediaPlayerState->setPrev(); |
367 | break; | 449 | break; |
368 | case Key_Escape: | 450 | case Key_Escape: |
369 | break; | 451 | break; |
370 | 452 | ||
371 | }; | 453 | }; |
372 | } | 454 | } |
455 | |||
373 | XineVideoWidget* VideoWidget::vidWidget() { | 456 | XineVideoWidget* VideoWidget::vidWidget() { |
374 | return videoFrame; | 457 | return videoFrame; |
375 | } | 458 | } |
376 | 459 | ||
377 | 460 | ||
378 | void VideoWidget::setFullscreen ( bool b ) | 461 | void VideoWidget::setFullscreen ( bool b ) { |
379 | { | 462 | setToggleButton( VideoFullscreen, b ); |
380 | 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 | |||
@@ -43,58 +43,73 @@ class QSlider; | |||
43 | enum VideoButtons { | 43 | enum VideoButtons { |
44 | VideoPrevious, | 44 | VideoPrevious, |
45 | VideoStop, | 45 | VideoStop, |
46 | VideoPlay, | 46 | VideoPlay, |
47 | VideoPause, | 47 | VideoPause, |
48 | VideoNext, | 48 | VideoNext, |
49 | VideoPlayList, | 49 | VideoPlayList, |
50 | VideoFullscreen | 50 | VideoFullscreen |
51 | }; | 51 | }; |
52 | 52 | ||
53 | class VideoWidget : public QWidget { | 53 | class VideoWidget : public QWidget { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
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(); |
60 | public slots: | 61 | public slots: |
61 | void updateSlider( long, long ); | 62 | void updateSlider( long, long ); |
62 | void sliderPressed( ); | 63 | void sliderPressed( ); |
63 | void sliderReleased( ); | 64 | void sliderReleased( ); |
64 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } | 65 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } |
65 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } | 66 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } |
66 | void setFullscreen( bool b ); | 67 | void setFullscreen( bool b ); |
67 | void makeVisible(); | 68 | void makeVisible(); |
68 | void setPosition( long ); | 69 | void setPosition( long ); |
69 | void setLength( long ); | 70 | void setLength( long ); |
70 | void setView( char ); | 71 | void setView( char ); |
71 | 72 | ||
72 | signals: | 73 | signals: |
73 | void sliderMoved( long ); | 74 | void sliderMoved( long ); |
74 | void videoResized ( const QSize &s ); | 75 | void videoResized ( const QSize &s ); |
75 | 76 | ||
76 | protected: | 77 | protected: |
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 | ||
84 | private: | 87 | private: |
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 | ||
89 | QString backgroundPix; | 104 | QString backgroundPix; |
90 | QSlider *slider; | 105 | QSlider *slider; |
91 | QPixmap *pixmaps[3]; | 106 | QPixmap *pixmaps[3]; |
92 | QImage *currentFrame; | 107 | QImage *currentFrame; |
93 | int scaledWidth; | 108 | int scaledWidth; |
94 | int scaledHeight; | 109 | int scaledHeight; |
95 | XineVideoWidget* videoFrame; | 110 | XineVideoWidget* videoFrame; |
96 | }; | 111 | }; |
97 | 112 | ||
98 | #endif // VIDEO_WIDGET_H | 113 | #endif // VIDEO_WIDGET_H |
99 | 114 | ||
100 | 115 | ||
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 | |||
@@ -26,242 +26,243 @@ | |||
26 | -. .:....=;==+<; You should have received a copy of the GNU | 26 | -. .:....=;==+<; You should have received a copy of the GNU |
27 | -_. . . )=. = Library General Public License along with | 27 | -_. . . )=. = Library General Public License along with |
28 | -- :-=` this library; see the file COPYING.LIB. | 28 | -- :-=` this library; see the file COPYING.LIB. |
29 | If not, write to the Free Software Foundation, | 29 | If not, write to the Free Software Foundation, |
30 | Inc., 59 Temple Place - Suite 330, | 30 | Inc., 59 Temple Place - Suite 330, |
31 | Boston, MA 02111-1307, USA. | 31 | Boston, MA 02111-1307, USA. |
32 | 32 | ||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <qimage.h> | 35 | #include <qimage.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qgfx_qws.h> | 37 | #include <qgfx_qws.h> |
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" |
46 | 47 | ||
47 | 48 | ||
48 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 49 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
49 | { | 50 | { |
50 | ((char *) src ) += len; | 51 | ((char *) src ) += len; |
51 | 52 | ||
52 | len >>= 1; | 53 | len >>= 1; |
53 | while ( len-- ) | 54 | while ( len-- ) |
54 | *((short int *) dst )++ = *--((short int *) src ); | 55 | *((short int *) dst )++ = *--((short int *) src ); |
55 | } | 56 | } |
56 | 57 | ||
57 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 58 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
58 | { | 59 | { |
59 | len >>= 1; | 60 | len >>= 1; |
60 | while ( len-- ) { | 61 | while ( len-- ) { |
61 | *((short int *) dst )++ = *((short int *) src ); | 62 | *((short int *) dst )++ = *((short int *) src ); |
62 | ((char *) src ) += step; | 63 | ((char *) src ) += step; |
63 | } | 64 | } |
64 | } | 65 | } |
65 | 66 | ||
66 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) | 67 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) |
67 | { | 68 | { |
68 | len >>= 1; | 69 | len >>= 1; |
69 | 70 | ||
70 | ((char *) src ) += ( len * step ); | 71 | ((char *) src ) += ( len * step ); |
71 | 72 | ||
72 | while ( len-- ) { | 73 | while ( len-- ) { |
73 | ((char *) src ) -= step; | 74 | ((char *) src ) -= step; |
74 | *((short int *) dst )++ = *((short int *) src ); | 75 | *((short int *) dst )++ = *((short int *) src ); |
75 | } | 76 | } |
76 | } | 77 | } |
77 | 78 | ||
78 | 79 | ||
79 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 80 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
80 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 81 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
81 | { | 82 | { |
82 | setBackgroundMode ( NoBackground ); | 83 | setBackgroundMode ( NoBackground ); |
83 | 84 | ||
84 | m_image = 0; | 85 | m_image = 0; |
85 | m_buff = 0; | 86 | m_buff = 0; |
86 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 87 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
87 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 88 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
88 | m_rotation = 0; | 89 | m_rotation = 0; |
89 | } | 90 | } |
90 | 91 | ||
91 | 92 | ||
92 | XineVideoWidget::~XineVideoWidget ( ) | 93 | XineVideoWidget::~XineVideoWidget ( ) |
93 | { | 94 | { |
94 | delete m_image; | 95 | delete m_image; |
95 | } | 96 | } |
96 | 97 | ||
97 | void XineVideoWidget::clear ( ) | 98 | void XineVideoWidget::clear ( ) |
98 | { | 99 | { |
99 | m_buff = 0; | 100 | m_buff = 0; |
100 | repaint ( false ); | 101 | repaint ( false ); |
101 | } | 102 | } |
102 | 103 | ||
103 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 104 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
104 | { | 105 | { |
105 | //qWarning( "painting <<<" ); | 106 | //qWarning( "painting <<<" ); |
106 | if ( m_buff == 0 ) { | 107 | if ( m_buff == 0 ) { |
107 | QPainter p ( this ); | 108 | QPainter p ( this ); |
108 | p. fillRect ( rect ( ), black ); | 109 | p. fillRect ( rect ( ), black ); |
109 | if ( m_image ) | 110 | if ( m_image ) |
110 | p. drawImage ( 0, 0, *m_image ); | 111 | p. drawImage ( 0, 0, *m_image ); |
111 | //qWarning ( "logo\n" ); | 112 | //qWarning ( "logo\n" ); |
112 | } | 113 | } |
113 | else { | 114 | else { |
114 | // qWarning ( "paintevent\n" ); | 115 | // qWarning ( "paintevent\n" ); |
115 | 116 | ||
116 | QArray <QRect> qt_bug_workaround_clip_rects; | 117 | QArray <QRect> qt_bug_workaround_clip_rects; |
117 | 118 | ||
118 | { | 119 | { |
119 | QDirectPainter dp ( this ); | 120 | QDirectPainter dp ( this ); |
120 | 121 | ||
121 | int rot = dp. transformOrientation ( ) + m_rotation; | 122 | int rot = dp. transformOrientation ( ) + m_rotation; |
122 | 123 | ||
123 | uchar *fb = dp. frameBuffer ( ); | 124 | uchar *fb = dp. frameBuffer ( ); |
124 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; | 125 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; |
125 | 126 | ||
126 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 127 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
127 | 128 | ||
128 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 129 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
129 | 130 | ||
130 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 131 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
131 | const QRect &clip = dp. rect ( i ); | 132 | const QRect &clip = dp. rect ( i ); |
132 | 133 | ||
133 | qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 134 | qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
134 | 135 | ||
135 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); | 136 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); |
136 | uchar *src = frame; | 137 | uchar *src = frame; |
137 | 138 | ||
138 | switch ( rot ) { | 139 | switch ( rot ) { |
139 | case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; | 140 | case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; |
140 | 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; | 141 | 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; |
141 | 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; | 142 | 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; |
142 | case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; | 143 | case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; |
143 | } | 144 | } |
144 | 145 | ||
145 | uint leftfill = 0; | 146 | uint leftfill = 0; |
146 | uint framefill = 0; | 147 | uint framefill = 0; |
147 | uint rightfill = 0; | 148 | uint rightfill = 0; |
148 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; | 149 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; |
149 | 150 | ||
150 | if ( clip. left ( ) < framerect. left ( )) | 151 | if ( clip. left ( ) < framerect. left ( )) |
151 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 152 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
152 | if ( clip. right ( ) > framerect. right ( )) | 153 | if ( clip. right ( ) > framerect. right ( )) |
153 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 154 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
154 | 155 | ||
155 | framefill = clipwidth - ( leftfill + rightfill ); | 156 | framefill = clipwidth - ( leftfill + rightfill ); |
156 | 157 | ||
157 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 158 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
158 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 159 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
159 | memset ( dst, 0, clipwidth ); | 160 | memset ( dst, 0, clipwidth ); |
160 | } | 161 | } |
161 | else { | 162 | else { |
162 | if ( leftfill ) | 163 | if ( leftfill ) |
163 | memset ( dst, 0, leftfill ); | 164 | memset ( dst, 0, leftfill ); |
164 | 165 | ||
165 | if ( framefill ) { | 166 | if ( framefill ) { |
166 | switch ( rot ) { | 167 | switch ( rot ) { |
167 | case 0: memcpy ( dst + leftfill, src, framefill ); break; | 168 | case 0: memcpy ( dst + leftfill, src, framefill ); break; |
168 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 169 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
169 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 170 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
170 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 171 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
171 | } | 172 | } |
172 | } | 173 | } |
173 | if ( rightfill ) | 174 | if ( rightfill ) |
174 | memset ( dst + leftfill + framefill, 0, rightfill ); | 175 | memset ( dst + leftfill + framefill, 0, rightfill ); |
175 | } | 176 | } |
176 | 177 | ||
177 | dst += m_bytes_per_line_fb; | 178 | dst += m_bytes_per_line_fb; |
178 | 179 | ||
179 | switch ( rot ) { | 180 | switch ( rot ) { |
180 | case 0: src += m_bytes_per_line_frame; break; | 181 | case 0: src += m_bytes_per_line_frame; break; |
181 | case 1: src -= m_bytes_per_pixel; break; | 182 | case 1: src -= m_bytes_per_pixel; break; |
182 | case 2: src -= m_bytes_per_line_frame; break; | 183 | case 2: src -= m_bytes_per_line_frame; break; |
183 | case 3: src += m_bytes_per_pixel; break; | 184 | case 3: src += m_bytes_per_pixel; break; |
184 | } | 185 | } |
185 | } | 186 | } |
186 | } | 187 | } |
187 | } | 188 | } |
188 | //qWarning ( " ||| painting |||" ); | 189 | //qWarning ( " ||| painting |||" ); |
189 | { | 190 | { |
190 | // QVFB hack by MArtin Jones | 191 | // QVFB hack by MArtin Jones |
191 | QPainter p ( this ); | 192 | QPainter p ( this ); |
192 | 193 | ||
193 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 194 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
194 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); | 195 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | } | 198 | } |
198 | //qWarning( "painting >>>" ); | 199 | //qWarning( "painting >>>" ); |
199 | } | 200 | } |
200 | 201 | ||
201 | 202 | ||
202 | void XineVideoWidget::setImage ( QImage* image ) | 203 | void XineVideoWidget::setImage ( QImage* image ) |
203 | { | 204 | { |
204 | delete m_image; | 205 | delete m_image; |
205 | m_image = image; | 206 | m_image = image; |
206 | } | 207 | } |
207 | 208 | ||
208 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) | 209 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) |
209 | { | 210 | { |
210 | bool rot90 = (( -m_rotation ) & 1 ); | 211 | bool rot90 = (( -m_rotation ) & 1 ); |
211 | 212 | ||
212 | if ( rot90 ) { | 213 | if ( rot90 ) { |
213 | int d = w; | 214 | int d = w; |
214 | w = h; | 215 | w = h; |
215 | h = d; | 216 | h = d; |
216 | } | 217 | } |
217 | 218 | ||
218 | m_lastframe = m_thisframe; | 219 | m_lastframe = m_thisframe; |
219 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 220 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
220 | 221 | ||
221 | //qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 222 | // qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
222 | 223 | ||
223 | m_buff = img; | 224 | m_buff = img; |
224 | m_bytes_per_line_frame = bpl; | 225 | m_bytes_per_line_frame = bpl; |
225 | 226 | ||
226 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 227 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
227 | } | 228 | } |
228 | 229 | ||
229 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 230 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
230 | { | 231 | { |
231 | QSize s = size ( ); | 232 | QSize s = size ( ); |
232 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | 233 | bool fs = ( s == qApp-> desktop ( )-> size ( )); |
233 | 234 | ||
234 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | 235 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; |
235 | 236 | ||
236 | if ( fs && qt_screen-> isTransformed ( )) { | 237 | if ( fs && qt_screen-> isTransformed ( )) { |
237 | s = qt_screen-> mapToDevice ( s ); | 238 | s = qt_screen-> mapToDevice ( s ); |
238 | } | 239 | } |
239 | 240 | ||
240 | //qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); | 241 | // qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); |
241 | 242 | ||
242 | emit videoResized ( s ); | 243 | emit videoResized ( s ); |
243 | } | 244 | } |
244 | 245 | ||
245 | 246 | ||
246 | void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) | 247 | void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) |
247 | { | 248 | { |
248 | QWidget *p = parentWidget ( ); | 249 | QWidget *p = parentWidget ( ); |
249 | 250 | ||
250 | if ( p ) { | 251 | if ( p ) { |
251 | QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | 252 | QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); |
252 | 253 | ||
253 | QApplication::sendEvent ( p, &pme ); | 254 | QApplication::sendEvent ( p, &pme ); |
254 | } | 255 | } |
255 | } | 256 | } |
256 | 257 | ||
257 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) | 258 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) |
258 | { | 259 | { |
259 | QWidget *p = parentWidget ( ); | 260 | QWidget *p = parentWidget ( ); |
260 | 261 | ||
261 | if ( p ) { | 262 | if ( p ) { |
262 | QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | 263 | QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); |
263 | 264 | ||
264 | QApplication::sendEvent ( p, &pme ); | 265 | QApplication::sendEvent ( p, &pme ); |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||