author | llornkcor <llornkcor> | 2004-03-16 11:04:20 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-03-16 11:04:20 (UTC) |
commit | 523022a20006312ac8573628b556d749dab3ec78 (patch) (unidiff) | |
tree | b407795a5e7e166bb6f28ede675d191802c80846 | |
parent | 2785830c856cb224b16e9a09cace2fbe3d76b466 (diff) | |
download | opie-523022a20006312ac8573628b556d749dab3ec78.zip opie-523022a20006312ac8573628b556d749dab3ec78.tar.gz opie-523022a20006312ac8573628b556d749dab3ec78.tar.bz2 |
fix ogg
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index efb5df3..3609f5d 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,453 +1,453 @@ | |||
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 | 22 | ||
23 | #include <qtoolbar.h> | 23 | #include <qtoolbar.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/lnkproperties.h> | 25 | #include <qpe/lnkproperties.h> |
26 | 26 | ||
27 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | 30 | ||
31 | //#include <qtimer.h> | 31 | //#include <qtimer.h> |
32 | 32 | ||
33 | #include "playlistselection.h" | 33 | #include "playlistselection.h" |
34 | #include "playlistwidget.h" | 34 | #include "playlistwidget.h" |
35 | #include "mediaplayerstate.h" | 35 | #include "mediaplayerstate.h" |
36 | 36 | ||
37 | #include "inputDialog.h" | 37 | #include "inputDialog.h" |
38 | 38 | ||
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include "audiowidget.h" | 40 | #include "audiowidget.h" |
41 | #include "videowidget.h" | 41 | #include "videowidget.h" |
42 | 42 | ||
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | #include <sys/file.h> | 44 | #include <sys/file.h> |
45 | #include <sys/ioctl.h> | 45 | #include <sys/ioctl.h> |
46 | #include <sys/soundcard.h> | 46 | #include <sys/soundcard.h> |
47 | 47 | ||
48 | // for setBacklight() | 48 | // for setBacklight() |
49 | #include <linux/fb.h> | 49 | #include <linux/fb.h> |
50 | #include <sys/types.h> | 50 | #include <sys/types.h> |
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #define BUTTONS_ON_TOOLBAR | 54 | #define BUTTONS_ON_TOOLBAR |
55 | #define SIDE_BUTTONS | 55 | #define SIDE_BUTTONS |
56 | #define CAN_SAVE_LOAD_PLAYLISTS | 56 | #define CAN_SAVE_LOAD_PLAYLISTS |
57 | 57 | ||
58 | extern AudioWidget *audioUI; | 58 | extern AudioWidget *audioUI; |
59 | extern VideoWidget *videoUI; | 59 | extern VideoWidget *videoUI; |
60 | extern MediaPlayerState *mediaPlayerState; | 60 | extern MediaPlayerState *mediaPlayerState; |
61 | 61 | ||
62 | static inline QString fullBaseName ( const QFileInfo &fi ) | 62 | static inline QString fullBaseName ( const QFileInfo &fi ) |
63 | { | 63 | { |
64 | QString str = fi. fileName ( ); | 64 | QString str = fi. fileName ( ); |
65 | return str. left ( str. findRev ( '.' )); | 65 | return str. left ( str. findRev ( '.' )); |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; | 69 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; |
70 | // class myFileSelector { | 70 | // class myFileSelector { |
71 | 71 | ||
72 | // }; | 72 | // }; |
73 | class PlayListWidgetPrivate { | 73 | class PlayListWidgetPrivate { |
74 | public: | 74 | public: |
75 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 75 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
76 | QFrame *playListFrame; | 76 | QFrame *playListFrame; |
77 | FileSelector *files; | 77 | FileSelector *files; |
78 | PlayListSelection *selectedFiles; | 78 | PlayListSelection *selectedFiles; |
79 | bool setDocumentUsed; | 79 | bool setDocumentUsed; |
80 | DocLnk *current; | 80 | DocLnk *current; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | class ToolButton : public QToolButton { | 84 | class ToolButton : public QToolButton { |
85 | public: | 85 | public: |
86 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 86 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
87 | : QToolButton( parent, name ) { | 87 | : QToolButton( parent, name ) { |
88 | setTextLabel( name ); | 88 | setTextLabel( name ); |
89 | setPixmap( Resource::loadPixmap( icon ) ); | 89 | setPixmap( Resource::loadPixmap( icon ) ); |
90 | setAutoRaise( TRUE ); | 90 | setAutoRaise( TRUE ); |
91 | setFocusPolicy( QWidget::NoFocus ); | 91 | setFocusPolicy( QWidget::NoFocus ); |
92 | setToggleButton( t ); | 92 | setToggleButton( t ); |
93 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 93 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
94 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 94 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
95 | } | 95 | } |
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | class MenuItem : public QAction { | 99 | class MenuItem : public QAction { |
100 | public: | 100 | public: |
101 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 101 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
102 | : QAction( text, QString::null, 0, 0 ) { | 102 | : QAction( text, QString::null, 0, 0 ) { |
103 | connect( this, SIGNAL( activated() ), handler, slot ); | 103 | connect( this, SIGNAL( activated() ), handler, slot ); |
104 | addTo( parent ); | 104 | addTo( parent ); |
105 | } | 105 | } |
106 | }; | 106 | }; |
107 | 107 | ||
108 | 108 | ||
109 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 109 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
110 | : QMainWindow( parent, name, fl ) { | 110 | : QMainWindow( parent, name, fl ) { |
111 | 111 | ||
112 | d = new PlayListWidgetPrivate; | 112 | d = new PlayListWidgetPrivate; |
113 | d->setDocumentUsed = FALSE; | 113 | d->setDocumentUsed = FALSE; |
114 | d->current = NULL; | 114 | d->current = NULL; |
115 | fromSetDocument = FALSE; | 115 | fromSetDocument = FALSE; |
116 | insanityBool=FALSE; | 116 | insanityBool=FALSE; |
117 | audioScan = FALSE; | 117 | audioScan = FALSE; |
118 | videoScan = FALSE; | 118 | videoScan = FALSE; |
119 | // menuTimer = new QTimer( this ,"menu timer"), | 119 | // menuTimer = new QTimer( this ,"menu timer"), |
120 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 120 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
121 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | 121 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); |
122 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 122 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
123 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); | 123 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
124 | 124 | ||
125 | setBackgroundMode( PaletteButton ); | 125 | setBackgroundMode( PaletteButton ); |
126 | 126 | ||
127 | setCaption( tr("OpiePlayer") ); | 127 | setCaption( tr("OpiePlayer") ); |
128 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 128 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
129 | 129 | ||
130 | setToolBarsMovable( FALSE ); | 130 | setToolBarsMovable( FALSE ); |
131 | 131 | ||
132 | // Create Toolbar | 132 | // Create Toolbar |
133 | QToolBar *toolbar = new QToolBar( this ); | 133 | QToolBar *toolbar = new QToolBar( this ); |
134 | toolbar->setHorizontalStretchable( TRUE ); | 134 | toolbar->setHorizontalStretchable( TRUE ); |
135 | 135 | ||
136 | // Create Menubar | 136 | // Create Menubar |
137 | QMenuBar *menu = new QMenuBar( toolbar ); | 137 | QMenuBar *menu = new QMenuBar( toolbar ); |
138 | menu->setMargin( 0 ); | 138 | menu->setMargin( 0 ); |
139 | 139 | ||
140 | QToolBar *bar = new QToolBar( this ); | 140 | QToolBar *bar = new QToolBar( this ); |
141 | bar->setLabel( tr( "Play Operations" ) ); | 141 | bar->setLabel( tr( "Play Operations" ) ); |
142 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 142 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
143 | // this , SLOT( addSelected()) ); | 143 | // this , SLOT( addSelected()) ); |
144 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 144 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
145 | tbDeletePlaylist->setFlat(TRUE); | 145 | tbDeletePlaylist->setFlat(TRUE); |
146 | 146 | ||
147 | tbDeletePlaylist->setFixedSize(20,20); | 147 | tbDeletePlaylist->setFixedSize(20,20); |
148 | 148 | ||
149 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 149 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
150 | this , SLOT(addSelected()) ); | 150 | this , SLOT(addSelected()) ); |
151 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 151 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
152 | this , SLOT(removeSelected()) ); | 152 | this , SLOT(removeSelected()) ); |
153 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); | 153 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); |
154 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 154 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
155 | this , SLOT( btnPlay(bool) ), TRUE ); | 155 | this , SLOT( btnPlay(bool) ), TRUE ); |
156 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 156 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
157 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 157 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
158 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 158 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
159 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 159 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
160 | tbDeletePlaylist->hide(); | 160 | tbDeletePlaylist->hide(); |
161 | 161 | ||
162 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 162 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
163 | menu->insertItem( tr( "File" ), pmPlayList ); | 163 | menu->insertItem( tr( "File" ), pmPlayList ); |
164 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 164 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
165 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 165 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
166 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 166 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
167 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 167 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
168 | pmPlayList->insertSeparator(-1); | 168 | pmPlayList->insertSeparator(-1); |
169 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 169 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
170 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 170 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
171 | pmPlayList->insertSeparator(-1); | 171 | pmPlayList->insertSeparator(-1); |
172 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 172 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
173 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 173 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
174 | 174 | ||
175 | QPopupMenu *pmView = new QPopupMenu( this ); | 175 | QPopupMenu *pmView = new QPopupMenu( this ); |
176 | menu->insertItem( tr( "View" ), pmView ); | 176 | menu->insertItem( tr( "View" ), pmView ); |
177 | 177 | ||
178 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 178 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
179 | fullScreenButton->addTo(pmView); | 179 | fullScreenButton->addTo(pmView); |
180 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 180 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
181 | scaleButton->addTo(pmView); | 181 | scaleButton->addTo(pmView); |
182 | 182 | ||
183 | 183 | ||
184 | skinsMenu = new QPopupMenu( this ); | 184 | skinsMenu = new QPopupMenu( this ); |
185 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 185 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
186 | skinsMenu->isCheckable(); | 186 | skinsMenu->isCheckable(); |
187 | connect( skinsMenu, SIGNAL( activated(int) ) , | 187 | connect( skinsMenu, SIGNAL( activated(int) ) , |
188 | this, SLOT( skinsMenuActivated(int) ) ); | 188 | this, SLOT( skinsMenuActivated(int) ) ); |
189 | populateSkinsMenu(); | 189 | populateSkinsMenu(); |
190 | 190 | ||
191 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 191 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
192 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 192 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
193 | 193 | ||
194 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 194 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
195 | 195 | ||
196 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 196 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
197 | // tabWidget->setTabShape(QTabWidget::Triangular); | 197 | // tabWidget->setTabShape(QTabWidget::Triangular); |
198 | 198 | ||
199 | QWidget *pTab; | 199 | QWidget *pTab; |
200 | pTab = new QWidget( tabWidget, "pTab" ); | 200 | pTab = new QWidget( tabWidget, "pTab" ); |
201 | // playlistView = new QListView( pTab, "playlistview" ); | 201 | // playlistView = new QListView( pTab, "playlistview" ); |
202 | // playlistView->setMinimumSize(236,260); | 202 | // playlistView->setMinimumSize(236,260); |
203 | tabWidget->insertTab( pTab,"Playlist"); | 203 | tabWidget->insertTab( pTab,"Playlist"); |
204 | 204 | ||
205 | 205 | ||
206 | // Add the playlist area | 206 | // Add the playlist area |
207 | 207 | ||
208 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 208 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
209 | d->playListFrame = vbox3; | 209 | d->playListFrame = vbox3; |
210 | 210 | ||
211 | QGridLayout *layoutF = new QGridLayout( pTab ); | 211 | QGridLayout *layoutF = new QGridLayout( pTab ); |
212 | layoutF->setSpacing( 2); | 212 | layoutF->setSpacing( 2); |
213 | layoutF->setMargin( 2); | 213 | layoutF->setMargin( 2); |
214 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); | 214 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); |
215 | 215 | ||
216 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 216 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
217 | 217 | ||
218 | d->selectedFiles = new PlayListSelection( hbox2); | 218 | d->selectedFiles = new PlayListSelection( hbox2); |
219 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 219 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
220 | 220 | ||
221 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 221 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
222 | 222 | ||
223 | 223 | ||
224 | 224 | ||
225 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 225 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
226 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 226 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
227 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 227 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
228 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 228 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
229 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 229 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
230 | 230 | ||
231 | QWidget *aTab; | 231 | QWidget *aTab; |
232 | aTab = new QWidget( tabWidget, "aTab" ); | 232 | aTab = new QWidget( tabWidget, "aTab" ); |
233 | audioView = new QListView( aTab, "Audioview" ); | 233 | audioView = new QListView( aTab, "Audioview" ); |
234 | 234 | ||
235 | QGridLayout *layoutA = new QGridLayout( aTab ); | 235 | QGridLayout *layoutA = new QGridLayout( aTab ); |
236 | layoutA->setSpacing( 2); | 236 | layoutA->setSpacing( 2); |
237 | layoutA->setMargin( 2); | 237 | layoutA->setMargin( 2); |
238 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 238 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
239 | 239 | ||
240 | audioView->addColumn( tr("Title"),-1); | 240 | audioView->addColumn( tr("Title"),-1); |
241 | audioView->addColumn(tr("Size"), -1); | 241 | audioView->addColumn(tr("Size"), -1); |
242 | audioView->addColumn(tr("Media"),-1); | 242 | audioView->addColumn(tr("Media"),-1); |
243 | audioView->addColumn( tr( "Path" ), -1 ); | 243 | audioView->addColumn( tr( "Path" ), -1 ); |
244 | 244 | ||
245 | audioView->setColumnAlignment(1, Qt::AlignRight); | 245 | audioView->setColumnAlignment(1, Qt::AlignRight); |
246 | audioView->setColumnAlignment(2, Qt::AlignRight); | 246 | audioView->setColumnAlignment(2, Qt::AlignRight); |
247 | audioView->setAllColumnsShowFocus(TRUE); | 247 | audioView->setAllColumnsShowFocus(TRUE); |
248 | 248 | ||
249 | audioView->setMultiSelection( TRUE ); | 249 | audioView->setMultiSelection( TRUE ); |
250 | audioView->setSelectionMode( QListView::Extended); | 250 | audioView->setSelectionMode( QListView::Extended); |
251 | audioView->setSorting( 3, TRUE ); | 251 | audioView->setSorting( 3, TRUE ); |
252 | 252 | ||
253 | tabWidget->insertTab(aTab,tr("Audio")); | 253 | tabWidget->insertTab(aTab,tr("Audio")); |
254 | 254 | ||
255 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 255 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
256 | 256 | ||
257 | // audioView | 257 | // audioView |
258 | // populateAudioView(); | 258 | // populateAudioView(); |
259 | // videowidget | 259 | // videowidget |
260 | 260 | ||
261 | QWidget *vTab; | 261 | QWidget *vTab; |
262 | vTab = new QWidget( tabWidget, "vTab" ); | 262 | vTab = new QWidget( tabWidget, "vTab" ); |
263 | videoView = new QListView( vTab, "Videoview" ); | 263 | videoView = new QListView( vTab, "Videoview" ); |
264 | 264 | ||
265 | QGridLayout *layoutV = new QGridLayout( vTab ); | 265 | QGridLayout *layoutV = new QGridLayout( vTab ); |
266 | layoutV->setSpacing( 2); | 266 | layoutV->setSpacing( 2); |
267 | layoutV->setMargin( 2); | 267 | layoutV->setMargin( 2); |
268 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 268 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
269 | 269 | ||
270 | videoView->addColumn(tr("Title"),-1); | 270 | videoView->addColumn(tr("Title"),-1); |
271 | videoView->addColumn(tr("Size"),-1); | 271 | videoView->addColumn(tr("Size"),-1); |
272 | videoView->addColumn(tr("Media"),-1); | 272 | videoView->addColumn(tr("Media"),-1); |
273 | videoView->addColumn(tr( "Path" ), -1 ); | 273 | videoView->addColumn(tr( "Path" ), -1 ); |
274 | videoView->setColumnAlignment(1, Qt::AlignRight); | 274 | videoView->setColumnAlignment(1, Qt::AlignRight); |
275 | videoView->setColumnAlignment(2, Qt::AlignRight); | 275 | videoView->setColumnAlignment(2, Qt::AlignRight); |
276 | videoView->setAllColumnsShowFocus(TRUE); | 276 | videoView->setAllColumnsShowFocus(TRUE); |
277 | videoView->setMultiSelection( TRUE ); | 277 | videoView->setMultiSelection( TRUE ); |
278 | videoView->setSelectionMode( QListView::Extended); | 278 | videoView->setSelectionMode( QListView::Extended); |
279 | 279 | ||
280 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 280 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
281 | 281 | ||
282 | tabWidget->insertTab( vTab,tr("Video")); | 282 | tabWidget->insertTab( vTab,tr("Video")); |
283 | 283 | ||
284 | QWidget *LTab; | 284 | QWidget *LTab; |
285 | LTab = new QWidget( tabWidget, "LTab" ); | 285 | LTab = new QWidget( tabWidget, "LTab" ); |
286 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); | 286 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); |
287 | 287 | ||
288 | QGridLayout *layoutL = new QGridLayout( LTab ); | 288 | QGridLayout *layoutL = new QGridLayout( LTab ); |
289 | layoutL->setSpacing( 2); | 289 | layoutL->setSpacing( 2); |
290 | layoutL->setMargin( 2); | 290 | layoutL->setMargin( 2); |
291 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 291 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
292 | 292 | ||
293 | tabWidget->insertTab(LTab,tr("Lists")); | 293 | tabWidget->insertTab(LTab,tr("Lists")); |
294 | 294 | ||
295 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 295 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
296 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 296 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
297 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 297 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
298 | 298 | ||
299 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 299 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
300 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) ); | 300 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) ); |
301 | 301 | ||
302 | 302 | ||
303 | ///audioView | 303 | ///audioView |
304 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 304 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
305 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); | 305 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); |
306 | 306 | ||
307 | connect( audioView, SIGNAL( returnPressed(QListViewItem*)), | 307 | connect( audioView, SIGNAL( returnPressed(QListViewItem*)), |
308 | this,SLOT( playIt(QListViewItem*)) ); | 308 | this,SLOT( playIt(QListViewItem*)) ); |
309 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); | 309 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); |
310 | 310 | ||
311 | 311 | ||
312 | //videoView | 312 | //videoView |
313 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 313 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
314 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); | 314 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); |
315 | connect( videoView, SIGNAL( returnPressed(QListViewItem*)), | 315 | connect( videoView, SIGNAL( returnPressed(QListViewItem*)), |
316 | this,SLOT( playIt(QListViewItem*)) ); | 316 | this,SLOT( playIt(QListViewItem*)) ); |
317 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); | 317 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); |
318 | 318 | ||
319 | //playlists | 319 | //playlists |
320 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) ); | 320 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) ); |
321 | 321 | ||
322 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 322 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
323 | 323 | ||
324 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) ); | 324 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) ); |
325 | 325 | ||
326 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) ); | 326 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) ); |
327 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) ); | 327 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) ); |
328 | connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) ); | 328 | connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) ); |
329 | 329 | ||
330 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) ); | 330 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) ); |
331 | 331 | ||
332 | setCentralWidget( vbox5 ); | 332 | setCentralWidget( vbox5 ); |
333 | 333 | ||
334 | Config cfg( "OpiePlayer" ); | 334 | Config cfg( "OpiePlayer" ); |
335 | readConfig( cfg ); | 335 | readConfig( cfg ); |
336 | 336 | ||
337 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); | 337 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); |
338 | loadList(DocLnk( currentPlayList)); | 338 | loadList(DocLnk( currentPlayList)); |
339 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); | 339 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); |
340 | 340 | ||
341 | initializeStates(); | 341 | initializeStates(); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | PlayListWidget::~PlayListWidget() { | 345 | PlayListWidget::~PlayListWidget() { |
346 | Config cfg( "OpiePlayer" ); | 346 | Config cfg( "OpiePlayer" ); |
347 | writeConfig( cfg ); | 347 | writeConfig( cfg ); |
348 | 348 | ||
349 | if ( d->current ) | 349 | if ( d->current ) |
350 | delete d->current; | 350 | delete d->current; |
351 | if(d) delete d; | 351 | if(d) delete d; |
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | void PlayListWidget::initializeStates() { | 355 | void PlayListWidget::initializeStates() { |
356 | 356 | ||
357 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 357 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
358 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 358 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
359 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 359 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
360 | setPlaylist( true); | 360 | setPlaylist( true); |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | void PlayListWidget::readConfig( Config& cfg ) { | 364 | void PlayListWidget::readConfig( Config& cfg ) { |
365 | cfg.setGroup("PlayList"); | 365 | cfg.setGroup("PlayList"); |
366 | QString currentString = cfg.readEntry("current", "" ); | 366 | QString currentString = cfg.readEntry("current", "" ); |
367 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 367 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
368 | for ( int i = 0; i < noOfFiles; i++ ) { | 368 | for ( int i = 0; i < noOfFiles; i++ ) { |
369 | QString entryName; | 369 | QString entryName; |
370 | entryName.sprintf( "File%i", i + 1 ); | 370 | entryName.sprintf( "File%i", i + 1 ); |
371 | QString linkFile = cfg.readEntry( entryName ); | 371 | QString linkFile = cfg.readEntry( entryName ); |
372 | DocLnk lnk( linkFile ); | 372 | DocLnk lnk( linkFile ); |
373 | if ( lnk.isValid() ) { | 373 | if ( lnk.isValid() ) { |
374 | d->selectedFiles->addToSelection( lnk ); | 374 | d->selectedFiles->addToSelection( lnk ); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | d->selectedFiles->setSelectedItem( currentString); | 377 | d->selectedFiles->setSelectedItem( currentString); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::writeConfig( Config& cfg ) const { | 381 | void PlayListWidget::writeConfig( Config& cfg ) const { |
382 | 382 | ||
383 | d->selectedFiles->writeCurrent( cfg); | 383 | d->selectedFiles->writeCurrent( cfg); |
384 | cfg.setGroup("PlayList"); | 384 | cfg.setGroup("PlayList"); |
385 | int noOfFiles = 0; | 385 | int noOfFiles = 0; |
386 | d->selectedFiles->first(); | 386 | d->selectedFiles->first(); |
387 | do { | 387 | do { |
388 | const DocLnk *lnk = d->selectedFiles->current(); | 388 | const DocLnk *lnk = d->selectedFiles->current(); |
389 | if ( lnk ) { | 389 | if ( lnk ) { |
390 | QString entryName; | 390 | QString entryName; |
391 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 391 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
392 | // qDebug(entryName); | 392 | // qDebug(entryName); |
393 | cfg.writeEntry( entryName, lnk->linkFile() ); | 393 | cfg.writeEntry( entryName, lnk->linkFile() ); |
394 | // if this link does exist, add it so we have the file | 394 | // if this link does exist, add it so we have the file |
395 | // next time... | 395 | // next time... |
396 | if ( !QFile::exists( lnk->linkFile() ) ) { | 396 | if ( !QFile::exists( lnk->linkFile() ) ) { |
397 | // the way writing lnks doesn't really check for out | 397 | // the way writing lnks doesn't really check for out |
398 | // of disk space, but check it anyway. | 398 | // of disk space, but check it anyway. |
399 | // if ( !lnk->writeLink() ) { | 399 | // if ( !lnk->writeLink() ) { |
400 | // QMessageBox::critical( 0, tr("Out of space"), | 400 | // QMessageBox::critical( 0, tr("Out of space"), |
401 | // tr( "There was a problem saving " | 401 | // tr( "There was a problem saving " |
402 | // "the playlist.\n" | 402 | // "the playlist.\n" |
403 | // "Your playlist " | 403 | // "Your playlist " |
404 | // "may be missing some entries\n" | 404 | // "may be missing some entries\n" |
405 | // "the next time you start it." ) | 405 | // "the next time you start it." ) |
406 | // ); | 406 | // ); |
407 | // } | 407 | // } |
408 | 408 | ||
409 | } | 409 | } |
410 | noOfFiles++; | 410 | noOfFiles++; |
411 | } | 411 | } |
412 | } | 412 | } |
413 | while ( d->selectedFiles->next() ); | 413 | while ( d->selectedFiles->next() ); |
414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
419 | d->setDocumentUsed = false; | 419 | d->setDocumentUsed = false; |
420 | if ( mediaPlayerState->playlist() ) { | 420 | if ( mediaPlayerState->playlist() ) { |
421 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 421 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
422 | d->selectedFiles->addToSelection( lnk ); | 422 | d->selectedFiles->addToSelection( lnk ); |
423 | } | 423 | } |
424 | else | 424 | else |
425 | mediaPlayerState->setPlaying( true); | 425 | mediaPlayerState->setPlaying( true); |
426 | 426 | ||
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | void PlayListWidget::clearList() { | 430 | void PlayListWidget::clearList() { |
431 | while ( first() ) | 431 | while ( first() ) |
432 | d->selectedFiles->removeSelected(); | 432 | d->selectedFiles->removeSelected(); |
433 | Config cfg( "OpiePlayer" ); | 433 | Config cfg( "OpiePlayer" ); |
434 | cfg.setGroup("PlayList"); | 434 | cfg.setGroup("PlayList"); |
435 | cfg.writeEntry("CurrentPlaylist",""); | 435 | cfg.writeEntry("CurrentPlaylist",""); |
436 | currentPlayList=""; | 436 | currentPlayList=""; |
437 | 437 | ||
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | void PlayListWidget::addAllToList() { | 441 | void PlayListWidget::addAllToList() { |
442 | DocLnkSet filesAll; | 442 | DocLnkSet filesAll; |
443 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 443 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
444 | QListIterator<DocLnk> Adit( filesAll.children() ); | 444 | QListIterator<DocLnk> Adit( filesAll.children() ); |
445 | for ( ; Adit.current(); ++Adit ) | 445 | for ( ; Adit.current(); ++Adit ) |
446 | if(QFileInfo(Adit.current()->file()).exists()) | 446 | if(QFileInfo(Adit.current()->file()).exists()) |
447 | d->selectedFiles->addToSelection( **Adit ); | 447 | d->selectedFiles->addToSelection( **Adit ); |
448 | tabWidget->setCurrentPage(0); | 448 | tabWidget->setCurrentPage(0); |
449 | 449 | ||
450 | writeCurrentM3u(); | 450 | writeCurrentM3u(); |
451 | d->selectedFiles->first(); | 451 | d->selectedFiles->first(); |
452 | } | 452 | } |
453 | 453 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 1a5e474..4460833 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -284,760 +284,760 @@ void PlayListWidget::addAllToList() { | |||
284 | } | 284 | } |
285 | 285 | ||
286 | 286 | ||
287 | void PlayListWidget::addAllMusicToList() { | 287 | void PlayListWidget::addAllMusicToList() { |
288 | 288 | ||
289 | audioView->populateView(); | 289 | audioView->populateView(); |
290 | 290 | ||
291 | QListViewItemIterator audioIt( audioView ); | 291 | QListViewItemIterator audioIt( audioView ); |
292 | DocLnk lnk; | 292 | DocLnk lnk; |
293 | QString filename; | 293 | QString filename; |
294 | // iterate through all items of the listview | 294 | // iterate through all items of the listview |
295 | for ( ; audioIt.current(); ++audioIt ) { | 295 | for ( ; audioIt.current(); ++audioIt ) { |
296 | filename = audioIt.current()->text(3); | 296 | filename = audioIt.current()->text(3); |
297 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 297 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
298 | lnk.setFile( filename ); //sets file name | 298 | lnk.setFile( filename ); //sets file name |
299 | d->selectedFiles->addToSelection( lnk); | 299 | d->selectedFiles->addToSelection( lnk); |
300 | } | 300 | } |
301 | 301 | ||
302 | tabWidget->setCurrentPage(0); | 302 | tabWidget->setCurrentPage(0); |
303 | writeCurrentM3u(); | 303 | writeCurrentM3u(); |
304 | d->selectedFiles->first(); | 304 | d->selectedFiles->first(); |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | void PlayListWidget::addAllVideoToList() { | 308 | void PlayListWidget::addAllVideoToList() { |
309 | 309 | ||
310 | videoView->populateView(); | 310 | videoView->populateView(); |
311 | 311 | ||
312 | QListViewItemIterator videoIt( videoView ); | 312 | QListViewItemIterator videoIt( videoView ); |
313 | DocLnk lnk; | 313 | DocLnk lnk; |
314 | QString filename; | 314 | QString filename; |
315 | for ( ; videoIt.current(); ++videoIt ) { | 315 | for ( ; videoIt.current(); ++videoIt ) { |
316 | filename = videoIt.current()->text(3); | 316 | filename = videoIt.current()->text(3); |
317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
318 | lnk.setFile( filename ); //sets file name | 318 | lnk.setFile( filename ); //sets file name |
319 | d->selectedFiles->addToSelection( lnk); | 319 | d->selectedFiles->addToSelection( lnk); |
320 | } | 320 | } |
321 | tabWidget->setCurrentPage(0); | 321 | tabWidget->setCurrentPage(0); |
322 | writeCurrentM3u(); | 322 | writeCurrentM3u(); |
323 | d->selectedFiles->first(); | 323 | d->selectedFiles->first(); |
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
327 | void PlayListWidget::setDocument( const QString& fileref ) { | 327 | void PlayListWidget::setDocument( const QString& fileref ) { |
328 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 328 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
329 | fromSetDocument = TRUE; | 329 | fromSetDocument = TRUE; |
330 | QFileInfo fileInfo(fileref); | 330 | QFileInfo fileInfo(fileref); |
331 | 331 | ||
332 | if ( !fileInfo.exists() ) { | 332 | if ( !fileInfo.exists() ) { |
333 | QMessageBox::warning( this, tr( "Invalid File" ), | 333 | QMessageBox::warning( this, tr( "Invalid File" ), |
334 | tr( "There was a problem in getting the file." ) ); | 334 | tr( "There was a problem in getting the file." ) ); |
335 | return; | 335 | return; |
336 | } | 336 | } |
337 | 337 | ||
338 | clearList(); | 338 | clearList(); |
339 | QString extension = fileInfo.extension(false); | 339 | QString extension = fileInfo.extension(false); |
340 | 340 | ||
341 | if( extension.find( "m3u", 0, false) != -1 | 341 | if( extension.find( "m3u", 0, false) != -1 |
342 | || extension.find( "pls", 0, false) != -1 ) { | 342 | || extension.find( "pls", 0, false) != -1 ) { |
343 | readListFromFile( fileref ); | 343 | readListFromFile( fileref ); |
344 | } else { | 344 | } else { |
345 | clearList(); | 345 | clearList(); |
346 | DocLnk lnk; | 346 | DocLnk lnk; |
347 | lnk.setName( fileInfo.baseName() ); //sets name | 347 | lnk.setName( fileInfo.baseName() ); //sets name |
348 | lnk.setFile( fileref ); //sets file name | 348 | lnk.setFile( fileref ); //sets file name |
349 | addToSelection( lnk ); | 349 | addToSelection( lnk ); |
350 | writeCurrentM3u(); | 350 | writeCurrentM3u(); |
351 | 351 | ||
352 | d->setDocumentUsed = TRUE; | 352 | d->setDocumentUsed = TRUE; |
353 | mediaPlayerState->setPlaying( FALSE ); | 353 | mediaPlayerState->setPlaying( FALSE ); |
354 | mediaPlayerState->setPlaying( TRUE ); | 354 | mediaPlayerState->setPlaying( TRUE ); |
355 | } | 355 | } |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | void PlayListWidget::useSelectedDocument() { | 359 | void PlayListWidget::useSelectedDocument() { |
360 | d->setDocumentUsed = FALSE; | 360 | d->setDocumentUsed = FALSE; |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | const DocLnk *PlayListWidget::current() const { // this is fugly | 364 | const DocLnk *PlayListWidget::current() const { // this is fugly |
365 | assert( currentTab() == CurrentPlayList ); | 365 | assert( currentTab() == CurrentPlayList ); |
366 | 366 | ||
367 | const DocLnk *lnk = d->selectedFiles->current(); | 367 | const DocLnk *lnk = d->selectedFiles->current(); |
368 | if ( !lnk ) { | 368 | if ( !lnk ) { |
369 | d->selectedFiles->first(); | 369 | d->selectedFiles->first(); |
370 | lnk = d->selectedFiles->current(); | 370 | lnk = d->selectedFiles->current(); |
371 | } | 371 | } |
372 | assert( lnk ); | 372 | assert( lnk ); |
373 | return lnk; | 373 | return lnk; |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | bool PlayListWidget::prev() { | 377 | bool PlayListWidget::prev() { |
378 | if ( mediaPlayerState->isShuffled() ) { | 378 | if ( mediaPlayerState->isShuffled() ) { |
379 | const DocLnk *cur = current(); | 379 | const DocLnk *cur = current(); |
380 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 380 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
381 | for ( int i = 0; i < j; i++ ) { | 381 | for ( int i = 0; i < j; i++ ) { |
382 | if ( !d->selectedFiles->next() ) | 382 | if ( !d->selectedFiles->next() ) |
383 | d->selectedFiles->first(); | 383 | d->selectedFiles->first(); |
384 | } | 384 | } |
385 | if ( cur == current() ) | 385 | if ( cur == current() ) |
386 | if ( !d->selectedFiles->next() ) { | 386 | if ( !d->selectedFiles->next() ) { |
387 | d->selectedFiles->first(); | 387 | d->selectedFiles->first(); |
388 | } | 388 | } |
389 | return TRUE; | 389 | return TRUE; |
390 | } else { | 390 | } else { |
391 | if ( !d->selectedFiles->prev() ) { | 391 | if ( !d->selectedFiles->prev() ) { |
392 | if ( mediaPlayerState->isLooping() ) { | 392 | if ( mediaPlayerState->isLooping() ) { |
393 | return d->selectedFiles->last(); | 393 | return d->selectedFiles->last(); |
394 | } else { | 394 | } else { |
395 | return FALSE; | 395 | return FALSE; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | return TRUE; | 398 | return TRUE; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | bool PlayListWidget::next() { | 403 | bool PlayListWidget::next() { |
404 | //qDebug("<<<<<<<<<<<<next()"); | 404 | //qDebug("<<<<<<<<<<<<next()"); |
405 | if ( mediaPlayerState->isShuffled() ) { | 405 | if ( mediaPlayerState->isShuffled() ) { |
406 | return prev(); | 406 | return prev(); |
407 | } else { | 407 | } else { |
408 | if ( !d->selectedFiles->next() ) { | 408 | if ( !d->selectedFiles->next() ) { |
409 | if ( mediaPlayerState->isLooping() ) { | 409 | if ( mediaPlayerState->isLooping() ) { |
410 | return d->selectedFiles->first(); | 410 | return d->selectedFiles->first(); |
411 | } else { | 411 | } else { |
412 | return FALSE; | 412 | return FALSE; |
413 | } | 413 | } |
414 | } | 414 | } |
415 | return TRUE; | 415 | return TRUE; |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | bool PlayListWidget::first() { | 420 | bool PlayListWidget::first() { |
421 | return d->selectedFiles->first(); | 421 | return d->selectedFiles->first(); |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | bool PlayListWidget::last() { | 425 | bool PlayListWidget::last() { |
426 | return d->selectedFiles->last(); | 426 | return d->selectedFiles->last(); |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | void PlayListWidget::saveList() { | 430 | void PlayListWidget::saveList() { |
431 | writem3u(); | 431 | writem3u(); |
432 | } | 432 | } |
433 | 433 | ||
434 | 434 | ||
435 | void PlayListWidget::loadList( const DocLnk & lnk) { | 435 | void PlayListWidget::loadList( const DocLnk & lnk) { |
436 | QString name = lnk.name(); | 436 | QString name = lnk.name(); |
437 | 437 | ||
438 | if( name.length()>0) { | 438 | if( name.length()>0) { |
439 | setCaption("OpiePlayer: "+name); | 439 | setCaption("OpiePlayer: "+name); |
440 | clearList(); | 440 | clearList(); |
441 | readListFromFile(lnk.file()); | 441 | readListFromFile(lnk.file()); |
442 | tabWidget->setCurrentPage(0); | 442 | tabWidget->setCurrentPage(0); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | void PlayListWidget::addSelected() { | 446 | void PlayListWidget::addSelected() { |
447 | assert( inFileListMode() ); | 447 | assert( inFileListMode() ); |
448 | 448 | ||
449 | QListViewItemIterator it( currentFileListView ); | 449 | QListViewItemIterator it( currentFileListView ); |
450 | for ( ; it.current(); ++it ) | 450 | for ( ; it.current(); ++it ) |
451 | if ( it.current()->isSelected() ) { | 451 | if ( it.current()->isSelected() ) { |
452 | QString filename = it.current()->text(3); | 452 | QString filename = it.current()->text(3); |
453 | 453 | ||
454 | DocLnk lnk; | 454 | DocLnk lnk; |
455 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 455 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
456 | lnk.setFile( filename ); //sets file name | 456 | lnk.setFile( filename ); //sets file name |
457 | 457 | ||
458 | d->selectedFiles->addToSelection( lnk ); | 458 | d->selectedFiles->addToSelection( lnk ); |
459 | } | 459 | } |
460 | 460 | ||
461 | currentFileListView->clearSelection(); | 461 | currentFileListView->clearSelection(); |
462 | 462 | ||
463 | writeCurrentM3u(); | 463 | writeCurrentM3u(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | void PlayListWidget::removeSelected() { | 467 | void PlayListWidget::removeSelected() { |
468 | d->selectedFiles->removeSelected( ); | 468 | d->selectedFiles->removeSelected( ); |
469 | writeCurrentM3u(); | 469 | writeCurrentM3u(); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | void PlayListWidget::playIt( QListViewItem *it) { | 473 | void PlayListWidget::playIt( QListViewItem *it) { |
474 | if(!it) return; | 474 | if(!it) return; |
475 | mediaPlayerState->setPlaying(FALSE); | 475 | mediaPlayerState->setPlaying(FALSE); |
476 | mediaPlayerState->setPlaying(TRUE); | 476 | mediaPlayerState->setPlaying(TRUE); |
477 | d->selectedFiles->unSelect(); | 477 | d->selectedFiles->unSelect(); |
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
481 | void PlayListWidget::addToSelection( QListViewItem *it) { | 481 | void PlayListWidget::addToSelection( QListViewItem *it) { |
482 | d->setDocumentUsed = FALSE; | 482 | d->setDocumentUsed = FALSE; |
483 | 483 | ||
484 | if(it) { | 484 | if(it) { |
485 | if ( currentTab() == CurrentPlayList ) | 485 | if ( currentTab() == CurrentPlayList ) |
486 | return; | 486 | return; |
487 | DocLnk lnk; | 487 | DocLnk lnk; |
488 | QString filename; | 488 | QString filename; |
489 | 489 | ||
490 | filename=it->text(3); | 490 | filename=it->text(3); |
491 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 491 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
492 | lnk.setFile( filename ); //sets file name | 492 | lnk.setFile( filename ); //sets file name |
493 | d->selectedFiles->addToSelection( lnk); | 493 | d->selectedFiles->addToSelection( lnk); |
494 | 494 | ||
495 | writeCurrentM3u(); | 495 | writeCurrentM3u(); |
496 | // tabWidget->setCurrentPage(0); | 496 | // tabWidget->setCurrentPage(0); |
497 | 497 | ||
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | void PlayListWidget::tabChanged(QWidget *) { | 502 | void PlayListWidget::tabChanged(QWidget *) { |
503 | 503 | ||
504 | d->tbPlay->setEnabled( true ); | 504 | d->tbPlay->setEnabled( true ); |
505 | 505 | ||
506 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), | 506 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), |
507 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 507 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
508 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), | 508 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), |
509 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 509 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
510 | 510 | ||
511 | currentFileListView = 0; | 511 | currentFileListView = 0; |
512 | 512 | ||
513 | switch ( currentTab() ) { | 513 | switch ( currentTab() ) { |
514 | case CurrentPlayList: | 514 | case CurrentPlayList: |
515 | { | 515 | { |
516 | if( !tbDeletePlaylist->isHidden() ) { | 516 | if( !tbDeletePlaylist->isHidden() ) { |
517 | tbDeletePlaylist->hide(); | 517 | tbDeletePlaylist->hide(); |
518 | } | 518 | } |
519 | d->tbRemoveFromList->setEnabled(TRUE); | 519 | d->tbRemoveFromList->setEnabled(TRUE); |
520 | d->tbAddToList->setEnabled(FALSE); | 520 | d->tbAddToList->setEnabled(FALSE); |
521 | 521 | ||
522 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 522 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
523 | } | 523 | } |
524 | break; | 524 | break; |
525 | case AudioFiles: | 525 | case AudioFiles: |
526 | { | 526 | { |
527 | audioView->populateView(); | 527 | audioView->populateView(); |
528 | 528 | ||
529 | if( !tbDeletePlaylist->isHidden() ) { | 529 | if( !tbDeletePlaylist->isHidden() ) { |
530 | tbDeletePlaylist->hide(); | 530 | tbDeletePlaylist->hide(); |
531 | } | 531 | } |
532 | d->tbRemoveFromList->setEnabled(FALSE); | 532 | d->tbRemoveFromList->setEnabled(FALSE); |
533 | d->tbAddToList->setEnabled(TRUE); | 533 | d->tbAddToList->setEnabled(TRUE); |
534 | 534 | ||
535 | connect( audioView, SIGNAL( itemsSelected(bool) ), | 535 | connect( audioView, SIGNAL( itemsSelected(bool) ), |
536 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 536 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
537 | 537 | ||
538 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 538 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
539 | 539 | ||
540 | currentFileListView = audioView; | 540 | currentFileListView = audioView; |
541 | } | 541 | } |
542 | break; | 542 | break; |
543 | case VideoFiles: | 543 | case VideoFiles: |
544 | { | 544 | { |
545 | videoView->populateView(); | 545 | videoView->populateView(); |
546 | if( !tbDeletePlaylist->isHidden() ) { | 546 | if( !tbDeletePlaylist->isHidden() ) { |
547 | tbDeletePlaylist->hide(); | 547 | tbDeletePlaylist->hide(); |
548 | } | 548 | } |
549 | d->tbRemoveFromList->setEnabled(FALSE); | 549 | d->tbRemoveFromList->setEnabled(FALSE); |
550 | d->tbAddToList->setEnabled(TRUE); | 550 | d->tbAddToList->setEnabled(TRUE); |
551 | 551 | ||
552 | connect( videoView, SIGNAL( itemsSelected(bool) ), | 552 | connect( videoView, SIGNAL( itemsSelected(bool) ), |
553 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 553 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
554 | 554 | ||
555 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 555 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
556 | 556 | ||
557 | currentFileListView = videoView; | 557 | currentFileListView = videoView; |
558 | } | 558 | } |
559 | break; | 559 | break; |
560 | case PlayLists: | 560 | case PlayLists: |
561 | { | 561 | { |
562 | if( tbDeletePlaylist->isHidden() ) { | 562 | if( tbDeletePlaylist->isHidden() ) { |
563 | tbDeletePlaylist->show(); | 563 | tbDeletePlaylist->show(); |
564 | } | 564 | } |
565 | playLists->reread(); | 565 | playLists->reread(); |
566 | d->tbAddToList->setEnabled(FALSE); | 566 | d->tbAddToList->setEnabled(FALSE); |
567 | 567 | ||
568 | d->tbPlay->setEnabled( false ); | 568 | d->tbPlay->setEnabled( false ); |
569 | } | 569 | } |
570 | break; | 570 | break; |
571 | }; | 571 | }; |
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | void PlayListWidget::btnPlay(bool b) { | 575 | void PlayListWidget::btnPlay(bool b) { |
576 | // mediaPlayerState->setPlaying(false); | 576 | // mediaPlayerState->setPlaying(false); |
577 | mediaPlayerState->setPlaying(b); | 577 | mediaPlayerState->setPlaying(b); |
578 | insanityBool=FALSE; | 578 | insanityBool=FALSE; |
579 | } | 579 | } |
580 | 580 | ||
581 | void PlayListWidget::deletePlaylist() { | 581 | void PlayListWidget::deletePlaylist() { |
582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
583 | (tr("You really want to delete\nthis playlist?")), | 583 | (tr("You really want to delete\nthis playlist?")), |
584 | (tr("Yes")), (tr("No")), 0 )){ | 584 | (tr("Yes")), (tr("No")), 0 )){ |
585 | case 0: // Yes clicked, | 585 | case 0: // Yes clicked, |
586 | QFile().remove(playLists->selectedDocument().file()); | 586 | QFile().remove(playLists->selectedDocument().file()); |
587 | QFile().remove(playLists->selectedDocument().linkFile()); | 587 | QFile().remove(playLists->selectedDocument().linkFile()); |
588 | playLists->reread(); | 588 | playLists->reread(); |
589 | break; | 589 | break; |
590 | case 1: // Cancel | 590 | case 1: // Cancel |
591 | break; | 591 | break; |
592 | }; | 592 | }; |
593 | } | 593 | } |
594 | 594 | ||
595 | 595 | ||
596 | void PlayListWidget::playSelected() { | 596 | void PlayListWidget::playSelected() { |
597 | btnPlay( TRUE); | 597 | btnPlay( TRUE); |
598 | } | 598 | } |
599 | 599 | ||
600 | bool PlayListWidget::inFileListMode() const | 600 | bool PlayListWidget::inFileListMode() const |
601 | { | 601 | { |
602 | TabType tab = currentTab(); | 602 | TabType tab = currentTab(); |
603 | return tab == AudioFiles || tab == VideoFiles; | 603 | return tab == AudioFiles || tab == VideoFiles; |
604 | } | 604 | } |
605 | 605 | ||
606 | void PlayListWidget::openURL() { | 606 | void PlayListWidget::openURL() { |
607 | // http://66.28.164.33:2080 | 607 | // http://66.28.164.33:2080 |
608 | // http://somafm.com/star0242.m3u | 608 | // http://somafm.com/star0242.m3u |
609 | QString filename, name; | 609 | QString filename, name; |
610 | InputDialog *fileDlg; | 610 | InputDialog *fileDlg; |
611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
612 | fileDlg->exec(); | 612 | fileDlg->exec(); |
613 | if( fileDlg->result() == 1 ) { | 613 | if( fileDlg->result() == 1 ) { |
614 | filename = fileDlg->text(); | 614 | filename = fileDlg->text(); |
615 | qDebug( "Selected filename is " + filename ); | 615 | qDebug( "Selected filename is " + filename ); |
616 | // Om3u *m3uList; | 616 | // Om3u *m3uList; |
617 | DocLnk lnk; | 617 | DocLnk lnk; |
618 | Config cfg( "OpiePlayer" ); | 618 | Config cfg( "OpiePlayer" ); |
619 | cfg.setGroup("PlayList"); | 619 | cfg.setGroup("PlayList"); |
620 | 620 | ||
621 | if(filename.left(4) == "http") { | 621 | if(filename.left(4) == "http") { |
622 | QString m3uFile, m3uFilePath; | 622 | QString m3uFile, m3uFilePath; |
623 | if(filename.find(":",8,TRUE) != -1) { //found a port | 623 | if(filename.find(":",8,TRUE) != -1) { //found a port |
624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
625 | m3uFile = m3uFile.right( 7); | 625 | m3uFile = m3uFile.right( 7); |
626 | } else if(filename.left(4) == "http"){ | 626 | } else if(filename.left(4) == "http"){ |
627 | m3uFile=filename; | 627 | m3uFile=filename; |
628 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 628 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
629 | } else{ | 629 | } else{ |
630 | m3uFile=filename; | 630 | m3uFile=filename; |
631 | } | 631 | } |
632 | 632 | ||
633 | lnk.setName( filename ); //sets name | 633 | lnk.setName( filename ); //sets name |
634 | lnk.setFile( filename ); //sets file name | 634 | lnk.setFile( filename ); //sets file name |
635 | 635 | ||
636 | // lnk.setIcon("opieplayer2/musicfile"); | 636 | // lnk.setIcon("opieplayer2/musicfile"); |
637 | 637 | ||
638 | d->selectedFiles->addToSelection( lnk ); | 638 | d->selectedFiles->addToSelection( lnk ); |
639 | writeCurrentM3u(); | 639 | writeCurrentM3u(); |
640 | d->selectedFiles->setSelectedItem( lnk.name()); | 640 | d->selectedFiles->setSelectedItem( lnk.name()); |
641 | } | 641 | } |
642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
643 | readListFromFile( filename ); | 643 | readListFromFile( filename ); |
644 | } else { | 644 | } else { |
645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
646 | lnk.setFile( filename ); //sets file name | 646 | lnk.setFile( filename ); //sets file name |
647 | d->selectedFiles->addToSelection( lnk); | 647 | d->selectedFiles->addToSelection( lnk); |
648 | writeCurrentM3u(); | 648 | writeCurrentM3u(); |
649 | d->selectedFiles->setSelectedItem( lnk.name()); | 649 | d->selectedFiles->setSelectedItem( lnk.name()); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | 652 | ||
653 | 653 | ||
654 | delete fileDlg; | 654 | delete fileDlg; |
655 | } | 655 | } |
656 | 656 | ||
657 | 657 | ||
658 | void PlayListWidget::openFile() { | 658 | void PlayListWidget::openFile() { |
659 | 659 | ||
660 | QString filename, name; | 660 | QString filename, name; |
661 | 661 | ||
662 | Config cfg( "OpiePlayer" ); | 662 | Config cfg( "OpiePlayer" ); |
663 | cfg.setGroup("Dialog"); | 663 | cfg.setGroup("Dialog"); |
664 | MimeTypes types; | 664 | MimeTypes types; |
665 | QStringList audio, video, all; | 665 | QStringList audio, video, all; |
666 | audio << "audio/*"; | 666 | audio << "audio/*"; |
667 | audio << "playlist/plain"; | 667 | audio << "playlist/plain"; |
668 | audio << "application/ogg"; | 668 | audio << "audio/x-ogg"; |
669 | audio << "audio/x-mpegurl"; | 669 | audio << "audio/x-mpegurl"; |
670 | 670 | ||
671 | video << "video/*"; | 671 | video << "video/*"; |
672 | video << "playlist/plain"; | 672 | video << "playlist/plain"; |
673 | 673 | ||
674 | all += audio; | 674 | all += audio; |
675 | all += video; | 675 | all += video; |
676 | types.insert("All Media Files", all ); | 676 | types.insert("All Media Files", all ); |
677 | types.insert("Audio", audio ); | 677 | types.insert("Audio", audio ); |
678 | types.insert("Video", video ); | 678 | types.insert("Video", video ); |
679 | 679 | ||
680 | QString str = OFileDialog::getOpenFileName( 1, | 680 | QString str = OFileDialog::getOpenFileName( 1, |
681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
682 | types, 0 ); | 682 | types, 0 ); |
683 | 683 | ||
684 | if(str.left(2) == "//") { | 684 | if(str.left(2) == "//") { |
685 | str=str.right(str.length()-1); | 685 | str=str.right(str.length()-1); |
686 | } | 686 | } |
687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
688 | 688 | ||
689 | if( !str.isEmpty() ) { | 689 | if( !str.isEmpty() ) { |
690 | 690 | ||
691 | qDebug( "Selected filename is " + str ); | 691 | qDebug( "Selected filename is " + str ); |
692 | filename = str; | 692 | filename = str; |
693 | DocLnk lnk; | 693 | DocLnk lnk; |
694 | 694 | ||
695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
696 | readListFromFile( filename ); | 696 | readListFromFile( filename ); |
697 | } else { | 697 | } else { |
698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
699 | lnk.setFile( filename ); //sets file name | 699 | lnk.setFile( filename ); //sets file name |
700 | d->selectedFiles->addToSelection( lnk ); | 700 | d->selectedFiles->addToSelection( lnk ); |
701 | writeCurrentM3u(); | 701 | writeCurrentM3u(); |
702 | d->selectedFiles->setSelectedItem( lnk.name() ); | 702 | d->selectedFiles->setSelectedItem( lnk.name() ); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | void PlayListWidget::readListFromFile( const QString &filename ) { | 708 | void PlayListWidget::readListFromFile( const QString &filename ) { |
709 | qDebug( "read list filename " + filename ); | 709 | qDebug( "read list filename " + filename ); |
710 | QFileInfo fi(filename); | 710 | QFileInfo fi(filename); |
711 | Om3u *m3uList; | 711 | Om3u *m3uList; |
712 | QString s, name; | 712 | QString s, name; |
713 | m3uList = new Om3u( filename, IO_ReadOnly ); | 713 | m3uList = new Om3u( filename, IO_ReadOnly ); |
714 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 714 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
715 | m3uList->readM3u(); | 715 | m3uList->readM3u(); |
716 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 716 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
717 | m3uList->readPls(); | 717 | m3uList->readPls(); |
718 | 718 | ||
719 | DocLnk lnk; | 719 | DocLnk lnk; |
720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
721 | s = *it; | 721 | s = *it; |
722 | // qDebug(s); | 722 | // qDebug(s); |
723 | if(s.left(4)=="http") { | 723 | if(s.left(4)=="http") { |
724 | lnk.setName( s ); //sets file name | 724 | lnk.setName( s ); //sets file name |
725 | lnk.setIcon("opieplayer2/musicfile"); | 725 | lnk.setIcon("opieplayer2/musicfile"); |
726 | lnk.setFile( s ); //sets file name | 726 | lnk.setFile( s ); //sets file name |
727 | 727 | ||
728 | } else { //is file | 728 | } else { //is file |
729 | lnk.setName( QFileInfo(s).baseName()); | 729 | lnk.setName( QFileInfo(s).baseName()); |
730 | if(s.left(1) != "/") { | 730 | if(s.left(1) != "/") { |
731 | 731 | ||
732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
733 | } else { | 733 | } else { |
734 | lnk.setFile( s); | 734 | lnk.setFile( s); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | d->selectedFiles->addToSelection( lnk ); | 737 | d->selectedFiles->addToSelection( lnk ); |
738 | } | 738 | } |
739 | Config config( "OpiePlayer" ); | 739 | Config config( "OpiePlayer" ); |
740 | config.setGroup( "PlayList" ); | 740 | config.setGroup( "PlayList" ); |
741 | 741 | ||
742 | config.writeEntry("CurrentPlaylist",filename); | 742 | config.writeEntry("CurrentPlaylist",filename); |
743 | config.write(); | 743 | config.write(); |
744 | currentPlayList=filename; | 744 | currentPlayList=filename; |
745 | 745 | ||
746 | m3uList->close(); | 746 | m3uList->close(); |
747 | delete m3uList; | 747 | delete m3uList; |
748 | 748 | ||
749 | d->selectedFiles->setSelectedItem( s); | 749 | d->selectedFiles->setSelectedItem( s); |
750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
751 | 751 | ||
752 | } | 752 | } |
753 | 753 | ||
754 | // writes current playlist to current m3u file */ | 754 | // writes current playlist to current m3u file */ |
755 | void PlayListWidget::writeCurrentM3u() { | 755 | void PlayListWidget::writeCurrentM3u() { |
756 | qDebug("writing to current m3u"); | 756 | qDebug("writing to current m3u"); |
757 | Config cfg( "OpiePlayer" ); | 757 | Config cfg( "OpiePlayer" ); |
758 | cfg.setGroup("PlayList"); | 758 | cfg.setGroup("PlayList"); |
759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
760 | 760 | ||
761 | Om3u *m3uList; | 761 | Om3u *m3uList; |
762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
763 | if( d->selectedFiles->first()) { | 763 | if( d->selectedFiles->first()) { |
764 | 764 | ||
765 | do { | 765 | do { |
766 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 766 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
767 | m3uList->add( d->selectedFiles->current()->file() ); | 767 | m3uList->add( d->selectedFiles->current()->file() ); |
768 | } | 768 | } |
769 | while ( d->selectedFiles->next() ); | 769 | while ( d->selectedFiles->next() ); |
770 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 770 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
771 | m3uList->write(); | 771 | m3uList->write(); |
772 | m3uList->close(); | 772 | m3uList->close(); |
773 | } | 773 | } |
774 | delete m3uList; | 774 | delete m3uList; |
775 | 775 | ||
776 | } | 776 | } |
777 | 777 | ||
778 | /* | 778 | /* |
779 | writes current playlist to m3u file */ | 779 | writes current playlist to m3u file */ |
780 | void PlayListWidget::writem3u() { | 780 | void PlayListWidget::writem3u() { |
781 | //InputDilog *fileDlg; | 781 | //InputDilog *fileDlg; |
782 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 782 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
783 | //fileDlg->exec(); | 783 | //fileDlg->exec(); |
784 | 784 | ||
785 | Config cfg( "OpiePlayer" ); | 785 | Config cfg( "OpiePlayer" ); |
786 | cfg.setGroup("Dialog"); | 786 | cfg.setGroup("Dialog"); |
787 | MimeTypes types; | 787 | MimeTypes types; |
788 | QStringList audio, video, all; | 788 | QStringList audio, video, all; |
789 | audio << "audio/*"; | 789 | audio << "audio/*"; |
790 | audio << "playlist/plain"; | 790 | audio << "playlist/plain"; |
791 | audio << "audio/x-mpegurl"; | 791 | audio << "audio/x-mpegurl"; |
792 | 792 | ||
793 | video << "video/*"; | 793 | video << "video/*"; |
794 | video << "playlist/plain"; | 794 | video << "playlist/plain"; |
795 | 795 | ||
796 | all += audio; | 796 | all += audio; |
797 | all += video; | 797 | all += video; |
798 | types.insert("All Media Files", all ); | 798 | types.insert("All Media Files", all ); |
799 | types.insert("Audio", audio ); | 799 | types.insert("Audio", audio ); |
800 | types.insert("Video", video ); | 800 | types.insert("Video", video ); |
801 | 801 | ||
802 | QString str = OFileDialog::getOpenFileName( 1, | 802 | QString str = OFileDialog::getOpenFileName( 1, |
803 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 803 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
804 | types, 0 ); | 804 | types, 0 ); |
805 | if(str.left(2) == "//") str=str.right(str.length()-1); | 805 | if(str.left(2) == "//") str=str.right(str.length()-1); |
806 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | 806 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); |
807 | 807 | ||
808 | 808 | ||
809 | QString name, filename, list; | 809 | QString name, filename, list; |
810 | Om3u *m3uList; | 810 | Om3u *m3uList; |
811 | 811 | ||
812 | if( !str.isEmpty() ) { | 812 | if( !str.isEmpty() ) { |
813 | name = str; | 813 | name = str; |
814 | // name = fileDlg->text(); | 814 | // name = fileDlg->text(); |
815 | // qDebug( filename ); | 815 | // qDebug( filename ); |
816 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 816 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
817 | filename = name; | 817 | filename = name; |
818 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 818 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
819 | } | 819 | } |
820 | else //otherwise dump it somewhere noticable | 820 | else //otherwise dump it somewhere noticable |
821 | filename = QPEApplication::documentDir() + "/" + name; | 821 | filename = QPEApplication::documentDir() + "/" + name; |
822 | 822 | ||
823 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 823 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
824 | filename += ".m3u"; | 824 | filename += ".m3u"; |
825 | 825 | ||
826 | if( d->selectedFiles->first()) { //ramble through playlist view | 826 | if( d->selectedFiles->first()) { //ramble through playlist view |
827 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 827 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
828 | 828 | ||
829 | do { | 829 | do { |
830 | m3uList->add( d->selectedFiles->current()->file()); | 830 | m3uList->add( d->selectedFiles->current()->file()); |
831 | } | 831 | } |
832 | while ( d->selectedFiles->next() ); | 832 | while ( d->selectedFiles->next() ); |
833 | // qDebug( list ); | 833 | // qDebug( list ); |
834 | m3uList->write(); | 834 | m3uList->write(); |
835 | m3uList->close(); | 835 | m3uList->close(); |
836 | delete m3uList; | 836 | delete m3uList; |
837 | 837 | ||
838 | //delete fileDlg; | 838 | //delete fileDlg; |
839 | 839 | ||
840 | DocLnk lnk; | 840 | DocLnk lnk; |
841 | lnk.setFile( filename); | 841 | lnk.setFile( filename); |
842 | lnk.setIcon("opieplayer2/playlist2"); | 842 | lnk.setIcon("opieplayer2/playlist2"); |
843 | lnk.setName( name); //sets file name | 843 | lnk.setName( name); //sets file name |
844 | 844 | ||
845 | // qDebug(filename); | 845 | // qDebug(filename); |
846 | Config config( "OpiePlayer" ); | 846 | Config config( "OpiePlayer" ); |
847 | config.setGroup( "PlayList" ); | 847 | config.setGroup( "PlayList" ); |
848 | 848 | ||
849 | config.writeEntry("CurrentPlaylist",filename); | 849 | config.writeEntry("CurrentPlaylist",filename); |
850 | currentPlayList=filename; | 850 | currentPlayList=filename; |
851 | 851 | ||
852 | if(!lnk.writeLink()) { | 852 | if(!lnk.writeLink()) { |
853 | qDebug("Writing doclink did not work"); | 853 | qDebug("Writing doclink did not work"); |
854 | } | 854 | } |
855 | 855 | ||
856 | setCaption(tr("OpiePlayer: ") + name); | 856 | setCaption(tr("OpiePlayer: ") + name); |
857 | } | 857 | } |
858 | } | 858 | } |
859 | } | 859 | } |
860 | 860 | ||
861 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 861 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
862 | switch ( e->key() ) { | 862 | switch ( e->key() ) { |
863 | ////////////////////////////// Zaurus keys | 863 | ////////////////////////////// Zaurus keys |
864 | case Key_F9: //activity | 864 | case Key_F9: //activity |
865 | // if(audioUI->isHidden()) | 865 | // if(audioUI->isHidden()) |
866 | // audioUI->showMaximized(); | 866 | // audioUI->showMaximized(); |
867 | break; | 867 | break; |
868 | case Key_F10: //contacts | 868 | case Key_F10: //contacts |
869 | // if( videoUI->isHidden()) | 869 | // if( videoUI->isHidden()) |
870 | // videoUI->showMaximized(); | 870 | // videoUI->showMaximized(); |
871 | break; | 871 | break; |
872 | case Key_F11: //menu | 872 | case Key_F11: //menu |
873 | break; | 873 | break; |
874 | case Key_F12: //home | 874 | case Key_F12: //home |
875 | // doBlank(); | 875 | // doBlank(); |
876 | break; | 876 | break; |
877 | case Key_F13: //mail | 877 | case Key_F13: //mail |
878 | // doUnblank(); | 878 | // doUnblank(); |
879 | break; | 879 | break; |
880 | case Key_Q: //add to playlist | 880 | case Key_Q: //add to playlist |
881 | addSelected(); | 881 | addSelected(); |
882 | break; | 882 | break; |
883 | case Key_R: //remove from playlist | 883 | case Key_R: //remove from playlist |
884 | removeSelected(); | 884 | removeSelected(); |
885 | break; | 885 | break; |
886 | // case Key_P: //play | 886 | // case Key_P: //play |
887 | // qDebug("Play"); | 887 | // qDebug("Play"); |
888 | // playSelected(); | 888 | // playSelected(); |
889 | // break; | 889 | // break; |
890 | case Key_Space: | 890 | case Key_Space: |
891 | // playSelected(); puh | 891 | // playSelected(); puh |
892 | break; | 892 | break; |
893 | case Key_1: | 893 | case Key_1: |
894 | tabWidget->setCurrentPage( 0 ); | 894 | tabWidget->setCurrentPage( 0 ); |
895 | break; | 895 | break; |
896 | case Key_2: | 896 | case Key_2: |
897 | tabWidget->setCurrentPage( 1 ); | 897 | tabWidget->setCurrentPage( 1 ); |
898 | break; | 898 | break; |
899 | case Key_3: | 899 | case Key_3: |
900 | tabWidget->setCurrentPage( 2 ); | 900 | tabWidget->setCurrentPage( 2 ); |
901 | break; | 901 | break; |
902 | case Key_4: | 902 | case Key_4: |
903 | tabWidget->setCurrentPage( 3 ); | 903 | tabWidget->setCurrentPage( 3 ); |
904 | break; | 904 | break; |
905 | case Key_Down: | 905 | case Key_Down: |
906 | if ( !d->selectedFiles->next() ) | 906 | if ( !d->selectedFiles->next() ) |
907 | d->selectedFiles->first(); | 907 | d->selectedFiles->first(); |
908 | break; | 908 | break; |
909 | case Key_Up: | 909 | case Key_Up: |
910 | if ( !d->selectedFiles->prev() ) | 910 | if ( !d->selectedFiles->prev() ) |
911 | // d->selectedFiles->last(); | 911 | // d->selectedFiles->last(); |
912 | break; | 912 | break; |
913 | } | 913 | } |
914 | } | 914 | } |
915 | 915 | ||
916 | void PlayListWidget::pmViewActivated(int index) { | 916 | void PlayListWidget::pmViewActivated(int index) { |
917 | // qDebug("%d", index); | 917 | // qDebug("%d", index); |
918 | switch(index) { | 918 | switch(index) { |
919 | case -16: | 919 | case -16: |
920 | { | 920 | { |
921 | mediaPlayerState->toggleFullscreen(); | 921 | mediaPlayerState->toggleFullscreen(); |
922 | bool b=mediaPlayerState->isFullscreen(); | 922 | bool b=mediaPlayerState->isFullscreen(); |
923 | pmView->setItemChecked( index, b); | 923 | pmView->setItemChecked( index, b); |
924 | Config cfg( "OpiePlayer" ); | 924 | Config cfg( "OpiePlayer" ); |
925 | cfg.writeEntry( "FullScreen", b ); | 925 | cfg.writeEntry( "FullScreen", b ); |
926 | } | 926 | } |
927 | break; | 927 | break; |
928 | }; | 928 | }; |
929 | } | 929 | } |
930 | 930 | ||
931 | void PlayListWidget::populateSkinsMenu() { | 931 | void PlayListWidget::populateSkinsMenu() { |
932 | int item = 0; | 932 | int item = 0; |
933 | defaultSkinIndex = 0; | 933 | defaultSkinIndex = 0; |
934 | QString skinName; | 934 | QString skinName; |
935 | Config cfg( "OpiePlayer" ); | 935 | Config cfg( "OpiePlayer" ); |
936 | cfg.setGroup("Options" ); | 936 | cfg.setGroup("Options" ); |
937 | QString skin = cfg.readEntry( "Skin", "default" ); | 937 | QString skin = cfg.readEntry( "Skin", "default" ); |
938 | 938 | ||
939 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 939 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
940 | skinsDir.setFilter( QDir::Dirs ); | 940 | skinsDir.setFilter( QDir::Dirs ); |
941 | skinsDir.setSorting(QDir::Name ); | 941 | skinsDir.setSorting(QDir::Name ); |
942 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 942 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
943 | QFileInfoListIterator it( *skinslist ); | 943 | QFileInfoListIterator it( *skinslist ); |
944 | QFileInfo *fi; | 944 | QFileInfo *fi; |
945 | while ( ( fi = it.current() ) ) { | 945 | while ( ( fi = it.current() ) ) { |
946 | skinName = fi->fileName(); | 946 | skinName = fi->fileName(); |
947 | // qDebug( fi->fileName() ); | 947 | // qDebug( fi->fileName() ); |
948 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 948 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
949 | item = skinsMenu->insertItem( fi->fileName() ) ; | 949 | item = skinsMenu->insertItem( fi->fileName() ) ; |
950 | } | 950 | } |
951 | if( skinName == "default" ) { | 951 | if( skinName == "default" ) { |
952 | defaultSkinIndex = item; | 952 | defaultSkinIndex = item; |
953 | } | 953 | } |
954 | if( skinName == skin ) { | 954 | if( skinName == skin ) { |
955 | skinsMenu->setItemChecked( item, TRUE ); | 955 | skinsMenu->setItemChecked( item, TRUE ); |
956 | } | 956 | } |
957 | ++it; | 957 | ++it; |
958 | } | 958 | } |
959 | } | 959 | } |
960 | 960 | ||
961 | void PlayListWidget::skinsMenuActivated( int item ) { | 961 | void PlayListWidget::skinsMenuActivated( int item ) { |
962 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 962 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
963 | skinsMenu->setItemChecked( i, FALSE ); | 963 | skinsMenu->setItemChecked( i, FALSE ); |
964 | } | 964 | } |
965 | skinsMenu->setItemChecked( item, TRUE ); | 965 | skinsMenu->setItemChecked( item, TRUE ); |
966 | 966 | ||
967 | { | 967 | { |
968 | Config cfg( "OpiePlayer" ); | 968 | Config cfg( "OpiePlayer" ); |
969 | cfg.setGroup("Options"); | 969 | cfg.setGroup("Options"); |
970 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 970 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
971 | } | 971 | } |
972 | 972 | ||
973 | emit skinSelected(); | 973 | emit skinSelected(); |
974 | } | 974 | } |
975 | 975 | ||
976 | PlayListWidget::TabType PlayListWidget::currentTab() const | 976 | PlayListWidget::TabType PlayListWidget::currentTab() const |
977 | { | 977 | { |
978 | static const TabType indexToTabType[ TabTypeCount ] = | 978 | static const TabType indexToTabType[ TabTypeCount ] = |
979 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 979 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
980 | 980 | ||
981 | int index = tabWidget->currentPageIndex(); | 981 | int index = tabWidget->currentPageIndex(); |
982 | assert( index < TabTypeCount && index >= 0 ); | 982 | assert( index < TabTypeCount && index >= 0 ); |
983 | 983 | ||
984 | return indexToTabType[ index ]; | 984 | return indexToTabType[ index ]; |
985 | } | 985 | } |
986 | 986 | ||
987 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 987 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
988 | { | 988 | { |
989 | if ( currentTab() == CurrentPlayList ) { | 989 | if ( currentTab() == CurrentPlayList ) { |
990 | const DocLnk *lnk = current(); | 990 | const DocLnk *lnk = current(); |
991 | return Entry( lnk->name(), lnk->file() ); | 991 | return Entry( lnk->name(), lnk->file() ); |
992 | } | 992 | } |
993 | 993 | ||
994 | return Entry( currentFileListPathName() ); | 994 | return Entry( currentFileListPathName() ); |
995 | } | 995 | } |
996 | 996 | ||
997 | QString PlayListWidget::currentFileListPathName() const { | 997 | QString PlayListWidget::currentFileListPathName() const { |
998 | return currentFileListView->currentItem()->text( 3 ); | 998 | return currentFileListView->currentItem()->text( 3 ); |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | 1001 | ||
1002 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1002 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1003 | qDebug("qcop message "+msg ); | 1003 | qDebug("qcop message "+msg ); |
1004 | QDataStream stream ( data, IO_ReadOnly ); | 1004 | QDataStream stream ( data, IO_ReadOnly ); |
1005 | if ( msg == "play()" ) { //plays current selection | 1005 | if ( msg == "play()" ) { //plays current selection |
1006 | btnPlay( true); | 1006 | btnPlay( true); |
1007 | } else if ( msg == "stop()" ) { | 1007 | } else if ( msg == "stop()" ) { |
1008 | mediaPlayerState->setPlaying( false); | 1008 | mediaPlayerState->setPlaying( false); |
1009 | } else if ( msg == "togglePause()" ) { | 1009 | } else if ( msg == "togglePause()" ) { |
1010 | mediaPlayerState->togglePaused(); | 1010 | mediaPlayerState->togglePaused(); |
1011 | } else if ( msg == "next()" ) { //select next in list | 1011 | } else if ( msg == "next()" ) { //select next in list |
1012 | mediaPlayerState->setNext(); | 1012 | mediaPlayerState->setNext(); |
1013 | } else if ( msg == "prev()" ) { //select previous in list | 1013 | } else if ( msg == "prev()" ) { //select previous in list |
1014 | mediaPlayerState->setPrev(); | 1014 | mediaPlayerState->setPrev(); |
1015 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1015 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1016 | mediaPlayerState->toggleLooping(); | 1016 | mediaPlayerState->toggleLooping(); |
1017 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1017 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1018 | mediaPlayerState->toggleShuffled(); | 1018 | mediaPlayerState->toggleShuffled(); |
1019 | } else if ( msg == "volUp()" ) { //volume more | 1019 | } else if ( msg == "volUp()" ) { //volume more |
1020 | // emit moreClicked(); | 1020 | // emit moreClicked(); |
1021 | // emit moreReleased(); | 1021 | // emit moreReleased(); |
1022 | } else if ( msg == "volDown()" ) { //volume less | 1022 | } else if ( msg == "volDown()" ) { //volume less |
1023 | // emit lessClicked(); | 1023 | // emit lessClicked(); |
1024 | // emit lessReleased(); | 1024 | // emit lessReleased(); |
1025 | } else if ( msg == "play(QString)" ) { //play this now | 1025 | } else if ( msg == "play(QString)" ) { //play this now |
1026 | QString file; | 1026 | QString file; |
1027 | stream >> file; | 1027 | stream >> file; |
1028 | setDocument( (const QString &) file); | 1028 | setDocument( (const QString &) file); |
1029 | } else if ( msg == "add(QString)" ) { //add to playlist | 1029 | } else if ( msg == "add(QString)" ) { //add to playlist |
1030 | QString file; | 1030 | QString file; |
1031 | stream >> file; | 1031 | stream >> file; |
1032 | QFileInfo fileInfo(file); | 1032 | QFileInfo fileInfo(file); |
1033 | DocLnk lnk; | 1033 | DocLnk lnk; |
1034 | lnk.setName( fileInfo.baseName() ); //sets name | 1034 | lnk.setName( fileInfo.baseName() ); //sets name |
1035 | lnk.setFile( file ); //sets file name | 1035 | lnk.setFile( file ); //sets file name |
1036 | addToSelection( lnk ); | 1036 | addToSelection( lnk ); |
1037 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1037 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1038 | QString file; | 1038 | QString file; |
1039 | stream >> file; | 1039 | stream >> file; |
1040 | 1040 | ||
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | } | 1043 | } |