author | llornkcor <llornkcor> | 2003-04-20 02:36:08 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-04-20 02:36:08 (UTC) |
commit | f4b192f79649abb3318c2c404da31f067f4ca467 (patch) (unidiff) | |
tree | e42225f67544daace708051585fb944c4ca6561d | |
parent | 845c8a880a2ff701f21c2845674e97a2493499f4 (diff) | |
download | opie-f4b192f79649abb3318c2c404da31f067f4ca467.zip opie-f4b192f79649abb3318c2c404da31f067f4ca467.tar.gz opie-f4b192f79649abb3318c2c404da31f067f4ca467.tar.bz2 |
fix sizing
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index bffda38..795feaf 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,1084 +1,1083 @@ | |||
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;audio/x-ogg"; | 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 | 170 | ||
171 | tbDeletePlaylist->setFixedSize(20,20); | 171 | tbDeletePlaylist->setFixedSize(20,20); |
172 | 172 | ||
173 | 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", |
174 | this , SLOT(addSelected()) ); | 174 | this , SLOT(addSelected()) ); |
175 | 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", |
176 | this , SLOT(removeSelected()) ); | 176 | this , SLOT(removeSelected()) ); |
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", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
178 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 178 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
179 | this , SLOT( btnPlay(bool) ), TRUE ); | 179 | this , SLOT( btnPlay(bool) ), TRUE ); |
180 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 180 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
181 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 181 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
182 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 182 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
183 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 183 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
184 | tbDeletePlaylist->hide(); | 184 | tbDeletePlaylist->hide(); |
185 | 185 | ||
186 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 186 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
187 | menu->insertItem( tr( "File" ), pmPlayList ); | 187 | menu->insertItem( tr( "File" ), pmPlayList ); |
188 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 188 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
189 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 189 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
190 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 190 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
191 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 191 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
192 | pmPlayList->insertSeparator(-1); | 192 | pmPlayList->insertSeparator(-1); |
193 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 193 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
194 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 194 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
195 | pmPlayList->insertSeparator(-1); | 195 | pmPlayList->insertSeparator(-1); |
196 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 196 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
197 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 197 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
198 | 198 | ||
199 | QPopupMenu *pmView = new QPopupMenu( this ); | 199 | QPopupMenu *pmView = new QPopupMenu( this ); |
200 | menu->insertItem( tr( "View" ), pmView ); | 200 | menu->insertItem( tr( "View" ), pmView ); |
201 | 201 | ||
202 | 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); |
203 | fullScreenButton->addTo(pmView); | 203 | fullScreenButton->addTo(pmView); |
204 | 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); |
205 | scaleButton->addTo(pmView); | 205 | scaleButton->addTo(pmView); |
206 | 206 | ||
207 | 207 | ||
208 | skinsMenu = new QPopupMenu( this ); | 208 | skinsMenu = new QPopupMenu( this ); |
209 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 209 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
210 | skinsMenu->isCheckable(); | 210 | skinsMenu->isCheckable(); |
211 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 211 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
212 | this, SLOT( skinsMenuActivated( int ) ) ); | 212 | this, SLOT( skinsMenuActivated( int ) ) ); |
213 | populateSkinsMenu(); | 213 | populateSkinsMenu(); |
214 | 214 | ||
215 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 215 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
216 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 216 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
217 | 217 | ||
218 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 218 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
219 | 219 | ||
220 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 220 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
221 | // tabWidget->setTabShape(QTabWidget::Triangular); | 221 | // tabWidget->setTabShape(QTabWidget::Triangular); |
222 | 222 | ||
223 | QWidget *pTab; | 223 | QWidget *pTab; |
224 | pTab = new QWidget( tabWidget, "pTab" ); | 224 | pTab = new QWidget( tabWidget, "pTab" ); |
225 | // playlistView = new QListView( pTab, "playlistview" ); | 225 | // playlistView = new QListView( pTab, "playlistview" ); |
226 | // playlistView->setMinimumSize(236,260); | 226 | // playlistView->setMinimumSize(236,260); |
227 | tabWidget->insertTab( pTab,"Playlist"); | 227 | tabWidget->insertTab( pTab,"Playlist"); |
228 | 228 | ||
229 | 229 | ||
230 | // Add the playlist area | 230 | // Add the playlist area |
231 | 231 | ||
232 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 232 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
233 | d->playListFrame = vbox3; | 233 | d->playListFrame = vbox3; |
234 | 234 | ||
235 | QGridLayout *layoutF = new QGridLayout( pTab ); | 235 | QGridLayout *layoutF = new QGridLayout( pTab ); |
236 | layoutF->setSpacing( 2); | 236 | layoutF->setSpacing( 2); |
237 | layoutF->setMargin( 2); | 237 | layoutF->setMargin( 2); |
238 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); | 238 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); |
239 | // d->playListFrame ->setMinimumSize(235,260); | ||
240 | 239 | ||
241 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 240 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
242 | 241 | ||
243 | d->selectedFiles = new PlayListSelection( hbox2); | 242 | d->selectedFiles = new PlayListSelection( hbox2); |
244 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 243 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
245 | 244 | ||
246 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 245 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
247 | 246 | ||
248 | 247 | ||
249 | 248 | ||
250 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 249 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
251 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 250 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
252 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 251 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
253 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 252 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
254 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 253 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
255 | 254 | ||
256 | QWidget *aTab; | 255 | QWidget *aTab; |
257 | aTab = new QWidget( tabWidget, "aTab" ); | 256 | aTab = new QWidget( tabWidget, "aTab" ); |
258 | audioView = new QListView( aTab, "Audioview" ); | 257 | audioView = new QListView( aTab, "Audioview" ); |
259 | 258 | ||
260 | QGridLayout *layoutA = new QGridLayout( aTab ); | 259 | QGridLayout *layoutA = new QGridLayout( aTab ); |
261 | layoutA->setSpacing( 2); | 260 | layoutA->setSpacing( 2); |
262 | layoutA->setMargin( 2); | 261 | layoutA->setMargin( 2); |
263 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 262 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
264 | 263 | ||
265 | audioView->addColumn( tr("Title"),140); | 264 | audioView->addColumn( tr("Title"),-1); |
266 | audioView->addColumn(tr("Size"), -1); | 265 | audioView->addColumn(tr("Size"), -1); |
267 | audioView->addColumn(tr("Media"),-1); | 266 | audioView->addColumn(tr("Media"),-1); |
268 | audioView->addColumn( tr( "Path" ), 0 ); | 267 | audioView->addColumn( tr( "Path" ), -1 ); |
269 | 268 | ||
270 | audioView->setColumnAlignment(1, Qt::AlignRight); | 269 | audioView->setColumnAlignment(1, Qt::AlignRight); |
271 | audioView->setColumnAlignment(2, Qt::AlignRight); | 270 | audioView->setColumnAlignment(2, Qt::AlignRight); |
272 | audioView->setAllColumnsShowFocus(TRUE); | 271 | audioView->setAllColumnsShowFocus(TRUE); |
273 | 272 | ||
274 | audioView->setMultiSelection( TRUE ); | 273 | audioView->setMultiSelection( TRUE ); |
275 | audioView->setSelectionMode( QListView::Extended); | 274 | audioView->setSelectionMode( QListView::Extended); |
276 | audioView->setSorting( 3, TRUE ); | 275 | audioView->setSorting( 3, TRUE ); |
277 | 276 | ||
278 | tabWidget->insertTab(aTab,tr("Audio")); | 277 | tabWidget->insertTab(aTab,tr("Audio")); |
279 | 278 | ||
280 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 279 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
281 | 280 | ||
282 | // audioView | 281 | // audioView |
283 | // populateAudioView(); | 282 | // populateAudioView(); |
284 | // videowidget | 283 | // videowidget |
285 | 284 | ||
286 | QWidget *vTab; | 285 | QWidget *vTab; |
287 | vTab = new QWidget( tabWidget, "vTab" ); | 286 | vTab = new QWidget( tabWidget, "vTab" ); |
288 | videoView = new QListView( vTab, "Videoview" ); | 287 | videoView = new QListView( vTab, "Videoview" ); |
289 | 288 | ||
290 | QGridLayout *layoutV = new QGridLayout( vTab ); | 289 | QGridLayout *layoutV = new QGridLayout( vTab ); |
291 | layoutV->setSpacing( 2); | 290 | layoutV->setSpacing( 2); |
292 | layoutV->setMargin( 2); | 291 | layoutV->setMargin( 2); |
293 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 292 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
294 | 293 | ||
295 | videoView->addColumn(tr("Title"),140); | 294 | videoView->addColumn(tr("Title"),-1); |
296 | videoView->addColumn(tr("Size"),-1); | 295 | videoView->addColumn(tr("Size"),-1); |
297 | videoView->addColumn(tr("Media"),-1); | 296 | videoView->addColumn(tr("Media"),-1); |
298 | videoView->addColumn(tr( "Path" ), 0 ); | 297 | videoView->addColumn(tr( "Path" ), -1 ); |
299 | videoView->setColumnAlignment(1, Qt::AlignRight); | 298 | videoView->setColumnAlignment(1, Qt::AlignRight); |
300 | videoView->setColumnAlignment(2, Qt::AlignRight); | 299 | videoView->setColumnAlignment(2, Qt::AlignRight); |
301 | videoView->setAllColumnsShowFocus(TRUE); | 300 | videoView->setAllColumnsShowFocus(TRUE); |
302 | videoView->setMultiSelection( TRUE ); | 301 | videoView->setMultiSelection( TRUE ); |
303 | videoView->setSelectionMode( QListView::Extended); | 302 | videoView->setSelectionMode( QListView::Extended); |
304 | 303 | ||
305 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 304 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
306 | 305 | ||
307 | tabWidget->insertTab( vTab,tr("Video")); | 306 | tabWidget->insertTab( vTab,tr("Video")); |
308 | 307 | ||
309 | QWidget *LTab; | 308 | QWidget *LTab; |
310 | LTab = new QWidget( tabWidget, "LTab" ); | 309 | LTab = new QWidget( tabWidget, "LTab" ); |
311 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 310 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
312 | 311 | ||
313 | QGridLayout *layoutL = new QGridLayout( LTab ); | 312 | QGridLayout *layoutL = new QGridLayout( LTab ); |
314 | layoutL->setSpacing( 2); | 313 | layoutL->setSpacing( 2); |
315 | layoutL->setMargin( 2); | 314 | layoutL->setMargin( 2); |
316 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 315 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
317 | // playLists->setMinimumSize(233,260); | 316 | // playLists->setMinimumSize(233,260); |
318 | 317 | ||
319 | tabWidget->insertTab(LTab,tr("Lists")); | 318 | tabWidget->insertTab(LTab,tr("Lists")); |
320 | 319 | ||
321 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 320 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
322 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 321 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
323 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 322 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
324 | 323 | ||
325 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 324 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
326 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 325 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
327 | 326 | ||
328 | 327 | ||
329 | ///audioView | 328 | ///audioView |
330 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 329 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
331 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 330 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
332 | 331 | ||
333 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 332 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
334 | this,SLOT( playIt( QListViewItem *)) ); | 333 | this,SLOT( playIt( QListViewItem *)) ); |
335 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 334 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
336 | 335 | ||
337 | 336 | ||
338 | //videoView | 337 | //videoView |
339 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 338 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
340 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 339 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
341 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 340 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
342 | this,SLOT( playIt( QListViewItem *)) ); | 341 | this,SLOT( playIt( QListViewItem *)) ); |
343 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 342 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
344 | 343 | ||
345 | //playlists | 344 | //playlists |
346 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 345 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
347 | 346 | ||
348 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 347 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
349 | 348 | ||
350 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 349 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
351 | 350 | ||
352 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 351 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
353 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 352 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
354 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 353 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
355 | 354 | ||
356 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
357 | 356 | ||
358 | setCentralWidget( vbox5 ); | 357 | setCentralWidget( vbox5 ); |
359 | 358 | ||
360 | Config cfg( "OpiePlayer" ); | 359 | Config cfg( "OpiePlayer" ); |
361 | readConfig( cfg ); | 360 | readConfig( cfg ); |
362 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 361 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
363 | loadList(DocLnk( currentPlaylist)); | 362 | loadList(DocLnk( currentPlaylist)); |
364 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); | 363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); |
365 | 364 | ||
366 | initializeStates(); | 365 | initializeStates(); |
367 | } | 366 | } |
368 | 367 | ||
369 | 368 | ||
370 | PlayListWidget::~PlayListWidget() { | 369 | PlayListWidget::~PlayListWidget() { |
371 | Config cfg( "OpiePlayer" ); | 370 | Config cfg( "OpiePlayer" ); |
372 | writeConfig( cfg ); | 371 | writeConfig( cfg ); |
373 | 372 | ||
374 | if ( d->current ) | 373 | if ( d->current ) |
375 | delete d->current; | 374 | delete d->current; |
376 | delete d; | 375 | delete d; |
377 | } | 376 | } |
378 | 377 | ||
379 | 378 | ||
380 | void PlayListWidget::initializeStates() { | 379 | void PlayListWidget::initializeStates() { |
381 | 380 | ||
382 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 381 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
383 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 382 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
384 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 383 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
385 | setPlaylist( true); | 384 | setPlaylist( true); |
386 | } | 385 | } |
387 | 386 | ||
388 | 387 | ||
389 | void PlayListWidget::readConfig( Config& cfg ) { | 388 | void PlayListWidget::readConfig( Config& cfg ) { |
390 | cfg.setGroup("PlayList"); | 389 | cfg.setGroup("PlayList"); |
391 | QString currentString = cfg.readEntry("current", "" ); | 390 | QString currentString = cfg.readEntry("current", "" ); |
392 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 391 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
393 | for ( int i = 0; i < noOfFiles; i++ ) { | 392 | for ( int i = 0; i < noOfFiles; i++ ) { |
394 | QString entryName; | 393 | QString entryName; |
395 | entryName.sprintf( "File%i", i + 1 ); | 394 | entryName.sprintf( "File%i", i + 1 ); |
396 | QString linkFile = cfg.readEntry( entryName ); | 395 | QString linkFile = cfg.readEntry( entryName ); |
397 | DocLnk lnk( linkFile ); | 396 | DocLnk lnk( linkFile ); |
398 | if ( lnk.isValid() ) { | 397 | if ( lnk.isValid() ) { |
399 | d->selectedFiles->addToSelection( lnk ); | 398 | d->selectedFiles->addToSelection( lnk ); |
400 | } | 399 | } |
401 | } | 400 | } |
402 | d->selectedFiles->setSelectedItem( currentString); | 401 | d->selectedFiles->setSelectedItem( currentString); |
403 | } | 402 | } |
404 | 403 | ||
405 | 404 | ||
406 | void PlayListWidget::writeConfig( Config& cfg ) const { | 405 | void PlayListWidget::writeConfig( Config& cfg ) const { |
407 | 406 | ||
408 | d->selectedFiles->writeCurrent( cfg); | 407 | d->selectedFiles->writeCurrent( cfg); |
409 | cfg.setGroup("PlayList"); | 408 | cfg.setGroup("PlayList"); |
410 | int noOfFiles = 0; | 409 | int noOfFiles = 0; |
411 | d->selectedFiles->first(); | 410 | d->selectedFiles->first(); |
412 | do { | 411 | do { |
413 | const DocLnk *lnk = d->selectedFiles->current(); | 412 | const DocLnk *lnk = d->selectedFiles->current(); |
414 | if ( lnk ) { | 413 | if ( lnk ) { |
415 | QString entryName; | 414 | QString entryName; |
416 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 415 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
417 | // qDebug(entryName); | 416 | // qDebug(entryName); |
418 | cfg.writeEntry( entryName, lnk->linkFile() ); | 417 | cfg.writeEntry( entryName, lnk->linkFile() ); |
419 | // if this link does exist, add it so we have the file | 418 | // if this link does exist, add it so we have the file |
420 | // next time... | 419 | // next time... |
421 | if ( !QFile::exists( lnk->linkFile() ) ) { | 420 | if ( !QFile::exists( lnk->linkFile() ) ) { |
422 | // the way writing lnks doesn't really check for out | 421 | // the way writing lnks doesn't really check for out |
423 | // of disk space, but check it anyway. | 422 | // of disk space, but check it anyway. |
424 | if ( !lnk->writeLink() ) { | 423 | if ( !lnk->writeLink() ) { |
425 | QMessageBox::critical( 0, tr("Out of space"), | 424 | QMessageBox::critical( 0, tr("Out of space"), |
426 | tr( "There was a problem saving " | 425 | tr( "There was a problem saving " |
427 | "the playlist.\n" | 426 | "the playlist.\n" |
428 | "Your playlist " | 427 | "Your playlist " |
429 | "may be missing some entries\n" | 428 | "may be missing some entries\n" |
430 | "the next time you start it." ) | 429 | "the next time you start it." ) |
431 | ); | 430 | ); |
432 | } | 431 | } |
433 | } | 432 | } |
434 | noOfFiles++; | 433 | noOfFiles++; |
435 | } | 434 | } |
436 | } | 435 | } |
437 | while ( d->selectedFiles->next() ); | 436 | while ( d->selectedFiles->next() ); |
438 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 437 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
439 | } | 438 | } |
440 | 439 | ||
441 | 440 | ||
442 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 441 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
443 | d->setDocumentUsed = false; | 442 | d->setDocumentUsed = false; |
444 | if ( mediaPlayerState->playlist() ) { | 443 | if ( mediaPlayerState->playlist() ) { |
445 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 444 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
446 | d->selectedFiles->addToSelection( lnk ); | 445 | d->selectedFiles->addToSelection( lnk ); |
447 | } | 446 | } |
448 | else | 447 | else |
449 | mediaPlayerState->setPlaying( true); | 448 | mediaPlayerState->setPlaying( true); |
450 | } | 449 | } |
451 | 450 | ||
452 | 451 | ||
453 | void PlayListWidget::clearList() { | 452 | void PlayListWidget::clearList() { |
454 | while ( first() ) | 453 | while ( first() ) |
455 | d->selectedFiles->removeSelected(); | 454 | d->selectedFiles->removeSelected(); |
456 | } | 455 | } |
457 | 456 | ||
458 | 457 | ||
459 | void PlayListWidget::addAllToList() { | 458 | void PlayListWidget::addAllToList() { |
460 | DocLnkSet filesAll; | 459 | DocLnkSet filesAll; |
461 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 460 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
462 | QListIterator<DocLnk> Adit( filesAll.children() ); | 461 | QListIterator<DocLnk> Adit( filesAll.children() ); |
463 | for ( ; Adit.current(); ++Adit ) | 462 | for ( ; Adit.current(); ++Adit ) |
464 | if(QFileInfo(Adit.current()->file()).exists()) | 463 | if(QFileInfo(Adit.current()->file()).exists()) |
465 | d->selectedFiles->addToSelection( **Adit ); | 464 | d->selectedFiles->addToSelection( **Adit ); |
466 | tabWidget->setCurrentPage(0); | 465 | tabWidget->setCurrentPage(0); |
467 | 466 | ||
468 | writeCurrentM3u(); | 467 | writeCurrentM3u(); |
469 | d->selectedFiles->first(); | 468 | d->selectedFiles->first(); |
470 | } | 469 | } |
471 | 470 | ||
472 | 471 | ||
473 | void PlayListWidget::addAllMusicToList() { | 472 | void PlayListWidget::addAllMusicToList() { |
474 | QListIterator<DocLnk> dit( files.children() ); | 473 | QListIterator<DocLnk> dit( files.children() ); |
475 | for ( ; dit.current(); ++dit ) | 474 | for ( ; dit.current(); ++dit ) |
476 | if(QFileInfo(dit.current()->file()).exists()) | 475 | if(QFileInfo(dit.current()->file()).exists()) |
477 | d->selectedFiles->addToSelection( **dit ); | 476 | d->selectedFiles->addToSelection( **dit ); |
478 | tabWidget->setCurrentPage(0); | 477 | tabWidget->setCurrentPage(0); |
479 | 478 | ||
480 | writeCurrentM3u(); | 479 | writeCurrentM3u(); |
481 | d->selectedFiles->first(); | 480 | d->selectedFiles->first(); |
482 | } | 481 | } |
483 | 482 | ||
484 | 483 | ||
485 | void PlayListWidget::addAllVideoToList() { | 484 | void PlayListWidget::addAllVideoToList() { |
486 | QListIterator<DocLnk> dit( vFiles.children() ); | 485 | QListIterator<DocLnk> dit( vFiles.children() ); |
487 | for ( ; dit.current(); ++dit ) | 486 | for ( ; dit.current(); ++dit ) |
488 | if(QFileInfo( dit.current()->file()).exists()) | 487 | if(QFileInfo( dit.current()->file()).exists()) |
489 | d->selectedFiles->addToSelection( **dit ); | 488 | d->selectedFiles->addToSelection( **dit ); |
490 | tabWidget->setCurrentPage(0); | 489 | tabWidget->setCurrentPage(0); |
491 | 490 | ||
492 | writeCurrentM3u(); | 491 | writeCurrentM3u(); |
493 | d->selectedFiles->first(); | 492 | d->selectedFiles->first(); |
494 | } | 493 | } |
495 | 494 | ||
496 | 495 | ||
497 | void PlayListWidget::setDocument(const QString& fileref) { | 496 | void PlayListWidget::setDocument(const QString& fileref) { |
498 | qDebug(fileref); | 497 | qDebug(fileref); |
499 | fromSetDocument = TRUE; | 498 | fromSetDocument = TRUE; |
500 | QFileInfo fileInfo(fileref); | 499 | QFileInfo fileInfo(fileref); |
501 | if ( !fileInfo.exists() ) { | 500 | if ( !fileInfo.exists() ) { |
502 | QMessageBox::critical( 0, tr( "Invalid File" ), | 501 | QMessageBox::critical( 0, tr( "Invalid File" ), |
503 | tr( "There was a problem in getting the file." ) ); | 502 | tr( "There was a problem in getting the file." ) ); |
504 | return; | 503 | return; |
505 | } | 504 | } |
506 | // qDebug("setDocument "+fileref); | 505 | // qDebug("setDocument "+fileref); |
507 | QString extension = fileInfo.extension(false); | 506 | QString extension = fileInfo.extension(false); |
508 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 507 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
509 | readm3u( fileref); | 508 | readm3u( fileref); |
510 | } | 509 | } |
511 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 510 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
512 | readPls( fileref); | 511 | readPls( fileref); |
513 | } | 512 | } |
514 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 513 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
515 | clearList(); | 514 | clearList(); |
516 | DocLnk lnk; | 515 | DocLnk lnk; |
517 | lnk.setName( fileInfo.baseName() ); //sets name | 516 | lnk.setName( fileInfo.baseName() ); //sets name |
518 | lnk.setFile( fileref ); //sets file name | 517 | lnk.setFile( fileref ); //sets file name |
519 | //addToSelection( lnk ); | 518 | //addToSelection( lnk ); |
520 | 519 | ||
521 | loadList( lnk); | 520 | loadList( lnk); |
522 | d->selectedFiles->first(); | 521 | d->selectedFiles->first(); |
523 | } else { | 522 | } else { |
524 | clearList(); | 523 | clearList(); |
525 | DocLnk lnk; | 524 | DocLnk lnk; |
526 | lnk.setName( fileInfo.baseName() ); //sets name | 525 | lnk.setName( fileInfo.baseName() ); //sets name |
527 | lnk.setFile( fileref ); //sets file name | 526 | lnk.setFile( fileref ); //sets file name |
528 | addToSelection( lnk ); | 527 | addToSelection( lnk ); |
529 | // addToSelection( DocLnk( fileref ) ); | 528 | // addToSelection( DocLnk( fileref ) ); |
530 | d->setDocumentUsed = TRUE; | 529 | d->setDocumentUsed = TRUE; |
531 | mediaPlayerState->setPlaying( FALSE ); | 530 | mediaPlayerState->setPlaying( FALSE ); |
532 | qApp->processEvents(); | 531 | qApp->processEvents(); |
533 | mediaPlayerState->setPlaying( TRUE ); | 532 | mediaPlayerState->setPlaying( TRUE ); |
534 | qApp->processEvents(); | 533 | qApp->processEvents(); |
535 | setCaption(tr("OpiePlayer")); | 534 | setCaption(tr("OpiePlayer")); |
536 | } | 535 | } |
537 | } | 536 | } |
538 | 537 | ||
539 | 538 | ||
540 | void PlayListWidget::setActiveWindow() { | 539 | void PlayListWidget::setActiveWindow() { |
541 | qDebug("SETTING active window"); | 540 | qDebug("SETTING active window"); |
542 | 541 | ||
543 | // When we get raised we need to ensure that it switches views | 542 | // When we get raised we need to ensure that it switches views |
544 | char origView = mediaPlayerState->view(); | 543 | char origView = mediaPlayerState->view(); |
545 | mediaPlayerState->setView( 'l' ); // invalidate | 544 | mediaPlayerState->setView( 'l' ); // invalidate |
546 | mediaPlayerState->setView( origView ); // now switch back | 545 | mediaPlayerState->setView( origView ); // now switch back |
547 | } | 546 | } |
548 | 547 | ||
549 | 548 | ||
550 | void PlayListWidget::useSelectedDocument() { | 549 | void PlayListWidget::useSelectedDocument() { |
551 | d->setDocumentUsed = FALSE; | 550 | d->setDocumentUsed = FALSE; |
552 | } | 551 | } |
553 | 552 | ||
554 | 553 | ||
555 | const DocLnk *PlayListWidget::current() { // this is fugly | 554 | const DocLnk *PlayListWidget::current() { // this is fugly |
556 | 555 | ||
557 | // if( fromSetDocument) { | 556 | // if( fromSetDocument) { |
558 | // qDebug("from setDoc"); | 557 | // qDebug("from setDoc"); |
559 | // DocLnkSet files; | 558 | // DocLnkSet files; |
560 | // Global::findDocuments(&files, "video/*;audio/*"); | 559 | // Global::findDocuments(&files, "video/*;audio/*"); |
561 | // QListIterator<DocLnk> dit( files.children() ); | 560 | // QListIterator<DocLnk> dit( files.children() ); |
562 | // for ( ; dit.current(); ++dit ) { | 561 | // for ( ; dit.current(); ++dit ) { |
563 | // if(dit.current()->linkFile() == setDocFileRef) { | 562 | // if(dit.current()->linkFile() == setDocFileRef) { |
564 | // qDebug(setDocFileRef); | 563 | // qDebug(setDocFileRef); |
565 | // return dit; | 564 | // return dit; |
566 | // } | 565 | // } |
567 | // } | 566 | // } |
568 | // } else | 567 | // } else |
569 | 568 | ||
570 | qDebug("current"); | 569 | qDebug("current"); |
571 | 570 | ||
572 | switch (tabWidget->currentPageIndex()) { | 571 | switch (tabWidget->currentPageIndex()) { |
573 | case 0: //playlist | 572 | case 0: //playlist |
574 | { | 573 | { |
575 | qDebug("playlist"); | 574 | qDebug("playlist"); |
576 | if ( mediaPlayerState->playlist() ) { | 575 | if ( mediaPlayerState->playlist() ) { |
577 | return d->selectedFiles->current(); | 576 | return d->selectedFiles->current(); |
578 | } | 577 | } |
579 | else if ( d->setDocumentUsed && d->current ) { | 578 | else if ( d->setDocumentUsed && d->current ) { |
580 | return d->current; | 579 | return d->current; |
581 | } else { | 580 | } else { |
582 | return &(d->files->selectedDocument()); | 581 | return &(d->files->selectedDocument()); |
583 | } | 582 | } |
584 | } | 583 | } |
585 | break; | 584 | break; |
586 | case 1://audio | 585 | case 1://audio |
587 | { | 586 | { |
588 | qDebug("audioView"); | 587 | qDebug("audioView"); |
589 | QListIterator<DocLnk> dit( files.children() ); | 588 | QListIterator<DocLnk> dit( files.children() ); |
590 | for ( ; dit.current(); ++dit ) { | 589 | for ( ; dit.current(); ++dit ) { |
591 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 590 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
592 | qDebug("here"); | 591 | qDebug("here"); |
593 | insanityBool=TRUE; | 592 | insanityBool=TRUE; |
594 | return dit; | 593 | return dit; |
595 | } | 594 | } |
596 | } | 595 | } |
597 | } | 596 | } |
598 | break; | 597 | break; |
599 | case 2: // video | 598 | case 2: // video |
600 | { | 599 | { |
601 | qDebug("videoView"); | 600 | qDebug("videoView"); |
602 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 601 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
603 | for ( ; Vdit.current(); ++Vdit ) { | 602 | for ( ; Vdit.current(); ++Vdit ) { |
604 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 603 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
605 | insanityBool=TRUE; | 604 | insanityBool=TRUE; |
606 | return Vdit; | 605 | return Vdit; |
607 | } | 606 | } |
608 | } | 607 | } |
609 | } | 608 | } |
610 | break; | 609 | break; |
611 | }; | 610 | }; |
612 | return 0; | 611 | return 0; |
613 | } | 612 | } |
614 | 613 | ||
615 | bool PlayListWidget::prev() { | 614 | bool PlayListWidget::prev() { |
616 | if ( mediaPlayerState->playlist() ) { | 615 | if ( mediaPlayerState->playlist() ) { |
617 | if ( mediaPlayerState->shuffled() ) { | 616 | if ( mediaPlayerState->shuffled() ) { |
618 | const DocLnk *cur = current(); | 617 | const DocLnk *cur = current(); |
619 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 618 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
620 | for ( int i = 0; i < j; i++ ) { | 619 | for ( int i = 0; i < j; i++ ) { |
621 | if ( !d->selectedFiles->next() ) | 620 | if ( !d->selectedFiles->next() ) |
622 | d->selectedFiles->first(); | 621 | d->selectedFiles->first(); |
623 | } | 622 | } |
624 | if ( cur == current() ) | 623 | if ( cur == current() ) |
625 | if ( !d->selectedFiles->next() ) | 624 | if ( !d->selectedFiles->next() ) |
626 | d->selectedFiles->first(); | 625 | d->selectedFiles->first(); |
627 | return TRUE; | 626 | return TRUE; |
628 | } else { | 627 | } else { |
629 | if ( !d->selectedFiles->prev() ) { | 628 | if ( !d->selectedFiles->prev() ) { |
630 | if ( mediaPlayerState->looping() ) { | 629 | if ( mediaPlayerState->looping() ) { |
631 | return d->selectedFiles->last(); | 630 | return d->selectedFiles->last(); |
632 | } else { | 631 | } else { |
633 | return FALSE; | 632 | return FALSE; |
634 | } | 633 | } |
635 | } | 634 | } |
636 | return TRUE; | 635 | return TRUE; |
637 | } | 636 | } |
638 | } else { | 637 | } else { |
639 | return mediaPlayerState->looping(); | 638 | return mediaPlayerState->looping(); |
640 | } | 639 | } |
641 | } | 640 | } |
642 | 641 | ||
643 | 642 | ||
644 | bool PlayListWidget::next() { | 643 | bool PlayListWidget::next() { |
645 | if ( mediaPlayerState->playlist() ) { | 644 | if ( mediaPlayerState->playlist() ) { |
646 | if ( mediaPlayerState->shuffled() ) { | 645 | if ( mediaPlayerState->shuffled() ) { |
647 | return prev(); | 646 | return prev(); |
648 | } else { | 647 | } else { |
649 | if ( !d->selectedFiles->next() ) { | 648 | if ( !d->selectedFiles->next() ) { |
650 | if ( mediaPlayerState->looping() ) { | 649 | if ( mediaPlayerState->looping() ) { |
651 | return d->selectedFiles->first(); | 650 | return d->selectedFiles->first(); |
652 | } else { | 651 | } else { |
653 | return FALSE; | 652 | return FALSE; |
654 | } | 653 | } |
655 | } | 654 | } |
656 | return TRUE; | 655 | return TRUE; |
657 | } | 656 | } |
658 | } else { | 657 | } else { |
659 | return mediaPlayerState->looping(); | 658 | return mediaPlayerState->looping(); |
660 | } | 659 | } |
661 | } | 660 | } |
662 | 661 | ||
663 | 662 | ||
664 | bool PlayListWidget::first() { | 663 | bool PlayListWidget::first() { |
665 | if ( mediaPlayerState->playlist() ) | 664 | if ( mediaPlayerState->playlist() ) |
666 | return d->selectedFiles->first(); | 665 | return d->selectedFiles->first(); |
667 | else | 666 | else |
668 | return mediaPlayerState->looping(); | 667 | return mediaPlayerState->looping(); |
669 | } | 668 | } |
670 | 669 | ||
671 | 670 | ||
672 | bool PlayListWidget::last() { | 671 | bool PlayListWidget::last() { |
673 | if ( mediaPlayerState->playlist() ) | 672 | if ( mediaPlayerState->playlist() ) |
674 | return d->selectedFiles->last(); | 673 | return d->selectedFiles->last(); |
675 | else | 674 | else |
676 | return mediaPlayerState->looping(); | 675 | return mediaPlayerState->looping(); |
677 | } | 676 | } |
678 | 677 | ||
679 | 678 | ||
680 | void PlayListWidget::saveList() { | 679 | void PlayListWidget::saveList() { |
681 | writem3u(); | 680 | writem3u(); |
682 | } | 681 | } |
683 | 682 | ||
684 | void PlayListWidget::loadList( const DocLnk & lnk) { | 683 | void PlayListWidget::loadList( const DocLnk & lnk) { |
685 | QString name = lnk.name(); | 684 | QString name = lnk.name(); |
686 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 685 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
687 | 686 | ||
688 | if( name.length()>0) { | 687 | if( name.length()>0) { |
689 | setCaption("OpiePlayer: "+name); | 688 | setCaption("OpiePlayer: "+name); |
690 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 689 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
691 | clearList(); | 690 | clearList(); |
692 | readm3u(lnk.file()); | 691 | readm3u(lnk.file()); |
693 | tabWidget->setCurrentPage(0); | 692 | tabWidget->setCurrentPage(0); |
694 | } | 693 | } |
695 | } | 694 | } |
696 | 695 | ||
697 | void PlayListWidget::setPlaylist( bool shown ) { | 696 | void PlayListWidget::setPlaylist( bool shown ) { |
698 | if ( shown ) | 697 | if ( shown ) |
699 | d->playListFrame->show(); | 698 | d->playListFrame->show(); |
700 | else | 699 | else |
701 | d->playListFrame->hide(); | 700 | d->playListFrame->hide(); |
702 | } | 701 | } |
703 | 702 | ||
704 | void PlayListWidget::setView( char view ) { | 703 | void PlayListWidget::setView( char view ) { |
705 | if ( view == 'l' ) | 704 | if ( view == 'l' ) |
706 | showMaximized(); | 705 | showMaximized(); |
707 | else | 706 | else |
708 | hide(); | 707 | hide(); |
709 | } | 708 | } |
710 | 709 | ||
711 | void PlayListWidget::addSelected() { | 710 | void PlayListWidget::addSelected() { |
712 | qDebug("addSelected"); | 711 | qDebug("addSelected"); |
713 | DocLnk lnk; | 712 | DocLnk lnk; |
714 | QString filename; | 713 | QString filename; |
715 | switch (tabWidget->currentPageIndex()) { | 714 | switch (tabWidget->currentPageIndex()) { |
716 | 715 | ||
717 | case 0: //playlist | 716 | case 0: //playlist |
718 | return; | 717 | return; |
719 | break; | 718 | break; |
720 | case 1: { //audio | 719 | case 1: { //audio |
721 | QListViewItemIterator it( audioView ); | 720 | QListViewItemIterator it( audioView ); |
722 | for ( ; it.current(); ++it ) { | 721 | for ( ; it.current(); ++it ) { |
723 | if ( it.current()->isSelected() ) { | 722 | if ( it.current()->isSelected() ) { |
724 | filename = it.current()->text(3); | 723 | filename = it.current()->text(3); |
725 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 724 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
726 | lnk.setFile( filename ); //sets file name | 725 | lnk.setFile( filename ); //sets file name |
727 | d->selectedFiles->addToSelection( lnk); | 726 | d->selectedFiles->addToSelection( lnk); |
728 | } | 727 | } |
729 | } | 728 | } |
730 | audioView->clearSelection(); | 729 | audioView->clearSelection(); |
731 | // d->selectedFiles->next(); | 730 | // d->selectedFiles->next(); |
732 | } | 731 | } |
733 | break; | 732 | break; |
734 | 733 | ||
735 | case 2: { // video | 734 | case 2: { // video |
736 | QListViewItemIterator it( videoView ); | 735 | QListViewItemIterator it( videoView ); |
737 | for ( ; it.current(); ++it ) { | 736 | for ( ; it.current(); ++it ) { |
738 | if ( it.current()->isSelected() ) { | 737 | if ( it.current()->isSelected() ) { |
739 | 738 | ||
740 | filename = it.current()->text(3); | 739 | filename = it.current()->text(3); |
741 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 740 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
742 | lnk.setFile( filename ); //sets file name | 741 | lnk.setFile( filename ); //sets file name |
743 | d->selectedFiles->addToSelection( lnk); | 742 | d->selectedFiles->addToSelection( lnk); |
744 | } | 743 | } |
745 | } | 744 | } |
746 | videoView->clearSelection(); | 745 | videoView->clearSelection(); |
747 | } | 746 | } |
748 | break; | 747 | break; |
749 | }; | 748 | }; |
750 | // tabWidget->setCurrentPage(0); | 749 | // tabWidget->setCurrentPage(0); |
751 | writeCurrentM3u(); | 750 | writeCurrentM3u(); |
752 | 751 | ||
753 | } | 752 | } |
754 | 753 | ||
755 | void PlayListWidget::removeSelected() { | 754 | void PlayListWidget::removeSelected() { |
756 | d->selectedFiles->removeSelected( ); | 755 | d->selectedFiles->removeSelected( ); |
757 | } | 756 | } |
758 | 757 | ||
759 | void PlayListWidget::playIt( QListViewItem *) { | 758 | void PlayListWidget::playIt( QListViewItem *) { |
760 | // d->setDocumentUsed = FALSE; | 759 | // d->setDocumentUsed = FALSE; |
761 | // mediaPlayerState->curPosition =0; | 760 | // mediaPlayerState->curPosition =0; |
762 | qDebug("playIt"); | 761 | qDebug("playIt"); |
763 | mediaPlayerState->setPlaying(FALSE); | 762 | mediaPlayerState->setPlaying(FALSE); |
764 | mediaPlayerState->setPlaying(TRUE); | 763 | mediaPlayerState->setPlaying(TRUE); |
765 | d->selectedFiles->unSelect(); | 764 | d->selectedFiles->unSelect(); |
766 | } | 765 | } |
767 | 766 | ||
768 | void PlayListWidget::addToSelection( QListViewItem *it) { | 767 | void PlayListWidget::addToSelection( QListViewItem *it) { |
769 | d->setDocumentUsed = FALSE; | 768 | d->setDocumentUsed = FALSE; |
770 | 769 | ||
771 | if(it) { | 770 | if(it) { |
772 | switch ( tabWidget->currentPageIndex()) { | 771 | switch ( tabWidget->currentPageIndex()) { |
773 | case 0: //playlist | 772 | case 0: //playlist |
774 | return; | 773 | return; |
775 | break; | 774 | break; |
776 | }; | 775 | }; |
777 | // case 1: { | 776 | // case 1: { |
778 | DocLnk lnk; | 777 | DocLnk lnk; |
779 | QString filename; | 778 | QString filename; |
780 | 779 | ||
781 | filename=it->text(3); | 780 | filename=it->text(3); |
782 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 781 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
783 | lnk.setFile( filename ); //sets file name | 782 | lnk.setFile( filename ); //sets file name |
784 | d->selectedFiles->addToSelection( lnk); | 783 | d->selectedFiles->addToSelection( lnk); |
785 | 784 | ||
786 | writeCurrentM3u(); | 785 | writeCurrentM3u(); |
787 | // tabWidget->setCurrentPage(0); | 786 | // tabWidget->setCurrentPage(0); |
788 | 787 | ||
789 | } | 788 | } |
790 | } | 789 | } |
791 | 790 | ||
792 | void PlayListWidget::tabChanged(QWidget *) { | 791 | void PlayListWidget::tabChanged(QWidget *) { |
793 | 792 | ||
794 | switch ( tabWidget->currentPageIndex()) { | 793 | switch ( tabWidget->currentPageIndex()) { |
795 | case 0: | 794 | case 0: |
796 | { | 795 | { |
797 | if( !tbDeletePlaylist->isHidden()) | 796 | if( !tbDeletePlaylist->isHidden()) |
798 | tbDeletePlaylist->hide(); | 797 | tbDeletePlaylist->hide(); |
799 | d->tbRemoveFromList->setEnabled(TRUE); | 798 | d->tbRemoveFromList->setEnabled(TRUE); |
800 | d->tbAddToList->setEnabled(FALSE); | 799 | d->tbAddToList->setEnabled(FALSE); |
801 | } | 800 | } |
802 | break; | 801 | break; |
803 | case 1: | 802 | case 1: |
804 | { | 803 | { |
805 | audioView->clear(); | 804 | audioView->clear(); |
806 | populateAudioView(); | 805 | populateAudioView(); |
807 | 806 | ||
808 | if( !tbDeletePlaylist->isHidden()) | 807 | if( !tbDeletePlaylist->isHidden()) |
809 | tbDeletePlaylist->hide(); | 808 | tbDeletePlaylist->hide(); |
810 | d->tbRemoveFromList->setEnabled(FALSE); | 809 | d->tbRemoveFromList->setEnabled(FALSE); |
811 | d->tbAddToList->setEnabled(TRUE); | 810 | d->tbAddToList->setEnabled(TRUE); |
812 | } | 811 | } |
813 | break; | 812 | break; |
814 | case 2: | 813 | case 2: |
815 | { | 814 | { |
816 | videoView->clear(); | 815 | videoView->clear(); |
817 | populateVideoView(); | 816 | populateVideoView(); |
818 | if( !tbDeletePlaylist->isHidden()) | 817 | if( !tbDeletePlaylist->isHidden()) |
819 | tbDeletePlaylist->hide(); | 818 | tbDeletePlaylist->hide(); |
820 | d->tbRemoveFromList->setEnabled(FALSE); | 819 | d->tbRemoveFromList->setEnabled(FALSE); |
821 | d->tbAddToList->setEnabled(TRUE); | 820 | d->tbAddToList->setEnabled(TRUE); |
822 | } | 821 | } |
823 | break; | 822 | break; |
824 | case 3: | 823 | case 3: |
825 | { | 824 | { |
826 | if( tbDeletePlaylist->isHidden()) | 825 | if( tbDeletePlaylist->isHidden()) |
827 | tbDeletePlaylist->show(); | 826 | tbDeletePlaylist->show(); |
828 | playLists->reread(); | 827 | playLists->reread(); |
829 | } | 828 | } |
830 | break; | 829 | break; |
831 | }; | 830 | }; |
832 | } | 831 | } |
833 | 832 | ||
834 | void PlayListWidget::btnPlay(bool b) { | 833 | void PlayListWidget::btnPlay(bool b) { |
835 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | 834 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); |
836 | // mediaPlayerState->setPlaying(b); | 835 | // mediaPlayerState->setPlaying(b); |
837 | switch ( tabWidget->currentPageIndex()) { | 836 | switch ( tabWidget->currentPageIndex()) { |
838 | case 0: | 837 | case 0: |
839 | { | 838 | { |
840 | qDebug("1"); | 839 | qDebug("1"); |
841 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
842 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
843 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
844 | // } else { | 843 | // } else { |
845 | mediaPlayerState->setPlaying(b); | 844 | mediaPlayerState->setPlaying(b); |
846 | insanityBool=FALSE; | 845 | insanityBool=FALSE; |
847 | qDebug("insanity"); | 846 | qDebug("insanity"); |
848 | // } | 847 | // } |
849 | } | 848 | } |
850 | break; | 849 | break; |
851 | case 1: | 850 | case 1: |
852 | { | 851 | { |
853 | qDebug("2"); | 852 | qDebug("2"); |
854 | // d->selectedFiles->unSelect(); | 853 | // d->selectedFiles->unSelect(); |
855 | addToSelection( audioView->currentItem() ); | 854 | addToSelection( audioView->currentItem() ); |
856 | mediaPlayerState->setPlaying(true); | 855 | mediaPlayerState->setPlaying(true); |
857 | d->selectedFiles->removeSelected( ); | 856 | d->selectedFiles->removeSelected( ); |
858 | d->selectedFiles->unSelect(); | 857 | d->selectedFiles->unSelect(); |
859 | tabWidget->setCurrentPage(1); | 858 | tabWidget->setCurrentPage(1); |
860 | insanityBool=FALSE; | 859 | insanityBool=FALSE; |
861 | }// audioView->clearSelection(); | 860 | }// audioView->clearSelection(); |
862 | break; | 861 | break; |
863 | case 2: | 862 | case 2: |
864 | { | 863 | { |
865 | qDebug("3"); | 864 | qDebug("3"); |
866 | 865 | ||
867 | addToSelection( videoView->currentItem() ); | 866 | addToSelection( videoView->currentItem() ); |
868 | mediaPlayerState->setPlaying(true); | 867 | mediaPlayerState->setPlaying(true); |
869 | // qApp->processEvents(); | 868 | // qApp->processEvents(); |
870 | d->selectedFiles->removeSelected( ); | 869 | d->selectedFiles->removeSelected( ); |
871 | d->selectedFiles->unSelect(); | 870 | d->selectedFiles->unSelect(); |
872 | tabWidget->setCurrentPage(2); | 871 | tabWidget->setCurrentPage(2); |
873 | insanityBool=FALSE; | 872 | insanityBool=FALSE; |
874 | }// videoView->clearSelection(); | 873 | }// videoView->clearSelection(); |
875 | break; | 874 | break; |
876 | }; | 875 | }; |
877 | 876 | ||
878 | } | 877 | } |
879 | 878 | ||
880 | void PlayListWidget::deletePlaylist() { | 879 | void PlayListWidget::deletePlaylist() { |
881 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 880 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
882 | (tr("You really want to delete\nthis playlist?")), | 881 | (tr("You really want to delete\nthis playlist?")), |
883 | (tr("Yes")), (tr("No")), 0 )){ | 882 | (tr("Yes")), (tr("No")), 0 )){ |
884 | case 0: // Yes clicked, | 883 | case 0: // Yes clicked, |
885 | QFile().remove(playLists->selectedDocument().file()); | 884 | QFile().remove(playLists->selectedDocument().file()); |
886 | QFile().remove(playLists->selectedDocument().linkFile()); | 885 | QFile().remove(playLists->selectedDocument().linkFile()); |
887 | playLists->reread(); | 886 | playLists->reread(); |
888 | break; | 887 | break; |
889 | case 1: // Cancel | 888 | case 1: // Cancel |
890 | break; | 889 | break; |
891 | }; | 890 | }; |
892 | } | 891 | } |
893 | 892 | ||
894 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 893 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
895 | { | 894 | { |
896 | switch (mouse) { | 895 | switch (mouse) { |
897 | case 1: | 896 | case 1: |
898 | break; | 897 | break; |
899 | case 2:{ | 898 | case 2:{ |
900 | 899 | ||
901 | QPopupMenu m; | 900 | QPopupMenu m; |
902 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 901 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
903 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 902 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
904 | m.insertSeparator(); | 903 | m.insertSeparator(); |
905 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 904 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
906 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 905 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
907 | 906 | ||
908 | m.exec( QCursor::pos() ); | 907 | m.exec( QCursor::pos() ); |
909 | } | 908 | } |
910 | break; | 909 | break; |
911 | }; | 910 | }; |
912 | } | 911 | } |
913 | 912 | ||
914 | void PlayListWidget::playSelected() | 913 | void PlayListWidget::playSelected() |
915 | { | 914 | { |
916 | qDebug("playSelected"); | 915 | qDebug("playSelected"); |
917 | btnPlay( true); | 916 | btnPlay( true); |
918 | // d->selectedFiles->unSelect(); | 917 | // d->selectedFiles->unSelect(); |
919 | } | 918 | } |
920 | 919 | ||
921 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 920 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
922 | { | 921 | { |
923 | switch (mouse) { | 922 | switch (mouse) { |
924 | case 1: | 923 | case 1: |
925 | 924 | ||
926 | break; | 925 | break; |
927 | case 2:{ | 926 | case 2:{ |
928 | QPopupMenu m; | 927 | QPopupMenu m; |
929 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 928 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
930 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 929 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
931 | // m.insertSeparator(); | 930 | // m.insertSeparator(); |
932 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 931 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
933 | m.exec( QCursor::pos() ); | 932 | m.exec( QCursor::pos() ); |
934 | } | 933 | } |
935 | break; | 934 | break; |
936 | }; | 935 | }; |
937 | 936 | ||
938 | } | 937 | } |
939 | 938 | ||
940 | void PlayListWidget::listDelete() { | 939 | void PlayListWidget::listDelete() { |
941 | Config cfg( "OpiePlayer" ); | 940 | Config cfg( "OpiePlayer" ); |
942 | cfg.setGroup("PlayList"); | 941 | cfg.setGroup("PlayList"); |
943 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 942 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
944 | QString file; | 943 | QString file; |
945 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 944 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
946 | switch ( tabWidget->currentPageIndex()) { | 945 | switch ( tabWidget->currentPageIndex()) { |
947 | case 0: | 946 | case 0: |
948 | break; | 947 | break; |
949 | case 1: | 948 | case 1: |
950 | { | 949 | { |
951 | file = audioView->currentItem()->text(0); | 950 | file = audioView->currentItem()->text(0); |
952 | QListIterator<DocLnk> Pdit( files.children() ); | 951 | QListIterator<DocLnk> Pdit( files.children() ); |
953 | for ( ; Pdit.current(); ++Pdit ) { | 952 | for ( ; Pdit.current(); ++Pdit ) { |
954 | if( Pdit.current()->name() == file) { | 953 | if( Pdit.current()->name() == file) { |
955 | LnkProperties prop( Pdit.current() ); | 954 | LnkProperties prop( Pdit.current() ); |
956 | prop.showMaximized(); | 955 | prop.showMaximized(); |
957 | prop.exec(); | 956 | prop.exec(); |
958 | } | 957 | } |
959 | } | 958 | } |
960 | populateAudioView(); | 959 | populateAudioView(); |
961 | } | 960 | } |
962 | break; | 961 | break; |
963 | case 2: | 962 | case 2: |
964 | { | 963 | { |
965 | // file = videoView->selectedItem()->text(0); | 964 | // file = videoView->selectedItem()->text(0); |
966 | // for ( int i = 0; i < noOfFiles; i++ ) { | 965 | // for ( int i = 0; i < noOfFiles; i++ ) { |
967 | // QString entryName; | 966 | // QString entryName; |
968 | // entryName.sprintf( "File%i", i + 1 ); | 967 | // entryName.sprintf( "File%i", i + 1 ); |
969 | // QString linkFile = cfg.readEntry( entryName ); | 968 | // QString linkFile = cfg.readEntry( entryName ); |
970 | // AppLnk lnk( AppLnk(linkFile)); | 969 | // AppLnk lnk( AppLnk(linkFile)); |
971 | // if( lnk.name() == file ) { | 970 | // if( lnk.name() == file ) { |
972 | // LnkProperties prop( &lnk); | 971 | // LnkProperties prop( &lnk); |
973 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 972 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
974 | // prop.showMaximized(); | 973 | // prop.showMaximized(); |
975 | // prop.exec(); | 974 | // prop.exec(); |
976 | // } | 975 | // } |
977 | // } | 976 | // } |
978 | } | 977 | } |
979 | break; | 978 | break; |
980 | }; | 979 | }; |
981 | } | 980 | } |
982 | 981 | ||
983 | void PlayListWidget::scanForAudio() { | 982 | void PlayListWidget::scanForAudio() { |
984 | // qDebug("scan for audio"); | 983 | // qDebug("scan for audio"); |
985 | files.detachChildren(); | 984 | files.detachChildren(); |
986 | QListIterator<DocLnk> sdit( files.children() ); | 985 | QListIterator<DocLnk> sdit( files.children() ); |
987 | for ( ; sdit.current(); ++sdit ) { | 986 | for ( ; sdit.current(); ++sdit ) { |
988 | delete sdit.current(); | 987 | delete sdit.current(); |
989 | } | 988 | } |
990 | Global::findDocuments( &files, audioMimes); | 989 | Global::findDocuments( &files, audioMimes); |
991 | audioScan = true; | 990 | audioScan = true; |
992 | } | 991 | } |
993 | void PlayListWidget::scanForVideo() { | 992 | void PlayListWidget::scanForVideo() { |
994 | // qDebug("scan for video"); | 993 | // qDebug("scan for video"); |
995 | vFiles.detachChildren(); | 994 | vFiles.detachChildren(); |
996 | QListIterator<DocLnk> sdit( vFiles.children() ); | 995 | QListIterator<DocLnk> sdit( vFiles.children() ); |
997 | for ( ; sdit.current(); ++sdit ) { | 996 | for ( ; sdit.current(); ++sdit ) { |
998 | delete sdit.current(); | 997 | delete sdit.current(); |
999 | } | 998 | } |
1000 | Global::findDocuments(&vFiles, "video/*"); | 999 | Global::findDocuments(&vFiles, "video/*"); |
1001 | videoScan = true; | 1000 | videoScan = true; |
1002 | } | 1001 | } |
1003 | 1002 | ||
1004 | void PlayListWidget::populateAudioView() { | 1003 | void PlayListWidget::populateAudioView() { |
1005 | 1004 | ||
1006 | audioView->clear(); | 1005 | audioView->clear(); |
1007 | StorageInfo storageInfo; | 1006 | StorageInfo storageInfo; |
1008 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1007 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1009 | if(!audioScan) scanForAudio(); | 1008 | if(!audioScan) scanForAudio(); |
1010 | 1009 | ||
1011 | QListIterator<DocLnk> dit( files.children() ); | 1010 | QListIterator<DocLnk> dit( files.children() ); |
1012 | QListIterator<FileSystem> it ( fs ); | 1011 | QListIterator<FileSystem> it ( fs ); |
1013 | 1012 | ||
1014 | QString storage; | 1013 | QString storage; |
1015 | for ( ; dit.current(); ++dit ) { | 1014 | for ( ; dit.current(); ++dit ) { |
1016 | for( ; it.current(); ++it ){ | 1015 | for( ; it.current(); ++it ){ |
1017 | const QString name = (*it)->name(); | 1016 | const QString name = (*it)->name(); |
1018 | const QString path = (*it)->path(); | 1017 | const QString path = (*it)->path(); |
1019 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1018 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1020 | } | 1019 | } |
1021 | 1020 | ||
1022 | QListViewItem * newItem; | 1021 | QListViewItem * newItem; |
1023 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 1022 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1024 | long size; | 1023 | long size; |
1025 | if( dit.current()->file().left(4) == "http" ) | 1024 | if( dit.current()->file().left(4) == "http" ) |
1026 | size=0; | 1025 | size=0; |
1027 | else | 1026 | else |
1028 | size = QFile( dit.current()->file() ).size(); | 1027 | size = QFile( dit.current()->file() ).size(); |
1029 | // qDebug(dit.current()->name()); | 1028 | // qDebug(dit.current()->name()); |
1030 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1029 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1031 | QString::number(size ), storage, dit.current()->file()); | 1030 | QString::number(size ), storage, dit.current()->file()); |
1032 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1031 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1033 | } | 1032 | } |
1034 | } | 1033 | } |
1035 | 1034 | ||
1036 | } | 1035 | } |
1037 | 1036 | ||
1038 | void PlayListWidget::populateVideoView() { | 1037 | void PlayListWidget::populateVideoView() { |
1039 | videoView->clear(); | 1038 | videoView->clear(); |
1040 | StorageInfo storageInfo; | 1039 | StorageInfo storageInfo; |
1041 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1040 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1042 | 1041 | ||
1043 | if(!videoScan ) scanForVideo(); | 1042 | if(!videoScan ) scanForVideo(); |
1044 | 1043 | ||
1045 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1044 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1046 | QListIterator<FileSystem> it ( fs ); | 1045 | QListIterator<FileSystem> it ( fs ); |
1047 | videoView->clear(); | 1046 | videoView->clear(); |
1048 | QString storage; | 1047 | QString storage; |
1049 | for ( ; Vdit.current(); ++Vdit ) { | 1048 | for ( ; Vdit.current(); ++Vdit ) { |
1050 | for( ; it.current(); ++it ){ | 1049 | for( ; it.current(); ++it ){ |
1051 | const QString name = (*it)->name(); | 1050 | const QString name = (*it)->name(); |
1052 | const QString path = (*it)->path(); | 1051 | const QString path = (*it)->path(); |
1053 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1052 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1054 | } | 1053 | } |
1055 | 1054 | ||
1056 | QListViewItem * newItem; | 1055 | QListViewItem * newItem; |
1057 | if ( QFile( Vdit.current()->file()).exists() ) { | 1056 | if ( QFile( Vdit.current()->file()).exists() ) { |
1058 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1057 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1059 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1058 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1060 | storage, Vdit.current()->file()); | 1059 | storage, Vdit.current()->file()); |
1061 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1060 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1062 | } | 1061 | } |
1063 | } | 1062 | } |
1064 | } | 1063 | } |
1065 | 1064 | ||
1066 | void PlayListWidget::openFile() { | 1065 | void PlayListWidget::openFile() { |
1067 | qDebug("<<<<<<<<<OPEN File"); | 1066 | qDebug("<<<<<<<<<OPEN File"); |
1068 | QString filename, name; | 1067 | QString filename, name; |
1069 | InputDialog *fileDlg; | 1068 | InputDialog *fileDlg; |
1070 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1069 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1071 | fileDlg->exec(); | 1070 | fileDlg->exec(); |
1072 | if( fileDlg->result() == 1 ) { | 1071 | if( fileDlg->result() == 1 ) { |
1073 | filename = fileDlg->text(); | 1072 | filename = fileDlg->text(); |
1074 | qDebug( "Selected filename is " + filename ); | 1073 | qDebug( "Selected filename is " + filename ); |
1075 | // Om3u *m3uList; | 1074 | // Om3u *m3uList; |
1076 | DocLnk lnk; | 1075 | DocLnk lnk; |
1077 | Config cfg( "OpiePlayer" ); | 1076 | Config cfg( "OpiePlayer" ); |
1078 | cfg.setGroup("PlayList"); | 1077 | cfg.setGroup("PlayList"); |
1079 | 1078 | ||
1080 | QString m3uFile; | 1079 | QString m3uFile; |
1081 | m3uFile = filename; | 1080 | m3uFile = filename; |
1082 | if(filename.left(4) == "http") { | 1081 | if(filename.left(4) == "http") { |
1083 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1082 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1084 | 1083 | ||