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,1495 +1,1494 @@ | |||
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 | ||
1085 | // m3uFile = filename.left( filename.find( ":",8,TRUE)); | 1084 | // m3uFile = filename.left( filename.find( ":",8,TRUE)); |
1086 | m3uFile = filename; | 1085 | m3uFile = filename; |
1087 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1086 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1088 | m3uFile += "/"; | 1087 | m3uFile += "/"; |
1089 | } | 1088 | } |
1090 | filename = m3uFile; | 1089 | filename = m3uFile; |
1091 | // qDebug("1 "+m3uFile); | 1090 | // qDebug("1 "+m3uFile); |
1092 | // } else if(filename.left(4) == "http"){ | 1091 | // } else if(filename.left(4) == "http"){ |
1093 | // m3uFile=filename; | 1092 | // m3uFile=filename; |
1094 | // m3uFile = m3uFile.right( m3uFile.length() - 7); | 1093 | // m3uFile = m3uFile.right( m3uFile.length() - 7); |
1095 | // qDebug("2 "+m3uFile); | 1094 | // qDebug("2 "+m3uFile); |
1096 | // } else{ | 1095 | // } else{ |
1097 | // m3uFile=filename; | 1096 | // m3uFile=filename; |
1098 | // qDebug("3 "+m3uFile); | 1097 | // qDebug("3 "+m3uFile); |
1099 | } | 1098 | } |
1100 | lnk.setName( m3uFile ); //sets name | 1099 | lnk.setName( m3uFile ); //sets name |
1101 | lnk.setFile( filename ); //sets file name | 1100 | lnk.setFile( filename ); //sets file name |
1102 | lnk.setIcon("opieplayer2/musicfile"); | 1101 | lnk.setIcon("opieplayer2/musicfile"); |
1103 | d->selectedFiles->addToSelection( lnk ); | 1102 | d->selectedFiles->addToSelection( lnk ); |
1104 | writeCurrentM3u(); | 1103 | writeCurrentM3u(); |
1105 | } | 1104 | } |
1106 | else if( filename.right( 3) == "m3u" ) { | 1105 | else if( filename.right( 3) == "m3u" ) { |
1107 | readm3u( filename ); | 1106 | readm3u( filename ); |
1108 | 1107 | ||
1109 | } else if( filename.right(3) == "pls" ) { | 1108 | } else if( filename.right(3) == "pls" ) { |
1110 | readPls( filename ); | 1109 | readPls( filename ); |
1111 | } else { | 1110 | } else { |
1112 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1111 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1113 | lnk.setFile( filename ); //sets file name | 1112 | lnk.setFile( filename ); //sets file name |
1114 | d->selectedFiles->addToSelection( lnk); | 1113 | d->selectedFiles->addToSelection( lnk); |
1115 | writeCurrentM3u(); | 1114 | writeCurrentM3u(); |
1116 | } | 1115 | } |
1117 | } | 1116 | } |
1118 | 1117 | ||
1119 | if( fileDlg ) { | 1118 | if( fileDlg ) { |
1120 | delete fileDlg; | 1119 | delete fileDlg; |
1121 | } | 1120 | } |
1122 | } | 1121 | } |
1123 | 1122 | ||
1124 | 1123 | ||
1125 | /* | 1124 | /* |
1126 | reads m3u and shows files/urls to playlist widget */ | 1125 | reads m3u and shows files/urls to playlist widget */ |
1127 | void PlayListWidget::readm3u( const QString &filename ) { | 1126 | void PlayListWidget::readm3u( const QString &filename ) { |
1128 | qDebug( "read m3u filename " + filename ); | 1127 | qDebug( "read m3u filename " + filename ); |
1129 | 1128 | ||
1130 | Om3u *m3uList; | 1129 | Om3u *m3uList; |
1131 | QString s, name; | 1130 | QString s, name; |
1132 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1131 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1133 | m3uList->readM3u(); | 1132 | m3uList->readM3u(); |
1134 | DocLnk lnk; | 1133 | DocLnk lnk; |
1135 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1134 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1136 | s = *it; | 1135 | s = *it; |
1137 | // qDebug("reading "+ s); | 1136 | // qDebug("reading "+ s); |
1138 | if(s.left(4)=="http") { | 1137 | if(s.left(4)=="http") { |
1139 | lnk.setName( s ); //sets file name | 1138 | lnk.setName( s ); //sets file name |
1140 | lnk.setIcon("opieplayer2/musicfile"); | 1139 | lnk.setIcon("opieplayer2/musicfile"); |
1141 | 1140 | ||
1142 | // if(s.right(4) != '.' || s.right(5) != '.') | 1141 | // if(s.right(4) != '.' || s.right(5) != '.') |
1143 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1142 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1144 | if( s.right(1) != "/") | 1143 | if( s.right(1) != "/") |
1145 | lnk.setFile( s+"/"); //if url with no extension | 1144 | lnk.setFile( s+"/"); //if url with no extension |
1146 | else | 1145 | else |
1147 | lnk.setFile( s ); //sets file name | 1146 | lnk.setFile( s ); //sets file name |
1148 | 1147 | ||
1149 | } else { | 1148 | } else { |
1150 | // if( QFileInfo( s ).exists() ) { | 1149 | // if( QFileInfo( s ).exists() ) { |
1151 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1150 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1152 | // if(s.right(4) == '.') {//if regular file | 1151 | // if(s.right(4) == '.') {//if regular file |
1153 | if(s.left(1) != "/") { | 1152 | if(s.left(1) != "/") { |
1154 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1153 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1155 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1154 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1156 | lnk.setIcon("SoundPlayer"); | 1155 | lnk.setIcon("SoundPlayer"); |
1157 | } else { | 1156 | } else { |
1158 | // qDebug("set link2 "+s); | 1157 | // qDebug("set link2 "+s); |
1159 | lnk.setFile( s); | 1158 | lnk.setFile( s); |
1160 | lnk.setIcon("SoundPlayer"); | 1159 | lnk.setIcon("SoundPlayer"); |
1161 | } | 1160 | } |
1162 | } | 1161 | } |
1163 | d->selectedFiles->addToSelection( lnk ); | 1162 | d->selectedFiles->addToSelection( lnk ); |
1164 | } | 1163 | } |
1165 | Config config( "OpiePlayer" ); | 1164 | Config config( "OpiePlayer" ); |
1166 | config.setGroup( "PlayList" ); | 1165 | config.setGroup( "PlayList" ); |
1167 | 1166 | ||
1168 | config.writeEntry("CurrentPlaylist",filename); | 1167 | config.writeEntry("CurrentPlaylist",filename); |
1169 | config.write(); | 1168 | config.write(); |
1170 | currentPlayList=filename; | 1169 | currentPlayList=filename; |
1171 | 1170 | ||
1172 | // m3uList->write(); | 1171 | // m3uList->write(); |
1173 | m3uList->close(); | 1172 | m3uList->close(); |
1174 | if(m3uList) delete m3uList; | 1173 | if(m3uList) delete m3uList; |
1175 | 1174 | ||
1176 | d->selectedFiles->setSelectedItem( s); | 1175 | d->selectedFiles->setSelectedItem( s); |
1177 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1176 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1178 | 1177 | ||
1179 | } | 1178 | } |
1180 | 1179 | ||
1181 | /* | 1180 | /* |
1182 | reads pls and adds files/urls to playlist */ | 1181 | reads pls and adds files/urls to playlist */ |
1183 | void PlayListWidget::readPls( const QString &filename ) { | 1182 | void PlayListWidget::readPls( const QString &filename ) { |
1184 | 1183 | ||
1185 | qDebug( "pls filename is " + filename ); | 1184 | qDebug( "pls filename is " + filename ); |
1186 | Om3u *m3uList; | 1185 | Om3u *m3uList; |
1187 | QString s, name; | 1186 | QString s, name; |
1188 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1187 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1189 | m3uList->readPls(); | 1188 | m3uList->readPls(); |
1190 | 1189 | ||
1191 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1190 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1192 | s = *it; | 1191 | s = *it; |
1193 | // s.replace( QRegExp( "%20" )," " ); | 1192 | // s.replace( QRegExp( "%20" )," " ); |
1194 | DocLnk lnk( s ); | 1193 | DocLnk lnk( s ); |
1195 | QFileInfo f( s ); | 1194 | QFileInfo f( s ); |
1196 | QString name = fullBaseName ( f); | 1195 | QString name = fullBaseName ( f); |
1197 | 1196 | ||
1198 | if( name.left( 4 ) == "http" ) { | 1197 | if( name.left( 4 ) == "http" ) { |
1199 | name = s.right( s.length() - 7); | 1198 | name = s.right( s.length() - 7); |
1200 | } else { | 1199 | } else { |
1201 | name = s; | 1200 | name = s; |
1202 | } | 1201 | } |
1203 | 1202 | ||
1204 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1203 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1205 | 1204 | ||
1206 | lnk.setName( name ); | 1205 | lnk.setName( name ); |
1207 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1206 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1208 | lnk.setFile( s ); | 1207 | lnk.setFile( s ); |
1209 | } else { //if its a url | 1208 | } else { //if its a url |
1210 | if( name.right( 1 ).find( '/' ) == -1) { | 1209 | if( name.right( 1 ).find( '/' ) == -1) { |
1211 | s += "/"; | 1210 | s += "/"; |
1212 | } | 1211 | } |
1213 | lnk.setFile( s ); | 1212 | lnk.setFile( s ); |
1214 | } | 1213 | } |
1215 | lnk.setType( "audio/x-mpegurl" ); | 1214 | lnk.setType( "audio/x-mpegurl" ); |
1216 | 1215 | ||
1217 | lnk.writeLink(); | 1216 | lnk.writeLink(); |
1218 | d->selectedFiles->addToSelection( lnk ); | 1217 | d->selectedFiles->addToSelection( lnk ); |
1219 | } | 1218 | } |
1220 | 1219 | ||
1221 | m3uList->close(); | 1220 | m3uList->close(); |
1222 | if(m3uList) delete m3uList; | 1221 | if(m3uList) delete m3uList; |
1223 | } | 1222 | } |
1224 | 1223 | ||
1225 | /* | 1224 | /* |
1226 | writes current playlist to current m3u file */ | 1225 | writes current playlist to current m3u file */ |
1227 | void PlayListWidget::writeCurrentM3u() { | 1226 | void PlayListWidget::writeCurrentM3u() { |
1228 | qDebug("writing to current m3u"); | 1227 | qDebug("writing to current m3u"); |
1229 | Config cfg( "OpiePlayer" ); | 1228 | Config cfg( "OpiePlayer" ); |
1230 | cfg.setGroup("PlayList"); | 1229 | cfg.setGroup("PlayList"); |
1231 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 1230 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
1232 | Om3u *m3uList; | 1231 | Om3u *m3uList; |
1233 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 1232 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
1234 | 1233 | ||
1235 | if( d->selectedFiles->first()) { | 1234 | if( d->selectedFiles->first()) { |
1236 | do { | 1235 | do { |
1237 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1236 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1238 | m3uList->add( d->selectedFiles->current()->file() ); | 1237 | m3uList->add( d->selectedFiles->current()->file() ); |
1239 | } | 1238 | } |
1240 | while ( d->selectedFiles->next() ); | 1239 | while ( d->selectedFiles->next() ); |
1241 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1240 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1242 | m3uList->write(); | 1241 | m3uList->write(); |
1243 | m3uList->close(); | 1242 | m3uList->close(); |
1244 | 1243 | ||
1245 | if(m3uList) delete m3uList; | 1244 | if(m3uList) delete m3uList; |
1246 | } | 1245 | } |
1247 | } | 1246 | } |
1248 | 1247 | ||
1249 | /* | 1248 | /* |
1250 | writes current playlist to m3u file */ | 1249 | writes current playlist to m3u file */ |
1251 | void PlayListWidget::writem3u() { | 1250 | void PlayListWidget::writem3u() { |
1252 | InputDialog *fileDlg; | 1251 | InputDialog *fileDlg; |
1253 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1252 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1254 | fileDlg->exec(); | 1253 | fileDlg->exec(); |
1255 | QString name, filename, list; | 1254 | QString name, filename, list; |
1256 | Om3u *m3uList; | 1255 | Om3u *m3uList; |
1257 | 1256 | ||
1258 | if( fileDlg->result() == 1 ) { | 1257 | if( fileDlg->result() == 1 ) { |
1259 | name = fileDlg->text(); | 1258 | name = fileDlg->text(); |
1260 | // qDebug( filename ); | 1259 | // qDebug( filename ); |
1261 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1260 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1262 | filename = name; | 1261 | filename = name; |
1263 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1262 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1264 | } | 1263 | } |
1265 | else //otherwise dump it somewhere noticable | 1264 | else //otherwise dump it somewhere noticable |
1266 | filename = QPEApplication::documentDir() + "/" + name; | 1265 | filename = QPEApplication::documentDir() + "/" + name; |
1267 | 1266 | ||
1268 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1267 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1269 | filename += ".m3u"; | 1268 | filename += ".m3u"; |
1270 | 1269 | ||
1271 | if( d->selectedFiles->first()) { | 1270 | if( d->selectedFiles->first()) { |
1272 | m3uList = new Om3u(filename, IO_ReadWrite); | 1271 | m3uList = new Om3u(filename, IO_ReadWrite); |
1273 | 1272 | ||
1274 | do { | 1273 | do { |
1275 | m3uList->add( d->selectedFiles->current()->file()); | 1274 | m3uList->add( d->selectedFiles->current()->file()); |
1276 | } | 1275 | } |
1277 | while ( d->selectedFiles->next() ); | 1276 | while ( d->selectedFiles->next() ); |
1278 | // qDebug( list ); | 1277 | // qDebug( list ); |
1279 | m3uList->write(); | 1278 | m3uList->write(); |
1280 | m3uList->close(); | 1279 | m3uList->close(); |
1281 | if(m3uList) delete m3uList; | 1280 | if(m3uList) delete m3uList; |
1282 | 1281 | ||
1283 | if(fileDlg) delete fileDlg; | 1282 | if(fileDlg) delete fileDlg; |
1284 | 1283 | ||
1285 | DocLnk lnk; | 1284 | DocLnk lnk; |
1286 | lnk.setFile( filename); | 1285 | lnk.setFile( filename); |
1287 | lnk.setIcon("opieplayer2/playlist2"); | 1286 | lnk.setIcon("opieplayer2/playlist2"); |
1288 | lnk.setName( name); //sets file name | 1287 | lnk.setName( name); //sets file name |
1289 | 1288 | ||
1290 | // qDebug(filename); | 1289 | // qDebug(filename); |
1291 | Config config( "OpiePlayer" ); | 1290 | Config config( "OpiePlayer" ); |
1292 | config.setGroup( "PlayList" ); | 1291 | config.setGroup( "PlayList" ); |
1293 | 1292 | ||
1294 | config.writeEntry("CurrentPlaylist",filename); | 1293 | config.writeEntry("CurrentPlaylist",filename); |
1295 | currentPlayList=filename; | 1294 | currentPlayList=filename; |
1296 | 1295 | ||
1297 | if(!lnk.writeLink()) { | 1296 | if(!lnk.writeLink()) { |
1298 | qDebug("Writing doclink did not work"); | 1297 | qDebug("Writing doclink did not work"); |
1299 | } | 1298 | } |
1300 | 1299 | ||
1301 | setCaption(tr("OpiePlayer: ") + name); | 1300 | setCaption(tr("OpiePlayer: ") + name); |
1302 | } | 1301 | } |
1303 | } | 1302 | } |
1304 | } | 1303 | } |
1305 | 1304 | ||
1306 | 1305 | ||
1307 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1306 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1308 | { | 1307 | { |
1309 | switch ( e->key() ) { | 1308 | switch ( e->key() ) { |
1310 | ////////////////////////////// Zaurus keys | 1309 | ////////////////////////////// Zaurus keys |
1311 | case Key_F9: //activity | 1310 | case Key_F9: //activity |
1312 | // if(audioUI->isHidden()) | 1311 | // if(audioUI->isHidden()) |
1313 | // audioUI->showMaximized(); | 1312 | // audioUI->showMaximized(); |
1314 | break; | 1313 | break; |
1315 | case Key_F10: //contacts | 1314 | case Key_F10: //contacts |
1316 | // if( videoUI->isHidden()) | 1315 | // if( videoUI->isHidden()) |
1317 | // videoUI->showMaximized(); | 1316 | // videoUI->showMaximized(); |
1318 | break; | 1317 | break; |
1319 | case Key_F11: //menu | 1318 | case Key_F11: //menu |
1320 | break; | 1319 | break; |
1321 | case Key_F12: //home | 1320 | case Key_F12: //home |
1322 | // doBlank(); | 1321 | // doBlank(); |
1323 | break; | 1322 | break; |
1324 | case Key_F13: //mail | 1323 | case Key_F13: //mail |
1325 | // doUnblank(); | 1324 | // doUnblank(); |
1326 | break; | 1325 | break; |
1327 | case Key_Q: //add to playlist | 1326 | case Key_Q: //add to playlist |
1328 | qDebug("Add"); | 1327 | qDebug("Add"); |
1329 | addSelected(); | 1328 | addSelected(); |
1330 | break; | 1329 | break; |
1331 | case Key_R: //remove from playlist | 1330 | case Key_R: //remove from playlist |
1332 | removeSelected(); | 1331 | removeSelected(); |
1333 | break; | 1332 | break; |
1334 | // case Key_P: //play | 1333 | // case Key_P: //play |
1335 | // qDebug("Play"); | 1334 | // qDebug("Play"); |
1336 | // playSelected(); | 1335 | // playSelected(); |
1337 | // break; | 1336 | // break; |
1338 | case Key_Space: | 1337 | case Key_Space: |
1339 | qDebug("Play"); | 1338 | qDebug("Play"); |
1340 | // playSelected(); puh | 1339 | // playSelected(); puh |
1341 | break; | 1340 | break; |
1342 | case Key_1: | 1341 | case Key_1: |
1343 | tabWidget->setCurrentPage(0); | 1342 | tabWidget->setCurrentPage(0); |
1344 | break; | 1343 | break; |
1345 | case Key_2: | 1344 | case Key_2: |
1346 | tabWidget->setCurrentPage(1); | 1345 | tabWidget->setCurrentPage(1); |
1347 | break; | 1346 | break; |
1348 | case Key_3: | 1347 | case Key_3: |
1349 | tabWidget->setCurrentPage(2); | 1348 | tabWidget->setCurrentPage(2); |
1350 | break; | 1349 | break; |
1351 | case Key_4: | 1350 | case Key_4: |
1352 | tabWidget->setCurrentPage(3); | 1351 | tabWidget->setCurrentPage(3); |
1353 | break; | 1352 | break; |
1354 | case Key_Down: | 1353 | case Key_Down: |
1355 | if ( !d->selectedFiles->next() ) | 1354 | if ( !d->selectedFiles->next() ) |
1356 | d->selectedFiles->first(); | 1355 | d->selectedFiles->first(); |
1357 | 1356 | ||
1358 | break; | 1357 | break; |
1359 | case Key_Up: | 1358 | case Key_Up: |
1360 | if ( !d->selectedFiles->prev() ) | 1359 | if ( !d->selectedFiles->prev() ) |
1361 | // d->selectedFiles->last(); | 1360 | // d->selectedFiles->last(); |
1362 | 1361 | ||
1363 | break; | 1362 | break; |
1364 | 1363 | ||
1365 | } | 1364 | } |
1366 | } | 1365 | } |
1367 | 1366 | ||
1368 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1367 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1369 | { | 1368 | { |
1370 | // qDebug("Key press"); | 1369 | // qDebug("Key press"); |
1371 | // switch ( e->key() ) { | 1370 | // switch ( e->key() ) { |
1372 | // ////////////////////////////// Zaurus keys | 1371 | // ////////////////////////////// Zaurus keys |
1373 | // case Key_A: //add to playlist | 1372 | // case Key_A: //add to playlist |
1374 | // qDebug("Add"); | 1373 | // qDebug("Add"); |
1375 | // addSelected(); | 1374 | // addSelected(); |
1376 | // break; | 1375 | // break; |
1377 | // case Key_R: //remove from playlist | 1376 | // case Key_R: //remove from playlist |
1378 | // removeSelected(); | 1377 | // removeSelected(); |
1379 | // break; | 1378 | // break; |
1380 | // case Key_P: //play | 1379 | // case Key_P: //play |
1381 | // qDebug("Play"); | 1380 | // qDebug("Play"); |
1382 | // playSelected(); | 1381 | // playSelected(); |
1383 | // break; | 1382 | // break; |
1384 | // case Key_Space: | 1383 | // case Key_Space: |
1385 | // qDebug("Play"); | 1384 | // qDebug("Play"); |
1386 | // playSelected(); | 1385 | // playSelected(); |
1387 | // break; | 1386 | // break; |
1388 | // } | 1387 | // } |
1389 | } | 1388 | } |
1390 | 1389 | ||
1391 | void PlayListWidget::doBlank() { | 1390 | void PlayListWidget::doBlank() { |
1392 | qDebug("do blanking"); | 1391 | qDebug("do blanking"); |
1393 | fd=open("/dev/fb0",O_RDWR); | 1392 | fd=open("/dev/fb0",O_RDWR); |
1394 | if (fd != -1) { | 1393 | if (fd != -1) { |
1395 | ioctl(fd,FBIOBLANK,1); | 1394 | ioctl(fd,FBIOBLANK,1); |
1396 | // close(fd); | 1395 | // close(fd); |
1397 | } | 1396 | } |
1398 | } | 1397 | } |
1399 | 1398 | ||
1400 | void PlayListWidget::doUnblank() { | 1399 | void PlayListWidget::doUnblank() { |
1401 | // this crashes opieplayer with a segfault | 1400 | // this crashes opieplayer with a segfault |
1402 | // int fd; | 1401 | // int fd; |
1403 | // fd=open("/dev/fb0",O_RDWR); | 1402 | // fd=open("/dev/fb0",O_RDWR); |
1404 | qDebug("do unblanking"); | 1403 | qDebug("do unblanking"); |
1405 | if (fd != -1) { | 1404 | if (fd != -1) { |
1406 | ioctl(fd,FBIOBLANK,0); | 1405 | ioctl(fd,FBIOBLANK,0); |
1407 | close(fd); | 1406 | close(fd); |
1408 | } | 1407 | } |
1409 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1408 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1410 | h <<-3;// v[1]; // -3 Force on | 1409 | h <<-3;// v[1]; // -3 Force on |
1411 | } | 1410 | } |
1412 | 1411 | ||
1413 | void PlayListWidget::populateSkinsMenu() { | 1412 | void PlayListWidget::populateSkinsMenu() { |
1414 | int item = 0; | 1413 | int item = 0; |
1415 | defaultSkinIndex = 0; | 1414 | defaultSkinIndex = 0; |
1416 | QString skinName; | 1415 | QString skinName; |
1417 | Config cfg( "OpiePlayer" ); | 1416 | Config cfg( "OpiePlayer" ); |
1418 | cfg.setGroup("Options" ); | 1417 | cfg.setGroup("Options" ); |
1419 | QString skin = cfg.readEntry( "Skin", "default" ); | 1418 | QString skin = cfg.readEntry( "Skin", "default" ); |
1420 | 1419 | ||
1421 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1420 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1422 | skinsDir.setFilter( QDir::Dirs ); | 1421 | skinsDir.setFilter( QDir::Dirs ); |
1423 | skinsDir.setSorting(QDir::Name ); | 1422 | skinsDir.setSorting(QDir::Name ); |
1424 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1423 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1425 | QFileInfoListIterator it( *skinslist ); | 1424 | QFileInfoListIterator it( *skinslist ); |
1426 | QFileInfo *fi; | 1425 | QFileInfo *fi; |
1427 | while ( ( fi = it.current() ) ) { | 1426 | while ( ( fi = it.current() ) ) { |
1428 | skinName = fi->fileName(); | 1427 | skinName = fi->fileName(); |
1429 | // qDebug( fi->fileName() ); | 1428 | // qDebug( fi->fileName() ); |
1430 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1429 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1431 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1430 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1432 | } | 1431 | } |
1433 | if( skinName == "default" ) { | 1432 | if( skinName == "default" ) { |
1434 | defaultSkinIndex = item; | 1433 | defaultSkinIndex = item; |
1435 | } | 1434 | } |
1436 | if( skinName == skin ) { | 1435 | if( skinName == skin ) { |
1437 | skinsMenu->setItemChecked( item, TRUE ); | 1436 | skinsMenu->setItemChecked( item, TRUE ); |
1438 | } | 1437 | } |
1439 | ++it; | 1438 | ++it; |
1440 | } | 1439 | } |
1441 | } | 1440 | } |
1442 | 1441 | ||
1443 | void PlayListWidget::skinsMenuActivated( int item ) { | 1442 | void PlayListWidget::skinsMenuActivated( int item ) { |
1444 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1443 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1445 | skinsMenu->setItemChecked( i, FALSE ); | 1444 | skinsMenu->setItemChecked( i, FALSE ); |
1446 | } | 1445 | } |
1447 | skinsMenu->setItemChecked( item, TRUE ); | 1446 | skinsMenu->setItemChecked( item, TRUE ); |
1448 | 1447 | ||
1449 | Config cfg( "OpiePlayer" ); | 1448 | Config cfg( "OpiePlayer" ); |
1450 | cfg.setGroup("Options"); | 1449 | cfg.setGroup("Options"); |
1451 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1450 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1452 | } | 1451 | } |
1453 | 1452 | ||
1454 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1453 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1455 | qDebug("qcop message "+msg ); | 1454 | qDebug("qcop message "+msg ); |
1456 | QDataStream stream ( data, IO_ReadOnly ); | 1455 | QDataStream stream ( data, IO_ReadOnly ); |
1457 | if ( msg == "play()" ) { //plays current selection | 1456 | if ( msg == "play()" ) { //plays current selection |
1458 | btnPlay( true); | 1457 | btnPlay( true); |
1459 | } else if ( msg == "stop()" ) { | 1458 | } else if ( msg == "stop()" ) { |
1460 | mediaPlayerState->setPlaying( false); | 1459 | mediaPlayerState->setPlaying( false); |
1461 | } else if ( msg == "togglePause()" ) { | 1460 | } else if ( msg == "togglePause()" ) { |
1462 | mediaPlayerState->togglePaused(); | 1461 | mediaPlayerState->togglePaused(); |
1463 | } else if ( msg == "next()" ) { //select next in list | 1462 | } else if ( msg == "next()" ) { //select next in list |
1464 | mediaPlayerState->setNext(); | 1463 | mediaPlayerState->setNext(); |
1465 | } else if ( msg == "prev()" ) { //select previous in list | 1464 | } else if ( msg == "prev()" ) { //select previous in list |
1466 | mediaPlayerState->setPrev(); | 1465 | mediaPlayerState->setPrev(); |
1467 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1466 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1468 | mediaPlayerState->toggleLooping(); | 1467 | mediaPlayerState->toggleLooping(); |
1469 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1468 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1470 | mediaPlayerState->toggleShuffled(); | 1469 | mediaPlayerState->toggleShuffled(); |
1471 | } else if ( msg == "volUp()" ) { //volume more | 1470 | } else if ( msg == "volUp()" ) { //volume more |
1472 | // emit moreClicked(); | 1471 | // emit moreClicked(); |
1473 | // emit moreReleased(); | 1472 | // emit moreReleased(); |
1474 | } else if ( msg == "volDown()" ) { //volume less | 1473 | } else if ( msg == "volDown()" ) { //volume less |
1475 | // emit lessClicked(); | 1474 | // emit lessClicked(); |
1476 | // emit lessReleased(); | 1475 | // emit lessReleased(); |
1477 | } else if ( msg == "play(QString)" ) { //play this now | 1476 | } else if ( msg == "play(QString)" ) { //play this now |
1478 | QString file; | 1477 | QString file; |
1479 | stream >> file; | 1478 | stream >> file; |
1480 | setDocument( (const QString &) file); | 1479 | setDocument( (const QString &) file); |
1481 | } else if ( msg == "add(QString)" ) { //add to playlist | 1480 | } else if ( msg == "add(QString)" ) { //add to playlist |
1482 | QString file; | 1481 | QString file; |
1483 | stream >> file; | 1482 | stream >> file; |
1484 | QFileInfo fileInfo(file); | 1483 | QFileInfo fileInfo(file); |
1485 | DocLnk lnk; | 1484 | DocLnk lnk; |
1486 | lnk.setName( fileInfo.baseName() ); //sets name | 1485 | lnk.setName( fileInfo.baseName() ); //sets name |
1487 | lnk.setFile( file ); //sets file name | 1486 | lnk.setFile( file ); //sets file name |
1488 | addToSelection( lnk ); | 1487 | addToSelection( lnk ); |
1489 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1488 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1490 | QString file; | 1489 | QString file; |
1491 | stream >> file; | 1490 | stream >> file; |
1492 | 1491 | ||
1493 | } | 1492 | } |
1494 | 1493 | ||
1495 | } | 1494 | } |