[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/MediaCenterComponents
From: Alessandro Diaferia <alediaferia () gmail ! com>
Date: 2009-07-13 21:28:37
Message-ID: 1247520517.464388.23856.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 996130 by adiaferia:
first mediaplayer-controls interactions and some api review
M +41 -9 applets/mediacontroller/controller.cpp
M +6 -0 applets/mediacontroller/controller.h
M +1 -1 applets/mediaplayer/mediaplayer.cpp
M +15 -0 containments/mediacontainment/mediacontainment.cpp
M +1 -0 containments/mediacontainment/mediacontainment.h
M +2 -1 containments/mediacontainment/medialayout.cpp
M +4 -0 libs/playbackcontrol.cpp
M +12 -8 libs/playbackcontrol.h
--- trunk/playground/base/plasma/MediaCenterComponents/applets/mediacontroller/controller.cpp \
#996129:996130 @@ -23,13 +23,17 @@
#include <Phonon/MediaObject>
#include <KIcon>
+#include <KDebug>
// Plasma
#include <Plasma/IconWidget>
+#include <Plasma/Slider>
MediaController::MediaController(QObject *parent, const QVariantList &args)
: MediaCenter::PlaybackControl(parent, args),
- m_svg(new Plasma::FrameSvg(this))
+ m_svg(new Plasma::FrameSvg(this)),
+ m_volumeSlider(new Plasma::Slider(this)),
+ m_seekSlider(new Plasma::Slider(this))
{
setAspectRatioMode(Plasma::IgnoreAspectRatio);
setContentsMargins(0, 0, 0, 0);
@@ -40,6 +44,11 @@
QGraphicsLinearLayout *controlLayout = new \
QGraphicsLinearLayout(Qt::Horizontal);
+ m_seekSlider->setRange(0, 100);
+ m_seekSlider->setOrientation(Qt::Horizontal);
+ connect (m_seekSlider, SIGNAL(sliderMoved(int)), this, \
SLOT(slotSeekSlider(int))); + controlLayout->addItem(m_seekSlider);
+
Plasma::IconWidget *skipBack = new Plasma::IconWidget(this);
skipBack->setIcon("media-skip-backward");
connect (skipBack, SIGNAL(clicked()), this, SIGNAL(mediaSkipBackwardRequest()));
@@ -54,12 +63,19 @@
m_playPause->setIcon("media-playback-start");
// TODO connect
controlLayout->addItem(m_playPause);
+ connect (m_playPause, SIGNAL(clicked()), SIGNAL(playPauseRequest()));
Plasma::IconWidget *skipForward = new Plasma::IconWidget(this);
skipForward->setIcon("media-skip-forward");
connect (skipForward, SIGNAL(clicked()), this, \
SIGNAL(mediaSkipForwardRequest())); controlLayout->addItem(skipForward);
+ m_volumeSlider->setRange(0, 100);
+ m_volumeSlider->setOrientation(Qt::Horizontal);
+ m_volumeSlider->setValue(100);
+ connect (m_volumeSlider, SIGNAL(sliderMoved(int)), this, \
SLOT(slotVolumeSlider(int))); + controlLayout->addItem(m_volumeSlider);
+
setLayout(controlLayout);
}
@@ -92,14 +108,6 @@
void MediaController::init()
{
- m_mediaObject = mediaObject();
-
- if (!m_mediaObject) {
- return;
- }
- if (m_mediaObject->state() == Phonon::PlayingState) {
- m_playPause->setIcon("media-playback-pause");
- }
}
void MediaController::togglePlayPayse(Phonon::State oldState, Phonon::State \
newState) @@ -113,5 +121,29 @@
}
}
+void MediaController::slotVolumeSlider(int value)
+{
+ emit volumeLevelChangeRequest((qreal)100 / value);
+}
+void MediaController::slotSeekSlider(int value)
+{
+ emit seekRequest(value);
+}
+
+void MediaController::receivedMediaObject()
+{
+ if (!mediaObject()) {
+ return;
+ }
+
+ m_mediaObject = mediaObject();
+
+ m_seekSlider->setRange(0, m_mediaObject->totalTime());
+ if (m_mediaObject->state() == Phonon::PlayingState) {
+ m_playPause->setIcon("media-playback-pause");
+ }
+}
+
+
K_EXPORT_PLASMA_APPLET(mediacontroller, MediaController)
--- trunk/playground/base/plasma/MediaCenterComponents/applets/mediacontroller/controller.h \
#996129:996130 @@ -29,6 +29,7 @@
namespace Plasma {
class IconWidget;
+ class Slider;
}
class MediaController : public MediaCenter::PlaybackControl
@@ -46,14 +47,19 @@
protected:
void resizeEvent(QGraphicsSceneResizeEvent *event);
+ void receivedMediaObject();
private slots:
void togglePlayPayse(Phonon::State, Phonon::State);
+ void slotVolumeSlider(int value);
+ void slotSeekSlider(int value);
private:
Plasma::FrameSvg *m_svg;
Phonon::MediaObject *m_mediaObject;
Plasma::IconWidget *m_playPause;
+ Plasma::Slider *m_volumeSlider;
+ Plasma::Slider *m_seekSlider;
int iconSizeFromCurrentSize() const;
--- trunk/playground/base/plasma/MediaCenterComponents/applets/mediaplayer/mediaplayer.cpp \
#996129:996130 @@ -94,7 +94,7 @@
media->play();
- m_video->setUsedControls(Plasma::VideoWidget::DefaultControls);
+// m_video->setUsedControls(Plasma::VideoWidget::DefaultControls);
m_hideTimer = new QTimer(this);
m_hideTimer->setSingleShot(true);
--- trunk/playground/base/plasma/MediaCenterComponents/containments/mediacontainment/mediacontainment.cpp \
#996129:996130 @@ -106,6 +106,10 @@
m_control = control;
m_layout->setPlaybackControl(m_control);
m_layout->invalidate();
+
+ if (m_player) {
+ initControls();
+ }
}
return;
}
@@ -136,12 +140,23 @@
m_player = player;
m_layout->setPlayer(m_player);
m_layout->invalidate();
+
+ if (m_control) {
+ initControls();
+ }
}
return;
}
}
+void MediaContainment::initControls()
+{
+ connect (m_control, SIGNAL(playPauseRequest()), m_player, SLOT(playPause()));
+ connect (m_control, SIGNAL(seekRequest(int)), m_player, SLOT(seek(int)));
+ m_control->setMediaObject(m_player->mediaObject());
+}
+
void MediaContainment::slotAppletRemoved(Plasma::Applet *applet)
{
if (applet == m_browser) {
--- trunk/playground/base/plasma/MediaCenterComponents/containments/mediacontainment/mediacontainment.h \
#996129:996130 @@ -58,6 +58,7 @@
MediaLayout *m_layout;
void addMediaApplet(Plasma::Applet *);
+ void initControls();
};
#endif // MEDIACONTAINMENT_H
--- trunk/playground/base/plasma/MediaCenterComponents/containments/mediacontainment/medialayout.cpp \
#996129:996130 @@ -52,6 +52,7 @@
{
m_control = control;
m_needLayouting << m_control;
+ m_control->setZValue(1000);
MediaHandler *handler = new MediaHandler(m_control, MediaHandler::Bottom);
connect (handler, SIGNAL(appletHideRequest(Plasma::Applet*)), this, \
SLOT(animateHidingApplet(Plasma::Applet*))); @@ -149,7 +150,7 @@
QRectF MediaLayout::controllerPreferredShowingRect() const
{
- const int width = 64 * 4;
+ const int width = 64 * 4 + 256;
const int height = 64;
return QRectF(QPointF((m_containment->size().width() - width) / 2, 0), \
QSizeF(width, height));
--- trunk/playground/base/plasma/MediaCenterComponents/libs/playbackcontrol.cpp \
#996129:996130 @@ -55,9 +55,13 @@
void PlaybackControl::setMediaObject(Phonon::MediaObject *mediaObject)
{
d->mediaObject = mediaObject;
+ receivedMediaObject();
}
Phonon::MediaObject* PlaybackControl::mediaObject()
{
return d->mediaObject;
}
+
+void PlaybackControl::receivedMediaObject()
+{}
--- trunk/playground/base/plasma/MediaCenterComponents/libs/playbackcontrol.h \
#996129:996130 @@ -68,21 +68,16 @@
signals:
/**
* Emit this signal whenever the controller receives
- * a play request from the user (e.g. the play button is clicked).
+ * a play/pause request from the user (e.g. the play button is clicked).
*/
- void playRequest();
+ void playPauseRequest();
/**
- * Emit this signal whenever pausing the reproduction is requested.
- */
- void pauseRequest();
-
- /**
* This signal has to be emitted whenever there is need for seeking
* the current reproduction.
* @note: if the current reproduction media is a picture this signal has no \
effect.
*/
- void seekRequest(qint64 time);
+ void seekRequest(int time);
/**
* Emit this signal whenever the user requests for the reproduction to be \
stopped- @@ -129,6 +124,15 @@
*/
virtual void mediaTypeChanged(MediaCenter::MediaType newType);
+protected:
+ /**
+ * This method is called whenever a new Phonon::MediaObject is set
+ * via setMediaObject(). Use this method for internal update purposes
+ * when the MediaObject is ready.
+ *
+ * @note: the default implementation does nothing.
+ */
+ virtual void receivedMediaObject();
private:
class PlaybackControlPrivate;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic