304void VideoWidget::setUsedControls(
const Controls controls)
306 if (controls == d->shownControls) {
310 d->shownControls = controls;
314 QGraphicsLinearLayout *controlsLayout = 0;
315 if (controls !=
NoControls && d->controlsWidget == 0) {
318 controlsLayout =
new QGraphicsLinearLayout(Qt::Horizontal, d->controlsWidget);
319 d->hideTimer =
new QTimer(
this);
320 connect(d->hideTimer, SIGNAL(timeout()),
this, SLOT(hideControlWidget()));
322 }
else if (d->controlsWidget != 0) {
323 d->controlsWidget->deleteLater();
324 d->hideTimer->deleteLater();
325 d->controlsWidget = 0;
328 disconnect(d->media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
this, SLOT(stateChanged(Phonon::State,Phonon::State)));
329 disconnect(d->media, SIGNAL(
tick(qint64)),
this, SLOT(ticked(qint64)));
330 disconnect(d->media, SIGNAL(totalTimeChanged(qint64)),
this, SLOT(totalTimeChanged(qint64)));
331 disconnect(d->audioOutput, SIGNAL(volumeChanged(qreal)),
this, SLOT(volumeChanged(qreal)));
335 Q_ASSERT(controlsLayout);
338 while (controlsLayout->count() > 0) {
339 controlsLayout->removeAt(0);
343 if (!d->previousButton) {
344 d->previousButton =
new IconWidget(d->controlsWidget);
345 d->previousButton->setIcon(
"media-playback-start");
346 connect(d->playButton, SIGNAL(clicked()),
this, SLOT(PreviousRequested()));
348 controlsLayout->addItem(d->previousButton);
350 d->previousButton->deleteLater();
351 d->previousButton = 0;
355 if (!d->playButton) {
356 d->playButton =
new IconWidget(d->controlsWidget);
357 d->playButton->setIcon(
"media-playback-start");
358 connect(d->playButton, SIGNAL(clicked()),
this, SLOT(
play()));
360 controlsLayout->addItem(d->playButton);
362 d->playButton->deleteLater();
366 if (controls&
Pause) {
367 if (!d->pauseButton) {
368 d->pauseButton =
new IconWidget(d->controlsWidget);
369 d->pauseButton->setIcon(
"media-playback-pause");
370 connect(d->pauseButton, SIGNAL(clicked()),
this, SLOT(
pause()));
372 controlsLayout->addItem(d->pauseButton);
374 d->pauseButton->deleteLater();
379 if (!d->stopButton) {
380 d->stopButton =
new IconWidget(d->controlsWidget);
381 d->stopButton->setIcon(
"media-playback-stop");
382 connect(d->stopButton, SIGNAL(clicked()),
this, SLOT(
stop()));
384 controlsLayout->addItem(d->stopButton);
386 d->stopButton->deleteLater();
391 if (!d->playPauseButton) {
392 d->playPauseButton =
new IconWidget(d->controlsWidget);
393 d->playPauseButton->setIcon(
"media-playback-start");
394 connect(d->playPauseButton, SIGNAL(clicked()),
this, SLOT(playPause()));
396 controlsLayout->addItem(d->playPauseButton);
398 d->playPauseButton->deleteLater();
399 d->playPauseButton = 0;
403 if (!d->nextButton) {
404 d->nextButton =
new IconWidget(d->nextButton);
405 d->nextButton->setIcon(
"media-playback-start");
406 connect(d->nextButton, SIGNAL(clicked()),
this, SIGNAL(
nextRequested()));
408 controlsLayout->addItem(d->nextButton);
410 d->nextButton->deleteLater();
414 connect(d->media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
this, SLOT(stateChanged(Phonon::State,Phonon::State)));
421 d->progress =
new Slider(d->controlsWidget);
422 d->progress->setMinimum(0);
423 d->progress->setMaximum(100);
424 d->progress->setOrientation(Qt::Horizontal);
425 controlsLayout->setStretchFactor(d->progress, 4);
426 d->progress->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
428 connect(d->media, SIGNAL(
tick(qint64)),
this, SLOT(ticked(qint64)));
429 connect(d->media, SIGNAL(totalTimeChanged(qint64)), SLOT(totalTimeChanged(qint64)));
430 connect(d->progress, SIGNAL(valueChanged(
int)),
this, SLOT(setPosition(
int)));
432 controlsLayout->addItem(d->progress);
434 d->progress->deleteLater();
441 d->volume =
new Slider(d->controlsWidget);
442 d->volume->setMinimum(0);
443 d->volume->setMaximum(100);
444 d->volume->setValue(100);
445 d->volume->setOrientation(Qt::Horizontal);
446 d->volume->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
448 connect(d->volume, SIGNAL(valueChanged(
int)), SLOT(setVolume(
int)));
449 connect(d->audioOutput, SIGNAL(volumeChanged(qreal)), SLOT(volumeChanged(qreal)));
451 controlsLayout->addItem(d->volume);
453 d->volume->deleteLater();
459 if (!d->openFileButton) {
460 d->openFileButton =
new IconWidget(d->controlsWidget);
461 d->openFileButton->setIcon(KIcon(
"document-open"));
462 connect(d->openFileButton, SIGNAL(clicked()),
this, SLOT(showOpenFileDialog()));
464 controlsLayout->addItem(d->openFileButton);
466 d->openFileButton->deleteLater();
467 d->openFileButton = 0;
470 controlsLayout->activate();
471 d->controlsWidget->setPos(0,-d->controlsWidget->size().height());
472 d->controlsWidget->resize(size().width(), d->controlsWidget->size().height());
473 d->controlsWidget->hide();
571void VideoWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
573 QGraphicsProxyWidget::resizeEvent(event);
575 if (d->controlsWidget) {
576 QSize newControlsSize(event->newSize().width(), d->controlsWidget->size().height());
577 int newHeight =
event->newSize().height();
578 qreal leftMargin, topMargin, rightMargin, bottomMargin;
579 d->controlsWidget->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
581 if (newHeight/5 >= KIconLoader::SizeEnormous) {
582 newControlsSize.setHeight(KIconLoader::SizeEnormous+topMargin+bottomMargin);
583 }
else if (newHeight/5 >= KIconLoader::SizeHuge) {
584 newControlsSize.setHeight(KIconLoader::SizeHuge+topMargin+bottomMargin);
585 }
else if (newHeight/5 >= KIconLoader::SizeLarge) {
586 newControlsSize.setHeight(KIconLoader::SizeLarge+topMargin+bottomMargin);
587 }
else if (newHeight/5 >= KIconLoader::SizeMedium) {
588 newControlsSize.setHeight(KIconLoader::SizeMedium+topMargin+bottomMargin);
590 newControlsSize.setHeight(KIconLoader::SizeSmallMedium+topMargin+bottomMargin);
592 d->controlsWidget->resize(newControlsSize);
594 if (d->spaceForControlsAvailable()) {
595 d->animateControlWidget(
false);