summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-04-20 02:30:43 (UTC)
committer llornkcor <llornkcor>2003-04-20 02:30:43 (UTC)
commit845c8a880a2ff701f21c2845674e97a2493499f4 (patch) (unidiff)
treec91b65869022c2628f509cb27685e45dfb199679
parentb62c40465c917e4952651b6f359e5ec76b340d3f (diff)
downloadopie-845c8a880a2ff701f21c2845674e97a2493499f4.zip
opie-845c8a880a2ff701f21c2845674e97a2493499f4.tar.gz
opie-845c8a880a2ff701f21c2845674e97a2493499f4.tar.bz2
add video skin support *finally*, fixed widget for landscape/sizing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp35
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp923
-rw-r--r--core/multimedia/opieplayer/videowidget.h21
3 files changed, 627 insertions, 352 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 8b295b0..bffda38 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1102 +1,1119 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23 23
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/lnkproperties.h> 28#include <qpe/lnkproperties.h>
29#include <qpe/storage.h> 29#include <qpe/storage.h>
30 30
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/global.h> 33#include <qpe/global.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qaction.h> 35#include <qaction.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qimage.h> 37#include <qimage.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlist.h> 42#include <qlist.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qmainwindow.h> 44#include <qmainwindow.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qtoolbutton.h> 46#include <qtoolbutton.h>
47#include <qtabwidget.h> 47#include <qtabwidget.h>
48#include <qlistview.h> 48#include <qlistview.h>
49#include <qpoint.h> 49#include <qpoint.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qtextstream.h> 53#include <qtextstream.h>
54 54
55//#include <qtimer.h> 55//#include <qtimer.h>
56 56
57#include "playlistselection.h" 57#include "playlistselection.h"
58#include "playlistwidget.h" 58#include "playlistwidget.h"
59#include "mediaplayerstate.h" 59#include "mediaplayerstate.h"
60 60
61#include "inputDialog.h" 61#include "inputDialog.h"
62 62
63#include <stdlib.h> 63#include <stdlib.h>
64#include "audiowidget.h" 64#include "audiowidget.h"
65#include "videowidget.h" 65#include "videowidget.h"
66 66
67#include <unistd.h> 67#include <unistd.h>
68#include <sys/file.h> 68#include <sys/file.h>
69#include <sys/ioctl.h> 69#include <sys/ioctl.h>
70#include <sys/soundcard.h> 70#include <sys/soundcard.h>
71 71
72// for setBacklight() 72// for setBacklight()
73#include <linux/fb.h> 73#include <linux/fb.h>
74#include <sys/types.h> 74#include <sys/types.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <stdlib.h> 76#include <stdlib.h>
77 77
78#define BUTTONS_ON_TOOLBAR 78#define BUTTONS_ON_TOOLBAR
79#define SIDE_BUTTONS 79#define SIDE_BUTTONS
80#define CAN_SAVE_LOAD_PLAYLISTS 80#define CAN_SAVE_LOAD_PLAYLISTS
81 81
82extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86static inline QString fullBaseName ( const QFileInfo &fi ) 86static inline QString fullBaseName ( const QFileInfo &fi )
87{ 87{
88 QString str = fi. fileName ( ); 88 QString str = fi. fileName ( );
89 return str. left ( str. findRev ( '.' )); 89 return str. left ( str. findRev ( '.' ));
90} 90}
91 91
92 92
93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod;audio/x-ogg"; 93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod;audio/x-ogg";
94// class myFileSelector { 94// class myFileSelector {
95 95
96// }; 96// };
97class PlayListWidgetPrivate { 97class PlayListWidgetPrivate {
98public: 98public:
99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
100 QFrame *playListFrame; 100 QFrame *playListFrame;
101 FileSelector *files; 101 FileSelector *files;
102 PlayListSelection *selectedFiles; 102 PlayListSelection *selectedFiles;
103 bool setDocumentUsed; 103 bool setDocumentUsed;
104 DocLnk *current; 104 DocLnk *current;
105}; 105};
106 106
107 107
108class ToolButton : public QToolButton { 108class ToolButton : public QToolButton {
109public: 109public:
110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
111 : QToolButton( parent, name ) { 111 : QToolButton( parent, name ) {
112 setTextLabel( name ); 112 setTextLabel( name );
113 setPixmap( Resource::loadPixmap( icon ) ); 113 setPixmap( Resource::loadPixmap( icon ) );
114 setAutoRaise( TRUE ); 114 setAutoRaise( TRUE );
115 setFocusPolicy( QWidget::NoFocus ); 115 setFocusPolicy( QWidget::NoFocus );
116 setToggleButton( t ); 116 setToggleButton( t );
117 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 117 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
118 QPEMenuToolFocusManager::manager()->addWidget( this ); 118 QPEMenuToolFocusManager::manager()->addWidget( this );
119 } 119 }
120}; 120};
121 121
122 122
123class MenuItem : public QAction { 123class MenuItem : public QAction {
124public: 124public:
125 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 125 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
126 : QAction( text, QString::null, 0, 0 ) { 126 : QAction( text, QString::null, 0, 0 ) {
127 connect( this, SIGNAL( activated() ), handler, slot ); 127 connect( this, SIGNAL( activated() ), handler, slot );
128 addTo( parent ); 128 addTo( parent );
129 } 129 }
130}; 130};
131 131
132 132
133PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 133PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
134 : QMainWindow( parent, name, fl ) { 134 : QMainWindow( parent, name, fl ) {
135 135
136 d = new PlayListWidgetPrivate; 136 d = new PlayListWidgetPrivate;
137 d->setDocumentUsed = FALSE; 137 d->setDocumentUsed = FALSE;
138 d->current = NULL; 138 d->current = NULL;
139 fromSetDocument = FALSE; 139 fromSetDocument = FALSE;
140 insanityBool=FALSE; 140 insanityBool=FALSE;
141 audioScan = FALSE; 141 audioScan = FALSE;
142 videoScan = FALSE; 142 videoScan = FALSE;
143// menuTimer = new QTimer( this ,"menu timer"), 143// menuTimer = new QTimer( this ,"menu timer"),
144// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 144// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
145 channel = new QCopChannel( "QPE/Application/opieplayer", this ); 145 channel = new QCopChannel( "QPE/Application/opieplayer", this );
146 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 146 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
147 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); 147 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) );
148 148
149 setBackgroundMode( PaletteButton ); 149 setBackgroundMode( PaletteButton );
150 150
151 setCaption( tr("OpiePlayer") ); 151 setCaption( tr("OpiePlayer") );
152 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 152 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
153 153
154 setToolBarsMovable( FALSE ); 154 setToolBarsMovable( FALSE );
155 155
156 // Create Toolbar 156 // Create Toolbar
157 QPEToolBar *toolbar = new QPEToolBar( this ); 157 QPEToolBar *toolbar = new QPEToolBar( this );
158 toolbar->setHorizontalStretchable( TRUE ); 158 toolbar->setHorizontalStretchable( TRUE );
159 159
160 // Create Menubar 160 // Create Menubar
161 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 161 QPEMenuBar *menu = new QPEMenuBar( toolbar );
162 menu->setMargin( 0 ); 162 menu->setMargin( 0 );
163 163
164 QPEToolBar *bar = new QPEToolBar( this ); 164 QPEToolBar *bar = new QPEToolBar( this );
165 bar->setLabel( tr( "Play Operations" ) ); 165 bar->setLabel( tr( "Play Operations" ) );
166// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 166// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
167// this , SLOT( addSelected()) ); 167// this , SLOT( addSelected()) );
168 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 168 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
169 tbDeletePlaylist->setFlat(TRUE); 169 tbDeletePlaylist->setFlat(TRUE);
170
170 tbDeletePlaylist->setFixedSize(20,20); 171 tbDeletePlaylist->setFixedSize(20,20);
171 172
172 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 173 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
173 this , SLOT(addSelected()) ); 174 this , SLOT(addSelected()) );
174 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 175 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
175 this , SLOT(removeSelected()) ); 176 this , SLOT(removeSelected()) );
176// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 177// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
177 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 178 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
178 this , SLOT( btnPlay(bool) ), TRUE ); 179 this , SLOT( btnPlay(bool) ), TRUE );
179 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 180 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
180 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 181 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
181 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 182 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
182 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 183 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
183 tbDeletePlaylist->hide(); 184 tbDeletePlaylist->hide();
184 185
185 QPopupMenu *pmPlayList = new QPopupMenu( this ); 186 QPopupMenu *pmPlayList = new QPopupMenu( this );
186 menu->insertItem( tr( "File" ), pmPlayList ); 187 menu->insertItem( tr( "File" ), pmPlayList );
187 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 188 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
188 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 189 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
189 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 190 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
190 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 191 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
191 pmPlayList->insertSeparator(-1); 192 pmPlayList->insertSeparator(-1);
192 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 193 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
193 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 194 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
194 pmPlayList->insertSeparator(-1); 195 pmPlayList->insertSeparator(-1);
195 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 196 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
196 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 197 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
197 198
198 QPopupMenu *pmView = new QPopupMenu( this ); 199 QPopupMenu *pmView = new QPopupMenu( this );
199 menu->insertItem( tr( "View" ), pmView ); 200 menu->insertItem( tr( "View" ), pmView );
200 201
201 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 202 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
202 fullScreenButton->addTo(pmView); 203 fullScreenButton->addTo(pmView);
203 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 204 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
204 scaleButton->addTo(pmView); 205 scaleButton->addTo(pmView);
205 206
206 207
207 skinsMenu = new QPopupMenu( this ); 208 skinsMenu = new QPopupMenu( this );
208 menu->insertItem( tr( "Skins" ), skinsMenu ); 209 menu->insertItem( tr( "Skins" ), skinsMenu );
209 skinsMenu->isCheckable(); 210 skinsMenu->isCheckable();
210 connect( skinsMenu, SIGNAL( activated( int ) ) , 211 connect( skinsMenu, SIGNAL( activated( int ) ) ,
211 this, SLOT( skinsMenuActivated( int ) ) ); 212 this, SLOT( skinsMenuActivated( int ) ) );
212 populateSkinsMenu(); 213 populateSkinsMenu();
213 214
214 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 215 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
215 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 216 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
216 217
217 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 218 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
218 219
219 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 220 tabWidget = new QTabWidget( hbox6, "tabWidget" );
220// tabWidget->setTabShape(QTabWidget::Triangular); 221// tabWidget->setTabShape(QTabWidget::Triangular);
221 222
222 QWidget *pTab; 223 QWidget *pTab;
223 pTab = new QWidget( tabWidget, "pTab" ); 224 pTab = new QWidget( tabWidget, "pTab" );
224// playlistView = new QListView( pTab, "playlistview" ); 225// playlistView = new QListView( pTab, "playlistview" );
225// playlistView->setMinimumSize(236,260); 226// playlistView->setMinimumSize(236,260);
226 tabWidget->insertTab( pTab,"Playlist"); 227 tabWidget->insertTab( pTab,"Playlist");
227 228
228 229
229 // Add the playlist area 230 // Add the playlist area
230 231
231 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 232 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
232 d->playListFrame = vbox3; 233 d->playListFrame = vbox3;
233 d->playListFrame ->setMinimumSize(235,260); 234
235 QGridLayout *layoutF = new QGridLayout( pTab );
236 layoutF->setSpacing( 2);
237 layoutF->setMargin( 2);
238 layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 );
239// d->playListFrame ->setMinimumSize(235,260);
234 240
235 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 241 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
236 242
237 d->selectedFiles = new PlayListSelection( hbox2); 243 d->selectedFiles = new PlayListSelection( hbox2);
238 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 244 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
239 245
240 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 246 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
241 247
242 248
243 249
244 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 250 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
245 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 251 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
246 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 252 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
247 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 253 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
248 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 254 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
249 255
250 QWidget *aTab; 256 QWidget *aTab;
251 aTab = new QWidget( tabWidget, "aTab" ); 257 aTab = new QWidget( tabWidget, "aTab" );
252 audioView = new QListView( aTab, "Audioview" ); 258 audioView = new QListView( aTab, "Audioview" );
253 audioView->setMinimumSize(233,260); 259
260 QGridLayout *layoutA = new QGridLayout( aTab );
261 layoutA->setSpacing( 2);
262 layoutA->setMargin( 2);
263 layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 );
264
254 audioView->addColumn( tr("Title"),140); 265 audioView->addColumn( tr("Title"),140);
255 audioView->addColumn(tr("Size"), -1); 266 audioView->addColumn(tr("Size"), -1);
256 audioView->addColumn(tr("Media"),-1); 267 audioView->addColumn(tr("Media"),-1);
257 audioView->addColumn( tr( "Path" ), 0 ); 268 audioView->addColumn( tr( "Path" ), 0 );
258 269
259 audioView->setColumnAlignment(1, Qt::AlignRight); 270 audioView->setColumnAlignment(1, Qt::AlignRight);
260 audioView->setColumnAlignment(2, Qt::AlignRight); 271 audioView->setColumnAlignment(2, Qt::AlignRight);
261 audioView->setAllColumnsShowFocus(TRUE); 272 audioView->setAllColumnsShowFocus(TRUE);
262 273
263 audioView->setMultiSelection( TRUE ); 274 audioView->setMultiSelection( TRUE );
264 audioView->setSelectionMode( QListView::Extended); 275 audioView->setSelectionMode( QListView::Extended);
265 audioView->setSorting( 3, TRUE ); 276 audioView->setSorting( 3, TRUE );
266 277
267 tabWidget->insertTab(aTab,tr("Audio")); 278 tabWidget->insertTab(aTab,tr("Audio"));
268 279
269 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 280 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
270 281
271// audioView 282// audioView
272// populateAudioView(); 283// populateAudioView();
273// videowidget 284// videowidget
274 285
275 QWidget *vTab; 286 QWidget *vTab;
276 vTab = new QWidget( tabWidget, "vTab" ); 287 vTab = new QWidget( tabWidget, "vTab" );
277 videoView = new QListView( vTab, "Videoview" ); 288 videoView = new QListView( vTab, "Videoview" );
278 videoView->setMinimumSize(233,260); 289
290 QGridLayout *layoutV = new QGridLayout( vTab );
291 layoutV->setSpacing( 2);
292 layoutV->setMargin( 2);
293 layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 );
279 294
280 videoView->addColumn(tr("Title"),140); 295 videoView->addColumn(tr("Title"),140);
281 videoView->addColumn(tr("Size"),-1); 296 videoView->addColumn(tr("Size"),-1);
282 videoView->addColumn(tr("Media"),-1); 297 videoView->addColumn(tr("Media"),-1);
283 videoView->addColumn(tr( "Path" ), 0 ); 298 videoView->addColumn(tr( "Path" ), 0 );
284 videoView->setColumnAlignment(1, Qt::AlignRight); 299 videoView->setColumnAlignment(1, Qt::AlignRight);
285 videoView->setColumnAlignment(2, Qt::AlignRight); 300 videoView->setColumnAlignment(2, Qt::AlignRight);
286 videoView->setAllColumnsShowFocus(TRUE); 301 videoView->setAllColumnsShowFocus(TRUE);
287 videoView->setMultiSelection( TRUE ); 302 videoView->setMultiSelection( TRUE );
288 videoView->setSelectionMode( QListView::Extended); 303 videoView->setSelectionMode( QListView::Extended);
289 304
290 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 305 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
291 306
292 tabWidget->insertTab( vTab,tr("Video")); 307 tabWidget->insertTab( vTab,tr("Video"));
293 308
294 QWidget *LTab; 309 QWidget *LTab;
295 LTab = new QWidget( tabWidget, "LTab" ); 310 LTab = new QWidget( tabWidget, "LTab" );
296 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 311 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
297 playLists->setMinimumSize(233,260); 312
313 QGridLayout *layoutL = new QGridLayout( LTab );
314 layoutL->setSpacing( 2);
315 layoutL->setMargin( 2);
316 layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 );
317// playLists->setMinimumSize(233,260);
318
298 tabWidget->insertTab(LTab,tr("Lists")); 319 tabWidget->insertTab(LTab,tr("Lists"));
299 320
300 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 321 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
301 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 322 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
302 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 323 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
303 324
304 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 325 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
305 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 326 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
306 327
307 328
308///audioView 329///audioView
309 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 330 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
310 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 331 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
311 332
312 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 333 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
313 this,SLOT( playIt( QListViewItem *)) ); 334 this,SLOT( playIt( QListViewItem *)) );
314 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 335 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
315 336
316 337
317//videoView 338//videoView
318 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 339 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
319 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 340 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
320 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 341 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
321 this,SLOT( playIt( QListViewItem *)) ); 342 this,SLOT( playIt( QListViewItem *)) );
322 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 343 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
323 344
324
325//playlists 345//playlists
326 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 346 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
327 347
328
329 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 348 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
330 349
331 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 350 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
332 351
333
334
335 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 352 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
336 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 353 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
337 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 354 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
338 355
339 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 356 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
340 357
341 setCentralWidget( vbox5 ); 358 setCentralWidget( vbox5 );
342 359
343 Config cfg( "OpiePlayer" ); 360 Config cfg( "OpiePlayer" );
344 readConfig( cfg ); 361 readConfig( cfg );
345 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 362 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
346 loadList(DocLnk( currentPlaylist)); 363 loadList(DocLnk( currentPlaylist));
347 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); 364 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist)));
348 365
349 initializeStates(); 366 initializeStates();
350} 367}
351 368
352 369
353PlayListWidget::~PlayListWidget() { 370PlayListWidget::~PlayListWidget() {
354 Config cfg( "OpiePlayer" ); 371 Config cfg( "OpiePlayer" );
355 writeConfig( cfg ); 372 writeConfig( cfg );
356 373
357 if ( d->current ) 374 if ( d->current )
358 delete d->current; 375 delete d->current;
359 delete d; 376 delete d;
360} 377}
361 378
362 379
363void PlayListWidget::initializeStates() { 380void PlayListWidget::initializeStates() {
364 381
365 d->tbPlay->setOn( mediaPlayerState->playing() ); 382 d->tbPlay->setOn( mediaPlayerState->playing() );
366 d->tbLoop->setOn( mediaPlayerState->looping() ); 383 d->tbLoop->setOn( mediaPlayerState->looping() );
367 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 384 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
368 setPlaylist( true); 385 setPlaylist( true);
369} 386}
370 387
371 388
372void PlayListWidget::readConfig( Config& cfg ) { 389void PlayListWidget::readConfig( Config& cfg ) {
373 cfg.setGroup("PlayList"); 390 cfg.setGroup("PlayList");
374 QString currentString = cfg.readEntry("current", "" ); 391 QString currentString = cfg.readEntry("current", "" );
375 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 392 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
376 for ( int i = 0; i < noOfFiles; i++ ) { 393 for ( int i = 0; i < noOfFiles; i++ ) {
377 QString entryName; 394 QString entryName;
378 entryName.sprintf( "File%i", i + 1 ); 395 entryName.sprintf( "File%i", i + 1 );
379 QString linkFile = cfg.readEntry( entryName ); 396 QString linkFile = cfg.readEntry( entryName );
380 DocLnk lnk( linkFile ); 397 DocLnk lnk( linkFile );
381 if ( lnk.isValid() ) { 398 if ( lnk.isValid() ) {
382 d->selectedFiles->addToSelection( lnk ); 399 d->selectedFiles->addToSelection( lnk );
383 } 400 }
384 } 401 }
385 d->selectedFiles->setSelectedItem( currentString); 402 d->selectedFiles->setSelectedItem( currentString);
386} 403}
387 404
388 405
389void PlayListWidget::writeConfig( Config& cfg ) const { 406void PlayListWidget::writeConfig( Config& cfg ) const {
390 407
391 d->selectedFiles->writeCurrent( cfg); 408 d->selectedFiles->writeCurrent( cfg);
392 cfg.setGroup("PlayList"); 409 cfg.setGroup("PlayList");
393 int noOfFiles = 0; 410 int noOfFiles = 0;
394 d->selectedFiles->first(); 411 d->selectedFiles->first();
395 do { 412 do {
396 const DocLnk *lnk = d->selectedFiles->current(); 413 const DocLnk *lnk = d->selectedFiles->current();
397 if ( lnk ) { 414 if ( lnk ) {
398 QString entryName; 415 QString entryName;
399 entryName.sprintf( "File%i", noOfFiles + 1 ); 416 entryName.sprintf( "File%i", noOfFiles + 1 );
400// qDebug(entryName); 417// qDebug(entryName);
401 cfg.writeEntry( entryName, lnk->linkFile() ); 418 cfg.writeEntry( entryName, lnk->linkFile() );
402 // if this link does exist, add it so we have the file 419 // if this link does exist, add it so we have the file
403 // next time... 420 // next time...
404 if ( !QFile::exists( lnk->linkFile() ) ) { 421 if ( !QFile::exists( lnk->linkFile() ) ) {
405 // the way writing lnks doesn't really check for out 422 // the way writing lnks doesn't really check for out
406 // of disk space, but check it anyway. 423 // of disk space, but check it anyway.
407 if ( !lnk->writeLink() ) { 424 if ( !lnk->writeLink() ) {
408 QMessageBox::critical( 0, tr("Out of space"), 425 QMessageBox::critical( 0, tr("Out of space"),
409 tr( "There was a problem saving " 426 tr( "There was a problem saving "
410 "the playlist.\n" 427 "the playlist.\n"
411 "Your playlist " 428 "Your playlist "
412 "may be missing some entries\n" 429 "may be missing some entries\n"
413 "the next time you start it." ) 430 "the next time you start it." )
414 ); 431 );
415 } 432 }
416 } 433 }
417 noOfFiles++; 434 noOfFiles++;
418 } 435 }
419 } 436 }
420 while ( d->selectedFiles->next() ); 437 while ( d->selectedFiles->next() );
421 cfg.writeEntry("NumberOfFiles", noOfFiles ); 438 cfg.writeEntry("NumberOfFiles", noOfFiles );
422} 439}
423 440
424 441
425void PlayListWidget::addToSelection( const DocLnk& lnk ) { 442void PlayListWidget::addToSelection( const DocLnk& lnk ) {
426 d->setDocumentUsed = false; 443 d->setDocumentUsed = false;
427 if ( mediaPlayerState->playlist() ) { 444 if ( mediaPlayerState->playlist() ) {
428 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 445 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
429 d->selectedFiles->addToSelection( lnk ); 446 d->selectedFiles->addToSelection( lnk );
430 } 447 }
431 else 448 else
432 mediaPlayerState->setPlaying( true); 449 mediaPlayerState->setPlaying( true);
433} 450}
434 451
435 452
436void PlayListWidget::clearList() { 453void PlayListWidget::clearList() {
437 while ( first() ) 454 while ( first() )
438 d->selectedFiles->removeSelected(); 455 d->selectedFiles->removeSelected();
439} 456}
440 457
441 458
442void PlayListWidget::addAllToList() { 459void PlayListWidget::addAllToList() {
443 DocLnkSet filesAll; 460 DocLnkSet filesAll;
444 Global::findDocuments(&filesAll, "video/*;audio/*"); 461 Global::findDocuments(&filesAll, "video/*;audio/*");
445 QListIterator<DocLnk> Adit( filesAll.children() ); 462 QListIterator<DocLnk> Adit( filesAll.children() );
446 for ( ; Adit.current(); ++Adit ) 463 for ( ; Adit.current(); ++Adit )
447 if(QFileInfo(Adit.current()->file()).exists()) 464 if(QFileInfo(Adit.current()->file()).exists())
448 d->selectedFiles->addToSelection( **Adit ); 465 d->selectedFiles->addToSelection( **Adit );
449 tabWidget->setCurrentPage(0); 466 tabWidget->setCurrentPage(0);
450 467
451 writeCurrentM3u(); 468 writeCurrentM3u();
452 d->selectedFiles->first(); 469 d->selectedFiles->first();
453} 470}
454 471
455 472
456void PlayListWidget::addAllMusicToList() { 473void PlayListWidget::addAllMusicToList() {
457 QListIterator<DocLnk> dit( files.children() ); 474 QListIterator<DocLnk> dit( files.children() );
458 for ( ; dit.current(); ++dit ) 475 for ( ; dit.current(); ++dit )
459 if(QFileInfo(dit.current()->file()).exists()) 476 if(QFileInfo(dit.current()->file()).exists())
460 d->selectedFiles->addToSelection( **dit ); 477 d->selectedFiles->addToSelection( **dit );
461 tabWidget->setCurrentPage(0); 478 tabWidget->setCurrentPage(0);
462 479
463 writeCurrentM3u(); 480 writeCurrentM3u();
464 d->selectedFiles->first(); 481 d->selectedFiles->first();
465} 482}
466 483
467 484
468void PlayListWidget::addAllVideoToList() { 485void PlayListWidget::addAllVideoToList() {
469 QListIterator<DocLnk> dit( vFiles.children() ); 486 QListIterator<DocLnk> dit( vFiles.children() );
470 for ( ; dit.current(); ++dit ) 487 for ( ; dit.current(); ++dit )
471 if(QFileInfo( dit.current()->file()).exists()) 488 if(QFileInfo( dit.current()->file()).exists())
472 d->selectedFiles->addToSelection( **dit ); 489 d->selectedFiles->addToSelection( **dit );
473 tabWidget->setCurrentPage(0); 490 tabWidget->setCurrentPage(0);
474 491
475 writeCurrentM3u(); 492 writeCurrentM3u();
476 d->selectedFiles->first(); 493 d->selectedFiles->first();
477} 494}
478 495
479 496
480void PlayListWidget::setDocument(const QString& fileref) { 497void PlayListWidget::setDocument(const QString& fileref) {
481 qDebug(fileref); 498 qDebug(fileref);
482 fromSetDocument = TRUE; 499 fromSetDocument = TRUE;
483 QFileInfo fileInfo(fileref); 500 QFileInfo fileInfo(fileref);
484 if ( !fileInfo.exists() ) { 501 if ( !fileInfo.exists() ) {
485 QMessageBox::critical( 0, tr( "Invalid File" ), 502 QMessageBox::critical( 0, tr( "Invalid File" ),
486 tr( "There was a problem in getting the file." ) ); 503 tr( "There was a problem in getting the file." ) );
487 return; 504 return;
488 } 505 }
489// qDebug("setDocument "+fileref); 506// qDebug("setDocument "+fileref);
490 QString extension = fileInfo.extension(false); 507 QString extension = fileInfo.extension(false);
491 if( extension.find( "m3u", 0, false) != -1) { //is m3u 508 if( extension.find( "m3u", 0, false) != -1) { //is m3u
492 readm3u( fileref); 509 readm3u( fileref);
493 } 510 }
494 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 511 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
495 readPls( fileref); 512 readPls( fileref);
496 } 513 }
497 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 514 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
498 clearList(); 515 clearList();
499 DocLnk lnk; 516 DocLnk lnk;
500 lnk.setName( fileInfo.baseName() ); //sets name 517 lnk.setName( fileInfo.baseName() ); //sets name
501 lnk.setFile( fileref ); //sets file name 518 lnk.setFile( fileref ); //sets file name
502 //addToSelection( lnk ); 519 //addToSelection( lnk );
503 520
504 loadList( lnk); 521 loadList( lnk);
505 d->selectedFiles->first(); 522 d->selectedFiles->first();
506 } else { 523 } else {
507 clearList(); 524 clearList();
508 DocLnk lnk; 525 DocLnk lnk;
509 lnk.setName( fileInfo.baseName() ); //sets name 526 lnk.setName( fileInfo.baseName() ); //sets name
510 lnk.setFile( fileref ); //sets file name 527 lnk.setFile( fileref ); //sets file name
511 addToSelection( lnk ); 528 addToSelection( lnk );
512// addToSelection( DocLnk( fileref ) ); 529// addToSelection( DocLnk( fileref ) );
513 d->setDocumentUsed = TRUE; 530 d->setDocumentUsed = TRUE;
514 mediaPlayerState->setPlaying( FALSE ); 531 mediaPlayerState->setPlaying( FALSE );
515 qApp->processEvents(); 532 qApp->processEvents();
516 mediaPlayerState->setPlaying( TRUE ); 533 mediaPlayerState->setPlaying( TRUE );
517 qApp->processEvents(); 534 qApp->processEvents();
518 setCaption(tr("OpiePlayer")); 535 setCaption(tr("OpiePlayer"));
519 } 536 }
520} 537}
521 538
522 539
523void PlayListWidget::setActiveWindow() { 540void PlayListWidget::setActiveWindow() {
524 qDebug("SETTING active window"); 541 qDebug("SETTING active window");
525 542
526 // When we get raised we need to ensure that it switches views 543 // When we get raised we need to ensure that it switches views
527 char origView = mediaPlayerState->view(); 544 char origView = mediaPlayerState->view();
528 mediaPlayerState->setView( 'l' ); // invalidate 545 mediaPlayerState->setView( 'l' ); // invalidate
529 mediaPlayerState->setView( origView ); // now switch back 546 mediaPlayerState->setView( origView ); // now switch back
530} 547}
531 548
532 549
533void PlayListWidget::useSelectedDocument() { 550void PlayListWidget::useSelectedDocument() {
534 d->setDocumentUsed = FALSE; 551 d->setDocumentUsed = FALSE;
535} 552}
536 553
537 554
538const DocLnk *PlayListWidget::current() { // this is fugly 555const DocLnk *PlayListWidget::current() { // this is fugly
539 556
540// if( fromSetDocument) { 557// if( fromSetDocument) {
541// qDebug("from setDoc"); 558// qDebug("from setDoc");
542// DocLnkSet files; 559// DocLnkSet files;
543// Global::findDocuments(&files, "video/*;audio/*"); 560// Global::findDocuments(&files, "video/*;audio/*");
544// QListIterator<DocLnk> dit( files.children() ); 561// QListIterator<DocLnk> dit( files.children() );
545// for ( ; dit.current(); ++dit ) { 562// for ( ; dit.current(); ++dit ) {
546// if(dit.current()->linkFile() == setDocFileRef) { 563// if(dit.current()->linkFile() == setDocFileRef) {
547// qDebug(setDocFileRef); 564// qDebug(setDocFileRef);
548// return dit; 565// return dit;
549// } 566// }
550// } 567// }
551// } else 568// } else
552 569
553 qDebug("current"); 570 qDebug("current");
554 571
555 switch (tabWidget->currentPageIndex()) { 572 switch (tabWidget->currentPageIndex()) {
556 case 0: //playlist 573 case 0: //playlist
557 { 574 {
558 qDebug("playlist"); 575 qDebug("playlist");
559 if ( mediaPlayerState->playlist() ) { 576 if ( mediaPlayerState->playlist() ) {
560 return d->selectedFiles->current(); 577 return d->selectedFiles->current();
561 } 578 }
562 else if ( d->setDocumentUsed && d->current ) { 579 else if ( d->setDocumentUsed && d->current ) {
563 return d->current; 580 return d->current;
564 } else { 581 } else {
565 return &(d->files->selectedDocument()); 582 return &(d->files->selectedDocument());
566 } 583 }
567 } 584 }
568 break; 585 break;
569 case 1://audio 586 case 1://audio
570 { 587 {
571 qDebug("audioView"); 588 qDebug("audioView");
572 QListIterator<DocLnk> dit( files.children() ); 589 QListIterator<DocLnk> dit( files.children() );
573 for ( ; dit.current(); ++dit ) { 590 for ( ; dit.current(); ++dit ) {
574 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 591 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
575 qDebug("here"); 592 qDebug("here");
576 insanityBool=TRUE; 593 insanityBool=TRUE;
577 return dit; 594 return dit;
578 } 595 }
579 } 596 }
580 } 597 }
581 break; 598 break;
582 case 2: // video 599 case 2: // video
583 { 600 {
584 qDebug("videoView"); 601 qDebug("videoView");
585 QListIterator<DocLnk> Vdit( vFiles.children() ); 602 QListIterator<DocLnk> Vdit( vFiles.children() );
586 for ( ; Vdit.current(); ++Vdit ) { 603 for ( ; Vdit.current(); ++Vdit ) {
587 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 604 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
588 insanityBool=TRUE; 605 insanityBool=TRUE;
589 return Vdit; 606 return Vdit;
590 } 607 }
591 } 608 }
592 } 609 }
593 break; 610 break;
594 }; 611 };
595 return 0; 612 return 0;
596} 613}
597 614
598bool PlayListWidget::prev() { 615bool PlayListWidget::prev() {
599 if ( mediaPlayerState->playlist() ) { 616 if ( mediaPlayerState->playlist() ) {
600 if ( mediaPlayerState->shuffled() ) { 617 if ( mediaPlayerState->shuffled() ) {
601 const DocLnk *cur = current(); 618 const DocLnk *cur = current();
602 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 619 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
603 for ( int i = 0; i < j; i++ ) { 620 for ( int i = 0; i < j; i++ ) {
604 if ( !d->selectedFiles->next() ) 621 if ( !d->selectedFiles->next() )
605 d->selectedFiles->first(); 622 d->selectedFiles->first();
606 } 623 }
607 if ( cur == current() ) 624 if ( cur == current() )
608 if ( !d->selectedFiles->next() ) 625 if ( !d->selectedFiles->next() )
609 d->selectedFiles->first(); 626 d->selectedFiles->first();
610 return TRUE; 627 return TRUE;
611 } else { 628 } else {
612 if ( !d->selectedFiles->prev() ) { 629 if ( !d->selectedFiles->prev() ) {
613 if ( mediaPlayerState->looping() ) { 630 if ( mediaPlayerState->looping() ) {
614 return d->selectedFiles->last(); 631 return d->selectedFiles->last();
615 } else { 632 } else {
616 return FALSE; 633 return FALSE;
617 } 634 }
618 } 635 }
619 return TRUE; 636 return TRUE;
620 } 637 }
621 } else { 638 } else {
622 return mediaPlayerState->looping(); 639 return mediaPlayerState->looping();
623 } 640 }
624} 641}
625 642
626 643
627bool PlayListWidget::next() { 644bool PlayListWidget::next() {
628 if ( mediaPlayerState->playlist() ) { 645 if ( mediaPlayerState->playlist() ) {
629 if ( mediaPlayerState->shuffled() ) { 646 if ( mediaPlayerState->shuffled() ) {
630 return prev(); 647 return prev();
631 } else { 648 } else {
632 if ( !d->selectedFiles->next() ) { 649 if ( !d->selectedFiles->next() ) {
633 if ( mediaPlayerState->looping() ) { 650 if ( mediaPlayerState->looping() ) {
634 return d->selectedFiles->first(); 651 return d->selectedFiles->first();
635 } else { 652 } else {
636 return FALSE; 653 return FALSE;
637 } 654 }
638 } 655 }
639 return TRUE; 656 return TRUE;
640 } 657 }
641 } else { 658 } else {
642 return mediaPlayerState->looping(); 659 return mediaPlayerState->looping();
643 } 660 }
644} 661}
645 662
646 663
647bool PlayListWidget::first() { 664bool PlayListWidget::first() {
648 if ( mediaPlayerState->playlist() ) 665 if ( mediaPlayerState->playlist() )
649 return d->selectedFiles->first(); 666 return d->selectedFiles->first();
650 else 667 else
651 return mediaPlayerState->looping(); 668 return mediaPlayerState->looping();
652} 669}
653 670
654 671
655bool PlayListWidget::last() { 672bool PlayListWidget::last() {
656 if ( mediaPlayerState->playlist() ) 673 if ( mediaPlayerState->playlist() )
657 return d->selectedFiles->last(); 674 return d->selectedFiles->last();
658 else 675 else
659 return mediaPlayerState->looping(); 676 return mediaPlayerState->looping();
660} 677}
661 678
662 679
663void PlayListWidget::saveList() { 680void PlayListWidget::saveList() {
664 writem3u(); 681 writem3u();
665} 682}
666 683
667void PlayListWidget::loadList( const DocLnk & lnk) { 684void PlayListWidget::loadList( const DocLnk & lnk) {
668 QString name = lnk.name(); 685 QString name = lnk.name();
669// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 686// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
670 687
671 if( name.length()>0) { 688 if( name.length()>0) {
672 setCaption("OpiePlayer: "+name); 689 setCaption("OpiePlayer: "+name);
673// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 690// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
674 clearList(); 691 clearList();
675 readm3u(lnk.file()); 692 readm3u(lnk.file());
676 tabWidget->setCurrentPage(0); 693 tabWidget->setCurrentPage(0);
677 } 694 }
678} 695}
679 696
680void PlayListWidget::setPlaylist( bool shown ) { 697void PlayListWidget::setPlaylist( bool shown ) {
681 if ( shown ) 698 if ( shown )
682 d->playListFrame->show(); 699 d->playListFrame->show();
683 else 700 else
684 d->playListFrame->hide(); 701 d->playListFrame->hide();
685} 702}
686 703
687void PlayListWidget::setView( char view ) { 704void PlayListWidget::setView( char view ) {
688 if ( view == 'l' ) 705 if ( view == 'l' )
689 showMaximized(); 706 showMaximized();
690 else 707 else
691 hide(); 708 hide();
692} 709}
693 710
694void PlayListWidget::addSelected() { 711void PlayListWidget::addSelected() {
695 qDebug("addSelected"); 712 qDebug("addSelected");
696 DocLnk lnk; 713 DocLnk lnk;
697 QString filename; 714 QString filename;
698 switch (tabWidget->currentPageIndex()) { 715 switch (tabWidget->currentPageIndex()) {
699 716
700 case 0: //playlist 717 case 0: //playlist
701 return; 718 return;
702 break; 719 break;
703 case 1: { //audio 720 case 1: { //audio
704 QListViewItemIterator it( audioView ); 721 QListViewItemIterator it( audioView );
705 for ( ; it.current(); ++it ) { 722 for ( ; it.current(); ++it ) {
706 if ( it.current()->isSelected() ) { 723 if ( it.current()->isSelected() ) {
707 filename = it.current()->text(3); 724 filename = it.current()->text(3);
708 lnk.setName( QFileInfo(filename).baseName() ); //sets name 725 lnk.setName( QFileInfo(filename).baseName() ); //sets name
709 lnk.setFile( filename ); //sets file name 726 lnk.setFile( filename ); //sets file name
710 d->selectedFiles->addToSelection( lnk); 727 d->selectedFiles->addToSelection( lnk);
711 } 728 }
712 } 729 }
713 audioView->clearSelection(); 730 audioView->clearSelection();
714 // d->selectedFiles->next(); 731 // d->selectedFiles->next();
715 } 732 }
716 break; 733 break;
717 734
718 case 2: { // video 735 case 2: { // video
719 QListViewItemIterator it( videoView ); 736 QListViewItemIterator it( videoView );
720 for ( ; it.current(); ++it ) { 737 for ( ; it.current(); ++it ) {
721 if ( it.current()->isSelected() ) { 738 if ( it.current()->isSelected() ) {
722 739
723 filename = it.current()->text(3); 740 filename = it.current()->text(3);
724 lnk.setName( QFileInfo(filename).baseName() ); //sets name 741 lnk.setName( QFileInfo(filename).baseName() ); //sets name
725 lnk.setFile( filename ); //sets file name 742 lnk.setFile( filename ); //sets file name
726 d->selectedFiles->addToSelection( lnk); 743 d->selectedFiles->addToSelection( lnk);
727 } 744 }
728 } 745 }
729 videoView->clearSelection(); 746 videoView->clearSelection();
730 } 747 }
731 break; 748 break;
732 }; 749 };
733// tabWidget->setCurrentPage(0); 750// tabWidget->setCurrentPage(0);
734 writeCurrentM3u(); 751 writeCurrentM3u();
735 752
736} 753}
737 754
738void PlayListWidget::removeSelected() { 755void PlayListWidget::removeSelected() {
739 d->selectedFiles->removeSelected( ); 756 d->selectedFiles->removeSelected( );
740} 757}
741 758
742void PlayListWidget::playIt( QListViewItem *) { 759void PlayListWidget::playIt( QListViewItem *) {
743// d->setDocumentUsed = FALSE; 760// d->setDocumentUsed = FALSE;
744// mediaPlayerState->curPosition =0; 761// mediaPlayerState->curPosition =0;
745 qDebug("playIt"); 762 qDebug("playIt");
746 mediaPlayerState->setPlaying(FALSE); 763 mediaPlayerState->setPlaying(FALSE);
747 mediaPlayerState->setPlaying(TRUE); 764 mediaPlayerState->setPlaying(TRUE);
748 d->selectedFiles->unSelect(); 765 d->selectedFiles->unSelect();
749} 766}
750 767
751void PlayListWidget::addToSelection( QListViewItem *it) { 768void PlayListWidget::addToSelection( QListViewItem *it) {
752 d->setDocumentUsed = FALSE; 769 d->setDocumentUsed = FALSE;
753 770
754 if(it) { 771 if(it) {
755 switch ( tabWidget->currentPageIndex()) { 772 switch ( tabWidget->currentPageIndex()) {
756 case 0: //playlist 773 case 0: //playlist
757 return; 774 return;
758 break; 775 break;
759 }; 776 };
760 // case 1: { 777 // case 1: {
761 DocLnk lnk; 778 DocLnk lnk;
762 QString filename; 779 QString filename;
763 780
764 filename=it->text(3); 781 filename=it->text(3);
765 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 782 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
766 lnk.setFile( filename ); //sets file name 783 lnk.setFile( filename ); //sets file name
767 d->selectedFiles->addToSelection( lnk); 784 d->selectedFiles->addToSelection( lnk);
768 785
769 writeCurrentM3u(); 786 writeCurrentM3u();
770// tabWidget->setCurrentPage(0); 787// tabWidget->setCurrentPage(0);
771 788
772 } 789 }
773} 790}
774 791
775void PlayListWidget::tabChanged(QWidget *) { 792void PlayListWidget::tabChanged(QWidget *) {
776 793
777 switch ( tabWidget->currentPageIndex()) { 794 switch ( tabWidget->currentPageIndex()) {
778 case 0: 795 case 0:
779 { 796 {
780 if( !tbDeletePlaylist->isHidden()) 797 if( !tbDeletePlaylist->isHidden())
781 tbDeletePlaylist->hide(); 798 tbDeletePlaylist->hide();
782 d->tbRemoveFromList->setEnabled(TRUE); 799 d->tbRemoveFromList->setEnabled(TRUE);
783 d->tbAddToList->setEnabled(FALSE); 800 d->tbAddToList->setEnabled(FALSE);
784 } 801 }
785 break; 802 break;
786 case 1: 803 case 1:
787 { 804 {
788 audioView->clear(); 805 audioView->clear();
789 populateAudioView(); 806 populateAudioView();
790 807
791 if( !tbDeletePlaylist->isHidden()) 808 if( !tbDeletePlaylist->isHidden())
792 tbDeletePlaylist->hide(); 809 tbDeletePlaylist->hide();
793 d->tbRemoveFromList->setEnabled(FALSE); 810 d->tbRemoveFromList->setEnabled(FALSE);
794 d->tbAddToList->setEnabled(TRUE); 811 d->tbAddToList->setEnabled(TRUE);
795 } 812 }
796 break; 813 break;
797 case 2: 814 case 2:
798 { 815 {
799 videoView->clear(); 816 videoView->clear();
800 populateVideoView(); 817 populateVideoView();
801 if( !tbDeletePlaylist->isHidden()) 818 if( !tbDeletePlaylist->isHidden())
802 tbDeletePlaylist->hide(); 819 tbDeletePlaylist->hide();
803 d->tbRemoveFromList->setEnabled(FALSE); 820 d->tbRemoveFromList->setEnabled(FALSE);
804 d->tbAddToList->setEnabled(TRUE); 821 d->tbAddToList->setEnabled(TRUE);
805 } 822 }
806 break; 823 break;
807 case 3: 824 case 3:
808 { 825 {
809 if( tbDeletePlaylist->isHidden()) 826 if( tbDeletePlaylist->isHidden())
810 tbDeletePlaylist->show(); 827 tbDeletePlaylist->show();
811 playLists->reread(); 828 playLists->reread();
812 } 829 }
813 break; 830 break;
814 }; 831 };
815} 832}
816 833
817void PlayListWidget::btnPlay(bool b) { 834void PlayListWidget::btnPlay(bool b) {
818 qDebug("<<<<<<<<<<<<<<<BtnPlay"); 835 qDebug("<<<<<<<<<<<<<<<BtnPlay");
819// mediaPlayerState->setPlaying(b); 836// mediaPlayerState->setPlaying(b);
820 switch ( tabWidget->currentPageIndex()) { 837 switch ( tabWidget->currentPageIndex()) {
821 case 0: 838 case 0:
822 { 839 {
823 qDebug("1"); 840 qDebug("1");
824// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 841// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
825// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 842// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
826// QMessageBox::message("Note","You are trying to play\na malformed url."); 843// QMessageBox::message("Note","You are trying to play\na malformed url.");
827// } else { 844// } else {
828 mediaPlayerState->setPlaying(b); 845 mediaPlayerState->setPlaying(b);
829 insanityBool=FALSE; 846 insanityBool=FALSE;
830 qDebug("insanity"); 847 qDebug("insanity");
831// } 848// }
832 } 849 }
833 break; 850 break;
834 case 1: 851 case 1:
835 { 852 {
836 qDebug("2"); 853 qDebug("2");
837// d->selectedFiles->unSelect(); 854// d->selectedFiles->unSelect();
838 addToSelection( audioView->currentItem() ); 855 addToSelection( audioView->currentItem() );
839 mediaPlayerState->setPlaying(true); 856 mediaPlayerState->setPlaying(true);
840 d->selectedFiles->removeSelected( ); 857 d->selectedFiles->removeSelected( );
841 d->selectedFiles->unSelect(); 858 d->selectedFiles->unSelect();
842 tabWidget->setCurrentPage(1); 859 tabWidget->setCurrentPage(1);
843 insanityBool=FALSE; 860 insanityBool=FALSE;
844 }// audioView->clearSelection(); 861 }// audioView->clearSelection();
845 break; 862 break;
846 case 2: 863 case 2:
847 { 864 {
848 qDebug("3"); 865 qDebug("3");
849 866
850 addToSelection( videoView->currentItem() ); 867 addToSelection( videoView->currentItem() );
851 mediaPlayerState->setPlaying(true); 868 mediaPlayerState->setPlaying(true);
852// qApp->processEvents(); 869// qApp->processEvents();
853 d->selectedFiles->removeSelected( ); 870 d->selectedFiles->removeSelected( );
854 d->selectedFiles->unSelect(); 871 d->selectedFiles->unSelect();
855 tabWidget->setCurrentPage(2); 872 tabWidget->setCurrentPage(2);
856 insanityBool=FALSE; 873 insanityBool=FALSE;
857 }// videoView->clearSelection(); 874 }// videoView->clearSelection();
858 break; 875 break;
859 }; 876 };
860 877
861} 878}
862 879
863void PlayListWidget::deletePlaylist() { 880void PlayListWidget::deletePlaylist() {
864 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 881 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
865 (tr("You really want to delete\nthis playlist?")), 882 (tr("You really want to delete\nthis playlist?")),
866 (tr("Yes")), (tr("No")), 0 )){ 883 (tr("Yes")), (tr("No")), 0 )){
867 case 0: // Yes clicked, 884 case 0: // Yes clicked,
868 QFile().remove(playLists->selectedDocument().file()); 885 QFile().remove(playLists->selectedDocument().file());
869 QFile().remove(playLists->selectedDocument().linkFile()); 886 QFile().remove(playLists->selectedDocument().linkFile());
870 playLists->reread(); 887 playLists->reread();
871 break; 888 break;
872 case 1: // Cancel 889 case 1: // Cancel
873 break; 890 break;
874 }; 891 };
875} 892}
876 893
877void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 894void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
878{ 895{
879 switch (mouse) { 896 switch (mouse) {
880 case 1: 897 case 1:
881 break; 898 break;
882 case 2:{ 899 case 2:{
883 900
884 QPopupMenu m; 901 QPopupMenu m;
885 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 902 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
886 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 903 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
887 m.insertSeparator(); 904 m.insertSeparator();
888 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 905 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
889 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 906 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
890 907
891 m.exec( QCursor::pos() ); 908 m.exec( QCursor::pos() );
892 } 909 }
893 break; 910 break;
894 }; 911 };
895} 912}
896 913
897void PlayListWidget::playSelected() 914void PlayListWidget::playSelected()
898{ 915{
899 qDebug("playSelected"); 916 qDebug("playSelected");
900 btnPlay( true); 917 btnPlay( true);
901// d->selectedFiles->unSelect(); 918// d->selectedFiles->unSelect();
902} 919}
903 920
904void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 921void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
905{ 922{
906 switch (mouse) { 923 switch (mouse) {
907 case 1: 924 case 1:
908 925
909 break; 926 break;
910 case 2:{ 927 case 2:{
911 QPopupMenu m; 928 QPopupMenu m;
912 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 929 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
913 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 930 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
914// m.insertSeparator(); 931// m.insertSeparator();
915// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 932// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
916 m.exec( QCursor::pos() ); 933 m.exec( QCursor::pos() );
917 } 934 }
918 break; 935 break;
919 }; 936 };
920 937
921} 938}
922 939
923void PlayListWidget::listDelete() { 940void PlayListWidget::listDelete() {
924 Config cfg( "OpiePlayer" ); 941 Config cfg( "OpiePlayer" );
925 cfg.setGroup("PlayList"); 942 cfg.setGroup("PlayList");
926 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 943 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
927 QString file; 944 QString file;
928// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 945// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
929 switch ( tabWidget->currentPageIndex()) { 946 switch ( tabWidget->currentPageIndex()) {
930 case 0: 947 case 0:
931 break; 948 break;
932 case 1: 949 case 1:
933 { 950 {
934 file = audioView->currentItem()->text(0); 951 file = audioView->currentItem()->text(0);
935 QListIterator<DocLnk> Pdit( files.children() ); 952 QListIterator<DocLnk> Pdit( files.children() );
936 for ( ; Pdit.current(); ++Pdit ) { 953 for ( ; Pdit.current(); ++Pdit ) {
937 if( Pdit.current()->name() == file) { 954 if( Pdit.current()->name() == file) {
938 LnkProperties prop( Pdit.current() ); 955 LnkProperties prop( Pdit.current() );
939 prop.showMaximized(); 956 prop.showMaximized();
940 prop.exec(); 957 prop.exec();
941 } 958 }
942 } 959 }
943 populateAudioView(); 960 populateAudioView();
944 } 961 }
945 break; 962 break;
946 case 2: 963 case 2:
947 { 964 {
948// file = videoView->selectedItem()->text(0); 965// file = videoView->selectedItem()->text(0);
949// for ( int i = 0; i < noOfFiles; i++ ) { 966// for ( int i = 0; i < noOfFiles; i++ ) {
950// QString entryName; 967// QString entryName;
951// entryName.sprintf( "File%i", i + 1 ); 968// entryName.sprintf( "File%i", i + 1 );
952// QString linkFile = cfg.readEntry( entryName ); 969// QString linkFile = cfg.readEntry( entryName );
953// AppLnk lnk( AppLnk(linkFile)); 970// AppLnk lnk( AppLnk(linkFile));
954// if( lnk.name() == file ) { 971// if( lnk.name() == file ) {
955// LnkProperties prop( &lnk); 972// LnkProperties prop( &lnk);
956// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 973// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
957// prop.showMaximized(); 974// prop.showMaximized();
958// prop.exec(); 975// prop.exec();
959// } 976// }
960// } 977// }
961 } 978 }
962 break; 979 break;
963 }; 980 };
964} 981}
965 982
966void PlayListWidget::scanForAudio() { 983void PlayListWidget::scanForAudio() {
967// qDebug("scan for audio"); 984// qDebug("scan for audio");
968 files.detachChildren(); 985 files.detachChildren();
969 QListIterator<DocLnk> sdit( files.children() ); 986 QListIterator<DocLnk> sdit( files.children() );
970 for ( ; sdit.current(); ++sdit ) { 987 for ( ; sdit.current(); ++sdit ) {
971 delete sdit.current(); 988 delete sdit.current();
972 } 989 }
973 Global::findDocuments( &files, audioMimes); 990 Global::findDocuments( &files, audioMimes);
974 audioScan = true; 991 audioScan = true;
975} 992}
976void PlayListWidget::scanForVideo() { 993void PlayListWidget::scanForVideo() {
977// qDebug("scan for video"); 994// qDebug("scan for video");
978 vFiles.detachChildren(); 995 vFiles.detachChildren();
979 QListIterator<DocLnk> sdit( vFiles.children() ); 996 QListIterator<DocLnk> sdit( vFiles.children() );
980 for ( ; sdit.current(); ++sdit ) { 997 for ( ; sdit.current(); ++sdit ) {
981 delete sdit.current(); 998 delete sdit.current();
982 } 999 }
983 Global::findDocuments(&vFiles, "video/*"); 1000 Global::findDocuments(&vFiles, "video/*");
984 videoScan = true; 1001 videoScan = true;
985} 1002}
986 1003
987void PlayListWidget::populateAudioView() { 1004void PlayListWidget::populateAudioView() {
988 1005
989 audioView->clear(); 1006 audioView->clear();
990 StorageInfo storageInfo; 1007 StorageInfo storageInfo;
991 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1008 const QList<FileSystem> &fs = storageInfo.fileSystems();
992 if(!audioScan) scanForAudio(); 1009 if(!audioScan) scanForAudio();
993 1010
994 QListIterator<DocLnk> dit( files.children() ); 1011 QListIterator<DocLnk> dit( files.children() );
995 QListIterator<FileSystem> it ( fs ); 1012 QListIterator<FileSystem> it ( fs );
996 1013
997 QString storage; 1014 QString storage;
998 for ( ; dit.current(); ++dit ) { 1015 for ( ; dit.current(); ++dit ) {
999 for( ; it.current(); ++it ){ 1016 for( ; it.current(); ++it ){
1000 const QString name = (*it)->name(); 1017 const QString name = (*it)->name();
1001 const QString path = (*it)->path(); 1018 const QString path = (*it)->path();
1002 if(dit.current()->file().find(path) != -1 ) storage=name; 1019 if(dit.current()->file().find(path) != -1 ) storage=name;
1003 } 1020 }
1004 1021
1005 QListViewItem * newItem; 1022 QListViewItem * newItem;
1006 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 1023 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1007 long size; 1024 long size;
1008 if( dit.current()->file().left(4) == "http" ) 1025 if( dit.current()->file().left(4) == "http" )
1009 size=0; 1026 size=0;
1010 else 1027 else
1011 size = QFile( dit.current()->file() ).size(); 1028 size = QFile( dit.current()->file() ).size();
1012// qDebug(dit.current()->name()); 1029// qDebug(dit.current()->name());
1013 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1030 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1014 QString::number(size ), storage, dit.current()->file()); 1031 QString::number(size ), storage, dit.current()->file());
1015 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1032 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1016 } 1033 }
1017 } 1034 }
1018 1035
1019} 1036}
1020 1037
1021void PlayListWidget::populateVideoView() { 1038void PlayListWidget::populateVideoView() {
1022 videoView->clear(); 1039 videoView->clear();
1023 StorageInfo storageInfo; 1040 StorageInfo storageInfo;
1024 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1041 const QList<FileSystem> &fs = storageInfo.fileSystems();
1025 1042
1026 if(!videoScan ) scanForVideo(); 1043 if(!videoScan ) scanForVideo();
1027 1044
1028 QListIterator<DocLnk> Vdit( vFiles.children() ); 1045 QListIterator<DocLnk> Vdit( vFiles.children() );
1029 QListIterator<FileSystem> it ( fs ); 1046 QListIterator<FileSystem> it ( fs );
1030 videoView->clear(); 1047 videoView->clear();
1031 QString storage; 1048 QString storage;
1032 for ( ; Vdit.current(); ++Vdit ) { 1049 for ( ; Vdit.current(); ++Vdit ) {
1033 for( ; it.current(); ++it ){ 1050 for( ; it.current(); ++it ){
1034 const QString name = (*it)->name(); 1051 const QString name = (*it)->name();
1035 const QString path = (*it)->path(); 1052 const QString path = (*it)->path();
1036 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1053 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1037 } 1054 }
1038 1055
1039 QListViewItem * newItem; 1056 QListViewItem * newItem;
1040 if ( QFile( Vdit.current()->file()).exists() ) { 1057 if ( QFile( Vdit.current()->file()).exists() ) {
1041 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1058 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1042 QString::number( QFile( Vdit.current()->file() ).size() ), 1059 QString::number( QFile( Vdit.current()->file() ).size() ),
1043 storage, Vdit.current()->file()); 1060 storage, Vdit.current()->file());
1044 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1061 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1045 } 1062 }
1046 } 1063 }
1047} 1064}
1048 1065
1049void PlayListWidget::openFile() { 1066void PlayListWidget::openFile() {
1050 qDebug("<<<<<<<<<OPEN File"); 1067 qDebug("<<<<<<<<<OPEN File");
1051 QString filename, name; 1068 QString filename, name;
1052 InputDialog *fileDlg; 1069 InputDialog *fileDlg;
1053 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1070 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1054 fileDlg->exec(); 1071 fileDlg->exec();
1055 if( fileDlg->result() == 1 ) { 1072 if( fileDlg->result() == 1 ) {
1056 filename = fileDlg->text(); 1073 filename = fileDlg->text();
1057 qDebug( "Selected filename is " + filename ); 1074 qDebug( "Selected filename is " + filename );
1058// Om3u *m3uList; 1075// Om3u *m3uList;
1059 DocLnk lnk; 1076 DocLnk lnk;
1060 Config cfg( "OpiePlayer" ); 1077 Config cfg( "OpiePlayer" );
1061 cfg.setGroup("PlayList"); 1078 cfg.setGroup("PlayList");
1062 1079
1063 QString m3uFile; 1080 QString m3uFile;
1064 m3uFile = filename; 1081 m3uFile = filename;
1065 if(filename.left(4) == "http") { 1082 if(filename.left(4) == "http") {
1066 if(filename.find(":",8,TRUE) != -1) { //found a port 1083 if(filename.find(":",8,TRUE) != -1) { //found a port
1067 1084
1068// m3uFile = filename.left( filename.find( ":",8,TRUE)); 1085// m3uFile = filename.left( filename.find( ":",8,TRUE));
1069 m3uFile = filename; 1086 m3uFile = filename;
1070 if( m3uFile.right( 1 ).find( '/' ) == -1) { 1087 if( m3uFile.right( 1 ).find( '/' ) == -1) {
1071 m3uFile += "/"; 1088 m3uFile += "/";
1072 } 1089 }
1073 filename = m3uFile; 1090 filename = m3uFile;
1074// qDebug("1 "+m3uFile); 1091// qDebug("1 "+m3uFile);
1075// } else if(filename.left(4) == "http"){ 1092// } else if(filename.left(4) == "http"){
1076// m3uFile=filename; 1093// m3uFile=filename;
1077// m3uFile = m3uFile.right( m3uFile.length() - 7); 1094// m3uFile = m3uFile.right( m3uFile.length() - 7);
1078// qDebug("2 "+m3uFile); 1095// qDebug("2 "+m3uFile);
1079// } else{ 1096// } else{
1080// m3uFile=filename; 1097// m3uFile=filename;
1081// qDebug("3 "+m3uFile); 1098// qDebug("3 "+m3uFile);
1082 } 1099 }
1083 lnk.setName( m3uFile ); //sets name 1100 lnk.setName( m3uFile ); //sets name
1084 lnk.setFile( filename ); //sets file name 1101 lnk.setFile( filename ); //sets file name
1085 lnk.setIcon("opieplayer2/musicfile"); 1102 lnk.setIcon("opieplayer2/musicfile");
1086 d->selectedFiles->addToSelection( lnk ); 1103 d->selectedFiles->addToSelection( lnk );
1087 writeCurrentM3u(); 1104 writeCurrentM3u();
1088 } 1105 }
1089 else if( filename.right( 3) == "m3u" ) { 1106 else if( filename.right( 3) == "m3u" ) {
1090 readm3u( filename ); 1107 readm3u( filename );
1091 1108
1092 } else if( filename.right(3) == "pls" ) { 1109 } else if( filename.right(3) == "pls" ) {
1093 readPls( filename ); 1110 readPls( filename );
1094 } else { 1111 } else {
1095 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1112 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1096 lnk.setFile( filename ); //sets file name 1113 lnk.setFile( filename ); //sets file name
1097 d->selectedFiles->addToSelection( lnk); 1114 d->selectedFiles->addToSelection( lnk);
1098 writeCurrentM3u(); 1115 writeCurrentM3u();
1099 } 1116 }
1100 } 1117 }
1101 1118
1102 if( fileDlg ) { 1119 if( fileDlg ) {
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 97997f9..1b38206 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,484 +1,731 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3 **
4** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5** 5 **
6** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9 ** packaging of this file.
10** 10 **
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13 **
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15 **
16** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17 ** not clear to you.
18** 18 **
19**********************************************************************/ 19 **********************************************************************/
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/mediaplayerplugininterface.h> 21#include <qpe/mediaplayerplugininterface.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qpeapplication.h>
23 24
25#include <qdir.h>
24#include <qwidget.h> 26#include <qwidget.h>
25#include <qpainter.h> 27#include <qpainter.h>
26#include <qpixmap.h> 28#include <qpixmap.h>
27#include <qslider.h> 29#include <qslider.h>
28#include <qdrawutil.h> 30#include <qdrawutil.h>
29#include "videowidget.h" 31#include "videowidget.h"
30#include "mediaplayerstate.h" 32#include "mediaplayerstate.h"
31 33
32 34
33#ifdef Q_WS_QWS 35#ifdef Q_WS_QWS
34# define USE_DIRECT_PAINTER 36# define USE_DIRECT_PAINTER
35# include <qdirectpainter_qws.h> 37# include <qdirectpainter_qws.h>
36# include <qgfxraster_qws.h> 38# include <qgfxraster_qws.h>
37#endif 39#endif
38 40
39 41
40extern MediaPlayerState *mediaPlayerState; 42extern MediaPlayerState *mediaPlayerState;
41 43
42 44
43static const int xo = 2; // movable x offset 45static const int xo = 2; // movable x offset
44static const int yo = 0; // movable y offset 46static const int yo = 0; // movable y offset
45 47
46 48
47struct MediaButton { 49struct MediaButton {
48 int xPos, yPos; 50// int xPos, yPos;
49 bool isToggle, isHeld, isDown; 51 bool isToggle, isHeld, isDown;
50 int controlType; 52// int controlType;
51}; 53};
52 54
53 55
54// Layout information for the videoButtons (and if it is a toggle button or not) 56// Layout information for the videoButtons (and if it is a toggle button or not)
55MediaButton videoButtons[] = { 57MediaButton videoButtons[] = {
56 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 58 { FALSE, FALSE, FALSE }, // stop
57 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 59 { TRUE, FALSE, FALSE }, // play
58 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 60 { FALSE, FALSE, FALSE }, // previous
59 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 61 { FALSE, FALSE, FALSE }, // next
60 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 62 { FALSE, FALSE, FALSE }, // volUp
61 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 63 { FALSE, FALSE, FALSE }, // volDown
62 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 64 { TRUE, FALSE, FALSE } // fullscreen
63}; 65};
64 66
67//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
65 68
66static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 69const char *skinV_mask_file_names[7] = {
70 "stop","play","back","fwd","up","down","full"
71};
67 72
73static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
68 74
69VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 75VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
70 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 76 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 )
71 setCaption( tr("OpiePlayer") ); 77{
72 Config cfg("OpiePlayer"); 78 setCaption( tr("OpiePlayer") );
73 cfg.setGroup("VideoWidget"); 79 Config cfg("OpiePlayer");
74 80
75 QString backgroundPix, Button0aPix, Button0bPix, controlsPix; 81 cfg.setGroup("Options");
76 backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish"); 82 skin = cfg.readEntry("Skin","default");
77 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); 83
78 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); 84 QString skinPath;
79 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); 85 skinPath = "opieplayer2/skins/" + skin;
80 86 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
81 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 87 skinPath = "opieplayer2/skins/default";
82 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); 88
83 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); 89 qDebug("skin path " + skinPath);
84 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); 90
85 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 91// QString skinPath = "opieplayer2/skins/" + skin;
86 92
87 slider = new QSlider( Qt::Horizontal, this ); 93 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
88 slider->setMinValue( 0 ); 94 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
89 slider->setMaxValue( 1 ); 95 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
90 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 96
91 slider->setFocusPolicy( QWidget::NoFocus ); 97 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
92 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 98 imgButtonMask->fill( 0 );
93 99
94 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 100 for ( int i = 0; i < 7; i++ )
95 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 101 {
96 102 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath +
97 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 103 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
98 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 104 qDebug("loading "+filename);
99 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 105 masks[i] = new QBitmap( filename );
100 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 106
101 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 107 if ( !masks[i]->isNull() )
102 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 108 {
103 109 QImage imgMask = masks[i]->convertToImage();
104 // Intialise state 110 uchar **dest = imgButtonMask->jumpTable();
105 setLength( mediaPlayerState->length() ); 111 for ( int y = 0; y < imgUp->height(); y++ )
106 setPosition( mediaPlayerState->position() ); 112 {
107 setFullscreen( mediaPlayerState->fullscreen() ); 113 uchar *line = dest[y];
108 setPaused( mediaPlayerState->paused() ); 114 for ( int x = 0; x < imgUp->width(); x++ )
109 setPlaying( mediaPlayerState->playing() ); 115 {
116 if ( !qRed( imgMask.pixel( x, y ) ) )
117 line[x] = i + 1;
118 }
119 }
120 }
121 }
122 qDebug("finished loading first pics");
123 for ( int i = 0; i < 7; i++ )
124 {
125 buttonPixUp[i] = NULL;
126 buttonPixDown[i] = NULL;
127 }
128
129 setBackgroundPixmap( *pixBg );
130
131 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
132
133 slider = new QSlider( Qt::Horizontal, this );
134 slider->setMinValue( 0 );
135 slider->setMaxValue( 1 );
136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
137 slider->setFocusPolicy( QWidget::NoFocus );
138// slider->setGeometry( QRect( 7, 250, 220, 20 ) );
139
140 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
141 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
142
143 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
144 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
145 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
146 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
147 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
148 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
149
150 // Intialise state
151 setLength( mediaPlayerState->length() );
152 setPosition( mediaPlayerState->position() );
153 setFullscreen( mediaPlayerState->fullscreen() );
154 setPaused( mediaPlayerState->paused() );
155 setPlaying( mediaPlayerState->playing() );
110} 156}
111 157
112 158
113VideoWidget::~VideoWidget() { 159VideoWidget::~VideoWidget() {
114 for ( int i = 0; i < 3; i++ ) 160
115 delete pixmaps[i]; 161 for ( int i = 0; i < 7; i++ )
116 delete currentFrame; 162 {
163 delete buttonPixUp[i];
164 delete buttonPixDown[i];
165 }
166
167 delete pixBg;
168 delete imgUp;
169 delete imgDn;
170 delete imgButtonMask;
171 for ( int i = 0; i < 7; i++ )
172 {
173 delete masks[i];
174 }
175
176// for ( int i = 0; i < 3; i++ )
177// delete pixmaps[i];
178// delete currentFrame;
117} 179}
118 180
119 181
120static bool videoSliderBeingMoved = FALSE; 182static bool videoSliderBeingMoved = FALSE;
121 183
184QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
185 QPixmap pix( img.width(), img.height() );
186 QPainter p( &pix );
187 p.drawTiledPixmap( pix.rect(), bg, offset );
188 p.drawImage( 0, 0, img );
189 return new QPixmap( pix );
190}
191
192QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
193 QPixmap *pixmap = new QPixmap( pix );
194 pixmap->setMask( mask );
195 return pixmap;
196}
197
198void VideoWidget::resizeEvent( QResizeEvent * ) {
199 int h = height();
200 int w = width();
201 //int Vh = 160;
202 //int Vw = 220;
203
204 slider->setFixedWidth( w - 20 );
205 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
206 slider->setBackgroundOrigin( QWidget::ParentOrigin );
207 slider->setFocusPolicy( QWidget::NoFocus );
208 slider->setBackgroundPixmap( *pixBg );
209
210 xoff = 0;// ( imgUp->width() ) / 2;
211 if(w>h)
212 yoff = 0;
213 else
214 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
215 QPoint p( xoff, yoff );
216
217 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
218 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
219
220 for ( int i = 0; i < 7; i++ )
221 {
222 if ( !masks[i]->isNull() )
223 {
224 delete buttonPixUp[i];
225 delete buttonPixDown[i];
226 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
227 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
228 }
229 }
230
231 delete pixUp;
232 delete pixDn;
233}
234
122 235
123void VideoWidget::sliderPressed() { 236void VideoWidget::sliderPressed() {
124 videoSliderBeingMoved = TRUE; 237 videoSliderBeingMoved = TRUE;
125} 238}
126 239
127 240
128void VideoWidget::sliderReleased() { 241void VideoWidget::sliderReleased() {
129 videoSliderBeingMoved = FALSE; 242 videoSliderBeingMoved = FALSE;
130 if ( slider->width() == 0 ) 243 if ( slider->width() == 0 )
131 return; 244 return;
132 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 245 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
133 mediaPlayerState->setPosition( val ); 246 mediaPlayerState->setPosition( val );
134} 247}
135 248
136 249
137void VideoWidget::setPosition( long i ) { 250void VideoWidget::setPosition( long i ) {
138 updateSlider( i, mediaPlayerState->length() ); 251 updateSlider( i, mediaPlayerState->length() );
139} 252}
140 253
141 254
142void VideoWidget::setLength( long max ) { 255void VideoWidget::setLength( long max ) {
143 updateSlider( mediaPlayerState->position(), max ); 256 updateSlider( mediaPlayerState->position(), max );
144} 257}
145 258
146 259
147void VideoWidget::setView( char view ) { 260void VideoWidget::setView( char view ) {
148 if ( view == 'v' ) { 261 if ( view == 'v' )
149 makeVisible(); 262 {
150 } else { 263 makeVisible();
151 // Effectively blank the view next time we show it so it looks nicer 264 }
152 scaledWidth = 0; 265 else
153 scaledHeight = 0; 266 {
154 hide(); 267 // Effectively blank the view next time we show it so it looks nicer
155 } 268 scaledWidth = 0;
269 scaledHeight = 0;
270 hide();
271 }
156} 272}
157 273
158 274
159void VideoWidget::updateSlider( long i, long max ) { 275void VideoWidget::updateSlider( long i, long max ) {
160 // Will flicker too much if we don't do this 276 // Will flicker too much if we don't do this
161 if ( max == 0 ) 277 if ( max == 0 )
162 return; 278 return;
163 int width = slider->width(); 279 int width = slider->width();
164 int val = int((double)i * width / max); 280 int val = int((double)i * width / max);
165 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 281 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved )
166 if ( slider->value() != val ) 282 {
167 slider->setValue( val ); 283 if ( slider->value() != val )
168 if ( slider->maxValue() != width ) 284 slider->setValue( val );
169 slider->setMaxValue( width ); 285 if ( slider->maxValue() != width )
170 } 286 slider->setMaxValue( width );
287 }
171} 288}
172 289
173 290
174void VideoWidget::setToggleButton( int i, bool down ) { 291void VideoWidget::setToggleButton( int i, bool down ) {
175 if ( down != videoButtons[i].isDown ) 292 if ( down != videoButtons[i].isDown )
176 toggleButton( i ); 293 toggleButton( i );
177} 294}
178 295
179 296
180void VideoWidget::toggleButton( int i ) { 297void VideoWidget::toggleButton( int i ) {
181 videoButtons[i].isDown = !videoButtons[i].isDown; 298 videoButtons[i].isDown = !videoButtons[i].isDown;
182 QPainter p(this); 299 QPainter p(this);
183 paintButton ( &p, i ); 300 paintButton ( &p, i );
184} 301}
185 302
186 303
187void VideoWidget::paintButton( QPainter *p, int i ) { 304void VideoWidget::paintButton( QPainter *p, int i ) {
188 int x = videoButtons[i].xPos; 305 if ( videoButtons[i].isDown )
189 int y = videoButtons[i].yPos; 306 {
190 int offset = 10 + videoButtons[i].isDown; 307 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
191 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); 308 }
192 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); 309 else
310 {
311 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
312 }
313// int x = videoButtons[i].xPos;
314// int y = videoButtons[i].yPos;
315// int offset = 10 + videoButtons[i].isDown;
316// p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
317// p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
193} 318}
194 319
195 320
196void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 321void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
197 for ( int i = 0; i < numButtons; i++ ) { 322
198 int x = videoButtons[i].xPos; 323 for ( int i = 0; i < numVButtons; i++ )
199 int y = videoButtons[i].yPos; 324 {
200 if ( event->state() == QMouseEvent::LeftButton ) { 325 if ( event->state() == QMouseEvent::LeftButton )
201 // The test to see if the mouse click is inside the circular button or not 326 {
202 // (compared with the radius squared to avoid a square-root of our distance) 327 // The test to see if the mouse click is inside the button or not
203 int radius = 16; 328 int x = event->pos().x() - xoff;
204 QPoint center = QPoint( x + radius, y + radius ); 329 int y = event->pos().y() - yoff;
205 QPoint dXY = center - event->pos(); 330
206 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 331 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
207 bool isOnButton = dist <= (radius * radius); 332 && y < imgButtonMask->height()
208 if ( isOnButton != videoButtons[i].isHeld ) { 333 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
209 videoButtons[i].isHeld = isOnButton; 334
210 toggleButton(i); 335 if ( isOnButton && !videoButtons[i].isHeld )
336 {
337 videoButtons[i].isHeld = TRUE;
338 toggleButton(i);
339
340// switch (i) {
341// case VideoVolUp:
342// emit moreClicked();
343// return;
344// case VideoVolDown:
345// emit lessClicked();
346// return;
347// }
348 }
349 else if ( !isOnButton && videoButtons[i].isHeld )
350 {
351 videoButtons[i].isHeld = FALSE;
352 toggleButton(i);
353 }
354 }
355 else
356 {
357
358 if ( videoButtons[i].isHeld )
359 {
360 videoButtons[i].isHeld = FALSE;
361 if ( !videoButtons[i].isToggle )
362 {
363 setToggleButton( i, FALSE );
211 } 364 }
212 } else { 365 qDebug("key %d", i);
213 if ( videoButtons[i].isHeld ) { 366 switch(i)
214 videoButtons[i].isHeld = FALSE; 367 {
215 if ( !videoButtons[i].isToggle ) 368// case VideoPlay:
216 setToggleButton( i, FALSE ); 369// {
370// if( mediaPlayerState->isPaused )
371// {
372// setToggleButton( i, FALSE );
373// mediaPlayerState->setPaused( FALSE );
374// return;
375// }
376// else if( !mediaPlayerState->isPaused )
377// {
378// setToggleButton( i, TRUE );
379// mediaPlayerState->setPaused( TRUE );
380// return;
381// }
382// else
383// {
384// return;
385// }
386// }
387
388 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
389 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
390// case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
391 case VideoNext: mediaPlayerState->setNext(); return;
392 case VideoPrevious: mediaPlayerState->setPrev(); return;
393// case VideoPlayList: mediaPlayerState->setList(); return;
394 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
395
396// case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
397// case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return;
398// case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return;
399// case VideoVolUp: emit moreReleased(); return;
400// case VideoVolDown: emit lessReleased(); return;
401// case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
217 } 402 }
218 } 403 }
219 switch (i) { 404 }
220 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 405 }
221 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 406
222 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 407
223 case VideoNext: mediaPlayerState->setNext(); return; 408
224 case VideoPrevious: mediaPlayerState->setPrev(); return; 409
225 case VideoPlayList: mediaPlayerState->setList(); return; 410
226 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 411
227 } 412// for ( int i = 0; i < numButtons; i++ ) {
228 413// int x = videoButtons[i].xPos;
229 } 414// int y = videoButtons[i].yPos;
415// if ( event->state() == QMouseEvent::LeftButton ) {
416// // The test to see if the mouse click is inside the circular button or not
417// // (compared with the radius squared to avoid a square-root of our distance)
418// int radius = 16;
419// QPoint center = QPoint( x + radius, y + radius );
420// QPoint dXY = center - event->pos();
421// int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
422// bool isOnButton = dist <= (radius * radius);
423// if ( isOnButton != videoButtons[i].isHeld ) {
424// videoButtons[i].isHeld = isOnButton;
425// toggleButton(i);
426// }
427// } else {
428// if ( videoButtons[i].isHeld ) {
429// videoButtons[i].isHeld = FALSE;
430// if ( !videoButtons[i].isToggle )
431// setToggleButton( i, FALSE );
432// }
433// }
434
435// switch (i) {
436// case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
437// case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
438// case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
439// case VideoNext: mediaPlayerState->setNext(); return;
440// case VideoPrevious: mediaPlayerState->setPrev(); return;
441// case VideoPlayList: mediaPlayerState->setList(); return;
442// case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
443// }
444
445// }
230} 446}
231 447
232 448
233void VideoWidget::mousePressEvent( QMouseEvent *event ) { 449void VideoWidget::mousePressEvent( QMouseEvent *event ) {
234 mouseMoveEvent( event ); 450 mouseMoveEvent( event );
235} 451}
236 452
237 453
238void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 454void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
239 if ( mediaPlayerState->fullscreen() ) { 455 if ( mediaPlayerState->fullscreen() )
240 mediaPlayerState->setFullscreen( FALSE ); 456 {
241 makeVisible(); 457 mediaPlayerState->setFullscreen( FALSE );
458 makeVisible();
242 459
243 mouseMoveEvent( event ); 460 mouseMoveEvent( event );
244 } 461 }
245} 462}
246 463
247 464
248void VideoWidget::makeVisible() { 465void VideoWidget::makeVisible() {
249 if ( mediaPlayerState->fullscreen() ) { 466 if ( mediaPlayerState->fullscreen() )
250 setBackgroundMode( QWidget::NoBackground ); 467 {
251 showFullScreen(); 468 setBackgroundMode( QWidget::NoBackground );
252 resize( qApp->desktop()->size() ); 469 showFullScreen();
253 slider->hide(); 470 resize( qApp->desktop()->size() );
254 } else { 471 slider->hide();
255 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 472 }
256 showNormal(); 473 else
257 showMaximized(); 474 {
258 slider->show(); 475 setBackgroundPixmap( *pixBg );
259 } 476 showNormal();
477 showMaximized();
478 slider->show();
479 }
260} 480}
261 481
262 482
263void VideoWidget::paintEvent( QPaintEvent * ) { 483void VideoWidget::paintEvent( QPaintEvent * pe) {
264 QPainter p( this ); 484 QPainter p( this );
265
266 if ( mediaPlayerState->fullscreen() ) {
267 // Clear the background
268 p.setBrush( QBrush( Qt::black ) );
269 p.drawRect( rect() );
270 485
271 // Draw the current frame 486 if ( mediaPlayerState->fullscreen() ) {
272 //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen 487 // Clear the background
273 } else { 488 p.setBrush( QBrush( Qt::black ) );
274 // draw border 489 p.drawRect( rect() );
275 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); 490 } else {
276 491 if ( !pe->erased() ) {
277 // Clear the movie screen first 492 // Combine with background and double buffer
278 p.setBrush( QBrush( Qt::black ) ); 493 QPixmap pix( pe->rect().size() );
279 p.drawRect( 9, 20, 220, 160 ); 494 QPainter p( &pix );
280 495 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
281 // draw current frame (centrally positioned from scaling to maintain aspect ratio) 496 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
282 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 497 for ( int i = 0; i < numVButtons; i++ ) {
283 498 paintButton( &p, i );
284 // draw the buttons 499 }
285 for ( int i = 0; i < numButtons; i++ ) 500 QPainter p2( this );
286 paintButton( &p, i ); 501 p2.drawPixmap( pe->rect().topLeft(), pix );
287 502 } else {
288 // draw the slider 503 QPainter p( this );
289 slider->repaint( TRUE ); 504 for ( int i = 0; i < numVButtons; i++ )
290 } 505 paintButton( &p, i );
506 }
507 slider->repaint( TRUE );
508 }
291} 509}
292 510
293 511
294void VideoWidget::closeEvent( QCloseEvent* ) { 512void VideoWidget::closeEvent( QCloseEvent* ) {
295 mediaPlayerState->setList(); 513 mediaPlayerState->setList();
296} 514}
297 515
298 516
299bool VideoWidget::playVideo() { 517bool VideoWidget::playVideo() {
300 bool result = FALSE; 518 bool result = FALSE;
301 519// qDebug("<<<<<<<<<<<<<<<< play video");
302 int stream = 0; 520 int stream = 0;
303 521
304 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 522 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
305 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 523 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
306 int dd = QPixmap::defaultDepth(); 524 int dd = QPixmap::defaultDepth();
307 int w = height(); 525 int w = height();
308 int h = width(); 526 int h = width();
309 527
310 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 528 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
311 529
312 if ( mediaPlayerState->fullscreen() ) { 530 if ( mediaPlayerState->fullscreen() )
531 {
313#ifdef USE_DIRECT_PAINTER 532#ifdef USE_DIRECT_PAINTER
314 QDirectPainter p(this); 533 QDirectPainter p(this);
315 534
316 if ( ( qt_screen->transformOrientation() == 3 ) && 535 if ( ( qt_screen->transformOrientation() == 3 ) &&
317 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { 536 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) )
318 537 {
319 w = 320; 538
320 h = 240; 539 w = 320;
321 540 h = 240;
322 if ( mediaPlayerState->scaled() ) { 541
323 // maintain aspect ratio 542 if ( mediaPlayerState->scaled() )
324 if ( w * sh > sw * h ) 543 {
325 w = sw * h / sh; 544 // maintain aspect ratio
326 else 545 if ( w * sh > sw * h )
327 h = sh * w / sw; 546 w = sw * h / sh;
328 } else { 547 else
329 w = sw; 548 h = sh * w / sw;
330 h = sh; 549 }
550 else
551 {
552 w = sw;
553 h = sh;
554 }
555
556 w--; // we can't allow libmpeg to overwrite.
557 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
558
559 int ox = roff.x() - height() + 2 + (height() - w) / 2;
560 int oy = roff.y() + (width() - h) / 2;
561 int sx = 0, sy = 0;
562
563 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
564 fp += dd * ox / 8;
565 uchar **jt = new uchar*[h];
566
567 for ( int i = h; i; i-- )
568 {
569 jt[h - i] = fp;
570 fp += p.lineStep();
571 }
572
573 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
574
575 delete [] jt;
331 } 576 }
577 else
578 {
579#endif
580 QPainter p(this);
581
582 w = 320;
583 h = 240;
584
585 if ( mediaPlayerState->scaled() )
586 {
587 // maintain aspect ratio
588 if ( w * sh > sw * h )
589 w = sw * h / sh;
590 else
591 h = sh * w / sw;
592 }
593 else
594 {
595 w = sw;
596 h = sh;
597 }
598
599 int bytes = ( dd == 16 ) ? 2 : 4;
600 QImage tempFrame( w, h, bytes << 3 );
601 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
602 0, 0, sw, sh, w, h, format, 0) == 0;
603
604 if ( result && mediaPlayerState->fullscreen() )
605 {
606
607 int rw = h, rh = w;
608 QImage rotatedFrame( rw, rh, bytes << 3 );
609
610 ushort* in = (ushort*)tempFrame.bits();
611 ushort* out = (ushort*)rotatedFrame.bits();
612 int spl = rotatedFrame.bytesPerLine() / bytes;
613
614 for (int x=0; x<h; x++)
615 {
616 if ( bytes == 2 )
617 {
618 ushort* lout = out++ + (w - 1)*spl;
619 for (int y=0; y<w; y++) {
620 *lout=*in++;
621 lout-=spl;
622 }
623 }
624 else
625 {
626 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
627 for (int y=0; y<w; y++)
628 {
629 *lout=*((ulong*)in)++;
630 lout-=spl;
631 }
632 }
633 }
332 634
333 w--; // we can't allow libmpeg to overwrite. 635 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
334 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); 636 }
335 637#ifdef USE_DIRECT_PAINTER
336 int ox = roff.x() - height() + 2 + (height() - w) / 2;
337 int oy = roff.y() + (width() - h) / 2;
338 int sx = 0, sy = 0;
339
340 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
341 fp += dd * ox / 8;
342 uchar **jt = new uchar*[h];
343 for ( int i = h; i; i-- ) {
344 jt[h - i] = fp;
345 fp += p.lineStep();
346 } 638 }
347
348 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
349
350 delete [] jt;
351 } else {
352#endif 639#endif
353 QPainter p(this); 640 }
354 641 else
355 w = 320; 642 {
356 h = 240; 643
357 644 w = 220;
358 if ( mediaPlayerState->scaled() ) { 645 h = 160;
359 // maintain aspect ratio 646
360 if ( w * sh > sw * h ) 647 // maintain aspect ratio
361 w = sw * h / sh; 648 if ( w * sh > sw * h )
362 else 649 w = sw * h / sh;
363 h = sh * w / sw; 650 else
364 } else { 651 h = sh * w / sw;
365 w = sw; 652
366 h = sh; 653 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0;
654
655 QPainter p( this );
656 int deskW = qApp->desktop()->width();
657 // Image changed size, therefore need to blank the possibly unpainted regions first
658 if ( scaledWidth != w || scaledHeight != h )
659 {
660 p.setBrush( QBrush( Qt::black ) );
661 p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 );
367 } 662 }
368 663
369 int bytes = ( dd == 16 ) ? 2 : 4; 664 scaledWidth = w;
370 QImage tempFrame( w, h, bytes << 3 ); 665 scaledHeight = h;
371 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
372 0, 0, sw, sh, w, h, format, 0) == 0;
373 if ( result && mediaPlayerState->fullscreen() ) {
374
375 int rw = h, rh = w;
376 QImage rotatedFrame( rw, rh, bytes << 3 );
377
378 ushort* in = (ushort*)tempFrame.bits();
379 ushort* out = (ushort*)rotatedFrame.bits();
380 int spl = rotatedFrame.bytesPerLine() / bytes;
381 for (int x=0; x<h; x++) {
382 if ( bytes == 2 ) {
383 ushort* lout = out++ + (w - 1)*spl;
384 for (int y=0; y<w; y++) {
385 *lout=*in++;
386 lout-=spl;
387 }
388 } else {
389 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
390 for (int y=0; y<w; y++) {
391 *lout=*((ulong*)in)++;
392 lout-=spl;
393 }
394 }
395 }
396 666
397 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); 667 if ( result )
668 {
669 p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
398 } 670 }
399#ifdef USE_DIRECT_PAINTER
400 }
401#endif
402 } else {
403
404 w = 220;
405 h = 160;
406 671
407 // maintain aspect ratio 672 }
408 if ( w * sh > sw * h )
409 w = sw * h / sh;
410 else
411 h = sh * w / sw;
412 673
413 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; 674 return result;
414
415 QPainter p( this );
416
417 // Image changed size, therefore need to blank the possibly unpainted regions first
418 if ( scaledWidth != w || scaledHeight != h ) {
419 p.setBrush( QBrush( Qt::black ) );
420 p.drawRect( 9, 20, 220, 160 );
421 }
422
423 scaledWidth = w;
424 scaledHeight = h;
425
426 if ( result ) {
427 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
428 }
429
430 }
431
432 return result;
433} 675}
434 676
435 677
436 678
437void VideoWidget::keyReleaseEvent( QKeyEvent *e) 679void VideoWidget::keyReleaseEvent( QKeyEvent *e)
438{ 680{
439 switch ( e->key() ) { 681 switch ( e->key() )
682 {
440////////////////////////////// Zaurus keys 683////////////////////////////// Zaurus keys
441 case Key_Home: 684 case Key_Home:
442 break; 685 break;
443 case Key_F9: //activity 686 case Key_F9: //activity
444 break; 687 break;
445 case Key_F10: //contacts 688 case Key_F10: //contacts
446// hide(); 689// hide();
447 break; 690 break;
448 case Key_F11: //menu 691 case Key_F11: //menu
449 break; 692 break;
450 case Key_F12: //home 693 case Key_F12: //home
451 break; 694 break;
452 case Key_F13: //mail 695 case Key_F13: //mail
453 break; 696 break;
454 case Key_Space: { 697 case Key_Space:
455 if(mediaPlayerState->playing()) { 698 {
456 mediaPlayerState->setPlaying(FALSE); 699 if(mediaPlayerState->playing())
457 } else { 700 {
458 mediaPlayerState->setPlaying(TRUE); 701 mediaPlayerState->setPlaying(FALSE);
459 } 702 }
703 else
704 {
705 mediaPlayerState->setPlaying(TRUE);
460 } 706 }
461 break; 707 }
462 case Key_Down: 708 break;
709 case Key_Down:
463// toggleButton(6); 710// toggleButton(6);
464// emit lessClicked(); 711// emit lessClicked();
465// emit lessReleased(); 712// emit lessReleased();
466// toggleButton(6); 713// toggleButton(6);
467 break; 714 break;
468 case Key_Up: 715 case Key_Up:
469// toggleButton(5); 716// toggleButton(5);
470// emit moreClicked(); 717// emit moreClicked();
471// emit moreReleased(); 718// emit moreReleased();
472// toggleButton(5); 719// toggleButton(5);
473 break; 720 break;
474 case Key_Right: 721 case Key_Right:
475 mediaPlayerState->setNext(); 722 mediaPlayerState->setNext();
476 break; 723 break;
477 case Key_Left: 724 case Key_Left:
478 mediaPlayerState->setPrev(); 725 mediaPlayerState->setPrev();
479 break; 726 break;
480 case Key_Escape: 727 case Key_Escape:
481 break; 728 break;
482 729
483 }; 730 };
484} 731}
diff --git a/core/multimedia/opieplayer/videowidget.h b/core/multimedia/opieplayer/videowidget.h
index fe56ca1..fd86cd2 100644
--- a/core/multimedia/opieplayer/videowidget.h
+++ b/core/multimedia/opieplayer/videowidget.h
@@ -1,88 +1,99 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef VIDEO_WIDGET_H 20#ifndef VIDEO_WIDGET_H
21#define VIDEO_WIDGET_H 21#define VIDEO_WIDGET_H
22 22
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25 25
26class QPixmap; 26class QPixmap;
27class QSlider; 27class QSlider;
28 28
29 29
30enum VideoButtons { 30enum VideoButtons {
31 VideoPrevious, 31 VideoPrevious,
32 VideoStop, 32 VideoStop,
33 VideoPlay, 33 VideoPlay,
34 VideoPause, 34 VideoPause,
35 VideoNext, 35 VideoNext,
36 VideoPlayList, 36 VideoPlayList,
37 VideoFullscreen 37 VideoFullscreen
38}; 38};
39 39
40
41class VideoWidget : public QWidget { 40class VideoWidget : public QWidget {
42 Q_OBJECT 41 Q_OBJECT
43public: 42public:
44 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 43 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
45 ~VideoWidget(); 44 ~VideoWidget();
46 45
47 bool playVideo(); 46 bool playVideo();
48 47
49public slots: 48public slots:
50 void updateSlider( long, long ); 49 void updateSlider( long, long );
51 void sliderPressed( ); 50 void sliderPressed( );
52 void sliderReleased( ); 51 void sliderReleased( );
53 void setPaused( bool b) { setToggleButton( VideoPause, b ); } 52 void setPaused( bool b) { setToggleButton( VideoPause, b ); }
54 void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } 53 void setPlaying( bool b) { setToggleButton( VideoPlay, b ); }
55 void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); } 54 void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); }
56 void makeVisible(); 55 void makeVisible();
57 void setPosition( long ); 56 void setPosition( long );
58 void setLength( long ); 57 void setLength( long );
59 void setView( char ); 58 void setView( char );
60 59
61signals: 60signals:
62 void sliderMoved( long ); 61 void sliderMoved( long );
63 62
64protected: 63protected:
64 void resizeEvent( QResizeEvent * );
65 void paintEvent( QPaintEvent *pe ); 65 void paintEvent( QPaintEvent *pe );
66 void mouseMoveEvent( QMouseEvent *event ); 66 void mouseMoveEvent( QMouseEvent *event );
67 void mousePressEvent( QMouseEvent *event ); 67 void mousePressEvent( QMouseEvent *event );
68 void mouseReleaseEvent( QMouseEvent *event ); 68 void mouseReleaseEvent( QMouseEvent *event );
69 void closeEvent( QCloseEvent *event ); 69 void closeEvent( QCloseEvent *event );
70 void keyReleaseEvent( QKeyEvent *e); 70 void keyReleaseEvent( QKeyEvent *e);
71 71
72private: 72private:
73 void paintButton( QPainter *p, int i ); 73 QPixmap *pixBg;
74 void toggleButton( int ); 74 QImage *imgUp;
75 void setToggleButton( int, bool ); 75 QImage *imgDn;
76 76 QImage *imgButtonMask;
77 QBitmap *masks[7];
78 QString backgroundPix;
79 QPixmap *buttonPixUp[7];
80 QPixmap *buttonPixDown[7];
81 QString skin;
77 QSlider *slider; 82 QSlider *slider;
78 QPixmap *pixmaps[3]; 83 QPixmap *pixmaps[3];
79 QImage *currentFrame; 84 QImage *currentFrame;
85 int xoff, yoff;
80 int scaledWidth; 86 int scaledWidth;
81 int scaledHeight; 87 int scaledHeight;
88
89 void paintButton( QPainter *p, int i );
90 void toggleButton( int );
91 void setToggleButton( int, bool );
92
82}; 93};
83 94
84 95
85#endif // VIDEO_WIDGET_H 96#endif // VIDEO_WIDGET_H
86 97
87 98
88 99