┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/information/phononwidget.cpp
diff options
context:
space:
mode:
authorSimon Paul St James <[email protected]>2009-01-27 19:50:21 +0000
committerSimon Paul St James <[email protected]>2009-01-27 19:50:21 +0000
commit9d3ed99ab02271496c0412fe97ad89575492582c (patch)
tree2149d08c98a349dad469dbf570ddfcd7ce64dbd7 /src/panels/information/phononwidget.cpp
parent68b3e86fdfcb1941b6dac4173cad924e27f36f5d (diff)
Initial import of Matthias's draft patch for adding video and audio previewing (similar to the file dialog) to Dolphin's metadata panel. Since Phonon is currently in-process only with the memory/ stability issues that come with this, this might have to be disabled by default - we'll see how it goes. Thanks, Matthias!
CCMAIL:[email protected] CCMAIL:[email protected] svn path=/trunk/KDE/kdebase/apps/; revision=917389
Diffstat (limited to 'src/panels/information/phononwidget.cpp')
-rw-r--r--src/panels/information/phononwidget.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp
new file mode 100644
index 000000000..d52ae9d8a
--- /dev/null
+++ b/src/panels/information/phononwidget.cpp
@@ -0,0 +1,85 @@
+/* This file is part of the KDE project
+ Copyright (C) 2007 Matthias Kretz <[email protected]>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+#include "phononwidget.h"
+
+#include <Phonon/Global>
+#include <Phonon/MediaObject>
+#include <Phonon/SeekSlider>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QToolButton>
+#include <kicon.h>
+#include <kurl.h>
+#include <klocale.h>
+
+PhononWidget::PhononWidget(QWidget *parent)
+ : QWidget(parent),
+ m_media(0)
+{
+ QHBoxLayout *innerLayout = new QHBoxLayout(this);
+ innerLayout->setMargin(0);
+ innerLayout->setSpacing(0);
+ m_playButton = new QToolButton(this);
+ m_stopButton = new QToolButton(this);
+ m_seekSlider = new Phonon::SeekSlider(this);
+ innerLayout->addWidget(m_playButton);
+ innerLayout->addWidget(m_stopButton);
+ innerLayout->addWidget(m_seekSlider);
+
+ m_playButton->setToolTip(i18n("play"));
+ m_playButton->setIconSize(QSize(16, 16));
+ m_playButton->setIcon(KIcon("media-playback-start"));
+ m_stopButton->setToolTip(i18n("stop"));
+ m_stopButton->setIconSize(QSize(16, 16));
+ m_stopButton->setIcon(KIcon("media-playback-stop"));
+ m_stopButton->hide();
+ m_seekSlider->setIconVisible(false);
+}
+
+void PhononWidget::setUrl(const KUrl &url)
+{
+ if (m_media) {
+ m_media->setCurrentSource(url);
+ } else {
+ m_media = Phonon::createPlayer(Phonon::MusicCategory, url);
+ m_media->setParent(this);
+ connect(m_playButton, SIGNAL(clicked()), m_media, SLOT(play()));
+ connect(m_stopButton, SIGNAL(clicked()), m_media, SLOT(stop()));
+ connect(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), SLOT(stateChanged(Phonon::State)));
+ m_seekSlider->setMediaObject(m_media);
+ }
+}
+
+void PhononWidget::stateChanged(Phonon::State newstate)
+{
+ setUpdatesEnabled(false);
+ switch (newstate) {
+ case Phonon::PlayingState:
+ case Phonon::BufferingState:
+ m_stopButton->show();
+ m_playButton->hide();
+ break;
+ default:
+ m_stopButton->hide();
+ m_playButton->show();
+ break;
+ }
+ setUpdatesEnabled(true);
+}