-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 5e1be2f..299181b 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,477 +1,477 @@ | |||
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 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | static inline QString fullBaseName ( const QFileInfo &fi ) | 86 | static 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 | ||
93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; | 93 | QString 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 | // }; |
97 | class PlayListWidgetPrivate { | 97 | class PlayListWidgetPrivate { |
98 | public: | 98 | public: |
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 | ||
108 | class ToolButton : public QToolButton { | 108 | class ToolButton : public QToolButton { |
109 | public: | 109 | public: |
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 | ||
123 | class MenuItem : public QAction { | 123 | class MenuItem : public QAction { |
124 | public: | 124 | public: |
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 | ||
133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 133 | PlayListWidget::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 | tbDeletePlaylist->setFixedSize(20,20); | 170 | tbDeletePlaylist->setFixedSize(20,20); |
171 | 171 | ||
172 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 172 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
173 | this , SLOT(addSelected()) ); | 173 | this , SLOT(addSelected()) ); |
174 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 174 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
175 | this , SLOT(removeSelected()) ); | 175 | this , SLOT(removeSelected()) ); |
176 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 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", | 177 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
178 | this , SLOT( btnPlay(bool) ), TRUE ); | 178 | this , SLOT( btnPlay(bool) ), TRUE ); |
179 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 179 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
180 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 180 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
181 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 181 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
182 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 182 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
183 | tbDeletePlaylist->hide(); | 183 | tbDeletePlaylist->hide(); |
184 | 184 | ||
185 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 185 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
186 | menu->insertItem( tr( "File" ), pmPlayList ); | 186 | menu->insertItem( tr( "File" ), pmPlayList ); |
187 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 187 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
188 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 188 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
189 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 189 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
190 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 190 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
191 | pmPlayList->insertSeparator(-1); | 191 | pmPlayList->insertSeparator(-1); |
192 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 192 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
193 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 193 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
194 | pmPlayList->insertSeparator(-1); | 194 | pmPlayList->insertSeparator(-1); |
195 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 195 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
196 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 196 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
197 | 197 | ||
198 | QPopupMenu *pmView = new QPopupMenu( this ); | 198 | QPopupMenu *pmView = new QPopupMenu( this ); |
199 | menu->insertItem( tr( "View" ), pmView ); | 199 | menu->insertItem( tr( "View" ), pmView ); |
200 | 200 | ||
201 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 201 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
202 | fullScreenButton->addTo(pmView); | 202 | fullScreenButton->addTo(pmView); |
203 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 203 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
204 | scaleButton->addTo(pmView); | 204 | scaleButton->addTo(pmView); |
205 | 205 | ||
206 | 206 | ||
207 | skinsMenu = new QPopupMenu( this ); | 207 | skinsMenu = new QPopupMenu( this ); |
208 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 208 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
209 | skinsMenu->isCheckable(); | 209 | skinsMenu->isCheckable(); |
210 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 210 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
211 | this, SLOT( skinsMenuActivated( int ) ) ); | 211 | this, SLOT( skinsMenuActivated( int ) ) ); |
212 | populateSkinsMenu(); | 212 | populateSkinsMenu(); |
213 | 213 | ||
214 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 214 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
215 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 215 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
216 | 216 | ||
217 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 217 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
218 | 218 | ||
219 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 219 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
220 | // tabWidget->setTabShape(QTabWidget::Triangular); | 220 | // tabWidget->setTabShape(QTabWidget::Triangular); |
221 | 221 | ||
222 | QWidget *pTab; | 222 | QWidget *pTab; |
223 | pTab = new QWidget( tabWidget, "pTab" ); | 223 | pTab = new QWidget( tabWidget, "pTab" ); |
224 | // playlistView = new QListView( pTab, "playlistview" ); | 224 | // playlistView = new QListView( pTab, "playlistview" ); |
225 | // playlistView->setMinimumSize(236,260); | 225 | // playlistView->setMinimumSize(236,260); |
226 | tabWidget->insertTab( pTab,"Playlist"); | 226 | tabWidget->insertTab( pTab,"Playlist"); |
227 | 227 | ||
228 | 228 | ||
229 | // Add the playlist area | 229 | // Add the playlist area |
230 | 230 | ||
231 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 231 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
232 | d->playListFrame = vbox3; | 232 | d->playListFrame = vbox3; |
233 | d->playListFrame ->setMinimumSize(235,260); | 233 | d->playListFrame ->setMinimumSize(235,260); |
234 | 234 | ||
235 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 235 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
236 | 236 | ||
237 | d->selectedFiles = new PlayListSelection( hbox2); | 237 | d->selectedFiles = new PlayListSelection( hbox2); |
238 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 238 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
239 | 239 | ||
240 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 240 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
241 | 241 | ||
242 | 242 | ||
243 | 243 | ||
244 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 244 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
245 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 245 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
246 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 246 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
247 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 247 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
248 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 248 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
249 | 249 | ||
250 | QWidget *aTab; | 250 | QWidget *aTab; |
251 | aTab = new QWidget( tabWidget, "aTab" ); | 251 | aTab = new QWidget( tabWidget, "aTab" ); |
252 | audioView = new QListView( aTab, "Audioview" ); | 252 | audioView = new QListView( aTab, "Audioview" ); |
253 | audioView->setMinimumSize(233,260); | 253 | audioView->setMinimumSize(233,260); |
254 | audioView->addColumn( tr("Title"),140); | 254 | audioView->addColumn( tr("Title"),140); |
255 | audioView->addColumn(tr("Size"), -1); | 255 | audioView->addColumn(tr("Size"), -1); |
256 | audioView->addColumn(tr("Media"),-1); | 256 | audioView->addColumn(tr("Media"),-1); |
257 | audioView->addColumn( tr( "Path" ), 0 ); | 257 | audioView->addColumn( tr( "Path" ), 0 ); |
258 | 258 | ||
259 | audioView->setColumnAlignment(1, Qt::AlignRight); | 259 | audioView->setColumnAlignment(1, Qt::AlignRight); |
260 | audioView->setColumnAlignment(2, Qt::AlignRight); | 260 | audioView->setColumnAlignment(2, Qt::AlignRight); |
261 | audioView->setAllColumnsShowFocus(TRUE); | 261 | audioView->setAllColumnsShowFocus(TRUE); |
262 | 262 | ||
263 | audioView->setMultiSelection( TRUE ); | 263 | audioView->setMultiSelection( TRUE ); |
264 | audioView->setSelectionMode( QListView::Extended); | 264 | audioView->setSelectionMode( QListView::Extended); |
265 | audioView->setSorting( 3, TRUE ); | 265 | audioView->setSorting( 3, TRUE ); |
266 | 266 | ||
267 | tabWidget->insertTab(aTab,tr("Audio")); | 267 | tabWidget->insertTab(aTab,tr("Audio")); |
268 | 268 | ||
269 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 269 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
270 | 270 | ||
271 | // audioView | 271 | // audioView |
272 | // populateAudioView(); | 272 | // populateAudioView(); |
273 | // videowidget | 273 | // videowidget |
274 | 274 | ||
275 | QWidget *vTab; | 275 | QWidget *vTab; |
276 | vTab = new QWidget( tabWidget, "vTab" ); | 276 | vTab = new QWidget( tabWidget, "vTab" ); |
277 | videoView = new QListView( vTab, "Videoview" ); | 277 | videoView = new QListView( vTab, "Videoview" ); |
278 | videoView->setMinimumSize(233,260); | 278 | videoView->setMinimumSize(233,260); |
279 | 279 | ||
280 | videoView->addColumn(tr("Title"),140); | 280 | videoView->addColumn(tr("Title"),140); |
281 | videoView->addColumn(tr("Size"),-1); | 281 | videoView->addColumn(tr("Size"),-1); |
282 | videoView->addColumn(tr("Media"),-1); | 282 | videoView->addColumn(tr("Media"),-1); |
283 | videoView->addColumn(tr( "Path" ), 0 ); | 283 | videoView->addColumn(tr( "Path" ), 0 ); |
284 | videoView->setColumnAlignment(1, Qt::AlignRight); | 284 | videoView->setColumnAlignment(1, Qt::AlignRight); |
285 | videoView->setColumnAlignment(2, Qt::AlignRight); | 285 | videoView->setColumnAlignment(2, Qt::AlignRight); |
286 | videoView->setAllColumnsShowFocus(TRUE); | 286 | videoView->setAllColumnsShowFocus(TRUE); |
287 | videoView->setMultiSelection( TRUE ); | 287 | videoView->setMultiSelection( TRUE ); |
288 | videoView->setSelectionMode( QListView::Extended); | 288 | videoView->setSelectionMode( QListView::Extended); |
289 | 289 | ||
290 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 290 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
291 | 291 | ||
292 | tabWidget->insertTab( vTab,tr("Video")); | 292 | tabWidget->insertTab( vTab,tr("Video")); |
293 | 293 | ||
294 | QWidget *LTab; | 294 | QWidget *LTab; |
295 | LTab = new QWidget( tabWidget, "LTab" ); | 295 | LTab = new QWidget( tabWidget, "LTab" ); |
296 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 296 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
297 | playLists->setMinimumSize(233,260); | 297 | playLists->setMinimumSize(233,260); |
298 | tabWidget->insertTab(LTab,tr("Lists")); | 298 | tabWidget->insertTab(LTab,tr("Lists")); |
299 | 299 | ||
300 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 300 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
301 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 301 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
302 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 302 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
303 | 303 | ||
304 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 304 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
305 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 305 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
306 | 306 | ||
307 | 307 | ||
308 | ///audioView | 308 | ///audioView |
309 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 309 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
310 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 310 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
311 | 311 | ||
312 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 312 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
313 | this,SLOT( playIt( QListViewItem *)) ); | 313 | this,SLOT( playIt( QListViewItem *)) ); |
314 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 314 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
315 | 315 | ||
316 | 316 | ||
317 | //videoView | 317 | //videoView |
318 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 318 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
319 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 319 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
320 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 320 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
321 | this,SLOT( playIt( QListViewItem *)) ); | 321 | this,SLOT( playIt( QListViewItem *)) ); |
322 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 322 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
323 | 323 | ||
324 | 324 | ||
325 | //playlists | 325 | //playlists |
326 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 326 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
327 | 327 | ||
328 | 328 | ||
329 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 329 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
330 | 330 | ||
331 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 331 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
332 | 332 | ||
333 | 333 | ||
334 | 334 | ||
335 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 335 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
336 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 336 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
337 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 337 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
338 | 338 | ||
339 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 339 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
340 | 340 | ||
341 | setCentralWidget( vbox5 ); | 341 | setCentralWidget( vbox5 ); |
342 | 342 | ||
343 | Config cfg( "OpiePlayer" ); | 343 | Config cfg( "OpiePlayer" ); |
344 | readConfig( cfg ); | 344 | readConfig( cfg ); |
345 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 345 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
346 | loadList(DocLnk( currentPlaylist)); | 346 | loadList(DocLnk( currentPlaylist)); |
347 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); | 347 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); |
348 | 348 | ||
349 | initializeStates(); | 349 | initializeStates(); |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
353 | PlayListWidget::~PlayListWidget() { | 353 | PlayListWidget::~PlayListWidget() { |
354 | Config cfg( "OpiePlayer" ); | 354 | Config cfg( "OpiePlayer" ); |
355 | writeConfig( cfg ); | 355 | writeConfig( cfg ); |
356 | 356 | ||
357 | if ( d->current ) | 357 | if ( d->current ) |
358 | delete d->current; | 358 | delete d->current; |
359 | delete d; | 359 | delete d; |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | void PlayListWidget::initializeStates() { | 363 | void PlayListWidget::initializeStates() { |
364 | 364 | ||
365 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 365 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
366 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 366 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
367 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 367 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
368 | setPlaylist( true); | 368 | setPlaylist( true); |
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | void PlayListWidget::readConfig( Config& cfg ) { | 372 | void PlayListWidget::readConfig( Config& cfg ) { |
373 | cfg.setGroup("PlayList"); | 373 | cfg.setGroup("PlayList"); |
374 | QString currentString = cfg.readEntry("current", "" ); | 374 | QString currentString = cfg.readEntry("current", "" ); |
375 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 375 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
376 | for ( int i = 0; i < noOfFiles; i++ ) { | 376 | for ( int i = 0; i < noOfFiles; i++ ) { |
377 | QString entryName; | 377 | QString entryName; |
378 | entryName.sprintf( "File%i", i + 1 ); | 378 | entryName.sprintf( "File%i", i + 1 ); |
379 | QString linkFile = cfg.readEntry( entryName ); | 379 | QString linkFile = cfg.readEntry( entryName ); |
380 | DocLnk lnk( linkFile ); | 380 | DocLnk lnk( linkFile ); |
381 | if ( lnk.isValid() ) { | 381 | if ( lnk.isValid() ) { |
382 | d->selectedFiles->addToSelection( lnk ); | 382 | d->selectedFiles->addToSelection( lnk ); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | d->selectedFiles->setSelectedItem( currentString); | 385 | d->selectedFiles->setSelectedItem( currentString); |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | void PlayListWidget::writeConfig( Config& cfg ) const { | 389 | void PlayListWidget::writeConfig( Config& cfg ) const { |
390 | 390 | ||
391 | d->selectedFiles->writeCurrent( cfg); | 391 | d->selectedFiles->writeCurrent( cfg); |
392 | cfg.setGroup("PlayList"); | 392 | cfg.setGroup("PlayList"); |
393 | int noOfFiles = 0; | 393 | int noOfFiles = 0; |
394 | d->selectedFiles->first(); | 394 | d->selectedFiles->first(); |
395 | do { | 395 | do { |
396 | const DocLnk *lnk = d->selectedFiles->current(); | 396 | const DocLnk *lnk = d->selectedFiles->current(); |
397 | if ( lnk ) { | 397 | if ( lnk ) { |
398 | QString entryName; | 398 | QString entryName; |
399 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 399 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
400 | // qDebug(entryName); | 400 | // qDebug(entryName); |
401 | cfg.writeEntry( entryName, lnk->linkFile() ); | 401 | cfg.writeEntry( entryName, lnk->linkFile() ); |
402 | // if this link does exist, add it so we have the file | 402 | // if this link does exist, add it so we have the file |
403 | // next time... | 403 | // next time... |
404 | if ( !QFile::exists( lnk->linkFile() ) ) { | 404 | if ( !QFile::exists( lnk->linkFile() ) ) { |
405 | // the way writing lnks doesn't really check for out | 405 | // the way writing lnks doesn't really check for out |
406 | // of disk space, but check it anyway. | 406 | // of disk space, but check it anyway. |
407 | if ( !lnk->writeLink() ) { | 407 | if ( !lnk->writeLink() ) { |
408 | QMessageBox::critical( 0, tr("Out of space"), | 408 | QMessageBox::critical( 0, tr("Out of space"), |
409 | tr( "There was a problem saving " | 409 | tr( "There was a problem saving " |
410 | "the playlist.\n" | 410 | "the playlist.\n" |
411 | "Your playlist " | 411 | "Your playlist " |
412 | "may be missing some entries\n" | 412 | "may be missing some entries\n" |
413 | "the next time you start it." ) | 413 | "the next time you start it." ) |
414 | ); | 414 | ); |
415 | } | 415 | } |
416 | } | 416 | } |
417 | noOfFiles++; | 417 | noOfFiles++; |
418 | } | 418 | } |
419 | } | 419 | } |
420 | while ( d->selectedFiles->next() ); | 420 | while ( d->selectedFiles->next() ); |
421 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 421 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 425 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
426 | d->setDocumentUsed = false; | 426 | d->setDocumentUsed = false; |
427 | if ( mediaPlayerState->playlist() ) { | 427 | if ( mediaPlayerState->playlist() ) { |
428 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 428 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
429 | d->selectedFiles->addToSelection( lnk ); | 429 | d->selectedFiles->addToSelection( lnk ); |
430 | } | 430 | } |
431 | else | 431 | else |
432 | mediaPlayerState->setPlaying( true); | 432 | mediaPlayerState->setPlaying( true); |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void PlayListWidget::clearList() { | 436 | void PlayListWidget::clearList() { |
437 | while ( first() ) | 437 | while ( first() ) |
438 | d->selectedFiles->removeSelected(); | 438 | d->selectedFiles->removeSelected(); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | void PlayListWidget::addAllToList() { | 442 | void PlayListWidget::addAllToList() { |
443 | DocLnkSet filesAll; | 443 | DocLnkSet filesAll; |
444 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 444 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
445 | QListIterator<DocLnk> Adit( filesAll.children() ); | 445 | QListIterator<DocLnk> Adit( filesAll.children() ); |
446 | for ( ; Adit.current(); ++Adit ) | 446 | for ( ; Adit.current(); ++Adit ) |
447 | if(QFileInfo(Adit.current()->file()).exists()) | 447 | if(QFileInfo(Adit.current()->file()).exists()) |
448 | d->selectedFiles->addToSelection( **Adit ); | 448 | d->selectedFiles->addToSelection( **Adit ); |
449 | tabWidget->setCurrentPage(0); | 449 | tabWidget->setCurrentPage(0); |
450 | 450 | ||
451 | writeCurrentM3u(); | 451 | writeCurrentM3u(); |
452 | d->selectedFiles->first(); | 452 | d->selectedFiles->first(); |
453 | } | 453 | } |
454 | 454 | ||
455 | 455 | ||
456 | void PlayListWidget::addAllMusicToList() { | 456 | void PlayListWidget::addAllMusicToList() { |
457 | QListIterator<DocLnk> dit( files.children() ); | 457 | QListIterator<DocLnk> dit( files.children() ); |
458 | for ( ; dit.current(); ++dit ) | 458 | for ( ; dit.current(); ++dit ) |
459 | if(QFileInfo(dit.current()->file()).exists()) | 459 | if(QFileInfo(dit.current()->file()).exists()) |
460 | d->selectedFiles->addToSelection( **dit ); | 460 | d->selectedFiles->addToSelection( **dit ); |
461 | tabWidget->setCurrentPage(0); | 461 | tabWidget->setCurrentPage(0); |
462 | 462 | ||
463 | writeCurrentM3u(); | 463 | writeCurrentM3u(); |
464 | d->selectedFiles->first(); | 464 | d->selectedFiles->first(); |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | void PlayListWidget::addAllVideoToList() { | 468 | void PlayListWidget::addAllVideoToList() { |
469 | QListIterator<DocLnk> dit( vFiles.children() ); | 469 | QListIterator<DocLnk> dit( vFiles.children() ); |
470 | for ( ; dit.current(); ++dit ) | 470 | for ( ; dit.current(); ++dit ) |
471 | if(QFileInfo( dit.current()->file()).exists()) | 471 | if(QFileInfo( dit.current()->file()).exists()) |
472 | d->selectedFiles->addToSelection( **dit ); | 472 | d->selectedFiles->addToSelection( **dit ); |
473 | tabWidget->setCurrentPage(0); | 473 | tabWidget->setCurrentPage(0); |
474 | 474 | ||
475 | writeCurrentM3u(); | 475 | writeCurrentM3u(); |
476 | d->selectedFiles->first(); | 476 | d->selectedFiles->first(); |
477 | } | 477 | } |