provide a nextRequested and previousRequested signals, don't make the

widget too heavy with an internal management of the playlist

svn path=/trunk/KDE/kdelibs/; revision=957136
This commit is contained in:
Marco Martin 2009-04-21 13:35:42 +00:00
parent 71c82013f7
commit 04a722f05b
2 changed files with 43 additions and 3 deletions

View File

@ -50,10 +50,12 @@ public:
hideTimer(0),
shownControls(VideoWidget::NoControls),
controlsWidget(0),
previousButton(0),
playButton(0),
pauseButton(0),
stopButton(0),
playPauseButton(0),
nextButton(0),
progress(0),
volume(0),
openFileButton(0)
@ -93,10 +95,12 @@ public:
QTimer *hideTimer;
VideoWidget::Controls shownControls;
Plasma::Frame *controlsWidget;
IconWidget *previousButton;
IconWidget *playButton;
IconWidget *pauseButton;
IconWidget *stopButton;
IconWidget *playPauseButton;
IconWidget *nextButton;
Slider *progress;
Slider *volume;
IconWidget *openFileButton;
@ -307,6 +311,18 @@ void VideoWidget::setUsedControls(const Controls controls)
controlsLayout->removeAt(0);
}
if (controls&Previous) {
if (!d->previousButton) {
d->previousButton = new IconWidget(d->controlsWidget);
d->previousButton->setIcon("media-playback-start");
connect(d->playButton, SIGNAL(clicked()), this, SLOT(PreviousRequested()));
}
controlsLayout->addItem(d->previousButton);
} else {
d->previousButton->deleteLater();
d->previousButton = 0;
}
if (controls&Play) {
if (!d->playButton) {
d->playButton = new IconWidget(d->controlsWidget);
@ -355,6 +371,18 @@ void VideoWidget::setUsedControls(const Controls controls)
d->playPauseButton = 0;
}
if (controls&Next) {
if (!d->nextButton) {
d->nextButton = new IconWidget(d->nextButton);
d->nextButton->setIcon("media-playback-start");
connect(d->nextButton, SIGNAL(clicked()), this, SIGNAL(nextRequested()));
}
controlsLayout->addItem(d->nextButton);
} else {
d->nextButton->deleteLater();
d->nextButton = 0;
}
connect(d->media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State, Phonon::State)));
@ -435,7 +463,6 @@ void VideoWidget::stop()
d->media->stop();
}
void VideoWidget::seek(qint64 time)
{
d->media->seek(time);

View File

@ -65,8 +65,10 @@ public:
Pause = 2,
Stop = 4,
PlayPause = 8,
Progress = 32,
Volume = 64,
Previous = 16,
Next = 32,
Progress = 64,
Volume = 128,
OpenFile = 128,
DefaultControls = PlayPause|Progress|Volume|OpenFile
};
@ -158,6 +160,7 @@ public:
Phonon::VideoWidget *nativeWidget() const;
public Q_SLOTS:
/**
* Play the current file
*/
@ -191,6 +194,16 @@ Q_SIGNALS:
*/
void aboutToFinish();
/**
* The user pressed the "next" button
*/
void nextRequested();
/**
* The user pressed the "previous" button
*/
void previousRequested();
protected:
void resizeEvent(QGraphicsSceneResizeEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);