-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 11 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 455 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 69 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | 207 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.h | 126 |
5 files changed, 507 insertions, 361 deletions
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index 3a47c06..a83a624 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro | |||
@@ -1,23 +1,24 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | #CONFIG = qt warn_on release |
3 | #CONFIG = qt warn_on debug | 3 | CONFIG = qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ | 5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ |
6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ | 6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ |
7 | frame.h lib.h xinevideowidget.h volumecontrol.h\ | 7 | frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\ |
8 | alphablend.h yuv2rgb.h | 8 | alphablend.h yuv2rgb.h |
9 | SOURCES = main.cpp \ | 9 | SOURCES = main.cpp \ |
10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ | 10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ |
11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ | 11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ |
12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\ | 12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\ |
13 | playlistwidgetgui.cpp\ | ||
13 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S | 14 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S |
14 | TARGET = opieplayer2 | 15 | TARGET = opieplayer2 |
15 | INCLUDEPATH += $(OPIEDIR)/include | 16 | INCLUDEPATH += $(OPIEDIR)/include |
16 | DEPENDPATH += $(OPIEDIR)/include | 17 | DEPENDPATH += $(OPIEDIR)/include |
17 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils | 18 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils |
18 | MOC_DIR=qpeobj | 19 | MOC_DIR=qpeobj |
19 | OBJECTS_DIR=qpeobj | 20 | OBJECTS_DIR=qpeobj |
20 | 21 | ||
21 | INCLUDEPATH += $(OPIEDIR)/include | 22 | #INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH += $(OPIEDIR)/include | 23 | #DEPENDPATH += $(OPIEDIR)/include |
23 | 24 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 098322b..6c7f6ba 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,125 +1,65 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
1 | 33 | ||
2 | #define QTOPIA_INTERNAL_FSLP | ||
3 | #include <qpe/qpemenubar.h> | ||
4 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
5 | #include <qpe/fileselector.h> | ||
6 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
7 | #include <qpe/lnkproperties.h> | ||
8 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
9 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
10 | |||
11 | #include <qpe/applnk.h> | ||
12 | #include <qpopupmenu.h> | ||
13 | #include <qpe/config.h> | ||
14 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
15 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
16 | #include <qaction.h> | 40 | |
17 | #include <qcursor.h> | ||
18 | #include <qimage.h> | ||
19 | #include <qfile.h> | ||
20 | #include <qdir.h> | 41 | #include <qdir.h> |
21 | #include <qlayout.h> | ||
22 | #include <qlabel.h> | ||
23 | #include <qlist.h> | ||
24 | #include <qlistbox.h> | ||
25 | #include <qmainwindow.h> | ||
26 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
27 | #include <qtoolbutton.h> | ||
28 | #include <qtabwidget.h> | ||
29 | #include <qlistview.h> | ||
30 | #include <qpoint.h> | ||
31 | #include <qlineedit.h> | ||
32 | #include <qpushbutton.h> | ||
33 | #include <qregexp.h> | 43 | #include <qregexp.h> |
34 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
35 | 45 | ||
36 | |||
37 | #include "playlistselection.h" | 46 | #include "playlistselection.h" |
38 | #include "playlistwidget.h" | 47 | #include "playlistwidget.h" |
39 | #include "mediaplayerstate.h" | 48 | #include "mediaplayerstate.h" |
40 | |||
41 | #include "inputDialog.h" | 49 | #include "inputDialog.h" |
42 | 50 | ||
51 | //only needed for the random play | ||
43 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | |||
44 | #include "audiowidget.h" | 54 | #include "audiowidget.h" |
45 | #include "videowidget.h" | 55 | #include "videowidget.h" |
46 | 56 | ||
47 | #define BUTTONS_ON_TOOLBAR | ||
48 | #define SIDE_BUTTONS | ||
49 | #define CAN_SAVE_LOAD_PLAYLISTS | ||
50 | |||
51 | extern MediaPlayerState *mediaPlayerState; | 57 | extern MediaPlayerState *mediaPlayerState; |
52 | 58 | ||
53 | 59 | ||
54 | class PlayListWidgetPrivate { | ||
55 | public: | ||
56 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | ||
57 | QFrame *playListFrame; | ||
58 | FileSelector *files; | ||
59 | PlayListSelection *selectedFiles; | ||
60 | bool setDocumentUsed; | ||
61 | DocLnk *current; | ||
62 | }; | ||
63 | |||
64 | |||
65 | class ToolButton : public QToolButton { | ||
66 | public: | ||
67 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | ||
68 | : QToolButton( parent, name ) { | ||
69 | setTextLabel( name ); | ||
70 | setPixmap( Resource::loadPixmap( icon ) ); | ||
71 | setAutoRaise( TRUE ); | ||
72 | setFocusPolicy( QWidget::NoFocus ); | ||
73 | setToggleButton( t ); | ||
74 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | ||
75 | QPEMenuToolFocusManager::manager()->addWidget( this ); | ||
76 | } | ||
77 | }; | ||
78 | |||
79 | |||
80 | class MenuItem : public QAction { | ||
81 | public: | ||
82 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | ||
83 | : QAction( text, QString::null, 0, 0 ) { | ||
84 | connect( this, SIGNAL( activated() ), handler, slot ); | ||
85 | addTo( parent ); | ||
86 | } | ||
87 | }; | ||
88 | |||
89 | |||
90 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 60 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
91 | : QMainWindow( parent, name, fl ) { | 61 | : PlayListWidgetGui( parent, name, fl ) { |
92 | |||
93 | d = new PlayListWidgetPrivate; | ||
94 | d->setDocumentUsed = FALSE; | ||
95 | d->current = NULL; | ||
96 | fromSetDocument = FALSE; | ||
97 | insanityBool=FALSE; | ||
98 | audioScan = FALSE; | ||
99 | videoScan = FALSE; | ||
100 | |||
101 | setBackgroundMode( PaletteButton ); | ||
102 | |||
103 | // setCaption( tr("OpiePlayer") ); | ||
104 | // setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); | ||
105 | |||
106 | setToolBarsMovable( FALSE ); | ||
107 | |||
108 | // Create Toolbar | ||
109 | QPEToolBar *toolbar = new QPEToolBar( this ); | ||
110 | toolbar->setHorizontalStretchable( TRUE ); | ||
111 | |||
112 | // Create Menubar | ||
113 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | ||
114 | menu->setMargin( 0 ); | ||
115 | |||
116 | QPEToolBar *bar = new QPEToolBar( this ); | ||
117 | bar->setLabel( tr( "Play Operations" ) ); | ||
118 | |||
119 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | ||
120 | tbDeletePlaylist->setFlat(TRUE); | ||
121 | tbDeletePlaylist->setFixedSize(20,20); | ||
122 | 62 | ||
123 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", | 63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", |
124 | this , SLOT(addSelected()) ); | 64 | this , SLOT(addSelected()) ); |
125 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", |
@@ -129,12 +69,9 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
129 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 69 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
130 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 70 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
131 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", | 71 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", |
132 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 72 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
133 | tbDeletePlaylist->hide(); | ||
134 | 73 | ||
135 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | ||
136 | menu->insertItem( tr( "File" ), pmPlayList ); | ||
137 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 74 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
138 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 75 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
139 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 76 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
140 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
@@ -146,137 +83,23 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
146 | pmPlayList->insertSeparator(-1); | 83 | pmPlayList->insertSeparator(-1); |
147 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 84 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
148 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 85 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
149 | 86 | ||
150 | pmView = new QPopupMenu( this ); | ||
151 | menu->insertItem( tr( "View" ), pmView ); | ||
152 | pmView->isCheckable(); | ||
153 | |||
154 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); | 87 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); |
155 | 88 | ||
156 | Config cfg( "OpiePlayer" ); | 89 | Config cfg( "OpiePlayer" ); |
157 | bool b= cfg.readBoolEntry("FullScreen", 0); | 90 | bool b= cfg.readBoolEntry("FullScreen", 0); |
158 | mediaPlayerState->setFullscreen( b ); | 91 | mediaPlayerState->setFullscreen( b ); |
159 | pmView->setItemChecked( -16, b ); | 92 | pmView->setItemChecked( -16, b ); |
160 | 93 | ||
161 | // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); | ||
162 | |||
163 | pmView->insertSeparator(-1); | ||
164 | |||
165 | skinsMenu = new QPopupMenu( this ); | ||
166 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | ||
167 | skinsMenu->isCheckable(); | ||
168 | populateSkinsMenu(); | ||
169 | |||
170 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | ||
171 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | ||
172 | |||
173 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | ||
174 | |||
175 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | ||
176 | // tabWidget->setTabShape(QTabWidget::Triangular); | ||
177 | |||
178 | QWidget *pTab; | ||
179 | pTab = new QWidget( tabWidget, "pTab" ); | ||
180 | tabWidget->insertTab( pTab,"Playlist"); | ||
181 | |||
182 | |||
183 | QGridLayout *Playout = new QGridLayout( pTab ); | ||
184 | Playout->setSpacing( 2); | ||
185 | Playout->setMargin( 2); | ||
186 | |||
187 | // Add the playlist area | ||
188 | |||
189 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | ||
190 | d->playListFrame = vbox3; | ||
191 | |||
192 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | ||
193 | |||
194 | d->selectedFiles = new PlayListSelection( hbox2); | ||
195 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | ||
196 | |||
197 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | ||
198 | |||
199 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | ||
200 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 94 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
201 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); | 95 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); |
202 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 96 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
203 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 97 | QVBox *stretch2 = new QVBox( vbox1 ); |
204 | |||
205 | |||
206 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | ||
207 | |||
208 | QWidget *aTab; | ||
209 | aTab = new QWidget( tabWidget, "aTab" ); | ||
210 | |||
211 | QGridLayout *Alayout = new QGridLayout( aTab ); | ||
212 | Alayout->setSpacing( 2); | ||
213 | Alayout->setMargin( 2); | ||
214 | |||
215 | audioView = new QListView( aTab, "Audioview" ); | ||
216 | audioView->addColumn( tr("Title"),140); | ||
217 | audioView->addColumn(tr("Size"), -1); | ||
218 | audioView->addColumn(tr("Media"),-1); | ||
219 | audioView->setColumnAlignment(1, Qt::AlignRight); | ||
220 | audioView->setColumnAlignment(2, Qt::AlignRight); | ||
221 | audioView->setAllColumnsShowFocus(TRUE); | ||
222 | audioView->setSorting(0,TRUE); | ||
223 | |||
224 | audioView->setMultiSelection( TRUE ); | ||
225 | audioView->setSelectionMode( QListView::Extended); | ||
226 | |||
227 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | ||
228 | |||
229 | tabWidget->insertTab(aTab,tr("Audio")); | ||
230 | |||
231 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | ||
232 | |||
233 | QWidget *vTab; | ||
234 | vTab = new QWidget( tabWidget, "vTab" ); | ||
235 | |||
236 | QGridLayout *Vlayout = new QGridLayout( vTab ); | ||
237 | Vlayout->setSpacing( 2); | ||
238 | Vlayout->setMargin( 2); | ||
239 | |||
240 | videoView = new QListView( vTab, "Videoview" ); | ||
241 | |||
242 | videoView->addColumn(tr("Title"),140); | ||
243 | videoView->addColumn(tr("Size"),-1); | ||
244 | videoView->addColumn(tr("Media"),-1); | ||
245 | videoView->setColumnAlignment(1, Qt::AlignRight); | ||
246 | videoView->setColumnAlignment(2, Qt::AlignRight); | ||
247 | videoView->setAllColumnsShowFocus(TRUE); | ||
248 | videoView->setSorting(0,TRUE); | ||
249 | |||
250 | videoView->setMultiSelection( TRUE ); | ||
251 | videoView->setSelectionMode( QListView::Extended); | ||
252 | |||
253 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | ||
254 | |||
255 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | ||
256 | |||
257 | tabWidget->insertTab( vTab,tr("Video")); | ||
258 | |||
259 | //playlists list | ||
260 | QWidget *LTab; | ||
261 | LTab = new QWidget( tabWidget, "LTab" ); | ||
262 | QGridLayout *Llayout = new QGridLayout( LTab ); | ||
263 | Llayout->setSpacing( 2); | ||
264 | Llayout->setMargin( 2); | ||
265 | |||
266 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | ||
267 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | ||
268 | |||
269 | tabWidget->insertTab(LTab,tr("Lists")); | ||
270 | 98 | ||
271 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 99 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
272 | |||
273 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); | 100 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); |
274 | |||
275 | connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); | 101 | connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); |
276 | |||
277 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); | ||
278 | |||
279 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 102 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
280 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 103 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
281 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 104 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
282 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 105 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
@@ -295,33 +118,31 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
295 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 118 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
296 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 119 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
297 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 120 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
298 | 121 | ||
299 | setCentralWidget( vbox5 ); | ||
300 | |||
301 | readConfig( cfg ); | 122 | readConfig( cfg ); |
302 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 123 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
303 | loadList(DocLnk( currentPlaylist)); | 124 | loadList(DocLnk( currentPlaylist)); |
304 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 125 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
305 | 126 | ||
127 | // see which skins are installed | ||
128 | populateSkinsMenu(); | ||
306 | initializeStates(); | 129 | initializeStates(); |
307 | } | 130 | } |
308 | 131 | ||
309 | 132 | ||
310 | PlayListWidget::~PlayListWidget() { | 133 | PlayListWidget::~PlayListWidget() { |
311 | /* fixing symptoms and not sources is entirely stupid - zecke */ | 134 | /* fixing symptoms and not sources is entirely stupid - zecke */ |
312 | // Config cfg( "OpiePlayer" ); | 135 | // Config cfg( "OpiePlayer" ); |
313 | // writeConfig( cfg ); | 136 | // writeConfig( cfg ); |
314 | |||
315 | if ( d->current ) { | 137 | if ( d->current ) { |
316 | delete d->current; | 138 | delete d->current; |
317 | } | 139 | } |
318 | delete d; | 140 | delete d; |
319 | } | 141 | } |
320 | 142 | ||
321 | 143 | ||
322 | void PlayListWidget::initializeStates() { | 144 | void PlayListWidget::initializeStates() { |
323 | |||
324 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 145 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
325 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 146 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
326 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 147 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
327 | setPlaylist( true); | 148 | setPlaylist( true); |
@@ -347,9 +168,8 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
347 | } | 168 | } |
348 | 169 | ||
349 | 170 | ||
350 | void PlayListWidget::writeConfig( Config& cfg ) const { | 171 | void PlayListWidget::writeConfig( Config& cfg ) const { |
351 | |||
352 | d->selectedFiles->writeCurrent( cfg); | 172 | d->selectedFiles->writeCurrent( cfg); |
353 | cfg.setGroup("PlayList"); | 173 | cfg.setGroup("PlayList"); |
354 | int noOfFiles = 0; | 174 | int noOfFiles = 0; |
355 | d->selectedFiles->first(); | 175 | d->selectedFiles->first(); |
@@ -399,8 +219,40 @@ void PlayListWidget::clearList() { | |||
399 | } | 219 | } |
400 | } | 220 | } |
401 | 221 | ||
402 | 222 | ||
223 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | ||
224 | switch (mouse) { | ||
225 | case 1: | ||
226 | break; | ||
227 | case 2: | ||
228 | { | ||
229 | QPopupMenu m; | ||
230 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | ||
231 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | ||
232 | m.exec( QCursor::pos() ); | ||
233 | } | ||
234 | break; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | |||
239 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | ||
240 | switch (mouse) { | ||
241 | case 1: | ||
242 | break; | ||
243 | case 2: | ||
244 | { | ||
245 | QPopupMenu m; | ||
246 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | ||
247 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | ||
248 | m.exec( QCursor::pos() ); | ||
249 | } | ||
250 | break; | ||
251 | } | ||
252 | } | ||
253 | |||
254 | |||
403 | void PlayListWidget::addAllToList() { | 255 | void PlayListWidget::addAllToList() { |
404 | DocLnkSet filesAll; | 256 | DocLnkSet filesAll; |
405 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 257 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
406 | QListIterator<DocLnk> Adit( filesAll.children() ); | 258 | QListIterator<DocLnk> Adit( filesAll.children() ); |
@@ -423,16 +275,18 @@ void PlayListWidget::addAllMusicToList() { | |||
423 | 275 | ||
424 | 276 | ||
425 | void PlayListWidget::addAllVideoToList() { | 277 | void PlayListWidget::addAllVideoToList() { |
426 | QListIterator<DocLnk> dit( vFiles.children() ); | 278 | QListIterator<DocLnk> dit( vFiles.children() ); |
427 | for ( ; dit.current(); ++dit ) | 279 | for ( ; dit.current(); ++dit ) { |
428 | if(QFileInfo( dit.current()->file()).exists()) | 280 | if( QFileInfo( dit.current()->file() ).exists() ) { |
429 | d->selectedFiles->addToSelection( **dit ); | 281 | d->selectedFiles->addToSelection( **dit ); |
430 | } | 282 | } |
283 | } | ||
284 | } | ||
431 | 285 | ||
432 | 286 | ||
433 | void PlayListWidget::setDocument(const QString& fileref) { | 287 | void PlayListWidget::setDocument(const QString& fileref) { |
434 | qDebug(fileref); | 288 | //qDebug( fileref ); |
435 | fromSetDocument = TRUE; | 289 | fromSetDocument = TRUE; |
436 | if ( fileref.isNull() ) { | 290 | if ( fileref.isNull() ) { |
437 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 291 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
438 | return; | 292 | return; |
@@ -458,24 +312,14 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
458 | } | 312 | } |
459 | } | 313 | } |
460 | 314 | ||
461 | 315 | ||
462 | void PlayListWidget::setActiveWindow() { | ||
463 | // qDebug("SETTING active window"); | ||
464 | // When we get raised we need to ensure that it switches views | ||
465 | char origView = mediaPlayerState->view(); | ||
466 | mediaPlayerState->setView( 'l' ); // invalidate | ||
467 | mediaPlayerState->setView( origView ); // now switch back | ||
468 | } | ||
469 | |||
470 | |||
471 | void PlayListWidget::useSelectedDocument() { | 316 | void PlayListWidget::useSelectedDocument() { |
472 | d->setDocumentUsed = FALSE; | 317 | d->setDocumentUsed = FALSE; |
473 | } | 318 | } |
474 | 319 | ||
475 | 320 | ||
476 | const DocLnk *PlayListWidget::current() { // this is fugly | 321 | const DocLnk *PlayListWidget::current() { // this is fugly |
477 | |||
478 | switch (tabWidget->currentPageIndex()) { | 322 | switch (tabWidget->currentPageIndex()) { |
479 | case 0: //playlist | 323 | case 0: //playlist |
480 | { | 324 | { |
481 | // qDebug("playlist"); | 325 | // qDebug("playlist"); |
@@ -515,8 +359,9 @@ const DocLnk *PlayListWidget::current() { // this is fugly | |||
515 | }; | 359 | }; |
516 | return 0; | 360 | return 0; |
517 | } | 361 | } |
518 | 362 | ||
363 | |||
519 | bool PlayListWidget::prev() { | 364 | bool PlayListWidget::prev() { |
520 | if ( mediaPlayerState->playlist() ) { | 365 | if ( mediaPlayerState->playlist() ) { |
521 | if ( mediaPlayerState->shuffled() ) { | 366 | if ( mediaPlayerState->shuffled() ) { |
522 | const DocLnk *cur = current(); | 367 | const DocLnk *cur = current(); |
@@ -525,10 +370,11 @@ bool PlayListWidget::prev() { | |||
525 | if ( !d->selectedFiles->next() ) | 370 | if ( !d->selectedFiles->next() ) |
526 | d->selectedFiles->first(); | 371 | d->selectedFiles->first(); |
527 | } | 372 | } |
528 | if ( cur == current() ) | 373 | if ( cur == current() ) |
529 | if ( !d->selectedFiles->next() ) | 374 | if ( !d->selectedFiles->next() ) { |
530 | d->selectedFiles->first(); | 375 | d->selectedFiles->first(); |
376 | } | ||
531 | return TRUE; | 377 | return TRUE; |
532 | } else { | 378 | } else { |
533 | if ( !d->selectedFiles->prev() ) { | 379 | if ( !d->selectedFiles->prev() ) { |
534 | if ( mediaPlayerState->looping() ) { | 380 | if ( mediaPlayerState->looping() ) { |
@@ -629,25 +475,19 @@ void PlayListWidget::loadList( const DocLnk & lnk) { | |||
629 | Config config( "OpiePlayer" ); | 475 | Config config( "OpiePlayer" ); |
630 | config.writeEntry("CurrentPlaylist", name); | 476 | config.writeEntry("CurrentPlaylist", name); |
631 | // d->selectedFiles->first(); | 477 | // d->selectedFiles->first(); |
632 | } | 478 | } |
633 | |||
634 | } | 479 | } |
635 | 480 | ||
481 | |||
636 | void PlayListWidget::setPlaylist( bool shown ) { | 482 | void PlayListWidget::setPlaylist( bool shown ) { |
637 | if ( shown ) { | 483 | if ( shown ) { |
638 | d->playListFrame->show(); | 484 | d->playListFrame->show(); |
639 | } else { | 485 | } else { |
640 | d->playListFrame->hide(); | 486 | d->playListFrame->hide(); |
641 | } | 487 | } |
642 | } | 488 | } |
643 | 489 | ||
644 | void PlayListWidget::setView( char view ) { | ||
645 | if ( view == 'l' ) | ||
646 | showMaximized(); | ||
647 | else | ||
648 | hide(); | ||
649 | } | ||
650 | 490 | ||
651 | void PlayListWidget::addSelected() { | 491 | void PlayListWidget::addSelected() { |
652 | 492 | ||
653 | Config cfg( "OpiePlayer" ); | 493 | Config cfg( "OpiePlayer" ); |
@@ -696,19 +536,22 @@ void PlayListWidget::addSelected() { | |||
696 | break; | 536 | break; |
697 | }; | 537 | }; |
698 | } | 538 | } |
699 | 539 | ||
540 | |||
700 | void PlayListWidget::removeSelected() { | 541 | void PlayListWidget::removeSelected() { |
701 | d->selectedFiles->removeSelected( ); | 542 | d->selectedFiles->removeSelected( ); |
702 | } | 543 | } |
703 | 544 | ||
545 | |||
704 | void PlayListWidget::playIt( QListViewItem *it) { | 546 | void PlayListWidget::playIt( QListViewItem *it) { |
705 | if(!it) return; | 547 | if(!it) return; |
706 | mediaPlayerState->setPlaying(FALSE); | 548 | mediaPlayerState->setPlaying(FALSE); |
707 | mediaPlayerState->setPlaying(TRUE); | 549 | mediaPlayerState->setPlaying(TRUE); |
708 | d->selectedFiles->unSelect(); | 550 | d->selectedFiles->unSelect(); |
709 | } | 551 | } |
710 | 552 | ||
553 | |||
711 | void PlayListWidget::addToSelection( QListViewItem *it) { | 554 | void PlayListWidget::addToSelection( QListViewItem *it) { |
712 | d->setDocumentUsed = FALSE; | 555 | d->setDocumentUsed = FALSE; |
713 | 556 | ||
714 | if(it) { | 557 | if(it) { |
@@ -739,15 +582,17 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
739 | tabWidget->setCurrentPage(0); | 582 | tabWidget->setCurrentPage(0); |
740 | } | 583 | } |
741 | } | 584 | } |
742 | 585 | ||
586 | |||
743 | void PlayListWidget::tabChanged(QWidget *) { | 587 | void PlayListWidget::tabChanged(QWidget *) { |
744 | 588 | ||
745 | switch ( tabWidget->currentPageIndex()) { | 589 | switch ( tabWidget->currentPageIndex()) { |
746 | case 0: | 590 | case 0: |
747 | { | 591 | { |
748 | if( !tbDeletePlaylist->isHidden()) | 592 | if( !tbDeletePlaylist->isHidden() ) { |
749 | tbDeletePlaylist->hide(); | 593 | tbDeletePlaylist->hide(); |
594 | } | ||
750 | d->tbRemoveFromList->setEnabled(TRUE); | 595 | d->tbRemoveFromList->setEnabled(TRUE); |
751 | d->tbAddToList->setEnabled(FALSE); | 596 | d->tbAddToList->setEnabled(FALSE); |
752 | } | 597 | } |
753 | break; | 598 | break; |
@@ -755,36 +600,39 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
755 | { | 600 | { |
756 | audioView->clear(); | 601 | audioView->clear(); |
757 | populateAudioView(); | 602 | populateAudioView(); |
758 | 603 | ||
759 | if( !tbDeletePlaylist->isHidden()) | 604 | if( !tbDeletePlaylist->isHidden() ) { |
760 | tbDeletePlaylist->hide(); | 605 | tbDeletePlaylist->hide(); |
606 | } | ||
761 | d->tbRemoveFromList->setEnabled(FALSE); | 607 | d->tbRemoveFromList->setEnabled(FALSE); |
762 | d->tbAddToList->setEnabled(TRUE); | 608 | d->tbAddToList->setEnabled(TRUE); |
763 | } | 609 | } |
764 | break; | 610 | break; |
765 | case 2: | 611 | case 2: |
766 | { | 612 | { |
767 | videoView->clear(); | 613 | videoView->clear(); |
768 | populateVideoView(); | 614 | populateVideoView(); |
769 | if( !tbDeletePlaylist->isHidden()) | 615 | if( !tbDeletePlaylist->isHidden() ) { |
770 | tbDeletePlaylist->hide(); | 616 | tbDeletePlaylist->hide(); |
617 | } | ||
771 | d->tbRemoveFromList->setEnabled(FALSE); | 618 | d->tbRemoveFromList->setEnabled(FALSE); |
772 | d->tbAddToList->setEnabled(TRUE); | 619 | d->tbAddToList->setEnabled(TRUE); |
773 | } | 620 | } |
774 | break; | 621 | break; |
775 | case 3: | 622 | case 3: |
776 | { | 623 | { |
777 | if( tbDeletePlaylist->isHidden()) | 624 | if( tbDeletePlaylist->isHidden() ) { |
778 | tbDeletePlaylist->show(); | 625 | tbDeletePlaylist->show(); |
626 | } | ||
779 | playLists->reread(); | 627 | playLists->reread(); |
780 | } | 628 | } |
781 | break; | 629 | break; |
782 | }; | 630 | }; |
783 | } | 631 | } |
784 | 632 | ||
785 | void PlayListWidget::btnPlay(bool b) { | ||
786 | 633 | ||
634 | void PlayListWidget::btnPlay(bool b) { | ||
787 | // mediaPlayerState->setPlaying(b); | 635 | // mediaPlayerState->setPlaying(b); |
788 | switch ( tabWidget->currentPageIndex()) { | 636 | switch ( tabWidget->currentPageIndex()) { |
789 | case 0: | 637 | case 0: |
790 | { | 638 | { |
@@ -829,42 +677,13 @@ void PlayListWidget::deletePlaylist() { | |||
829 | break; | 677 | break; |
830 | }; | 678 | }; |
831 | } | 679 | } |
832 | 680 | ||
833 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | ||
834 | switch (mouse) { | ||
835 | case 1: | ||
836 | break; | ||
837 | case 2:{ | ||
838 | QPopupMenu m; | ||
839 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | ||
840 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | ||
841 | m.exec( QCursor::pos() ); | ||
842 | } | ||
843 | break; | ||
844 | }; | ||
845 | } | ||
846 | 681 | ||
847 | void PlayListWidget::playSelected() { | 682 | void PlayListWidget::playSelected() { |
848 | btnPlay( TRUE); | 683 | btnPlay( TRUE); |
849 | } | 684 | } |
850 | 685 | ||
851 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | ||
852 | switch (mouse) { | ||
853 | case 1: | ||
854 | |||
855 | break; | ||
856 | case 2: | ||
857 | { | ||
858 | QPopupMenu m; | ||
859 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | ||
860 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | ||
861 | m.exec( QCursor::pos() ); | ||
862 | } | ||
863 | break; | ||
864 | }; | ||
865 | } | ||
866 | |||
867 | 686 | ||
868 | void PlayListWidget::scanForAudio() { | 687 | void PlayListWidget::scanForAudio() { |
869 | // qDebug("scan for audio"); | 688 | // qDebug("scan for audio"); |
870 | files.detachChildren(); | 689 | files.detachChildren(); |
@@ -887,13 +706,14 @@ void PlayListWidget::scanForVideo() { | |||
887 | videoScan = TRUE; | 706 | videoScan = TRUE; |
888 | } | 707 | } |
889 | 708 | ||
890 | void PlayListWidget::populateAudioView() { | 709 | void PlayListWidget::populateAudioView() { |
891 | |||
892 | audioView->clear(); | 710 | audioView->clear(); |
893 | StorageInfo storageInfo; | 711 | StorageInfo storageInfo; |
894 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 712 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
895 | if(!audioScan) scanForAudio(); | 713 | if(!audioScan) { |
714 | scanForAudio(); | ||
715 | } | ||
896 | 716 | ||
897 | QListIterator<DocLnk> dit( files.children() ); | 717 | QListIterator<DocLnk> dit( files.children() ); |
898 | QListIterator<FileSystem> it ( fs ); | 718 | QListIterator<FileSystem> it ( fs ); |
899 | 719 | ||
@@ -901,9 +721,11 @@ void PlayListWidget::populateAudioView() { | |||
901 | for ( ; dit.current(); ++dit ) { | 721 | for ( ; dit.current(); ++dit ) { |
902 | for( ; it.current(); ++it ){ | 722 | for( ; it.current(); ++it ){ |
903 | const QString name = (*it)->name(); | 723 | const QString name = (*it)->name(); |
904 | const QString path = (*it)->path(); | 724 | const QString path = (*it)->path(); |
905 | if(dit.current()->file().find(path) != -1 ) storage=name; | 725 | if(dit.current()->file().find(path) != -1 ) { |
726 | storage = name; | ||
727 | } | ||
906 | } | 728 | } |
907 | 729 | ||
908 | QListViewItem * newItem; | 730 | QListViewItem * newItem; |
909 | if ( QFile( dit.current()->file()).exists() ) { | 731 | if ( QFile( dit.current()->file()).exists() ) { |
@@ -912,17 +734,19 @@ void PlayListWidget::populateAudioView() { | |||
912 | QString::number( QFile( dit.current()->file()).size() ), storage); | 734 | QString::number( QFile( dit.current()->file()).size() ), storage); |
913 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); | 735 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); |
914 | } | 736 | } |
915 | } | 737 | } |
916 | |||
917 | } | 738 | } |
918 | 739 | ||
740 | |||
919 | void PlayListWidget::populateVideoView() { | 741 | void PlayListWidget::populateVideoView() { |
920 | videoView->clear(); | 742 | videoView->clear(); |
921 | StorageInfo storageInfo; | 743 | StorageInfo storageInfo; |
922 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 744 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
923 | 745 | ||
924 | if(!videoScan ) scanForVideo(); | 746 | if(!videoScan ) { |
747 | scanForVideo(); | ||
748 | } | ||
925 | 749 | ||
926 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 750 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
927 | QListIterator<FileSystem> it ( fs ); | 751 | QListIterator<FileSystem> it ( fs ); |
928 | videoView->clear(); | 752 | videoView->clear(); |
@@ -930,9 +754,11 @@ void PlayListWidget::populateVideoView() { | |||
930 | for ( ; Vdit.current(); ++Vdit ) { | 754 | for ( ; Vdit.current(); ++Vdit ) { |
931 | for( ; it.current(); ++it ){ | 755 | for( ; it.current(); ++it ){ |
932 | const QString name = (*it)->name(); | 756 | const QString name = (*it)->name(); |
933 | const QString path = (*it)->path(); | 757 | const QString path = (*it)->path(); |
934 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 758 | if( Vdit.current()->file().find(path) != -1 ) { |
759 | storage=name; | ||
760 | } | ||
935 | } | 761 | } |
936 | 762 | ||
937 | QListViewItem * newItem; | 763 | QListViewItem * newItem; |
938 | if ( QFile( Vdit.current()->file()).exists() ) { | 764 | if ( QFile( Vdit.current()->file()).exists() ) { |
@@ -942,8 +768,9 @@ void PlayListWidget::populateVideoView() { | |||
942 | } | 768 | } |
943 | } | 769 | } |
944 | } | 770 | } |
945 | 771 | ||
772 | |||
946 | void PlayListWidget::openFile() { | 773 | void PlayListWidget::openFile() { |
947 | QString filename, name; | 774 | QString filename, name; |
948 | InputDialog *fileDlg; | 775 | InputDialog *fileDlg; |
949 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 776 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
@@ -958,9 +785,8 @@ void PlayListWidget::openFile() { | |||
958 | readPls( filename ); | 785 | readPls( filename ); |
959 | } else { | 786 | } else { |
960 | /* FIXME ....... AUDIO/X-MPEGURL is bad*/ | 787 | /* FIXME ....... AUDIO/X-MPEGURL is bad*/ |
961 | DocLnk lnk; | 788 | DocLnk lnk; |
962 | |||
963 | lnk.setName(filename); //sets file name | 789 | lnk.setName(filename); //sets file name |
964 | lnk.setFile(filename); //sets File property | 790 | lnk.setFile(filename); //sets File property |
965 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); | 791 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); |
966 | lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); | 792 | lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); |
@@ -977,10 +803,9 @@ void PlayListWidget::openFile() { | |||
977 | delete fileDlg; | 803 | delete fileDlg; |
978 | } | 804 | } |
979 | } | 805 | } |
980 | 806 | ||
981 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 807 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
982 | { | ||
983 | switch ( e->key() ) { | 808 | switch ( e->key() ) { |
984 | ////////////////////////////// Zaurus keys | 809 | ////////////////////////////// Zaurus keys |
985 | case Key_F9: //activity | 810 | case Key_F9: //activity |
986 | // if(audioUI->isHidden()) | 811 | // if(audioUI->isHidden()) |
@@ -1036,35 +861,9 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1036 | 861 | ||
1037 | } | 862 | } |
1038 | } | 863 | } |
1039 | 864 | ||
1040 | void PlayListWidget::keyPressEvent( QKeyEvent *) | ||
1041 | { | ||
1042 | // qDebug("Key press"); | ||
1043 | // switch ( e->key() ) { | ||
1044 | // ////////////////////////////// Zaurus keys | ||
1045 | // case Key_A: //add to playlist | ||
1046 | // qDebug("Add"); | ||
1047 | // addSelected(); | ||
1048 | // break; | ||
1049 | // case Key_R: //remove from playlist | ||
1050 | // removeSelected(); | ||
1051 | // break; | ||
1052 | // case Key_P: //play | ||
1053 | // qDebug("Play"); | ||
1054 | // playSelected(); | ||
1055 | // break; | ||
1056 | // case Key_Space: | ||
1057 | // qDebug("Play"); | ||
1058 | // playSelected(); | ||
1059 | // break; | ||
1060 | // } | ||
1061 | } | ||
1062 | |||
1063 | |||
1064 | |||
1065 | void PlayListWidget::readm3u(const QString &filename) { | 865 | void PlayListWidget::readm3u(const QString &filename) { |
1066 | |||
1067 | qDebug("m3u filename is "+filename); | 866 | qDebug("m3u filename is "+filename); |
1068 | QFile f(filename); | 867 | QFile f(filename); |
1069 | 868 | ||
1070 | if(f.open(IO_ReadOnly)) { | 869 | if(f.open(IO_ReadOnly)) { |
@@ -1077,9 +876,8 @@ void PlayListWidget::readm3u(const QString &filename) { | |||
1077 | if(s.find("#",0,TRUE) == -1) { | 876 | if(s.find("#",0,TRUE) == -1) { |
1078 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 877 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1079 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 878 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1080 | s=s.right(s.length()-2); | 879 | s=s.right(s.length()-2); |
1081 | // if(QFile(s).exists()) { | ||
1082 | DocLnk lnk( s ); | 880 | DocLnk lnk( s ); |
1083 | QFileInfo f(s); | 881 | QFileInfo f(s); |
1084 | QString name = f.baseName(); | 882 | QString name = f.baseName(); |
1085 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 883 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
@@ -1088,9 +886,8 @@ void PlayListWidget::readm3u(const QString &filename) { | |||
1088 | lnk.setFile( s ); | 886 | lnk.setFile( s ); |
1089 | lnk.writeLink(); | 887 | lnk.writeLink(); |
1090 | qDebug("add "+name); | 888 | qDebug("add "+name); |
1091 | d->selectedFiles->addToSelection( lnk); | 889 | d->selectedFiles->addToSelection( lnk); |
1092 | // } | ||
1093 | } else { // is url | 890 | } else { // is url |
1094 | s.replace(QRegExp("%20")," "); | 891 | s.replace(QRegExp("%20")," "); |
1095 | DocLnk lnk( s ); | 892 | DocLnk lnk( s ); |
1096 | QString name; | 893 | QString name; |
@@ -1117,9 +914,8 @@ void PlayListWidget::readm3u(const QString &filename) { | |||
1117 | f.close(); | 914 | f.close(); |
1118 | } | 915 | } |
1119 | 916 | ||
1120 | void PlayListWidget::writem3u() { | 917 | void PlayListWidget::writem3u() { |
1121 | |||
1122 | InputDialog *fileDlg; | 918 | InputDialog *fileDlg; |
1123 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 919 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1124 | fileDlg->exec(); | 920 | fileDlg->exec(); |
1125 | QString filename,list; | 921 | QString filename,list; |
@@ -1130,24 +926,29 @@ void PlayListWidget::writem3u() { | |||
1130 | d->selectedFiles->first(); | 926 | d->selectedFiles->first(); |
1131 | do { | 927 | do { |
1132 | // we dont check for existance because of url's | 928 | // we dont check for existance because of url's |
1133 | // qDebug(d->selectedFiles->current()->file()); | 929 | // qDebug(d->selectedFiles->current()->file()); |
930 | |||
931 | // so maybe we should do some net checking to ,-) | ||
1134 | list += d->selectedFiles->current()->file()+"\n"; | 932 | list += d->selectedFiles->current()->file()+"\n"; |
1135 | noOfFiles++; | 933 | noOfFiles++; |
1136 | } | 934 | } |
1137 | while ( d->selectedFiles->next() ); | 935 | while ( d->selectedFiles->next() ); |
1138 | qDebug(list); | 936 | qDebug(list); |
1139 | if(filename.left(1) != "/") | 937 | if( filename.left( 1) != "/" ) { |
1140 | filename=QPEApplication::documentDir()+"/"+filename; | 938 | filename=QPEApplication::documentDir()+"/"+filename; |
1141 | if(filename.right(3) != "m3u") | 939 | } |
940 | if( filename.right( 3 ) != "m3u" ) { | ||
1142 | filename=filename+".m3u"; | 941 | filename=filename+".m3u"; |
1143 | 942 | } | |
1144 | QFile f(filename); | 943 | QFile f(filename); |
1145 | f.open(IO_WriteOnly); | 944 | f.open(IO_WriteOnly); |
1146 | f.writeBlock(list, list.length()); | 945 | f.writeBlock(list, list.length()); |
1147 | f.close(); | 946 | f.close(); |
1148 | } | 947 | } |
1149 | if(fileDlg) delete fileDlg; | 948 | if( fileDlg ) { |
949 | delete fileDlg; | ||
950 | } | ||
1150 | } | 951 | } |
1151 | 952 | ||
1152 | void PlayListWidget::readPls(const QString &filename) { | 953 | void PlayListWidget::readPls(const QString &filename) { |
1153 | 954 | ||
@@ -1173,24 +974,26 @@ void PlayListWidget::readPls(const QString &filename) { | |||
1173 | s=s.replace( QRegExp("\\"),"/"); | 974 | s=s.replace( QRegExp("\\"),"/"); |
1174 | DocLnk lnk( s ); | 975 | DocLnk lnk( s ); |
1175 | QFileInfo f(s); | 976 | QFileInfo f(s); |
1176 | QString name = f.baseName(); | 977 | QString name = f.baseName(); |
1177 | if(name.left(4)=="http") | 978 | if( name.left( 4 ) == "http" ) { |
1178 | name = s.right( s.length() - 7); | 979 | name = s.right( s.length() - 7); |
1179 | else | 980 | } else { |
1180 | name=s; | 981 | name=s; |
982 | } | ||
1181 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 983 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1182 | lnk.setName( name); | 984 | lnk.setName( name); |
1183 | if(s.at(s.length()-4) == '.') // if this is probably a file | 985 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1184 | lnk.setFile( s); | 986 | lnk.setFile( s); |
1185 | else { //if its a url | 987 | else { //if its a url |
1186 | if( name.right(1).find('/') == -1) | 988 | if( name.right( 1 ).find( '/' ) == -1) { |
1187 | s+="/"; | 989 | s+="/"; |
990 | } | ||
1188 | lnk.setFile( s); | 991 | lnk.setFile( s); |
1189 | } | 992 | } |
1190 | lnk.setType("audio/x-mpegurl"); | 993 | lnk.setType("audio/x-mpegurl"); |
1191 | 994 | ||
1192 | qDebug("DocLnk add "+name); | 995 | //qDebug("DocLnk add "+name); |
1193 | d->selectedFiles->addToSelection( lnk); | 996 | d->selectedFiles->addToSelection( lnk); |
1194 | } | 997 | } |
1195 | } | 998 | } |
1196 | i++; | 999 | i++; |
@@ -1201,15 +1004,13 @@ void PlayListWidget::pmViewActivated(int index) { | |||
1201 | // qDebug("%d", index); | 1004 | // qDebug("%d", index); |
1202 | switch(index) { | 1005 | switch(index) { |
1203 | case -16: | 1006 | case -16: |
1204 | { | 1007 | { |
1205 | |||
1206 | mediaPlayerState->toggleFullscreen(); | 1008 | mediaPlayerState->toggleFullscreen(); |
1207 | bool b=mediaPlayerState->fullscreen(); | 1009 | bool b=mediaPlayerState->fullscreen(); |
1208 | pmView->setItemChecked( index,b); | 1010 | pmView->setItemChecked( index,b); |
1209 | Config cfg( "OpiePlayer" ); | 1011 | Config cfg( "OpiePlayer" ); |
1210 | cfg.writeEntry("FullScreen", b); | 1012 | cfg.writeEntry("FullScreen", b); |
1211 | |||
1212 | } | 1013 | } |
1213 | break; | 1014 | break; |
1214 | }; | 1015 | }; |
1215 | } | 1016 | } |
@@ -1230,15 +1031,17 @@ void PlayListWidget::populateSkinsMenu() { | |||
1230 | QFileInfo *fi; | 1031 | QFileInfo *fi; |
1231 | while ( (fi=it.current()) ) { | 1032 | while ( (fi=it.current()) ) { |
1232 | skinName = fi->fileName(); | 1033 | skinName = fi->fileName(); |
1233 | qDebug( fi->fileName()); | 1034 | qDebug( fi->fileName()); |
1234 | if( skinName != "." && skinName != ".." && skinName !="CVS") | 1035 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1235 | item = skinsMenu->insertItem( fi->fileName()); | 1036 | item = skinsMenu->insertItem( fi->fileName()); |
1236 | if( skinName == "default") | 1037 | } |
1038 | if( skinName == "default" ) { | ||
1237 | defaultSkinIndex = item; | 1039 | defaultSkinIndex = item; |
1238 | if( skinName == skin) | 1040 | } |
1041 | if( skinName == skin ) { | ||
1239 | skinsMenu->setItemChecked( item, TRUE); | 1042 | skinsMenu->setItemChecked( item, TRUE); |
1240 | 1043 | } | |
1241 | ++it; | 1044 | ++it; |
1242 | } | 1045 | } |
1243 | } | 1046 | } |
1244 | 1047 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 8710a99..2742252 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,4 +1,36 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
1 | 33 | ||
2 | #ifndef PLAY_LIST_WIDGET_H | 34 | #ifndef PLAY_LIST_WIDGET_H |
3 | #define PLAY_LIST_WIDGET_H | 35 | #define PLAY_LIST_WIDGET_H |
4 | 36 | ||
@@ -8,67 +40,54 @@ | |||
8 | #include <qpe/fileselector.h> | 40 | #include <qpe/fileselector.h> |
9 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
10 | #include <qpopupmenu.h> | 42 | #include <qpopupmenu.h> |
11 | 43 | ||
12 | /* #include <qtimer.h> */ | 44 | #include "playlistwidgetgui.h" |
13 | 45 | ||
14 | 46 | ||
15 | class PlayListWidgetPrivate; | 47 | //class PlayListWidgetPrivate; |
16 | class Config; | 48 | class Config; |
17 | class QListViewItem; | 49 | class QListViewItem; |
18 | class QListView; | 50 | class QListView; |
19 | class QPoint; | 51 | class QPoint; |
20 | class QAction; | 52 | class QAction; |
21 | class QLabel; | 53 | class QLabel; |
22 | 54 | ||
23 | class PlayListWidget : public QMainWindow { | 55 | class PlayListWidget : public PlayListWidgetGui { |
24 | Q_OBJECT | 56 | Q_OBJECT |
25 | public: | 57 | public: |
26 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 58 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
27 | ~PlayListWidget(); | 59 | ~PlayListWidget(); |
28 | QTabWidget * tabWidget; | ||
29 | // MenuItem *fullScreenButton, *scaleButton; | ||
30 | // QAction *fullScreenButton, *scaleButton; | ||
31 | DocLnkSet files; | 60 | DocLnkSet files; |
32 | DocLnkSet vFiles; | 61 | DocLnkSet vFiles; |
33 | QListView *audioView, *videoView, *playlistView; | ||
34 | QLabel *libString; | ||
35 | QPopupMenu *pmView ; | ||
36 | bool fromSetDocument; | 62 | bool fromSetDocument; |
37 | bool insanityBool; | 63 | bool insanityBool; |
38 | QString setDocFileRef; | 64 | QString setDocFileRef; |
39 | // retrieve the current playlist entry (media file link) | 65 | // retrieve the current playlist entry (media file link) |
40 | const DocLnk *current(); | 66 | const DocLnk *current(); |
41 | void useSelectedDocument(); | 67 | void useSelectedDocument(); |
42 | /* QTimer * menuTimer; */ | ||
43 | FileSelector* playLists; | ||
44 | QPushButton *tbDeletePlaylist; | ||
45 | int selected; | 68 | int selected; |
69 | |||
46 | public slots: | 70 | public slots: |
47 | bool first(); | 71 | bool first(); |
48 | bool last(); | 72 | bool last(); |
49 | bool next(); | 73 | bool next(); |
50 | bool prev(); | 74 | bool prev(); |
51 | void writeConfig( Config& cfg ) const; | 75 | void writeConfig( Config& cfg ) const; |
52 | /* void setFullScreen(); */ | 76 | |
53 | /* void setScaled(); */ | ||
54 | protected: | 77 | protected: |
55 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | ||
56 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | ||
57 | void keyReleaseEvent( QKeyEvent *e); | 78 | void keyReleaseEvent( QKeyEvent *e); |
58 | void keyPressEvent( QKeyEvent *e); | 79 | |
59 | private: | 80 | private: |
60 | int defaultSkinIndex; | 81 | int defaultSkinIndex; |
61 | QPopupMenu *skinsMenu; | ||
62 | bool audioScan, videoScan; | 82 | bool audioScan, videoScan; |
63 | void readm3u(const QString &); | 83 | void readm3u(const QString &); |
64 | void readPls(const QString &); | 84 | void readPls(const QString &); |
65 | |||
66 | void initializeStates(); | 85 | void initializeStates(); |
67 | void readConfig( Config& cfg ); | 86 | void readConfig( Config& cfg ); |
68 | PlayListWidgetPrivate *d; // Private implementation data | ||
69 | void populateAudioView(); | 87 | void populateAudioView(); |
70 | void populateVideoView(); | 88 | void populateVideoView(); |
89 | |||
71 | private slots: | 90 | private slots: |
72 | void populateSkinsMenu(); | 91 | void populateSkinsMenu(); |
73 | void skinsMenuActivated(int); | 92 | void skinsMenuActivated(int); |
74 | void pmViewActivated(int); | 93 | void pmViewActivated(int); |
@@ -78,34 +97,24 @@ private slots: | |||
78 | void openFile(); | 97 | void openFile(); |
79 | void setDocument( const QString& fileref ); | 98 | void setDocument( const QString& fileref ); |
80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 99 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 100 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
82 | void setActiveWindow(); // need to handle this to show the right view | ||
83 | void setPlaylist( bool ); // Show/Hide the playlist | 101 | void setPlaylist( bool ); // Show/Hide the playlist |
84 | void setView( char ); | ||
85 | void clearList(); | 102 | void clearList(); |
86 | void addAllToList(); | 103 | void addAllToList(); |
87 | void addAllMusicToList(); | 104 | void addAllMusicToList(); |
88 | void addAllVideoToList(); | 105 | void addAllVideoToList(); |
89 | void saveList(); // Save the playlist | 106 | void saveList(); // Save the playlist |
90 | void loadList( const DocLnk &); // Load a playlist | 107 | void loadList( const DocLnk &); // Load a playlist |
91 | void playIt( QListViewItem *); | 108 | void playIt( QListViewItem *); |
92 | |||
93 | void btnPlay(bool); | 109 | void btnPlay(bool); |
94 | void deletePlaylist(); | 110 | void deletePlaylist(); |
95 | void addSelected(); | 111 | void addSelected(); |
96 | void removeSelected(); | 112 | void removeSelected(); |
97 | void tabChanged(QWidget*); | 113 | void tabChanged(QWidget*); |
98 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 114 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 115 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
100 | void playSelected(); | 116 | void playSelected(); |
101 | |||
102 | protected slots: | ||
103 | /* void cancelMenuTimer(); */ | ||
104 | /* void showFileMenu(); */ | ||
105 | |||
106 | |||
107 | }; | 117 | }; |
108 | 118 | ||
109 | |||
110 | #endif // PLAY_LIST_WIDGET_H | 119 | #endif // PLAY_LIST_WIDGET_H |
111 | 120 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp new file mode 100644 index 0000000..6ecd016 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -0,0 +1,207 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #include <qpe/qpemenubar.h> | ||
35 | #include <qpe/qpetoolbar.h> | ||
36 | #include <qpe/fileselector.h> | ||
37 | #include <qpe/qpeapplication.h> | ||
38 | #include <qpe/storage.h> | ||
39 | #include <qpe/mimetype.h> | ||
40 | #include <qpe/config.h> | ||
41 | #include <qpe/global.h> | ||
42 | #include <qpe/resource.h> | ||
43 | |||
44 | #include <qpopupmenu.h> | ||
45 | #include <qaction.h> | ||
46 | #include <qcursor.h> | ||
47 | #include <qdir.h> | ||
48 | #include <qlayout.h> | ||
49 | |||
50 | #include "playlistselection.h" | ||
51 | #include "playlistwidget.h" | ||
52 | #include "mediaplayerstate.h" | ||
53 | #include "inputDialog.h" | ||
54 | |||
55 | //only needed for the random play | ||
56 | #include <stdlib.h> | ||
57 | |||
58 | #include "audiowidget.h" | ||
59 | #include "videowidget.h" | ||
60 | #include "mediaplayerstate.h" | ||
61 | |||
62 | extern MediaPlayerState *mediaPlayerState; | ||
63 | |||
64 | PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) | ||
65 | : QMainWindow( parent, name, fl ) { | ||
66 | |||
67 | d = new PlayListWidgetPrivate; | ||
68 | d->setDocumentUsed = FALSE; | ||
69 | d->current = NULL; | ||
70 | |||
71 | setBackgroundMode( PaletteButton ); | ||
72 | setToolBarsMovable( FALSE ); | ||
73 | |||
74 | // Create Toolbar | ||
75 | QPEToolBar *toolbar = new QPEToolBar( this ); | ||
76 | toolbar->setHorizontalStretchable( TRUE ); | ||
77 | |||
78 | // Create Menubar | ||
79 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | ||
80 | menu->setMargin( 0 ); | ||
81 | |||
82 | bar = new QPEToolBar( this ); | ||
83 | bar->setLabel( tr( "Play Operations" ) ); | ||
84 | |||
85 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | ||
86 | tbDeletePlaylist->setFlat( TRUE ); | ||
87 | tbDeletePlaylist->setFixedSize( 20, 20 ); | ||
88 | |||
89 | tbDeletePlaylist->hide(); | ||
90 | |||
91 | pmPlayList = new QPopupMenu( this ); | ||
92 | menu->insertItem( tr( "File" ), pmPlayList ); | ||
93 | |||
94 | pmView = new QPopupMenu( this ); | ||
95 | menu->insertItem( tr( "View" ), pmView ); | ||
96 | pmView->isCheckable(); | ||
97 | |||
98 | skinsMenu = new QPopupMenu( this ); | ||
99 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | ||
100 | skinsMenu->isCheckable(); | ||
101 | |||
102 | vbox5 = new QVBox( this ); | ||
103 | QVBox *vbox4 = new QVBox( vbox5 ); | ||
104 | QHBox *hbox6 = new QHBox( vbox4 ); | ||
105 | |||
106 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | ||
107 | |||
108 | QWidget *pTab; | ||
109 | pTab = new QWidget( tabWidget, "pTab" ); | ||
110 | tabWidget->insertTab( pTab,"Playlist"); | ||
111 | |||
112 | QGridLayout *Playout = new QGridLayout( pTab ); | ||
113 | Playout->setSpacing( 2); | ||
114 | Playout->setMargin( 2); | ||
115 | |||
116 | // Add the playlist area | ||
117 | QVBox *vbox3 = new QVBox( pTab ); | ||
118 | d->playListFrame = vbox3; | ||
119 | |||
120 | QHBox *hbox2 = new QHBox( vbox3 ); | ||
121 | d->selectedFiles = new PlayListSelection( hbox2 ); | ||
122 | |||
123 | vbox1 = new QVBox( hbox2 ); | ||
124 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | ||
125 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | ||
126 | |||
127 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | ||
128 | |||
129 | QWidget *aTab; | ||
130 | aTab = new QWidget( tabWidget, "aTab" ); | ||
131 | |||
132 | QGridLayout *Alayout = new QGridLayout( aTab ); | ||
133 | Alayout->setSpacing( 2 ); | ||
134 | Alayout->setMargin( 2 ); | ||
135 | audioView = new QListView( aTab, "Audioview" ); | ||
136 | audioView->addColumn( tr( "Title" ), 140 ); | ||
137 | audioView->addColumn( tr( "Size" ), -1 ); | ||
138 | audioView->addColumn( tr( "Media" ), -1 ); | ||
139 | audioView->setColumnAlignment( 1, Qt::AlignRight ); | ||
140 | audioView->setColumnAlignment( 2, Qt::AlignRight ); | ||
141 | audioView->setAllColumnsShowFocus( TRUE ); | ||
142 | audioView->setSorting( 0, TRUE ); | ||
143 | audioView->setMultiSelection( TRUE ); | ||
144 | audioView->setSelectionMode( QListView::Extended ); | ||
145 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | ||
146 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | ||
147 | |||
148 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | ||
149 | |||
150 | QWidget *vTab; | ||
151 | vTab = new QWidget( tabWidget, "vTab" ); | ||
152 | |||
153 | QGridLayout *Vlayout = new QGridLayout( vTab ); | ||
154 | Vlayout->setSpacing( 2 ); | ||
155 | Vlayout->setMargin( 2 ); | ||
156 | videoView = new QListView( vTab, "Videoview" ); | ||
157 | videoView->addColumn( tr( "Title" ), 140); | ||
158 | videoView->addColumn( tr( "Size" ), -1 ); | ||
159 | videoView->addColumn(tr( "Media" ), -1 ); | ||
160 | videoView->setColumnAlignment( 1, Qt::AlignRight ); | ||
161 | videoView->setColumnAlignment( 2, Qt::AlignRight ); | ||
162 | videoView->setAllColumnsShowFocus( TRUE ); | ||
163 | videoView->setSorting( 0, TRUE ); | ||
164 | videoView->setMultiSelection( TRUE ); | ||
165 | videoView->setSelectionMode( QListView::Extended ); | ||
166 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | ||
167 | |||
168 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | ||
169 | |||
170 | tabWidget->insertTab( vTab, tr( "Video" ) ); | ||
171 | |||
172 | //playlists list | ||
173 | QWidget *LTab; | ||
174 | LTab = new QWidget( tabWidget, "LTab" ); | ||
175 | QGridLayout *Llayout = new QGridLayout( LTab ); | ||
176 | Llayout->setSpacing( 2 ); | ||
177 | Llayout->setMargin( 2 ); | ||
178 | |||
179 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE ); //buggy | ||
180 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | ||
181 | |||
182 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | ||
183 | |||
184 | setCentralWidget( vbox5 ); | ||
185 | } | ||
186 | |||
187 | |||
188 | |||
189 | PlayListWidgetGui::~PlayListWidgetGui() { | ||
190 | } | ||
191 | |||
192 | void PlayListWidgetGui::setView( char view ) { | ||
193 | if ( view == 'l' ) | ||
194 | showMaximized(); | ||
195 | else | ||
196 | hide(); | ||
197 | } | ||
198 | |||
199 | |||
200 | void PlayListWidgetGui::setActiveWindow() { | ||
201 | // qDebug("SETTING active window"); | ||
202 | // When we get raised we need to ensure that it switches views | ||
203 | char origView = mediaPlayerState->view(); | ||
204 | mediaPlayerState->setView( 'l' ); // invalidate | ||
205 | mediaPlayerState->setView( origView ); // now switch back | ||
206 | } | ||
207 | |||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h new file mode 100644 index 0000000..4c8d737 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h | |||
@@ -0,0 +1,126 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #ifndef PLAY_LIST_WIDGET_GUI_H | ||
35 | #define PLAY_LIST_WIDGET_GUI_H | ||
36 | |||
37 | #include <qmainwindow.h> | ||
38 | #include <qpe/applnk.h> | ||
39 | #include <qpe/resource.h> | ||
40 | #include <qpe/qpemenubar.h> | ||
41 | |||
42 | #include <qtabwidget.h> | ||
43 | #include <qpe/fileselector.h> | ||
44 | #include <qpushbutton.h> | ||
45 | #include <qpopupmenu.h> | ||
46 | #include <qaction.h> | ||
47 | |||
48 | |||
49 | class PlayListWidgetPrivate; | ||
50 | class PlayListSelection; | ||
51 | |||
52 | class Config; | ||
53 | class QPEToolBar; | ||
54 | class QListViewItem; | ||
55 | class QListView; | ||
56 | class QPoint; | ||
57 | class QAction; | ||
58 | class QLabel; | ||
59 | |||
60 | class PlayListWidgetPrivate { | ||
61 | public: | ||
62 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | ||
63 | QFrame *playListFrame; | ||
64 | FileSelector *files; | ||
65 | PlayListSelection *selectedFiles; | ||
66 | bool setDocumentUsed; | ||
67 | DocLnk *current; | ||
68 | }; | ||
69 | |||
70 | |||
71 | class ToolButton : public QToolButton { | ||
72 | public: | ||
73 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | ||
74 | : QToolButton( parent, name ) { | ||
75 | setTextLabel( name ); | ||
76 | setPixmap( Resource::loadPixmap( icon ) ); | ||
77 | setAutoRaise( TRUE ); | ||
78 | setFocusPolicy( QWidget::NoFocus ); | ||
79 | setToggleButton( t ); | ||
80 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | ||
81 | QPEMenuToolFocusManager::manager()->addWidget( this ); | ||
82 | } | ||
83 | }; | ||
84 | |||
85 | |||
86 | class MenuItem : public QAction { | ||
87 | |||
88 | public: | ||
89 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | ||
90 | : QAction( text, QString::null, 0, 0 ) { | ||
91 | connect( this, SIGNAL( activated() ), handler, slot ); | ||
92 | addTo( parent ); | ||
93 | } | ||
94 | }; | ||
95 | |||
96 | class PlayListWidgetGui : public QMainWindow { | ||
97 | Q_OBJECT | ||
98 | public: | ||
99 | PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | ||
100 | ~PlayListWidgetGui(); | ||
101 | |||
102 | protected: | ||
103 | QTabWidget * tabWidget; | ||
104 | QListView *audioView, *videoView, *playlistView; | ||
105 | QLabel *libString; | ||
106 | QPopupMenu *pmView ; | ||
107 | bool fromSetDocument; | ||
108 | bool insanityBool; | ||
109 | QString setDocFileRef; | ||
110 | // retrieve the current playlist entry (media file link) | ||
111 | QPushButton *tbDeletePlaylist; | ||
112 | int selected; | ||
113 | QPopupMenu *pmPlayList; | ||
114 | FileSelector* playLists; | ||
115 | QPopupMenu *skinsMenu; | ||
116 | PlayListWidgetPrivate *d; // Private implementation data | ||
117 | QVBox *vbox1; | ||
118 | QVBox *vbox5; | ||
119 | QPEToolBar *bar; | ||
120 | void setActiveWindow(); // need to handle this to show the right view | ||
121 | void setView( char ); | ||
122 | |||
123 | }; | ||
124 | |||
125 | #endif | ||
126 | |||