summaryrefslogtreecommitdiffstats
path: root/interfaces/kmediaplayer
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /interfaces/kmediaplayer
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'interfaces/kmediaplayer')
-rw-r--r--interfaces/kmediaplayer/Makefile.am18
-rw-r--r--interfaces/kmediaplayer/kfileaudiopreview/Makefile.am13
-rw-r--r--interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp146
-rw-r--r--interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.h64
-rw-r--r--interfaces/kmediaplayer/kmediaplayer.desktop4
-rw-r--r--interfaces/kmediaplayer/kmediaplayerengine.desktop3
-rw-r--r--interfaces/kmediaplayer/player.cpp79
-rw-r--r--interfaces/kmediaplayer/player.h143
-rw-r--r--interfaces/kmediaplayer/playerdcopobject.h62
-rw-r--r--interfaces/kmediaplayer/view.cpp89
-rw-r--r--interfaces/kmediaplayer/view.h98
11 files changed, 719 insertions, 0 deletions
diff --git a/interfaces/kmediaplayer/Makefile.am b/interfaces/kmediaplayer/Makefile.am
new file mode 100644
index 000000000..11838080a
--- /dev/null
+++ b/interfaces/kmediaplayer/Makefile.am
@@ -0,0 +1,18 @@
+if include_ARTS
+kfileaudiopreview_subdir = kfileaudiopreview
+endif
+
+SUBDIRS = . $(kfileaudiopreview_subdir)
+INCLUDES = -I$(srcdir)/.. $(all_includes)
+
+lib_LTLIBRARIES = libkmediaplayer.la
+
+libkmediaplayer_la_SOURCES = player.cpp playerdcopobject.skel view.cpp
+libkmediaplayer_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+libkmediaplayer_la_LIBADD = $(LIB_KPARTS)
+libkmediaplayer_la_METASOURCES = AUTO
+
+kmediaplayerinclude_HEADERS = player.h playerdcopobject.h view.h
+kmediaplayerincludedir = $(includedir)/kmediaplayer
+
+kde_servicetypes_DATA = kmediaplayerengine.desktop kmediaplayer.desktop
diff --git a/interfaces/kmediaplayer/kfileaudiopreview/Makefile.am b/interfaces/kmediaplayer/kfileaudiopreview/Makefile.am
new file mode 100644
index 000000000..3eb9b5da8
--- /dev/null
+++ b/interfaces/kmediaplayer/kfileaudiopreview/Makefile.am
@@ -0,0 +1,13 @@
+INCLUDES = -I$(top_srcdir)/interfaces/ -I$(top_srcdir)/arts/kde -I$(includedir)/arts $(all_includes)
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = kfileaudiopreview.la
+
+kfileaudiopreview_la_SOURCES = kfileaudiopreview.cpp
+kfileaudiopreview_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module -avoid-version -no-undefined
+kfileaudiopreview_la_LIBADD = $(top_builddir)/interfaces/kmediaplayer/libkmediaplayer.la $(top_builddir)/arts/kde/libartskde.la $(LIB_KIO)
+
+noinst_HEADERS = kfileaudiopreview.h
+
+messages:
+ $(XGETTEXT) $(kfileaudiopreview_la_SOURCES) -o $(podir)/kfileaudiopreview.pot
diff --git a/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp b/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp
new file mode 100644
index 000000000..5db8f65d0
--- /dev/null
+++ b/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.cpp
@@ -0,0 +1,146 @@
+#include "kfileaudiopreview.h"
+
+#include <qcheckbox.h>
+#include <qhbox.h>
+#include <qlayout.h>
+#include <qvgroupbox.h>
+
+#include <kglobal.h>
+#include <kconfig.h>
+#include <klibloader.h>
+#include <klocale.h>
+#include <kmediaplayer/player.h>
+#include <kmimetype.h>
+#include <kparts/componentfactory.h>
+
+#include <kplayobjectfactory.h>
+
+#include <config-kfile.h>
+
+class KFileAudioPreviewFactory : public KLibFactory
+{
+protected:
+ virtual QObject *createObject( QObject *parent, const char *name,
+ const char *className, const QStringList & args)
+ {
+ Q_UNUSED(className);
+ Q_UNUSED(args);
+ return new KFileAudioPreview( dynamic_cast<QWidget*>( parent ), name );
+ }
+};
+
+K_EXPORT_COMPONENT_FACTORY( kfileaudiopreview, KFileAudioPreviewFactory )
+
+
+///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+
+
+class KFileAudioPreview::KFileAudioPreviewPrivate
+{
+public:
+ KFileAudioPreviewPrivate( QWidget *parent )
+ {
+ player = KParts::ComponentFactory::createInstanceFromQuery<KMediaPlayer::Player>( "KMediaPlayer/Player", QString::null, parent );
+ }
+
+ ~KFileAudioPreviewPrivate()
+ {
+ delete player;
+ }
+
+ KMediaPlayer::Player *player;
+};
+
+
+KFileAudioPreview::KFileAudioPreview( QWidget *parent, const char *name )
+ : KPreviewWidgetBase( parent, name )
+{
+ KGlobal::locale()->insertCatalogue("kfileaudiopreview");
+
+ QStringList formats = KDE::PlayObjectFactory::mimeTypes();
+ // ###
+ QStringList::ConstIterator it = formats.begin();
+ for ( ; it != formats.end(); ++it )
+ m_supportedFormats.insert( *it, (void*) 1 );
+
+ QVGroupBox *box = new QVGroupBox( i18n("Media Player"), this );
+ QVBoxLayout *layout = new QVBoxLayout( this );
+ layout->addWidget( box );
+
+ (void) new QWidget( box ); // spacer
+
+ d = new KFileAudioPreviewPrivate( 0L ); // not box -- being reparented anyway
+ if ( d->player ) // only if there actually is a component...
+ {
+ setSupportedMimeTypes( formats );
+ KMediaPlayer::View *view = d->player->view();
+ view->setEnabled( false );
+
+ // if we have access to the video widget, show it above the player
+ // So, reparent first the video widget, then the view.
+ if ( view->videoWidget() )
+ {
+ QHBox *frame = new QHBox( box );
+ frame->setFrameStyle( QFrame::Panel | QFrame::Sunken );
+ frame->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+ view->videoWidget()->reparent( frame, QPoint(0,0) );
+ }
+
+ view->reparent( box, QPoint(0,0) );
+ }
+
+ m_autoPlay = new QCheckBox( i18n("Play &automatically"), box );
+ KConfigGroup config( KGlobal::config(), ConfigGroup );
+ m_autoPlay->setChecked( config.readBoolEntry( "Autoplay sounds", true ) );
+ connect( m_autoPlay, SIGNAL(toggled(bool)), SLOT(toggleAuto(bool)) );
+}
+
+KFileAudioPreview::~KFileAudioPreview()
+{
+ KConfigGroup config( KGlobal::config(), ConfigGroup );
+ config.writeEntry( "Autoplay sounds", m_autoPlay->isChecked() );
+
+ delete d;
+}
+
+void KFileAudioPreview::showPreview( const KURL &url )
+{
+ if ( !d->player || !url.isValid() )
+ return;
+
+ KMimeType::Ptr mt = KMimeType::findByURL( url );
+ bool supported = m_supportedFormats.find( mt->name() );
+ d->player->view()->setEnabled( supported );
+ if ( !supported )
+ return;
+
+ static_cast<KParts::ReadOnlyPart*>(d->player)->openURL( url );
+ if ( m_autoPlay->isChecked() )
+ d->player->play();
+}
+
+void KFileAudioPreview::clearPreview()
+{
+ if ( d->player )
+ {
+ d->player->stop();
+ d->player->closeURL();
+ }
+}
+
+void KFileAudioPreview::toggleAuto( bool on )
+{
+ if ( !d->player )
+ return;
+
+ if ( on && m_currentURL.isValid() && d->player->view()->isEnabled() )
+ d->player->play();
+ else
+ d->player->stop();
+}
+
+void KFileAudioPreview::virtual_hook( int, void* )
+{}
+
+#include "kfileaudiopreview.moc"
diff --git a/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.h b/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.h
new file mode 100644
index 000000000..df1d19e5b
--- /dev/null
+++ b/interfaces/kmediaplayer/kfileaudiopreview/kfileaudiopreview.h
@@ -0,0 +1,64 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2003 Carsten Pfeiffer <pfeiffer@kde.org>
+
+ library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation, version 2.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KFILEAUDIOPREVIEW_H
+#define KFILEAUDIOPREVIEW_H
+
+#include <qdict.h>
+
+#include <kurl.h>
+#include <kpreviewwidgetbase.h>
+
+class QCheckBox;
+class QPushButton;
+class QLabel;
+
+class KFileDialog;
+class KFileItem;
+
+/**
+ * Audio "preview" widget for the file dialog.
+ */
+class KFileAudioPreview : public KPreviewWidgetBase
+{
+ Q_OBJECT
+
+public:
+ KFileAudioPreview(QWidget *parent = 0, const char *name = 0 );
+ ~KFileAudioPreview();
+
+public slots:
+ virtual void showPreview(const KURL &url);
+ virtual void clearPreview();
+
+private slots:
+ void toggleAuto(bool);
+
+private:
+ QDict<void> m_supportedFormats;
+ KURL m_currentURL;
+ QCheckBox *m_autoPlay;
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+private:
+ class KFileAudioPreviewPrivate;
+ KFileAudioPreviewPrivate *d;
+};
+
+#endif // KFILEAUDIOPREVIEW_H
diff --git a/interfaces/kmediaplayer/kmediaplayer.desktop b/interfaces/kmediaplayer/kmediaplayer.desktop
new file mode 100644
index 000000000..310247337
--- /dev/null
+++ b/interfaces/kmediaplayer/kmediaplayer.desktop
@@ -0,0 +1,4 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KMediaPlayer/Player
+X-KDE-Derived=KParts/ReadOnlyPart
diff --git a/interfaces/kmediaplayer/kmediaplayerengine.desktop b/interfaces/kmediaplayer/kmediaplayerengine.desktop
new file mode 100644
index 000000000..3fa56fae7
--- /dev/null
+++ b/interfaces/kmediaplayer/kmediaplayerengine.desktop
@@ -0,0 +1,3 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KMediaPlayer/Engine
diff --git a/interfaces/kmediaplayer/player.cpp b/interfaces/kmediaplayer/player.cpp
new file mode 100644
index 000000000..cbfba1368
--- /dev/null
+++ b/interfaces/kmediaplayer/player.cpp
@@ -0,0 +1,79 @@
+// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Except as contained in this notice, the name(s) of the author(s) shall not be
+// used in advertising or otherwise to promote the sale, use or other dealings
+// in this Software without prior written authorization from the author(s).
+
+#include <kmediaplayer/player.h>
+
+KMediaPlayer::PlayerDCOPObject::PlayerDCOPObject(void)
+ : DCOPObject("KMediaPlayer")
+{
+}
+
+KMediaPlayer::Player::Player(QWidget *, const char *, QObject *parent, const char *name)
+ : KParts::ReadOnlyPart(parent, name)
+ , currentLooping(false)
+ , currentState(Empty)
+ , d(0)
+{
+}
+
+KMediaPlayer::Player::Player(QObject *parent, const char *name)
+ : KParts::ReadOnlyPart(parent, name)
+ , currentLooping(false)
+ , currentState(Empty)
+ , d(0)
+{
+}
+
+KMediaPlayer::Player::~Player(void)
+{
+}
+
+void KMediaPlayer::Player::setLooping(bool b)
+{
+ if(b != currentLooping)
+ {
+ currentLooping = b;
+ emit loopingChanged(b);
+ }
+}
+
+bool KMediaPlayer::Player::isLooping(void) const
+{
+ return currentLooping;
+}
+
+void KMediaPlayer::Player::setState(int s)
+{
+ if(s != currentState)
+ {
+ currentState = (State)s;
+ emit stateChanged(s);
+ }
+}
+
+int KMediaPlayer::Player::state(void) const
+{
+ return (int)currentState;
+}
+
+#include "player.moc"
diff --git a/interfaces/kmediaplayer/player.h b/interfaces/kmediaplayer/player.h
new file mode 100644
index 000000000..89a4a0b23
--- /dev/null
+++ b/interfaces/kmediaplayer/player.h
@@ -0,0 +1,143 @@
+// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Except as contained in this notice, the name(s) of the author(s) shall not be
+// used in advertising or otherwise to promote the sale, use or other dealings
+// in this Software without prior written authorization from the author(s).
+
+#ifndef KMEDIAPLAYERPLAYER_H
+#define KMEDIAPLAYERPLAYER_H
+
+#include <kparts/part.h>
+#include <kmediaplayer/playerdcopobject.h>
+#include <kmediaplayer/view.h>
+
+/** KMediaPlayer contains an interface to reusable media player components.
+*/
+namespace KMediaPlayer
+{
+
+/** Player is the center of the KMediaPlayer interface. It provides all of
+ * the necessary media player operations, and optionally provides the GUI to
+ * control them.
+ *
+ * There are two servicetypes for Player: KMediaPlayer/Player and
+ * KMediaPlayer/Engine. KMediaPlayer/Player provides a widget (accessable
+ * through view as well as XML GUI KActions. KMediaPlayer/Engine omits
+ * the user interface facets, for those who wish to provide their own
+ * interface.
+ */
+class KDE_EXPORT Player : public KParts::ReadOnlyPart, public PlayerDCOPObject
+{
+Q_OBJECT
+
+public:
+ /** This constructor is what to use when no GUI is required, as in the
+ * case of a KMediaPlayer/Engine.
+ */
+ Player(QObject *parent, const char *name);
+
+ /** This constructor is what to use when a GUI is required, as in the
+ * case of a KMediaPlayer/Player.
+ */
+ Player(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name);
+
+ virtual ~Player(void);
+
+ /** A convenience function returning a pointer to the View for this
+ * Player, or 0 if this Player has no GUI.
+ */
+ virtual View *view(void) = 0;
+
+public slots:
+ /** Pause playback of the media track.*/
+ virtual void pause(void) = 0;
+
+ /** Begin playing the media track.*/
+ virtual void play(void) = 0;
+
+ /** Stop playback of the media track and return to the beginning.*/
+ virtual void stop(void) = 0;
+
+ /** Move the current playback position to the specified time in
+ * milliseconds, if the track is seekable. Some streams may not be
+ * seeked.
+ */
+ virtual void seek(unsigned long msec) = 0;
+public:
+ /** Returns whether the current track honors seek requests.*/
+ virtual bool isSeekable(void) const = 0;
+
+ /** Returns the current playback position in the track.*/
+ virtual unsigned long position(void) const = 0;
+
+ /** Returns whether the current track has a length. Some streams are
+ * endless, and do not have one. */
+ virtual bool hasLength(void) const = 0;
+
+ /** Returns the length of the current track.*/
+ virtual unsigned long length(void) const = 0;
+
+public slots:
+ /** Set whether the Player should continue playing at the beginning of
+ * the track when the end of the track is reached.
+ */
+ void setLooping(bool);
+public:
+ /** Return the current looping state. */
+ bool isLooping(void) const;
+signals:
+ /** Emitted when the looping state is changed. */
+ void loopingChanged(bool);
+
+public:
+ /** The possible states of the Player */
+ enum State
+ {
+ /** No track is loaded. */
+ Empty,
+ /** Not playing. */
+ Stop,
+ /** Playing is temporarily suspended. */
+ Pause,
+ /** The media is currently being output. */
+ Play
+ };
+ /** Return the current state of the player. */
+ int state(void) const;
+signals:
+ /** Emitted when the state changes. */
+ void stateChanged(int);
+
+protected slots:
+ /** Implementers use this to control what users see as the current
+ * state.*/
+ void setState(int);
+
+private:
+ bool currentLooping;
+ State currentState;
+
+ struct Data;
+ Data *d;
+};
+
+}
+
+#endif
diff --git a/interfaces/kmediaplayer/playerdcopobject.h b/interfaces/kmediaplayer/playerdcopobject.h
new file mode 100644
index 000000000..73a1cfa1d
--- /dev/null
+++ b/interfaces/kmediaplayer/playerdcopobject.h
@@ -0,0 +1,62 @@
+// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Except as contained in this notice, the name(s) of the author(s) shall not be
+// used in advertising or otherwise to promote the sale, use or other dealings
+// in this Software without prior written authorization from the author(s).
+
+#ifndef KMEDIAPLAYERPLAYERDCOPOBJECT_H
+#define KMEDIAPLAYERPLAYERDCOPOBJECT_H
+
+#include <dcopobject.h>
+#include <kurl.h>
+
+namespace KMediaPlayer
+{
+
+class KDE_EXPORT PlayerDCOPObject : public DCOPObject
+{
+K_DCOP
+
+public:
+ PlayerDCOPObject(void);
+
+k_dcop:
+ virtual bool openURL(const KURL &file) = 0;
+ virtual void pause() = 0;
+ virtual void play() = 0;
+ virtual void stop() = 0;
+
+ virtual void seek(unsigned long msec) = 0;
+ virtual bool isSeekable() const = 0;
+ virtual unsigned long position() const = 0;
+
+ virtual bool hasLength() const = 0;
+ virtual unsigned long length() const = 0;
+
+ virtual void setLooping(bool) = 0;
+ virtual bool isLooping() const = 0;
+
+ virtual int state() const = 0;
+ virtual void setState(int) = 0;
+};
+
+}
+
+#endif
diff --git a/interfaces/kmediaplayer/view.cpp b/interfaces/kmediaplayer/view.cpp
new file mode 100644
index 000000000..c231d8aaf
--- /dev/null
+++ b/interfaces/kmediaplayer/view.cpp
@@ -0,0 +1,89 @@
+// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Except as contained in this notice, the name(s) of the author(s) shall not be
+// used in advertising or otherwise to promote the sale, use or other dealings
+// in this Software without prior written authorization from the author(s).
+
+#include <kmediaplayer/view.h>
+
+struct KMediaPlayer::View::Data
+{
+ Data() : videoWidget(0L) {}
+
+ QWidget *videoWidget;
+};
+
+KMediaPlayer::View::View(QWidget *parent, const char *name)
+ : QWidget(parent, name)
+ , currentButtons((int)All)
+ , d(new Data())
+{
+}
+
+KMediaPlayer::View::~View(void)
+{
+ delete d;
+}
+
+int KMediaPlayer::View::buttons(void)
+{
+ return currentButtons;
+}
+
+void KMediaPlayer::View::setButtons(int buttons)
+{
+ if(buttons != currentButtons)
+ {
+ currentButtons = buttons;
+ emit buttonsChanged(buttons);
+ }
+}
+
+bool KMediaPlayer::View::button(int b)
+{
+ return currentButtons & b;
+}
+
+void KMediaPlayer::View::showButton(int b)
+{
+ setButtons(currentButtons | b);
+}
+
+void KMediaPlayer::View::hideButton(int b)
+{
+ setButtons(currentButtons & ~b);
+}
+
+void KMediaPlayer::View::toggleButton(int b)
+{
+ setButtons(currentButtons ^ b);
+}
+
+void KMediaPlayer::View::setVideoWidget(QWidget *videoWidget)
+{
+ d->videoWidget = videoWidget;
+}
+
+QWidget* KMediaPlayer::View::videoWidget()
+{
+ return d->videoWidget;
+}
+
+#include "view.moc"
diff --git a/interfaces/kmediaplayer/view.h b/interfaces/kmediaplayer/view.h
new file mode 100644
index 000000000..be60f9e75
--- /dev/null
+++ b/interfaces/kmediaplayer/view.h
@@ -0,0 +1,98 @@
+// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Except as contained in this notice, the name(s) of the author(s) shall not be
+// used in advertising or otherwise to promote the sale, use or other dealings
+// in this Software without prior written authorization from the author(s).
+
+#ifndef KMEDIAPLAYERVIEW_H
+#define KMEDIAPLAYERVIEW_H
+
+#include <qwidget.h>
+#include <kdelibs_export.h>
+
+namespace KMediaPlayer
+{
+
+/** View is part of the user interface of a Player. */
+class KDE_EXPORT View : public QWidget
+{
+Q_OBJECT
+
+public:
+ /** Your typical QWidget constructor. */
+ View(QWidget *parent, const char *name);
+ virtual ~View(void);
+
+ /** The Possible buttons that can appear in the UI. */
+ enum Button
+ {
+ /** Button that connects to Player::play */
+ Play = 1,
+ /** Button that connects to Player::stop */
+ Stop = 2,
+ /** Button that connects to Player::pause */
+ Pause = 4,
+ /** A seeker that interfaces with Player::seek */
+ Seeker = 8,
+ /** Show all buttons. */
+ All = 255
+ };
+
+ /** Return which buttons are being displayed. */
+ int buttons(void);
+
+ /** Return the QWidget in which video is displayed.
+ May Return 0L if there is none. */
+ QWidget *videoWidget();
+
+public slots:
+ /** Set which buttons to display. See Button. */
+ void setButtons(int);
+
+ /** Returns if a particular button is being displayed. */
+ bool button(int);
+ /** Display a particular button. */
+ void showButton(int);
+ /** Stop displaying a particular button. */
+ void hideButton(int);
+ /** Toggle the display of a particular button. */
+ void toggleButton(int);
+
+signals:
+ /** Emitted when the set of displayed buttons changes. */
+ void buttonsChanged(int);
+
+protected:
+ /** The implementing view should set the widget in which
+ the video will be displayed. KMediaPlayer users may
+ reparent() it to somewhere else, for example.
+ */
+ void setVideoWidget(QWidget *videoWidget);
+
+private:
+ int currentButtons;
+
+ struct Data;
+ Data *d;
+};
+
+}
+
+#endif