File indexing completed on 2024-04-28 12:31:53

0001 /*  This file is part of the KDE project
0002     Copyright (C) 2006-2007 Matthias Kretz <kretz@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Lesser General Public
0006     License as published by the Free Software Foundation; either
0007     version 2.1 of the License, or (at your option) version 3, or any
0008     later version accepted by the membership of KDE e.V. (or its
0009     successor approved by the membership of KDE e.V.), Nokia Corporation
0010     (or its successors, if any) and the KDE Free Qt Foundation, which shall
0011     act as a proxy defined in Section 6 of version 3 of the license.
0012 
0013     This library is distributed in the hope that it will be useful,
0014     but WITHOUT ANY WARRANTY; without even the implied warranty of
0015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016     Lesser General Public License for more details.
0017 
0018     You should have received a copy of the GNU Lesser General Public
0019     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 */
0022 
0023 #ifndef PHONON_UI_SEEKSLIDER_H
0024 #define PHONON_UI_SEEKSLIDER_H
0025 
0026 #include "phonon_export.h"
0027 #include "phonondefs.h"
0028 #include "phononnamespace.h"
0029 #include <QWidget>
0030 
0031 
0032 #ifndef QT_NO_PHONON_SEEKSLIDER
0033 
0034 namespace Phonon
0035 {
0036 class MediaObject;
0037 
0038 class SeekSliderPrivate;
0039 
0040 /** \class SeekSlider seekslider.h phonon/SeekSlider
0041  * \short Widget providing a slider for seeking in MediaObject objects.
0042  *
0043  * \ingroup PhononWidgets
0044  * \author Matthias Kretz <kretz@kde.org>
0045  */
0046 class PHONON_EXPORT SeekSlider : public QWidget
0047 {
0048     Q_OBJECT
0049     P_DECLARE_PRIVATE(SeekSlider)
0050     /**
0051      * This property holds whether the icon next to the slider is visible.
0052      *
0053      * By default the icon is visible if the platform provides an icon; else
0054      * it's hidden.
0055      */
0056     Q_PROPERTY(bool iconVisible READ isIconVisible WRITE setIconVisible)
0057 
0058     /**
0059      * This property holds whether slider tracking is enabled.
0060      *
0061      * If tracking is enabled (the default), the media seeks
0062      * while the slider is being dragged. If tracking is
0063      * disabled, the media seeks only when the user
0064      * releases the slider.
0065      */
0066     Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
0067 
0068     /**
0069      * This property holds the page step.
0070      *
0071      * The larger of two natural steps that a slider provides and
0072      * typically corresponds to the user pressing PageUp or PageDown.
0073      *
0074      * Defaults to 5 seconds.
0075      */
0076     Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep)
0077 
0078     /**
0079      * This property holds the single step.
0080      *
0081      * The smaller of two natural steps that a slider provides and
0082      * typically corresponds to the user pressing an arrow key.
0083      *
0084      * Defaults to 0.5 seconds.
0085      */
0086     Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
0087 
0088     /**
0089      * This property holds the orientation of the slider.
0090      *
0091      * The orientation must be Qt::Vertical or Qt::Horizontal (the default).
0092      */
0093     Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
0094 
0095     /**
0096      * \brief the icon size used for the mute button/icon.
0097      *
0098      * The default size is defined by the GUI style.
0099      */
0100     Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
0101 
0102     public:
0103         /**
0104          * Constructs a seek slider widget with the given \p parent.
0105          */
0106         explicit SeekSlider(QWidget *parent = nullptr);
0107         explicit SeekSlider(MediaObject *media, QWidget *parent = nullptr);
0108 
0109         /**
0110          * Destroys the seek slider.
0111          */
0112         ~SeekSlider() override;
0113 
0114         bool hasTracking() const;
0115         void setTracking(bool tracking);
0116         int pageStep() const;
0117         void setPageStep(int milliseconds);
0118         int singleStep() const;
0119         void setSingleStep(int milliseconds);
0120         Qt::Orientation orientation() const;
0121         bool isIconVisible() const;
0122         QSize iconSize() const;
0123         MediaObject *mediaObject() const;
0124 
0125     public Q_SLOTS:
0126         void setOrientation(Qt::Orientation);
0127         void setIconVisible(bool);
0128         void setIconSize(const QSize &size);
0129 
0130         /**
0131          * Sets the media object to be controlled by this slider.
0132          */
0133         void setMediaObject(MediaObject *);
0134 
0135     protected:
0136         SeekSliderPrivate *const k_ptr;
0137 
0138     private:
0139         Q_PRIVATE_SLOT(k_func(), void _k_stateChanged(Phonon::State))
0140         Q_PRIVATE_SLOT(k_func(), void _k_seek(int))
0141         Q_PRIVATE_SLOT(k_func(), void _k_tick(qint64))
0142         Q_PRIVATE_SLOT(k_func(), void _k_length(qint64))
0143         Q_PRIVATE_SLOT(k_func(), void _k_seekableChanged(bool))
0144         Q_PRIVATE_SLOT(k_func(), void _k_currentSourceChanged())
0145 };
0146 
0147 } // namespace Phonon
0148 
0149 #endif //QT_NO_PHONON_SEEKSLIDER
0150 
0151 
0152 // vim: sw=4 ts=4 tw=80
0153 #endif // PHONON_UI_SEEKSLIDER_H