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 | |||
@@ -60,6 +60,7 @@ using namespace Opie::Ui; | |||
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); |
@@ -69,9 +70,9 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) | |||
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); |
@@ -87,8 +88,14 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) | |||
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(); |
@@ -99,6 +106,7 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) | |||
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 | } |
@@ -117,8 +125,9 @@ void PMainWindow::mediaWindowraised() | |||
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 | } |
@@ -199,7 +208,7 @@ void PMainWindow::slotUserStop() | |||
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 | } |
@@ -231,16 +240,16 @@ 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(); |
@@ -258,9 +267,9 @@ void PMainWindow::slotPlayCurrent() | |||
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 | ||
@@ -289,6 +298,7 @@ void PMainWindow::slotPlayPrevious() | |||
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 | } |
@@ -296,8 +306,11 @@ void PMainWindow::slotStopped() | |||
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 | ||
@@ -315,9 +328,9 @@ void PMainWindow::setupActions() | |||
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); |
@@ -351,10 +364,18 @@ void PMainWindow::setupActions() | |||
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() |
@@ -427,6 +448,30 @@ void PMainWindow::setupMenu() | |||
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 | } |