summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.cpp9
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.h1
-rw-r--r--noncore/multimedia/opieplayer3/playlist.cpp6
-rw-r--r--noncore/multimedia/opieplayer3/videowidget.cpp1
4 files changed, 14 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp
index 75d1490..0898c7b 100644
--- a/noncore/multimedia/opieplayer3/mwindow.cpp
+++ b/noncore/multimedia/opieplayer3/mwindow.cpp
@@ -1,477 +1,482 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9 .>+-= 9 .>+-=
10 _;:, .> :=|. This program is free software; you can 10 _;:, .> :=|. This program is free software; you can
11.> <`_, > . <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.-- : the terms of the GNU General Public 12:`=1 )Y*s>-.-- : the terms of the GNU General Public
13.="- .-=="i, .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - . .-<_> .<> Foundation; either version 2 of the License, 14 - . .-<_> .<> Foundation; either version 2 of the License,
15 ._= =} : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16 .%`+i> _;_. 16 .%`+i> _;_.
17 .i_,=:_. -<s. This program is distributed in the hope that 17 .i_,=:_. -<s. This program is distributed in the hope that
18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19 : .. .:, . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.= = ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++= -. .` .: details. 23++= -. .` .: details.
24 : = ...= . :.=- 24 : = ...= . :.=-
25 -. .:....=;==+<; You should have received a copy of the GNU 25 -. .:....=;==+<; You should have received a copy of the GNU
26 -_. . . )=. = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "mwindow.h" 34#include "mwindow.h"
35#include "playlist.h" 35#include "playlist.h"
36#include "audiowidget.h" 36#include "audiowidget.h"
37#include "videowidget.h" 37#include "videowidget.h"
38#include "../opieplayer2/lib.h" 38#include "../opieplayer2/lib.h"
39 39
40#include <opie2/oapplicationfactory.h> 40#include <opie2/oapplicationfactory.h>
41#include <opie2/owidgetstack.h> 41#include <opie2/owidgetstack.h>
42#include <opie2/ofileselector.h> 42#include <opie2/ofileselector.h>
43#include <opie2/odebug.h> 43#include <opie2/odebug.h>
44 44
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/qpeapplication.h>
46 47
47#include <qfileinfo.h> 48#include <qfileinfo.h>
48#include <qfile.h> 49#include <qfile.h>
49#include <qtoolbar.h> 50#include <qtoolbar.h>
50#include <qpopupmenu.h> 51#include <qpopupmenu.h>
51#include <qmenubar.h> 52#include <qmenubar.h>
52#include <qtimer.h> 53#include <qtimer.h>
53#include <qslider.h> 54#include <qslider.h>
54#include <qlayout.h> 55#include <qlayout.h>
55 56
56OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 57OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
57 58
58using namespace Opie::Ui; 59using namespace Opie::Ui;
59 60
60PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) 61PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
61 : QMainWindow(w,name,f) 62 : QMainWindow(w,name,f)
62{ 63{
63 checkLib(); 64 checkLib();
64 setCaption( QObject::tr("Opie Mediaplayer 3" ) ); 65 setCaption(appTitle());
65 66
66 m_MainBox = new QWidget(this); 67 m_MainBox = new QWidget(this);
67 68
68 QVBoxLayout*m_l = new QVBoxLayout(m_MainBox); 69 QVBoxLayout*m_l = new QVBoxLayout(m_MainBox);
69 70
70 m_stack = new OWidgetStack(m_MainBox); 71 m_stack = new OWidgetStack(m_MainBox);
71 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); 72 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
72 m_l->addWidget(m_stack); 73 m_l->addWidget(m_stack);
73 m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox); 74 m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox);
74 m_l->addWidget(m_PosSlider); 75 m_l->addWidget(m_PosSlider);
75 m_PosSlider->setEnabled(false); 76 m_PosSlider->setEnabled(false);
76 77
77 m_playList = new PlaylistView(m_stack,"playlist"); 78 m_playList = new PlaylistView(m_stack,"playlist");
78 m_stack->addWidget(m_playList,stack_list); 79 m_stack->addWidget(m_playList,stack_list);
79 connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int))); 80 connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int)));
80 m_sfl = new OFileSelector("video/*;audio/*",m_stack); 81 m_sfl = new OFileSelector("video/*;audio/*",m_stack);
81 m_stack->addWidget(m_sfl,stack_file); 82 m_stack->addWidget(m_sfl,stack_file);
82 connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &))); 83 connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &)));
83 m_AudioPlayer = new AudioWidget(m_stack); 84 m_AudioPlayer = new AudioWidget(m_stack);
84 m_stack->addWidget(m_AudioPlayer,stack_audio); 85 m_stack->addWidget(m_AudioPlayer,stack_audio);
85 connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int))); 86 connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int)));
86 m_VideoPlayer = new VideoWidget(m_stack); 87 m_VideoPlayer = new VideoWidget(m_stack);
87 m_stack->addWidget(m_VideoPlayer,stack_video); 88 m_stack->addWidget(m_VideoPlayer,stack_video);
88 connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); 89 connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int)));
89 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); 90 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
90 91
91 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int))); 92 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
92 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int))); 93 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
93 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); 94 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
94 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); 95 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
95 m_pressed = false; 96 m_pressed = false;
96 m_uppos=0; 97 m_uppos=0;
97 98
98 m_stack->raiseWidget(stack_list); 99 m_stack->raiseWidget(stack_list);
99 m_LastItem = 0; 100 m_LastItem = 0;
100 setupActions(); 101 setupActions();
101 setupToolBar(); 102 setupToolBar();
102 setupMenu(); 103 setupMenu();
103 104
104 setCentralWidget(m_MainBox ); 105 setCentralWidget(m_MainBox );
105} 106}
106 107
107void PMainWindow::slotListChanged(int count) 108void PMainWindow::slotListChanged(int count)
108{ 109{
109 playersGroup->setEnabled(count>0); 110 playersGroup->setEnabled(count>0);
110 if (!m_playList->isVisible()) { 111 if (!m_playList->isVisible()) {
111 return; 112 return;
112 } 113 }
113 a_removeFiles->setEnabled(count>0); 114 a_removeFiles->setEnabled(count>0);
114} 115}
115 116
116void PMainWindow::mediaWindowraised() 117void PMainWindow::mediaWindowraised()
117{ 118{
118 playlistOnly->setEnabled(false); 119 playlistOnly->setEnabled(false);
119 a_appendFiles->setEnabled(true); 120 a_appendFiles->setEnabled(true);
120 a_loadPlaylist->setEnabled(true); 121 a_loadPlaylist->setEnabled(true);
121 a_showPlaylist->setEnabled(true); 122 a_showPlaylist->setEnabled(true);
122 a_ShowMedia->setEnabled(false); 123 a_ShowMedia->setEnabled(false);
123} 124}
124 125
125void PMainWindow::checkLib() 126void PMainWindow::checkLib()
126{ 127{
127 if (m_PlayLib == 0) { 128 if (m_PlayLib == 0) {
128 m_PlayLib = new XINE::Lib(XINE::Lib::InitializeInThread); 129 m_PlayLib = new XINE::Lib(XINE::Lib::InitializeInThread);
129 qApp->processEvents(); 130 qApp->processEvents();
130// m_PlayLib->ensureInitialized(); 131// m_PlayLib->ensureInitialized();
131 connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped())); 132 connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
132 } 133 }
133} 134}
134 135
135PMainWindow::~PMainWindow() 136PMainWindow::~PMainWindow()
136{ 137{
137 if (m_PlayLib) { 138 if (m_PlayLib) {
138 m_PlayLib->stop(); 139 m_PlayLib->stop();
139 delete m_PlayLib; 140 delete m_PlayLib;
140 } 141 }
141} 142}
142 143
143void PMainWindow::fileSelected(const DocLnk&) 144void PMainWindow::fileSelected(const DocLnk&)
144{ 145{
145} 146}
146 147
147void PMainWindow::slotAppendFiles() 148void PMainWindow::slotAppendFiles()
148{ 149{
149 m_stack->raiseWidget(m_sfl); 150 m_stack->raiseWidget(m_sfl);
150 playlistOnly->setEnabled(false); 151 playlistOnly->setEnabled(false);
151 152
152 a_showPlaylist->setEnabled(true); 153 a_showPlaylist->setEnabled(true);
153 if (m_PlayLib && m_playing) { 154 if (m_PlayLib && m_playing) {
154 a_ShowMedia->setEnabled(true); 155 a_ShowMedia->setEnabled(true);
155 } else { 156 } else {
156 a_ShowMedia->setEnabled(false); 157 a_ShowMedia->setEnabled(false);
157 } 158 }
158} 159}
159 160
160void PMainWindow::slotShowList() 161void PMainWindow::slotShowList()
161{ 162{
162 m_stack->raiseWidget(m_playList); 163 m_stack->raiseWidget(m_playList);
163 playlistOnly->setEnabled(true); 164 playlistOnly->setEnabled(true);
164 a_showPlaylist->setEnabled(false); 165 a_showPlaylist->setEnabled(false);
165 if (m_playList->childCount()) { 166 if (m_playList->childCount()) {
166 a_removeFiles->setEnabled(true); 167 a_removeFiles->setEnabled(true);
167 } else { 168 } else {
168 a_removeFiles->setEnabled(false); 169 a_removeFiles->setEnabled(false);
169 } 170 }
170 if (m_PlayLib && m_playing) { 171 if (m_PlayLib && m_playing) {
171 a_ShowMedia->setEnabled(true); 172 a_ShowMedia->setEnabled(true);
172 } else { 173 } else {
173 a_ShowMedia->setEnabled(false); 174 a_ShowMedia->setEnabled(false);
174 } 175 }
175} 176}
176 177
177void PMainWindow::slotShowMediaWindow() 178void PMainWindow::slotShowMediaWindow()
178{ 179{
179 if (m_playing && m_LastItem && m_PlayLib) { 180 if (m_playing && m_LastItem && m_PlayLib) {
180 if (!m_LastItem->isVideo()) { 181 if (!m_LastItem->isVideo()) {
181 m_stack->raiseWidget(stack_audio); 182 m_stack->raiseWidget(stack_audio);
182 } else { 183 } else {
183 m_stack->raiseWidget(stack_video); 184 m_stack->raiseWidget(stack_video);
184 } 185 }
185 mediaWindowraised(); 186 mediaWindowraised();
186 return; 187 return;
187 } 188 }
188} 189}
189 190
190void PMainWindow::slotPlayList() 191void PMainWindow::slotPlayList()
191{ 192{
192 if (m_playing && m_LastItem && m_PlayLib) { 193 if (m_playing && m_LastItem && m_PlayLib) {
193 slotShowMediaWindow(); 194 slotShowMediaWindow();
194 return; 195 return;
195 } 196 }
196 197
197 m_LastItem = m_playList->currentItem(); 198 m_LastItem = m_playList->currentItem();
198 if (!m_LastItem) { 199 if (!m_LastItem) {
199 slotPlayNext(); 200 slotPlayNext();
200 return; 201 return;
201 } 202 }
202 //m_VideoPlayer->setFullScreen(a_ShowFull->isOn()); 203 //m_VideoPlayer->setFullScreen(a_ShowFull->isOn());
203 slotPlayCurrent(); 204 slotPlayCurrent();
204} 205}
205 206
206void PMainWindow::slotUserStop() 207void PMainWindow::slotUserStop()
207{ 208{
208 if (!m_playing || !m_PlayLib) return; 209 if (!m_playing || !m_PlayLib) return;
209 m_playing = false; 210 m_playing = false;
210 m_PlayLib->stop(); 211 m_PlayLib->stop();
211 m_PosSlider->setEnabled(false); 212 m_PosSlider->setEnabled(false);
212 hideVideo(); 213 hideVideo();
213 slotShowList(); 214 slotShowList();
215 setCaption(appTitle());
214} 216}
215 217
216void PMainWindow::slotTogglePlay(bool how) 218void PMainWindow::slotTogglePlay(bool how)
217{ 219{
218 if (how == m_playing) { 220 if (how == m_playing) {
219 if (how) { 221 if (how) {
220 slotShowMediaWindow(); 222 slotShowMediaWindow();
221 } 223 }
222 return; 224 return;
223 } 225 }
224 if (how) { 226 if (how) {
225 slotPlayList(); 227 slotPlayList();
226 } else { 228 } else {
227 slotUserStop(); 229 slotUserStop();
228 } 230 }
229} 231}
230 232
231void PMainWindow::hideVideo() 233void PMainWindow::hideVideo()
232{ 234{
233 if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) { 235 if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) {
234 //m_VideoPlayer->showNormal(); 236 //m_VideoPlayer->showNormal();
235 m_VideoPlayer->hide(); 237 m_VideoPlayer->hide();
236 } 238 }
237} 239}
238 240
239void PMainWindow::slotPlayCurrent() 241void PMainWindow::slotPlayCurrent()
240{ 242{
241 if (!m_LastItem) { 243 if (!m_LastItem) {
242 if (m_PlayLib) m_PlayLib->stop(); 244 if (m_PlayLib) m_PlayLib->stop();
243 m_PosSlider->setEnabled(false); 245 m_PosSlider->setEnabled(false);
244 a_playAction->setOn(false); 246 a_playAction->setOn(false);
245 hideVideo(); 247 hideVideo();
246 slotShowList(); 248 slotShowList();
249 setCaption(appTitle());
247 return; 250 return;
248 } 251 }
249 m_CurrentPos = 0; 252 m_CurrentPos = 0;
250 m_playList->setCurrentItem(m_LastItem); 253 m_playList->setCurrentItem(m_LastItem);
251 m_uppos = 0; 254 m_uppos = 0;
252 m_PosSlider->setValue(0); 255 m_PosSlider->setValue(0);
253 int result = 0; 256 int result = 0;
254 if (!m_LastItem->isVideo()) { 257 if (!m_LastItem->isVideo()) {
255 hideVideo(); 258 hideVideo();
256 m_playing = true; 259 m_playing = true;
257 m_stack->raiseWidget(stack_audio); 260 m_stack->raiseWidget(stack_audio);
258 result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); 261 result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
259 } else { 262 } else {
260 m_playing = true; 263 m_playing = true;
261 setupVideo(a_ShowFull->isOn()); 264 setupVideo(a_ShowFull->isOn());
262 result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); 265 result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
263 } 266 }
264 if (result<0) { 267 if (result<0) {
265 // fehler 268 // fehler
266 return; 269 return;
267 } 270 }
268 mediaWindowraised(); 271 mediaWindowraised();
272 setCaption(appTitle()+" - "+m_LastItem->Lnk().name());
269 odebug << "Range: " << result << oendl; 273 odebug << "Range: " << result << oendl;
270 m_PosSlider->setEnabled(true); 274 m_PosSlider->setEnabled(true);
271 m_PosSlider->setRange(0,m_PlayLib->length()); 275 m_PosSlider->setRange(0,m_PlayLib->length());
272 m_PosSlider->setValue(m_PlayLib->currentTime()); 276 m_PosSlider->setValue(m_PlayLib->currentTime());
273 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); 277 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
274} 278}
275 279
276void PMainWindow::slotPlayNext() 280void PMainWindow::slotPlayNext()
277{ 281{
278 PlaylistItem*item = m_playList->nextItem(m_LastItem); 282 PlaylistItem*item = m_playList->nextItem(m_LastItem);
279 if (!item) return; 283 if (!item) return;
280 m_LastItem = item; 284 m_LastItem = item;
281 slotPlayCurrent(); 285 slotPlayCurrent();
282} 286}
283 287
284void PMainWindow::slotGoNext() 288void PMainWindow::slotGoNext()
285{ 289{
286 m_LastItem = m_playList->nextItem(m_LastItem); 290 m_LastItem = m_playList->nextItem(m_LastItem);
287 slotPlayCurrent(); 291 slotPlayCurrent();
288} 292}
289 293
290void PMainWindow::slotPlayPrevious() 294void PMainWindow::slotPlayPrevious()
291{ 295{
292 PlaylistItem*item = m_playList->prevItem(m_LastItem); 296 PlaylistItem*item = m_playList->prevItem(m_LastItem);
293 if (!item) return; 297 if (!item) return;
294 m_LastItem = item; 298 m_LastItem = item;
295 slotPlayCurrent(); 299 slotPlayCurrent();
296} 300}
297 301
298void PMainWindow::slotStopped() 302void PMainWindow::slotStopped()
299{ 303{
300 if (!m_playing) return; 304 if (!m_playing) return;
301 odebug << "Slot stopped" << oendl; 305 odebug << "Slot stopped" << oendl;
302 m_playing = false; 306 m_playing = false;
303 slotGoNext(); 307 slotGoNext();
304} 308}
305 309
306void PMainWindow::slotCheckPos() 310void PMainWindow::slotCheckPos()
307{ 311{
308 if (!m_playing) return; 312 if (!m_playing) return;
309 if (!m_pressed) { 313 if (!m_pressed) {
310 m_uppos = m_PlayLib->currentTime(); 314 m_uppos = m_PlayLib->currentTime();
311 emit sigPos(m_uppos); 315 emit sigPos(m_uppos);
312 m_PosSlider->setValue(m_PlayLib->currentTime()); 316 m_PosSlider->setValue(m_PlayLib->currentTime());
313 } 317 }
314 QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); 318 qApp->processEvents(100);
319 QTimer::singleShot( 900, this, SLOT( slotCheckPos() ) );
315} 320}
316 321
317void PMainWindow::slotRemoveFiles() 322void PMainWindow::slotRemoveFiles()
318{ 323{
319 if (m_playing||!m_playList->isVisible()) return; 324 if (m_playing||!m_playList->isVisible()) return;
320 PlaylistItem* Item = m_playList->currentItem(); 325 PlaylistItem* Item = m_playList->currentItem();
321 slotShowList(); 326 slotShowList();
322 m_playList->removeFromList(Item); 327 m_playList->removeFromList(Item);
323} 328}
324 329
325void PMainWindow::setupActions() 330void PMainWindow::setupActions()
326{ 331{
327 a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); 332 a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false );
328 connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); 333 connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles()));
329 a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false); 334 a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false);
330 connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir())); 335 connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir()));
331 a_loadPlaylist = new QAction(tr("Append playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false); 336 a_loadPlaylist = new QAction(tr("Append playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false);
332 connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u())); 337 connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u()));
333 a_savePlaylist = new QAction(tr("Save playlist"),Resource::loadIconSet("save"),0,0,this,0,false); 338 a_savePlaylist = new QAction(tr("Save playlist"),Resource::loadIconSet("save"),0,0,this,0,false);
334 connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u())); 339 connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u()));
335 340
336 playlistOnly = new QActionGroup(this,"playlistgroup",false); 341 playlistOnly = new QActionGroup(this,"playlistgroup",false);
337 playlistOnly->insert(a_appendFiles); 342 playlistOnly->insert(a_appendFiles);
338 playlistOnly->insert(a_addDir); 343 playlistOnly->insert(a_addDir);
339 playlistOnly->insert(a_loadPlaylist); 344 playlistOnly->insert(a_loadPlaylist);
340 playlistOnly->insert(a_savePlaylist); 345 playlistOnly->insert(a_savePlaylist);
341 346
342 a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false ); 347 a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false );
343 connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList())); 348 connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList()));
344 a_ShowMedia = new QAction(tr("Show media window"),Resource::loadIconSet("opieplayer2/musicfile"), 0, 0, this, 0, false ); 349 a_ShowMedia = new QAction(tr("Show media window"),Resource::loadIconSet("opieplayer2/musicfile"), 0, 0, this, 0, false );
345 connect(a_ShowMedia,SIGNAL(activated()),this,SLOT(slotShowMediaWindow())); 350 connect(a_ShowMedia,SIGNAL(activated()),this,SLOT(slotShowMediaWindow()));
346 351
347 a_removeFiles = new QAction(tr("Remove file"),Resource::loadIconSet( "opieplayer2/remove_from_playlist" ), 0, 0, this, 0, false ); 352 a_removeFiles = new QAction(tr("Remove file"),Resource::loadIconSet( "opieplayer2/remove_from_playlist" ), 0, 0, this, 0, false );
348 connect(a_removeFiles,SIGNAL(activated()),this,SLOT(slotRemoveFiles())); 353 connect(a_removeFiles,SIGNAL(activated()),this,SLOT(slotRemoveFiles()));
349 354
350 playersGroup = new QActionGroup(this,"playgroup",false); 355 playersGroup = new QActionGroup(this,"playgroup",false);
351 356
352 a_playAction = new QAction(tr("Play list"),Resource::loadIconSet( "opieplayer2/play" ), 0, 0, this, 0, true); 357 a_playAction = new QAction(tr("Play list"),Resource::loadIconSet( "opieplayer2/play" ), 0, 0, this, 0, true);
353 a_playAction->setOn(false); 358 a_playAction->setOn(false);
354 connect(a_playAction,SIGNAL(toggled(bool)),this,SLOT(slotTogglePlay(bool))); 359 connect(a_playAction,SIGNAL(toggled(bool)),this,SLOT(slotTogglePlay(bool)));
355 360
356 a_playNext = new QAction(tr("Play next in list"),Resource::loadIconSet( "fastforward" ), 0, 0, this, 0, false ); 361 a_playNext = new QAction(tr("Play next in list"),Resource::loadIconSet( "fastforward" ), 0, 0, this, 0, false );
357 connect(a_playNext,SIGNAL(activated()),this,SLOT(slotPlayNext())); 362 connect(a_playNext,SIGNAL(activated()),this,SLOT(slotPlayNext()));
358 a_playPrevious = new QAction(tr("Play previous in list"),Resource::loadIconSet( "fastback" ), 0, 0, this, 0, false ); 363 a_playPrevious = new QAction(tr("Play previous in list"),Resource::loadIconSet( "fastback" ), 0, 0, this, 0, false );
359 connect(a_playPrevious,SIGNAL(activated()),this,SLOT(slotPlayPrevious())); 364 connect(a_playPrevious,SIGNAL(activated()),this,SLOT(slotPlayPrevious()));
360 a_ShowFull = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true ); 365 a_ShowFull = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true );
361 connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool))); 366 connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool)));
362 367
363 playersGroup->insert(a_playPrevious); 368 playersGroup->insert(a_playPrevious);
364 playersGroup->insert(a_playAction); 369 playersGroup->insert(a_playAction);
365 playersGroup->insert(a_playNext); 370 playersGroup->insert(a_playNext);
366 371
367 372
368 /* initial states of actions */ 373 /* initial states of actions */
369 a_showPlaylist->setEnabled(false); 374 a_showPlaylist->setEnabled(false);
370 a_removeFiles->setEnabled(false); 375 a_removeFiles->setEnabled(false);
371 a_ShowMedia->setEnabled(false); 376 a_ShowMedia->setEnabled(false);
372 playersGroup->setEnabled(false); 377 playersGroup->setEnabled(false);
373 378
374 settingsGroup = new QActionGroup(this,"configgroup",false); 379 settingsGroup = new QActionGroup(this,"configgroup",false);
375 380
376 a_Scaleup = new QAction(tr("Scale videos larger"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true ); 381 a_Scaleup = new QAction(tr("Scale videos larger"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true );
377 connect(a_Scaleup,SIGNAL(toggled(bool)),this,SLOT(slot_scaleupToggled(bool))); 382 connect(a_Scaleup,SIGNAL(toggled(bool)),this,SLOT(slot_scaleupToggled(bool)));
378 settingsGroup->insert(a_Scaleup); 383 settingsGroup->insert(a_Scaleup);
379} 384}
380 385
381void PMainWindow::setupToolBar() 386void PMainWindow::setupToolBar()
382{ 387{
383 setToolBarsMovable( false ); 388 setToolBarsMovable( false );
384 m_toolBar = new QToolBar( this ); 389 m_toolBar = new QToolBar( this );
385 //m_menuBar = new QMenuBar(m_toolBar); 390 //m_menuBar = new QMenuBar(m_toolBar);
386 m_menuBar=menuBar(); 391 m_menuBar=menuBar();
387 addToolBar(m_toolBar); 392 addToolBar(m_toolBar);
388 m_toolBar->setHorizontalStretchable( true ); 393 m_toolBar->setHorizontalStretchable( true );
389 a_appendFiles->addTo(m_toolBar); 394 a_appendFiles->addTo(m_toolBar);
390 a_removeFiles->addTo(m_toolBar); 395 a_removeFiles->addTo(m_toolBar);
391 a_showPlaylist->addTo(m_toolBar); 396 a_showPlaylist->addTo(m_toolBar);
392 a_ShowMedia->addTo(m_toolBar); 397 a_ShowMedia->addTo(m_toolBar);
393 a_ShowFull->addTo(m_toolBar); 398 a_ShowFull->addTo(m_toolBar);
394 playersGroup->addTo(m_toolBar); 399 playersGroup->addTo(m_toolBar);
395} 400}
396 401
397void PMainWindow::setupVideo(bool full) 402void PMainWindow::setupVideo(bool full)
398{ 403{
399 if (full) { 404 if (full) {
400 m_VideoPlayer->setBackgroundColor(black); 405 m_VideoPlayer->setBackgroundColor(black);
401 m_VideoPlayer->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); 406 m_VideoPlayer->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0));
402 m_VideoPlayer->setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); 407 m_VideoPlayer->setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height());
403 m_VideoPlayer->showFullScreen(); 408 m_VideoPlayer->showFullScreen();
404 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); 409 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
405 } else { 410 } else {
406 m_VideoPlayer->hide(); 411 m_VideoPlayer->hide();
407 m_VideoPlayer->disconnect(this); 412 m_VideoPlayer->disconnect(this);
408 m_stack->addWidget(m_VideoPlayer,stack_video); 413 m_stack->addWidget(m_VideoPlayer,stack_video);
409 m_stack->raiseWidget(stack_video); 414 m_stack->raiseWidget(stack_video);
410 } 415 }
411 mediaWindowraised(); 416 mediaWindowraised();
412 m_VideoPlayer->fullScreen(full); 417 m_VideoPlayer->fullScreen(full);
413} 418}
414 419
415void PMainWindow::slotVideoclicked() 420void PMainWindow::slotVideoclicked()
416{ 421{
417 odebug << "PMainWindow::slotVideoclicked()" << oendl; 422 odebug << "PMainWindow::slotVideoclicked()" << oendl;
418 if (a_ShowFull->isOn()) { 423 if (a_ShowFull->isOn()) {
419 a_ShowFull->setOn(false); 424 a_ShowFull->setOn(false);
420 slotToggleFull(false); 425 slotToggleFull(false);
421 } 426 }
422} 427}
423 428
424void PMainWindow::slotToggleFull(bool how) 429void PMainWindow::slotToggleFull(bool how)
425{ 430{
426 if (m_PlayLib && m_VideoPlayer->isVisible() && m_PlayLib->isShowingVideo()) { 431 if (m_PlayLib && m_VideoPlayer->isVisible() && m_PlayLib->isShowingVideo()) {
427 m_PlayLib->pause(true); 432 m_PlayLib->pause(true);
428 setupVideo(how); 433 setupVideo(how);
429 m_PlayLib->pause(false); 434 m_PlayLib->pause(false);
430 } 435 }
431} 436}
432 437
433void PMainWindow::setupMenu() 438void PMainWindow::setupMenu()
434{ 439{
435 fileMenu = new QPopupMenu( m_menuBar ); 440 fileMenu = new QPopupMenu( m_menuBar );
436 m_menuBar->insertItem( tr( "Playlist" ), fileMenu ); 441 m_menuBar->insertItem( tr( "Playlist" ), fileMenu );
437 a_appendFiles->addTo(fileMenu); 442 a_appendFiles->addTo(fileMenu);
438 a_removeFiles->addTo(fileMenu); 443 a_removeFiles->addTo(fileMenu);
439 a_addDir->addTo(fileMenu); 444 a_addDir->addTo(fileMenu);
440 fileMenu->insertSeparator(); 445 fileMenu->insertSeparator();
441 a_loadPlaylist->addTo(fileMenu); 446 a_loadPlaylist->addTo(fileMenu);
442 a_savePlaylist->addTo(fileMenu); 447 a_savePlaylist->addTo(fileMenu);
443 448
444 dispMenu = new QPopupMenu( m_menuBar ); 449 dispMenu = new QPopupMenu( m_menuBar );
445 m_menuBar->insertItem( tr( "Show" ), dispMenu ); 450 m_menuBar->insertItem( tr( "Show" ), dispMenu );
446 a_showPlaylist->addTo(dispMenu); 451 a_showPlaylist->addTo(dispMenu);
447 a_ShowMedia->addTo(dispMenu); 452 a_ShowMedia->addTo(dispMenu);
448 a_ShowFull->addTo(dispMenu); 453 a_ShowFull->addTo(dispMenu);
449 playMenu = new QPopupMenu(m_menuBar); 454 playMenu = new QPopupMenu(m_menuBar);
450 m_menuBar->insertItem(tr("Playing"),playMenu); 455 m_menuBar->insertItem(tr("Playing"),playMenu);
451 playersGroup->addTo(playMenu); 456 playersGroup->addTo(playMenu);
452 configMenu = new QPopupMenu(m_menuBar); 457 configMenu = new QPopupMenu(m_menuBar);
453 m_menuBar->insertItem(tr("Config"),configMenu); 458 m_menuBar->insertItem(tr("Config"),configMenu);
454 settingsGroup->addTo(configMenu); 459 settingsGroup->addTo(configMenu);
455} 460}
456 461
457void PMainWindow::slotNewPos(int pos) 462void PMainWindow::slotNewPos(int pos)
458{ 463{
459 if (!m_PlayLib) return; 464 if (!m_PlayLib) return;
460 if (m_uppos==pos) return; 465 if (m_uppos==pos) return;
461 m_PlayLib->seekTo(pos); 466 m_PlayLib->seekTo(pos);
462} 467}
463 468
464void PMainWindow::sliderPressed() 469void PMainWindow::sliderPressed()
465{ 470{
466 m_pressed = true; 471 m_pressed = true;
467} 472}
468 473
469void PMainWindow::sliderReleased() 474void PMainWindow::sliderReleased()
470{ 475{
471 m_pressed = false; 476 m_pressed = false;
472} 477}
473 478
474void PMainWindow::slot_scaleupToggled(bool how) 479void PMainWindow::slot_scaleupToggled(bool how)
475{ 480{
476 m_VideoPlayer->scaleUp(how); 481 m_VideoPlayer->scaleUp(how);
477} 482}
diff --git a/noncore/multimedia/opieplayer3/mwindow.h b/noncore/multimedia/opieplayer3/mwindow.h
index 5d011d5..3ea9a52 100644
--- a/noncore/multimedia/opieplayer3/mwindow.h
+++ b/noncore/multimedia/opieplayer3/mwindow.h
@@ -1,138 +1,139 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9 .>+-= 9 .>+-=
10 _;:, .> :=|. This program is free software; you can 10 _;:, .> :=|. This program is free software; you can
11.> <`_, > . <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.-- : the terms of the GNU General Public 12:`=1 )Y*s>-.-- : the terms of the GNU General Public
13.="- .-=="i, .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - . .-<_> .<> Foundation; either version 2 of the License, 14 - . .-<_> .<> Foundation; either version 2 of the License,
15 ._= =} : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16 .%`+i> _;_. 16 .%`+i> _;_.
17 .i_,=:_. -<s. This program is distributed in the hope that 17 .i_,=:_. -<s. This program is distributed in the hope that
18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19 : .. .:, . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.= = ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++= -. .` .: details. 23++= -. .` .: details.
24 : = ...= . :.=- 24 : = ...= . :.=-
25 -. .:....=;==+<; You should have received a copy of the GNU 25 -. .:....=;==+<; You should have received a copy of the GNU
26 -_. . . )=. = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef _mwindow_h 34#ifndef _mwindow_h
35#define _mwindow_h 35#define _mwindow_h
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38 38
39#include <qpe/applnk.h> 39#include <qpe/applnk.h>
40 40
41#include <qaction.h> 41#include <qaction.h>
42 42
43namespace Opie { 43namespace Opie {
44namespace Ui { 44namespace Ui {
45 class OWidgetStack; 45 class OWidgetStack;
46 class OFileSelector; 46 class OFileSelector;
47} 47}
48} 48}
49 49
50namespace XINE { 50namespace XINE {
51 class Lib; 51 class Lib;
52} 52}
53 53
54class PlaylistView; 54class PlaylistView;
55class QToolBar; 55class QToolBar;
56class QPopupMenu; 56class QPopupMenu;
57class QMenuBar; 57class QMenuBar;
58class AudioWidget; 58class AudioWidget;
59class VideoWidget; 59class VideoWidget;
60class PlaylistItem; 60class PlaylistItem;
61class QSlider; 61class QSlider;
62 62
63class PMainWindow : public QMainWindow { 63class PMainWindow : public QMainWindow {
64 Q_OBJECT 64 Q_OBJECT
65public: 65public:
66 static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); } 66 static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); }
67 static QString appTitle() {return QString::fromLatin1("Opie Mediaplayer 3" ); }
67 PMainWindow(QWidget*, const char*, WFlags ); 68 PMainWindow(QWidget*, const char*, WFlags );
68 virtual ~PMainWindow(); 69 virtual ~PMainWindow();
69 70
70public slots: 71public slots:
71 virtual void slotVideoclicked(); 72 virtual void slotVideoclicked();
72protected: 73protected:
73 74
74 /* GUI parts */ 75 /* GUI parts */
75 static const int stack_list = 0; 76 static const int stack_list = 0;
76 static const int stack_file = 1; 77 static const int stack_file = 1;
77 static const int stack_audio = 2; 78 static const int stack_audio = 2;
78 static const int stack_video = 3; 79 static const int stack_video = 3;
79 Opie::Ui::OWidgetStack *m_stack; 80 Opie::Ui::OWidgetStack *m_stack;
80 Opie::Ui::OFileSelector*m_sfl; 81 Opie::Ui::OFileSelector*m_sfl;
81 PlaylistView*m_playList; 82 PlaylistView*m_playList;
82 AudioWidget*m_AudioPlayer; 83 AudioWidget*m_AudioPlayer;
83 VideoWidget*m_VideoPlayer; 84 VideoWidget*m_VideoPlayer;
84 QWidget*m_MainBox; 85 QWidget*m_MainBox;
85 QSlider*m_PosSlider; 86 QSlider*m_PosSlider;
86 87
87 QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction; 88 QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction;
88 QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia; 89 QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia;
89 QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist; 90 QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist;
90 QAction*a_Scaleup; 91 QAction*a_Scaleup;
91 QActionGroup*playersGroup,*playlistOnly,*settingsGroup; 92 QActionGroup*playersGroup,*playlistOnly,*settingsGroup;
92 QToolBar*m_toolBar; 93 QToolBar*m_toolBar;
93 QPopupMenu *fileMenu,*dispMenu,*playMenu,*configMenu; 94 QPopupMenu *fileMenu,*dispMenu,*playMenu,*configMenu;
94 QMenuBar*m_menuBar; 95 QMenuBar*m_menuBar;
95 XINE::Lib*m_PlayLib; 96 XINE::Lib*m_PlayLib;
96 97
97 void setupActions(); 98 void setupActions();
98 void setupToolBar(); 99 void setupToolBar();
99 void setupMenu(); 100 void setupMenu();
100 void checkLib(); 101 void checkLib();
101 void setupVideo(bool full); 102 void setupVideo(bool full);
102 void hideVideo(); 103 void hideVideo();
103 bool m_playing:1; 104 bool m_playing:1;
104 bool m_pressed:1; 105 bool m_pressed:1;
105 int m_uppos; 106 int m_uppos;
106 107
107 int m_CurrentPos; 108 int m_CurrentPos;
108 PlaylistItem*m_LastItem; 109 PlaylistItem*m_LastItem;
109 void mediaWindowraised(); 110 void mediaWindowraised();
110 111
111protected slots: 112protected slots:
112 virtual void fileSelected(const DocLnk&); 113 virtual void fileSelected(const DocLnk&);
113 virtual void slotAppendFiles(); 114 virtual void slotAppendFiles();
114 virtual void slotRemoveFiles(); 115 virtual void slotRemoveFiles();
115 virtual void slotShowList(); 116 virtual void slotShowList();
116 virtual void slotPlayList(); 117 virtual void slotPlayList();
117 virtual void slotPlayNext(); 118 virtual void slotPlayNext();
118 virtual void slotPlayPrevious(); 119 virtual void slotPlayPrevious();
119 virtual void slotPlayCurrent(); 120 virtual void slotPlayCurrent();
120 virtual void slotStopped(); 121 virtual void slotStopped();
121 virtual void slotCheckPos(); 122 virtual void slotCheckPos();
122 virtual void slotToggleFull(bool); 123 virtual void slotToggleFull(bool);
123 virtual void slotUserStop(); 124 virtual void slotUserStop();
124 virtual void slotGoNext(); 125 virtual void slotGoNext();
125 virtual void slotTogglePlay(bool); 126 virtual void slotTogglePlay(bool);
126 virtual void slotShowMediaWindow(); 127 virtual void slotShowMediaWindow();
127 virtual void slotListChanged(int); 128 virtual void slotListChanged(int);
128 virtual void slotNewPos(int pos); 129 virtual void slotNewPos(int pos);
129 virtual void sliderPressed(); 130 virtual void sliderPressed();
130 virtual void sliderReleased(); 131 virtual void sliderReleased();
131 virtual void slot_scaleupToggled(bool); 132 virtual void slot_scaleupToggled(bool);
132 133
133 134
134signals: 135signals:
135 void sigPos(int); 136 void sigPos(int);
136}; 137};
137 138
138#endif 139#endif
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp
index 2eb40e3..6f2e668 100644
--- a/noncore/multimedia/opieplayer3/playlist.cpp
+++ b/noncore/multimedia/opieplayer3/playlist.cpp
@@ -1,329 +1,333 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9 .>+-= 9 .>+-=
10 _;:, .> :=|. This program is free software; you can 10 _;:, .> :=|. This program is free software; you can
11.> <`_, > . <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.-- : the terms of the GNU General Public 12:`=1 )Y*s>-.-- : the terms of the GNU General Public
13.="- .-=="i, .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - . .-<_> .<> Foundation; either version 2 of the License, 14 - . .-<_> .<> Foundation; either version 2 of the License,
15 ._= =} : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16 .%`+i> _;_. 16 .%`+i> _;_.
17 .i_,=:_. -<s. This program is distributed in the hope that 17 .i_,=:_. -<s. This program is distributed in the hope that
18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19 : .. .:, . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.= = ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++= -. .` .: details. 23++= -. .` .: details.
24 : = ...= . :.=- 24 : = ...= . :.=-
25 -. .:....=;==+<; You should have received a copy of the GNU 25 -. .:....=;==+<; You should have received a copy of the GNU
26 -_. . . )=. = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27 -- :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33#include "playlist.h" 33#include "playlist.h"
34#include "../opieplayer2/lib.h" 34#include "../opieplayer2/lib.h"
35#include "../opieplayer2/om3u.h" 35#include "../opieplayer2/om3u.h"
36 36
37#include <opie2/odebug.h> 37#include <opie2/odebug.h>
38#include <opie2/oresource.h> 38#include <opie2/oresource.h>
39#include <opie2/ofiledialog.h> 39#include <opie2/ofiledialog.h>
40 40
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42 42
43#include <qfileinfo.h> 43#include <qfileinfo.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qdir.h> 45#include <qdir.h>
46 46
47//#define DEFAULT_FILE_TYPES "*.mp3;*.ogg;*.ogm;*.wma;*.wav;*.asf;*.au;*.avi;*.mpeg;*.mpg;*.mv1;*.mov;*.wmv;*.pls;*.m3u;*.mp4;*.m4a" 47//#define DEFAULT_FILE_TYPES "*.mp3;*.ogg;*.ogm;*.wma;*.wav;*.asf;*.au;*.avi;*.mpeg;*.mpg;*.mv1;*.mov;*.wmv;*.pls;*.m3u;*.mp4;*.m4a"
48#define DEFAULT_FILE_TYPES "*.mp3;*.ogg;*.ogm;*.wma;*.wav;*.asf;*.au;*.avi;*.mpeg;*.mpg;*.mv1;*.mov;*.wmv;*.mp4;*.m4a" 48#define DEFAULT_FILE_TYPES "*.mp3;*.ogg;*.ogm;*.wma;*.wav;*.asf;*.au;*.avi;*.mpeg;*.mpg;*.mv1;*.mov;*.wmv;*.mp4;*.m4a"
49 49
50PlaylistItem::PlaylistItem(const DocLnk& aLink,PlaylistView*parent) 50PlaylistItem::PlaylistItem(const DocLnk& aLink,PlaylistView*parent)
51 :QListViewItem(parent),m_Content(aLink),m_video(false) 51 :QListViewItem(parent),m_Content(aLink),m_video(false)
52{ 52{
53} 53}
54 54
55PlaylistItem::PlaylistItem(const DocLnk&aLink,PlaylistView*parent,PlaylistItem*after) 55PlaylistItem::PlaylistItem(const DocLnk&aLink,PlaylistView*parent,PlaylistItem*after)
56 :QListViewItem(parent,after),m_Content(aLink),m_video(false) 56 :QListViewItem(parent,after),m_Content(aLink),m_video(false)
57{ 57{
58} 58}
59 59
60void PlaylistItem::Video(bool y) 60void PlaylistItem::Video(bool y)
61{ 61{
62 m_video=y; 62 m_video=y;
63 if (m_video) { 63 if (m_video) {
64 setPixmap(0,Opie::Core::OResource::loadPixmap("opieplayer2/videofile")); 64 setPixmap(0,Opie::Core::OResource::loadPixmap("opieplayer2/videofile"));
65 } else { 65 } else {
66 setPixmap(0,Opie::Core::OResource::loadPixmap("opieplayer2/musicfile")); 66 setPixmap(0,Opie::Core::OResource::loadPixmap("opieplayer2/musicfile"));
67 } 67 }
68} 68}
69 69
70PlaylistItem::~PlaylistItem() 70PlaylistItem::~PlaylistItem()
71{ 71{
72} 72}
73 73
74/* PlaylistView Methods */ 74/* PlaylistView Methods */
75PlaylistView::PlaylistView(QWidget *parent, const char *name) 75PlaylistView::PlaylistView(QWidget *parent, const char *name)
76 : QListView(parent,name) 76 : QListView(parent,name)
77{ 77{
78// columnLabels << tr("FullName"); 78// columnLabels << tr("FullName");
79 columnLabels << tr(""); // icon 79 columnLabels << tr(""); // icon
80 columnLabels << tr("File"); 80 columnLabels << tr("File");
81 columnLabels << tr("Playtime"); 81 columnLabels << tr("Playtime");
82 columnLabels << tr("Artist"); 82 columnLabels << tr("Artist");
83 columnLabels << tr("Album"); 83 columnLabels << tr("Album");
84 columnLabels << tr("Title"); 84 columnLabels << tr("Title");
85 columnLabels << tr("Type"); 85 columnLabels << tr("Type");
86 columnLabels << tr("Size"); 86 columnLabels << tr("Size");
87 for (QStringList::Iterator it = columnLabels.begin(); it != columnLabels.end(); ++it) { 87 for (QStringList::Iterator it = columnLabels.begin(); it != columnLabels.end(); ++it) {
88 addColumn(*it); 88 addColumn(*it);
89 } 89 }
90 m_Infolib=0; 90 m_Infolib=0;
91 setAllColumnsShowFocus(true); 91 setAllColumnsShowFocus(true);
92 setSelectionMode(Single); 92 setSelectionMode(Single);
93 setSorting(-1); 93 setSorting(-1);
94 m_lastItem = 0; 94 m_lastItem = 0;
95 m_lastDir = QDir::homeDirPath(); 95 m_lastDir = QDir::homeDirPath();
96} 96}
97 97
98PlaylistView::~PlaylistView() 98PlaylistView::~PlaylistView()
99{ 99{
100 if (m_Infolib) delete m_Infolib; 100 if (m_Infolib) delete m_Infolib;
101} 101}
102 102
103void PlaylistView::checkLib() 103void PlaylistView::checkLib()
104{ 104{
105 if (!m_Infolib) { 105 if (!m_Infolib) {
106 m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately); 106 m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately);
107 connect(m_Infolib,SIGNAL(stopped()),this,SLOT(slotDummyStop())); 107 connect(m_Infolib,SIGNAL(stopped()),this,SLOT(slotDummyStop()));
108 m_Infolib->ensureInitialized(); 108 m_Infolib->ensureInitialized();
109 } 109 }
110} 110}
111 111
112void PlaylistView::slotDummyStop() 112void PlaylistView::slotDummyStop()
113{ 113{
114 odebug << "void PlaylistView::slotDummyStop()" << oendl; 114 odebug << "void PlaylistView::slotDummyStop()" << oendl;
115} 115}
116 116
117void PlaylistView::slotAddFile(const DocLnk&aLink) 117void PlaylistView::slotAddFile(const DocLnk&aLink)
118{ 118{
119 QFileInfo f(aLink.file()); 119 QFileInfo f(aLink.file());
120 if (f.extension(FALSE).lower()=="m3u"||f.extension(FALSE).lower()=="pls") { 120 if (f.extension(FALSE).lower()=="m3u"||f.extension(FALSE).lower()=="pls") {
121 readPlayList(aLink.file()); 121 readPlayList(aLink.file());
122 } else { 122 } else {
123 addFile(aLink.file(),aLink.name()); 123 addFile(aLink.file(),aLink.name());
124 } 124 }
125 emit contentChanged(childCount()); 125 emit contentChanged(childCount());
126} 126}
127 127
128void PlaylistView::addFile(const QString&aFile,const QString&aName) 128void PlaylistView::addFile(const QString&aFile,const QString&aName)
129{ 129{
130 QFileInfo fileInfo(aFile); 130 QFileInfo fileInfo(aFile);
131 if (!fileInfo.exists()) return; 131 if (!fileInfo.exists()) return;
132 checkLib(); 132 checkLib();
133 QString name = aName; 133 QString name = aName;
134 if (name.isEmpty()) { 134 if (name.isEmpty()) {
135 name = fileInfo.fileName(); 135 name = fileInfo.fileName();
136 } 136 }
137 int i = m_Infolib->setfile(aFile.utf8().data()); 137 int i = m_Infolib->setfile(aFile.utf8().data());
138 /* realy! otherwise we get an "stopped" signal when playing! - I don't know why */ 138 /* realy! otherwise we get an "stopped" signal when playing! - I don't know why */
139 m_Infolib->stop(); 139 m_Infolib->stop();
140 odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl; 140 odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl;
141 if (i<1) { 141 if (i<1) {
142 i = m_Infolib->error(); 142 i = m_Infolib->error();
143 odebug << "Errorcode: " << i << oendl; 143 odebug << "Errorcode: " << i << oendl;
144 QString msg; 144 QString msg;
145 msg = QString(tr("Error open file %1: ")).arg(name); 145 msg = QString(tr("Error open file %1: ")).arg(name);
146 switch (i) { 146 switch (i) {
147 case 1: 147 case 1:
148 msg += tr("No input plugin"); 148 msg += tr("No input plugin");
149 break; 149 break;
150 case 2: 150 case 2:
151 msg += tr("No demuxer plugin"); 151 msg += tr("No demuxer plugin");
152 break; 152 break;
153 case 3: 153 case 3:
154 msg += tr("Demuxer failed"); 154 msg += tr("Demuxer failed");
155 break; 155 break;
156 case 4: 156 case 4:
157 msg+=tr("Malformed mrl"); 157 msg+=tr("Malformed mrl");
158 break; 158 break;
159 default: 159 default:
160 msg += tr("Unknown error"); 160 msg += tr("Unknown error");
161 break; 161 break;
162 } 162 }
163 QMessageBox::warning(0,tr("Error reading fileheader"),msg); 163 QMessageBox::warning(0,tr("Error reading fileheader"),msg);
164 return; 164 return;
165 } 165 }
166 m_lastItem = m_items.last(); 166 m_lastItem = m_items.last();
167 PlaylistItem*_it = currentItem();
168
167 if (m_lastItem) { 169 if (m_lastItem) {
168 m_lastItem = new PlaylistItem(aFile,this,m_lastItem); 170 m_lastItem = new PlaylistItem(aFile,this,m_lastItem);
169 } else { 171 } else {
170 m_lastItem = new PlaylistItem(aFile,this); 172 m_lastItem = new PlaylistItem(aFile,this);
171 } 173 }
172 m_lastItem->setExpandable(false); 174 m_lastItem->setExpandable(false);
173 m_lastItem->setText(1,name); 175 m_lastItem->setText(1,name);
174 176
175 QString codec = m_Infolib->metaInfo(6); 177 QString codec = m_Infolib->metaInfo(6);
176 if (codec.isEmpty()) { 178 if (codec.isEmpty()) {
177 codec = m_Infolib->metaInfo(7); 179 codec = m_Infolib->metaInfo(7);
178 } 180 }
179 // codec 181 // codec
180 m_lastItem->setText(COL_TYPE,codec); 182 m_lastItem->setText(COL_TYPE,codec);
181 // title 183 // title
182 m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); 184 m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0));
183 // artist 185 // artist
184 m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2)); 186 m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2));
185 // album 187 // album
186 m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); 188 m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4));
187 int l = m_Infolib->length(); 189 int l = m_Infolib->length();
188 int h = l/3600; 190 int h = l/3600;
189 l-=h*3600; 191 l-=h*3600;
190 int m = l/60; 192 int m = l/60;
191 l-=m*60; 193 l-=m*60;
192 codec = ""; 194 codec = "";
193 if (h>0) { 195 if (h>0) {
194 codec.sprintf("%2i:%2i:%2i h",h,m,l); 196 codec.sprintf("%2i:%2i:%2i h",h,m,l);
195 } else { 197 } else {
196 codec.sprintf("%02i:%02i m",m,l); 198 codec.sprintf("%02i:%02i m",m,l);
197 } 199 }
198 // time 200 // time
199 m_lastItem->setText(COL_TIME,codec); 201 m_lastItem->setText(COL_TIME,codec);
200 m_lastItem->Video(m_Infolib->hasVideo()); 202 m_lastItem->Video(m_Infolib->hasVideo());
201 m_items.append(m_lastItem); 203 m_items.append(m_lastItem);
202 setSelected(m_lastItem,true); 204 if (_it==NULL) {
205 setSelected(m_lastItem,true);
206 }
203} 207}
204 208
205void PlaylistView::slotAppendDir() 209void PlaylistView::slotAppendDir()
206{ 210{
207 QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir); 211 QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir);
208 if (_dir.isEmpty()) return; 212 if (_dir.isEmpty()) return;
209 m_lastDir = _dir; 213 m_lastDir = _dir;
210 QDir sDir(_dir); 214 QDir sDir(_dir);
211 QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase); 215 QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase);
212 for (unsigned i = 0; i < list.count();++i) { 216 for (unsigned i = 0; i < list.count();++i) {
213 addFile(_dir+QString("/")+list[i]); 217 addFile(_dir+QString("/")+list[i]);
214 } 218 }
215 emit contentChanged(childCount()); 219 emit contentChanged(childCount());
216} 220}
217 221
218void PlaylistView::slotOpenM3u() 222void PlaylistView::slotOpenM3u()
219{ 223{
220 QStringList types; 224 QStringList types;
221 QMap<QString, QStringList> mimeTypes; 225 QMap<QString, QStringList> mimeTypes;
222 types << "audio/x-mpegurl"; 226 types << "audio/x-mpegurl";
223 mimeTypes.insert("Playlists",types); 227 mimeTypes.insert("Playlists",types);
224// mimeTypes.insert("All",types); 228// mimeTypes.insert("All",types);
225 QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED, 229 QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED,
226 m_lastDir,"playlist.m3u", mimeTypes); 230 m_lastDir,"playlist.m3u", mimeTypes);
227 if (fileName.isEmpty()) { 231 if (fileName.isEmpty()) {
228 return; 232 return;
229 } 233 }
230 readPlayList(fileName); 234 readPlayList(fileName);
231 emit contentChanged(childCount()); 235 emit contentChanged(childCount());
232} 236}
233 237
234void PlaylistView::readPlayList(const QString&fileName) 238void PlaylistView::readPlayList(const QString&fileName)
235{ 239{
236 QFileInfo f(fileName); 240 QFileInfo f(fileName);
237 241
238 Om3u _om3u(fileName, IO_ReadOnly); 242 Om3u _om3u(fileName, IO_ReadOnly);
239 if (f.extension(FALSE).lower()=="m3u") { 243 if (f.extension(FALSE).lower()=="m3u") {
240 _om3u.readM3u(); 244 _om3u.readM3u();
241 } else if (f.extension(FALSE).lower()=="pls") { 245 } else if (f.extension(FALSE).lower()=="pls") {
242 _om3u.readPls(); 246 _om3u.readPls();
243 } 247 }
244 for (unsigned int j=0; j<_om3u.count();++j) { 248 for (unsigned int j=0; j<_om3u.count();++j) {
245 addFile(_om3u[j]); 249 addFile(_om3u[j]);
246 } 250 }
247} 251}
248 252
249void PlaylistView::slotSaveAsM3u() 253void PlaylistView::slotSaveAsM3u()
250{ 254{
251 QStringList types; 255 QStringList types;
252 QMap<QString, QStringList> mimeTypes; 256 QMap<QString, QStringList> mimeTypes;
253 types << "audio/x-mpegurl"; 257 types << "audio/x-mpegurl";
254 mimeTypes.insert("Playlists",types); 258 mimeTypes.insert("Playlists",types);
255 QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED, 259 QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED,
256 m_lastDir,"playlist.m3u", mimeTypes); 260 m_lastDir,"playlist.m3u", mimeTypes);
257 odebug << "Save as " << fileName << oendl; 261 odebug << "Save as " << fileName << oendl;
258 if (fileName.isEmpty()) { 262 if (fileName.isEmpty()) {
259 return; 263 return;
260 } 264 }
261 Om3u _om3u(fileName, IO_ReadWrite | IO_Truncate); 265 Om3u _om3u(fileName, IO_ReadWrite | IO_Truncate);
262 for (unsigned j=0; j<m_items.count();++j) { 266 for (unsigned j=0; j<m_items.count();++j) {
263 _om3u.add(m_items[j]->Lnk().file()); 267 _om3u.add(m_items[j]->Lnk().file());
264 } 268 }
265 _om3u.write(); 269 _om3u.write();
266} 270}
267 271
268void PlaylistView::removeFromList(PlaylistItem*Item) 272void PlaylistView::removeFromList(PlaylistItem*Item)
269{ 273{
270 if (!Item)return; 274 if (!Item)return;
271 t_itemlist::Iterator iter,it2; 275 t_itemlist::Iterator iter,it2;
272 iter = m_items.find(Item); 276 iter = m_items.find(Item);
273 it2 = m_items.end(); 277 it2 = m_items.end();
274 if (iter!=m_items.end()) { 278 if (iter!=m_items.end()) {
275 it2 = iter; 279 it2 = iter;
276 ++it2; 280 ++it2;
277 m_items.remove(iter); 281 m_items.remove(iter);
278 } 282 }
279 delete Item; 283 delete Item;
280 if (it2!=m_items.end()) { 284 if (it2!=m_items.end()) {
281 setSelected((*it2),true); 285 setSelected((*it2),true);
282 } else if (m_items.count()) { 286 } else if (m_items.count()) {
283 QListViewItem * it = m_items.last(); 287 QListViewItem * it = m_items.last();
284 setSelected(it,true); 288 setSelected(it,true);
285 } 289 }
286 emit contentChanged(childCount()); 290 emit contentChanged(childCount());
287} 291}
288 292
289XINE::Lib*PlaylistView::getXine() 293XINE::Lib*PlaylistView::getXine()
290{ 294{
291 checkLib(); 295 checkLib();
292 return m_Infolib; 296 return m_Infolib;
293} 297}
294 298
295void PlaylistView::setCurrentItem(PlaylistItem*aItem) 299void PlaylistView::setCurrentItem(PlaylistItem*aItem)
296{ 300{
297 setSelected(aItem,true); 301 setSelected(aItem,true);
298} 302}
299 303
300PlaylistItem* PlaylistView::currentItem()const 304PlaylistItem* PlaylistView::currentItem()const
301{ 305{
302 QListViewItem*it = selectedItem(); 306 QListViewItem*it = selectedItem();
303 if (!it) return 0; 307 if (!it) return 0;
304 return (PlaylistItem*)it; 308 return (PlaylistItem*)it;
305} 309}
306 310
307PlaylistItem* PlaylistView::nextItem(PlaylistItem*parent)const 311PlaylistItem* PlaylistView::nextItem(PlaylistItem*parent)const
308{ 312{
309 if (m_items.count()==0) return 0; 313 if (m_items.count()==0) return 0;
310 if (!parent) return m_items[0]; 314 if (!parent) return m_items[0];
311 for (unsigned j=0; j<m_items.count()-1;++j) { 315 for (unsigned j=0; j<m_items.count()-1;++j) {
312 if (m_items[j]==parent) { 316 if (m_items[j]==parent) {
313 return m_items[j+1]; 317 return m_items[j+1];
314 } 318 }
315 } 319 }
316 return 0; 320 return 0;
317} 321}
318 322
319PlaylistItem* PlaylistView::prevItem(PlaylistItem*parent)const 323PlaylistItem* PlaylistView::prevItem(PlaylistItem*parent)const
320{ 324{
321 if (m_items.count()==0) return 0; 325 if (m_items.count()==0) return 0;
322 if (!parent) return m_items[m_items.count()-1]; 326 if (!parent) return m_items[m_items.count()-1];
323 for (unsigned j=m_items.count()-1; j>0;--j) { 327 for (unsigned j=m_items.count()-1; j>0;--j) {
324 if (m_items[j]==parent) { 328 if (m_items[j]==parent) {
325 return m_items[j-1]; 329 return m_items[j-1];
326 } 330 }
327 } 331 }
328 return 0; 332 return 0;
329} 333}
diff --git a/noncore/multimedia/opieplayer3/videowidget.cpp b/noncore/multimedia/opieplayer3/videowidget.cpp
index 833ecb4..414400b 100644
--- a/noncore/multimedia/opieplayer3/videowidget.cpp
+++ b/noncore/multimedia/opieplayer3/videowidget.cpp
@@ -1,100 +1,101 @@
1#include "videowidget.h" 1#include "videowidget.h"
2#include "../opieplayer2/lib.h" 2#include "../opieplayer2/lib.h"
3#include "../opieplayer2/threadutil.h" 3#include "../opieplayer2/threadutil.h"
4#include "../opieplayer2/xinevideowidget.h" 4#include "../opieplayer2/xinevideowidget.h"
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9 9
10#include <qlayout.h> 10#include <qlayout.h>
11#include <qslider.h> 11#include <qslider.h>
12#include <qlabel.h> 12#include <qlabel.h>
13 13
14VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f) 14VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f)
15 :QWidget(parent,name,f) 15 :QWidget(parent,name,f)
16{ 16{
17 m_xineLib = 0; 17 m_xineLib = 0;
18 m_scaleUp = false; 18 m_scaleUp = false;
19 m_MainLayout = new QVBoxLayout(this); 19 m_MainLayout = new QVBoxLayout(this);
20 m_MainLayout->setAutoAdd(true); 20 m_MainLayout->setAutoAdd(true);
21 m_Videodisplay = new XineVideoWidget(this,"videodisp"); 21 m_Videodisplay = new XineVideoWidget(this,"videodisp");
22 connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&))); 22 connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&)));
23 connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked())); 23 connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked()));
24} 24}
25 25
26VideoWidget::~VideoWidget() 26VideoWidget::~VideoWidget()
27{ 27{
28} 28}
29 29
30void VideoWidget::slotClicked() 30void VideoWidget::slotClicked()
31{ 31{
32 emit videoclicked(); 32 emit videoclicked();
33} 33}
34 34
35void VideoWidget::closeEvent(QCloseEvent*e) 35void VideoWidget::closeEvent(QCloseEvent*e)
36{ 36{
37} 37}
38 38
39void VideoWidget::fullScreen(bool /* how */) 39void VideoWidget::fullScreen(bool /* how */)
40{ 40{
41} 41}
42 42
43int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) 43int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
44{ 44{
45 m_current = aLnk; 45 m_current = aLnk;
46 bool recon; 46 bool recon;
47 if (m_xineLib != aLib) { 47 if (m_xineLib != aLib) {
48 if (m_xineLib) disconnect(m_xineLib); 48 if (m_xineLib) disconnect(m_xineLib);
49 m_xineLib = aLib; 49 m_xineLib = aLib;
50 if (aLib) m_xineLib->setWidget(m_Videodisplay); 50 if (aLib) m_xineLib->setWidget(m_Videodisplay);
51 } 51 }
52 if (!m_xineLib) { 52 if (!m_xineLib) {
53 return -1; 53 return -1;
54 } 54 }
55 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped())); 55 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
56 m_xineLib->setWidget(m_Videodisplay); 56 m_xineLib->setWidget(m_Videodisplay);
57 m_xineLib->setShowVideo(true); 57 m_xineLib->setShowVideo(true);
58 int res = m_xineLib->play(m_current.file()); 58 int res = m_xineLib->play(m_current.file());
59 vSize = m_xineLib->videoSize(); 59 vSize = m_xineLib->videoSize();
60
60 slot_Videoresized(m_Videodisplay->size()); 61 slot_Videoresized(m_Videodisplay->size());
61 odebug << "Xine play: " << res << oendl; 62 odebug << "Xine play: " << res << oendl;
62 if (res != 1) { 63 if (res != 1) {
63 return -2; 64 return -2;
64 } 65 }
65 return m_xineLib->length(); 66 return m_xineLib->length();
66} 67}
67 68
68void VideoWidget::stopPlaying() 69void VideoWidget::stopPlaying()
69{ 70{
70 if (m_xineLib) { 71 if (m_xineLib) {
71 m_xineLib->stop(); 72 m_xineLib->stop();
72 } 73 }
73} 74}
74 75
75void VideoWidget::slotStopped() 76void VideoWidget::slotStopped()
76{ 77{
77} 78}
78 79
79void VideoWidget::slot_Videoresized(const QSize&s) 80void VideoWidget::slot_Videoresized(const QSize&s)
80{ 81{
81 if (m_xineLib) { 82 if (m_xineLib) {
82 if (vSize.width()<s.width()&&vSize.height()<s.height()&&!m_scaleUp) { 83 if (vSize.width()<s.width()&&vSize.height()<s.height()&&!m_scaleUp) {
83 m_xineLib->resize(vSize); 84 m_xineLib->resize(vSize);
84 } else { 85 } else {
85 m_xineLib->resize(s); 86 m_xineLib->resize(s);
86 } 87 }
87 } 88 }
88} 89}
89 90
90void VideoWidget::scaleUp(bool how) 91void VideoWidget::scaleUp(bool how)
91{ 92{
92 if (how == m_scaleUp) return; 93 if (how == m_scaleUp) return;
93 m_scaleUp = how; 94 m_scaleUp = how;
94 slot_Videoresized(m_Videodisplay->size()); 95 slot_Videoresized(m_Videodisplay->size());
95 m_Videodisplay->repaint(); 96 m_Videodisplay->repaint();
96} 97}
97 98
98void VideoWidget::updatePos(int /*val*/) 99void VideoWidget::updatePos(int /*val*/)
99{ 100{
100} 101}