+ if (m_url != url) {
+ stop(); // emits playingStopped() signal
+ m_url = url;
+ }
+}
+
+KUrl PhononWidget::url() const
+{
+ return m_url;
+}
+
+void PhononWidget::setMode(Mode mode)
+{
+ if (m_mode != mode) {
+ stop(); // emits playingStopped() signal
+ m_mode = mode;
+ }
+}
+
+PhononWidget::Mode PhononWidget::mode() const
+{
+ return m_mode;
+}
+
+void PhononWidget::setVideoSize(const QSize& size)
+{
+ if (m_videoSize != size) {
+ m_videoSize = size;
+ applyVideoSize();
+ }
+}
+
+QSize PhononWidget::videoSize() const
+{
+ return m_videoSize;
+}
+
+void PhononWidget::showEvent(QShowEvent *event)
+{
+ if (event->spontaneous()) {
+ QWidget::showEvent(event);
+ return;
+ }
+
+ if (m_topLayout == 0) {
+ m_topLayout = new QVBoxLayout(this);
+ m_topLayout->setMargin(0);
+ m_topLayout->setSpacing(KDialog::spacingHint());
+ QHBoxLayout *controlsLayout = new QHBoxLayout(this);
+ controlsLayout->setMargin(0);
+ controlsLayout->setSpacing(0);
+
+ m_playButton = new QToolButton(this);
+ m_stopButton = new QToolButton(this);
+ m_seekSlider = new Phonon::SeekSlider(this);
+
+ controlsLayout->addWidget(m_playButton);
+ controlsLayout->addWidget(m_stopButton);
+ controlsLayout->addWidget(m_seekSlider);
+
+ m_topLayout->addLayout(controlsLayout);
+
+ m_playButton->setToolTip(i18n("play"));
+ m_playButton->setIconSize(QSize(16, 16));
+ m_playButton->setIcon(KIcon("media-playback-start"));
+ connect(m_playButton, SIGNAL(clicked()), this, SLOT(play()));
+
+ m_stopButton->setToolTip(i18n("stop"));
+ m_stopButton->setIconSize(QSize(16, 16));
+ m_stopButton->setIcon(KIcon("media-playback-stop"));
+ m_stopButton->hide();
+ connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop()));
+
+ m_seekSlider->setIconVisible(false);
+
+ // Creating an audio player or video player instance might take up to
+ // 2 seconds when doing it the first time. To prevent that the user
+ // interface gets noticeable blocked, the creation is delayed until
+ // the play button has been pressed (see PhononWidget::play()).
+ }
+}
+
+void PhononWidget::hideEvent(QHideEvent *event)
+{
+ QWidget::hideEvent(event);
+ if (!event->spontaneous()) {
+ stop();