File indexing completed on 2024-04-14 04:52:26

0001 /*  This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2006 Matthias Kretz <kretz@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 
0006 */
0007 
0008 #ifndef PHONON_UI_MEDIACONTROLS_H
0009 #define PHONON_UI_MEDIACONTROLS_H
0010 
0011 #include <QWidget>
0012 #include <phonon/phononnamespace.h>
0013 
0014 namespace Phonon
0015 {
0016 class MediaObject;
0017 class AudioOutput;
0018 class MediaControlsPrivate;
0019 
0020 /**
0021  * \short Simple widget showing buttons to control an MediaObject
0022  * object.
0023  *
0024  * This widget shows the standard player controls. There's at least the
0025  * play/pause and stop buttons. If the media is seekable it shows a seek-slider.
0026  * Optional controls include a volume control and a loop control button.
0027  *
0028  * \author Matthias Kretz <kretz@kde.org>
0029  */
0030 class MediaControls : public QWidget
0031 {
0032     Q_OBJECT
0033     Q_DECLARE_PRIVATE(MediaControls)
0034     /**
0035      * This property holds whether the slider showing the progress of the
0036      * playback is visible.
0037      *
0038      * By default the slider is visible. It is enabled/disabled automatically
0039      * depending on whether the media can be sought or not.
0040      */
0041     Q_PROPERTY(bool seekSliderVisible READ isSeekSliderVisible WRITE setSeekSliderVisible)
0042 
0043     /**
0044      * This property holds whether the slider controlling the volume is visible.
0045      *
0046      * By default the slider is visible if an AudioOutput has been set with
0047      * setAudioOutput.
0048      *
0049      * \see setAudioOutput
0050      */
0051     Q_PROPERTY(bool volumeControlVisible READ isVolumeControlVisible WRITE setVolumeControlVisible)
0052 
0053 public:
0054     /**
0055      * Constructs a media control widget with a \p parent.
0056      */
0057     explicit MediaControls(QWidget *parent = nullptr);
0058     ~MediaControls() override;
0059 
0060     bool isSeekSliderVisible() const;
0061     bool isVolumeControlVisible() const;
0062 
0063 public Q_SLOTS:
0064     void setSeekSliderVisible(bool isVisible);
0065     void setVolumeControlVisible(bool isVisible);
0066 
0067     /**
0068      * Sets the media object to be controlled by this widget.
0069      */
0070     void setMediaObject(MediaObject *mediaObject);
0071 
0072     /**
0073      * Sets the audio output object to be controlled by this widget.
0074      */
0075     void setAudioOutput(AudioOutput *audioOutput);
0076 
0077 protected:
0078     void resizeEvent(QResizeEvent *event) override;
0079 
0080 private:
0081     Q_PRIVATE_SLOT(d_func(), void _k_stateChanged(Phonon::State, Phonon::State))
0082     Q_PRIVATE_SLOT(d_func(), void _k_mediaDestroyed())
0083 
0084     MediaControlsPrivate *const d_ptr;
0085 };
0086 
0087 } // namespace Phonon
0088 
0089 #endif // PHONON_UI_MEDIACONTROLS_H