Diffstat (limited to 'noncore/multimedia/opieplayer3/mwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer3/mwindow.cpp | 81 |
1 files changed, 63 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp index 57418f0..75d1490 100644 --- a/noncore/multimedia/opieplayer3/mwindow.cpp +++ b/noncore/multimedia/opieplayer3/mwindow.cpp | |||
@@ -57,24 +57,25 @@ OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | |||
57 | 57 | ||
58 | using namespace Opie::Ui; | 58 | using namespace Opie::Ui; |
59 | 59 | ||
60 | PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) | 60 | PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) |
61 | : QMainWindow(w,name,f) | 61 | : QMainWindow(w,name,f) |
62 | { | 62 | { |
63 | checkLib(); | ||
63 | setCaption( QObject::tr("Opie Mediaplayer 3" ) ); | 64 | setCaption( QObject::tr("Opie Mediaplayer 3" ) ); |
64 | 65 | ||
65 | m_MainBox = new QWidget(this); | 66 | m_MainBox = new QWidget(this); |
66 | 67 | ||
67 | QVBoxLayout*m_l = new QVBoxLayout(m_MainBox); | 68 | QVBoxLayout*m_l = new QVBoxLayout(m_MainBox); |
68 | 69 | ||
69 | m_stack = new OWidgetStack(m_MainBox); | 70 | m_stack = new OWidgetStack(m_MainBox); |
70 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); | 71 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); |
71 | m_l->addWidget(m_stack); | 72 | m_l->addWidget(m_stack); |
72 | m_scrollBar = new QSlider(QSlider::Horizontal,m_MainBox); | 73 | m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox); |
73 | m_l->addWidget(m_scrollBar); | 74 | m_l->addWidget(m_PosSlider); |
74 | m_scrollBar->setEnabled(false); | 75 | m_PosSlider->setEnabled(false); |
75 | 76 | ||
76 | m_playList = new PlaylistView(m_stack,"playlist"); | 77 | m_playList = new PlaylistView(m_stack,"playlist"); |
77 | m_stack->addWidget(m_playList,stack_list); | 78 | m_stack->addWidget(m_playList,stack_list); |
78 | connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int))); | 79 | connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int))); |
79 | m_sfl = new OFileSelector("video/*;audio/*",m_stack); | 80 | m_sfl = new OFileSelector("video/*;audio/*",m_stack); |
80 | m_stack->addWidget(m_sfl,stack_file); | 81 | m_stack->addWidget(m_sfl,stack_file); |
@@ -84,24 +85,31 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) | |||
84 | connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int))); | 85 | connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int))); |
85 | m_VideoPlayer = new VideoWidget(m_stack); | 86 | m_VideoPlayer = new VideoWidget(m_stack); |
86 | m_stack->addWidget(m_VideoPlayer,stack_video); | 87 | m_stack->addWidget(m_VideoPlayer,stack_video); |
87 | connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); | 88 | connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); |
88 | connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); | 89 | connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); |
89 | 90 | ||
91 | 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(sliderPressed()),this,SLOT(sliderPressed())); | ||
94 | connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); | ||
95 | m_pressed = false; | ||
96 | m_uppos=0; | ||
97 | |||
90 | m_stack->raiseWidget(stack_list); | 98 | m_stack->raiseWidget(stack_list); |
91 | m_PlayLib = 0; | ||
92 | m_LastItem = 0; | 99 | m_LastItem = 0; |
93 | setupActions(); | 100 | setupActions(); |
94 | setupToolBar(); | 101 | setupToolBar(); |
95 | setupMenu(); | 102 | setupMenu(); |
96 | 103 | ||
97 | setCentralWidget(m_MainBox ); | 104 | setCentralWidget(m_MainBox ); |
98 | } | 105 | } |
99 | 106 | ||
100 | void PMainWindow::slotListChanged(int count) | 107 | void PMainWindow::slotListChanged(int count) |
101 | { | 108 | { |
109 | playersGroup->setEnabled(count>0); | ||
102 | if (!m_playList->isVisible()) { | 110 | if (!m_playList->isVisible()) { |
103 | return; | 111 | return; |
104 | } | 112 | } |
105 | a_removeFiles->setEnabled(count>0); | 113 | a_removeFiles->setEnabled(count>0); |
106 | } | 114 | } |
107 | 115 | ||
@@ -114,14 +122,15 @@ void PMainWindow::mediaWindowraised() | |||
114 | a_ShowMedia->setEnabled(false); | 122 | a_ShowMedia->setEnabled(false); |
115 | } | 123 | } |
116 | 124 | ||
117 | void PMainWindow::checkLib() | 125 | void PMainWindow::checkLib() |
118 | { | 126 | { |
119 | if (m_PlayLib == 0) { | 127 | if (m_PlayLib == 0) { |
120 | m_PlayLib = new XINE::Lib(XINE::Lib::InitializeImmediately); | 128 | m_PlayLib = new XINE::Lib(XINE::Lib::InitializeInThread); |
121 | m_PlayLib->ensureInitialized(); | 129 | qApp->processEvents(); |
130 | // m_PlayLib->ensureInitialized(); | ||
122 | connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped())); | 131 | connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped())); |
123 | } | 132 | } |
124 | } | 133 | } |
125 | 134 | ||
126 | PMainWindow::~PMainWindow() | 135 | PMainWindow::~PMainWindow() |
127 | { | 136 | { |
@@ -196,13 +205,13 @@ void PMainWindow::slotPlayList() | |||
196 | 205 | ||
197 | void PMainWindow::slotUserStop() | 206 | void PMainWindow::slotUserStop() |
198 | { | 207 | { |
199 | if (!m_playing || !m_PlayLib) return; | 208 | if (!m_playing || !m_PlayLib) return; |
200 | m_playing = false; | 209 | m_playing = false; |
201 | m_PlayLib->stop(); | 210 | m_PlayLib->stop(); |
202 | m_scrollBar->setEnabled(false); | 211 | m_PosSlider->setEnabled(false); |
203 | hideVideo(); | 212 | hideVideo(); |
204 | slotShowList(); | 213 | slotShowList(); |
205 | } | 214 | } |
206 | 215 | ||
207 | void PMainWindow::slotTogglePlay(bool how) | 216 | void PMainWindow::slotTogglePlay(bool how) |
208 | { | 217 | { |
@@ -228,22 +237,22 @@ void PMainWindow::hideVideo() | |||
228 | } | 237 | } |
229 | 238 | ||
230 | void PMainWindow::slotPlayCurrent() | 239 | void PMainWindow::slotPlayCurrent() |
231 | { | 240 | { |
232 | if (!m_LastItem) { | 241 | if (!m_LastItem) { |
233 | if (m_PlayLib) m_PlayLib->stop(); | 242 | if (m_PlayLib) m_PlayLib->stop(); |
234 | m_scrollBar->setEnabled(false); | 243 | m_PosSlider->setEnabled(false); |
235 | a_playAction->setOn(false); | 244 | a_playAction->setOn(false); |
236 | hideVideo(); | 245 | hideVideo(); |
237 | slotShowList(); | 246 | slotShowList(); |
238 | return; | 247 | return; |
239 | } | 248 | } |
240 | checkLib(); | ||
241 | m_CurrentPos = 0; | 249 | m_CurrentPos = 0; |
242 | m_playList->setCurrentItem(m_LastItem); | 250 | m_playList->setCurrentItem(m_LastItem); |
243 | odebug << "Pos: " << m_PlayLib->currentTime() << oendl; | 251 | m_uppos = 0; |
252 | m_PosSlider->setValue(0); | ||
244 | int result = 0; | 253 | int result = 0; |
245 | if (!m_LastItem->isVideo()) { | 254 | if (!m_LastItem->isVideo()) { |
246 | hideVideo(); | 255 | hideVideo(); |
247 | m_playing = true; | 256 | m_playing = true; |
248 | m_stack->raiseWidget(stack_audio); | 257 | m_stack->raiseWidget(stack_audio); |
249 | result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); | 258 | result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); |
@@ -255,15 +264,15 @@ void PMainWindow::slotPlayCurrent() | |||
255 | if (result<0) { | 264 | if (result<0) { |
256 | // fehler | 265 | // fehler |
257 | return; | 266 | return; |
258 | } | 267 | } |
259 | mediaWindowraised(); | 268 | mediaWindowraised(); |
260 | odebug << "Range: " << result << oendl; | 269 | odebug << "Range: " << result << oendl; |
261 | m_scrollBar->setRange(0,result); | 270 | m_PosSlider->setEnabled(true); |
262 | m_scrollBar->setValue(0); | 271 | m_PosSlider->setRange(0,m_PlayLib->length()); |
263 | m_scrollBar->setEnabled(true); | 272 | m_PosSlider->setValue(m_PlayLib->currentTime()); |
264 | QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); | 273 | QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); |
265 | } | 274 | } |
266 | 275 | ||
267 | void PMainWindow::slotPlayNext() | 276 | void PMainWindow::slotPlayNext() |
268 | { | 277 | { |
269 | PlaylistItem*item = m_playList->nextItem(m_LastItem); | 278 | PlaylistItem*item = m_playList->nextItem(m_LastItem); |
@@ -286,21 +295,25 @@ void PMainWindow::slotPlayPrevious() | |||
286 | slotPlayCurrent(); | 295 | slotPlayCurrent(); |
287 | } | 296 | } |
288 | 297 | ||
289 | void PMainWindow::slotStopped() | 298 | void PMainWindow::slotStopped() |
290 | { | 299 | { |
291 | if (!m_playing) return; | 300 | if (!m_playing) return; |
301 | odebug << "Slot stopped" << oendl; | ||
292 | m_playing = false; | 302 | m_playing = false; |
293 | slotGoNext(); | 303 | slotGoNext(); |
294 | } | 304 | } |
295 | 305 | ||
296 | void PMainWindow::slotCheckPos() | 306 | void PMainWindow::slotCheckPos() |
297 | { | 307 | { |
298 | if (!m_playing) return; | 308 | if (!m_playing) return; |
299 | //emit sigPos(m_PlayLib->currentTime()); | 309 | if (!m_pressed) { |
300 | m_scrollBar->setValue(m_PlayLib->currentTime()); | 310 | m_uppos = m_PlayLib->currentTime(); |
311 | emit sigPos(m_uppos); | ||
312 | m_PosSlider->setValue(m_PlayLib->currentTime()); | ||
313 | } | ||
301 | QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); | 314 | QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); |
302 | } | 315 | } |
303 | 316 | ||
304 | void PMainWindow::slotRemoveFiles() | 317 | void PMainWindow::slotRemoveFiles() |
305 | { | 318 | { |
306 | if (m_playing||!m_playList->isVisible()) return; | 319 | if (m_playing||!m_playList->isVisible()) return; |
@@ -312,15 +325,15 @@ void PMainWindow::slotRemoveFiles() | |||
312 | void PMainWindow::setupActions() | 325 | void PMainWindow::setupActions() |
313 | { | 326 | { |
314 | a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); | 327 | a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); |
315 | connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); | 328 | connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); |
316 | a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false); | 329 | a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false); |
317 | connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir())); | 330 | connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir())); |
318 | a_loadPlaylist = new QAction(tr("Append .m3u playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false); | 331 | a_loadPlaylist = new QAction(tr("Append playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false); |
319 | connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u())); | 332 | connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u())); |
320 | a_savePlaylist = new QAction(tr("Save .m3u playlist"),Resource::loadIconSet("save"),0,0,this,0,false); | 333 | a_savePlaylist = new QAction(tr("Save playlist"),Resource::loadIconSet("save"),0,0,this,0,false); |
321 | connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u())); | 334 | connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u())); |
322 | 335 | ||
323 | playlistOnly = new QActionGroup(this,"playlistgroup",false); | 336 | playlistOnly = new QActionGroup(this,"playlistgroup",false); |
324 | playlistOnly->insert(a_appendFiles); | 337 | playlistOnly->insert(a_appendFiles); |
325 | playlistOnly->insert(a_addDir); | 338 | playlistOnly->insert(a_addDir); |
326 | playlistOnly->insert(a_loadPlaylist); | 339 | playlistOnly->insert(a_loadPlaylist); |
@@ -348,16 +361,24 @@ void PMainWindow::setupActions() | |||
348 | connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool))); | 361 | connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool))); |
349 | 362 | ||
350 | playersGroup->insert(a_playPrevious); | 363 | playersGroup->insert(a_playPrevious); |
351 | playersGroup->insert(a_playAction); | 364 | playersGroup->insert(a_playAction); |
352 | playersGroup->insert(a_playNext); | 365 | playersGroup->insert(a_playNext); |
353 | 366 | ||
367 | |||
354 | /* initial states of actions */ | 368 | /* initial states of actions */ |
355 | a_showPlaylist->setEnabled(false); | 369 | a_showPlaylist->setEnabled(false); |
356 | a_removeFiles->setEnabled(false); | 370 | a_removeFiles->setEnabled(false); |
357 | a_ShowMedia->setEnabled(false); | 371 | a_ShowMedia->setEnabled(false); |
372 | playersGroup->setEnabled(false); | ||
373 | |||
374 | settingsGroup = new QActionGroup(this,"configgroup",false); | ||
375 | |||
376 | 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))); | ||
378 | settingsGroup->insert(a_Scaleup); | ||
358 | } | 379 | } |
359 | 380 | ||
360 | void PMainWindow::setupToolBar() | 381 | void PMainWindow::setupToolBar() |
361 | { | 382 | { |
362 | setToolBarsMovable( false ); | 383 | setToolBarsMovable( false ); |
363 | m_toolBar = new QToolBar( this ); | 384 | m_toolBar = new QToolBar( this ); |
@@ -424,9 +445,33 @@ void PMainWindow::setupMenu() | |||
424 | m_menuBar->insertItem( tr( "Show" ), dispMenu ); | 445 | m_menuBar->insertItem( tr( "Show" ), dispMenu ); |
425 | a_showPlaylist->addTo(dispMenu); | 446 | a_showPlaylist->addTo(dispMenu); |
426 | a_ShowMedia->addTo(dispMenu); | 447 | a_ShowMedia->addTo(dispMenu); |
427 | a_ShowFull->addTo(dispMenu); | 448 | a_ShowFull->addTo(dispMenu); |
428 | playMenu = new QPopupMenu(m_menuBar); | 449 | playMenu = new QPopupMenu(m_menuBar); |
429 | m_menuBar->insertItem(tr("Playing"),playMenu); | 450 | m_menuBar->insertItem(tr("Playing"),playMenu); |
430 | |||
431 | playersGroup->addTo(playMenu); | 451 | playersGroup->addTo(playMenu); |
452 | configMenu = new QPopupMenu(m_menuBar); | ||
453 | m_menuBar->insertItem(tr("Config"),configMenu); | ||
454 | settingsGroup->addTo(configMenu); | ||
455 | } | ||
456 | |||
457 | void PMainWindow::slotNewPos(int pos) | ||
458 | { | ||
459 | if (!m_PlayLib) return; | ||
460 | if (m_uppos==pos) return; | ||
461 | m_PlayLib->seekTo(pos); | ||
462 | } | ||
463 | |||
464 | void PMainWindow::sliderPressed() | ||
465 | { | ||
466 | m_pressed = true; | ||
467 | } | ||
468 | |||
469 | void PMainWindow::sliderReleased() | ||
470 | { | ||
471 | m_pressed = false; | ||
472 | } | ||
473 | |||
474 | void PMainWindow::slot_scaleupToggled(bool how) | ||
475 | { | ||
476 | m_VideoPlayer->scaleUp(how); | ||
432 | } | 477 | } |