File indexing completed on 2025-02-09 05:31:55
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_VOLUMESLIDER_H 0024 #define PHONON_UI_VOLUMESLIDER_H 0025 0026 #include "phonon_export.h" 0027 #include "phonondefs.h" 0028 #include <QWidget> 0029 0030 0031 #ifndef QT_NO_PHONON_VOLUMESLIDER 0032 0033 namespace Phonon 0034 { 0035 class AudioOutput; 0036 class VolumeSliderPrivate; 0037 0038 /** \class VolumeSlider volumeslider.h phonon/VolumeSlider 0039 * \short Widget providing a slider to control the volume of an AudioOutput. 0040 * 0041 * \ingroup PhononWidgets 0042 * \author Matthias Kretz <kretz@kde.org> 0043 */ 0044 class PHONON_EXPORT VolumeSlider : public QWidget 0045 { 0046 Q_OBJECT 0047 P_DECLARE_PRIVATE(VolumeSlider) 0048 /** 0049 * This property holds the maximum volume that can be set with this slider. 0050 * 0051 * By default the maximum value is 1.0 (100%). 0052 */ 0053 Q_PROPERTY(qreal maximumVolume READ maximumVolume WRITE setMaximumVolume) 0054 /** 0055 * This property holds the orientation of the slider. 0056 * 0057 * The orientation must be Qt::Vertical (the default) or Qt::Horizontal. 0058 */ 0059 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) 0060 0061 /** 0062 * This property holds whether slider tracking is enabled. 0063 * 0064 * If tracking is enabled (the default), the volume changes 0065 * while the slider is being dragged. If tracking is 0066 * disabled, the volume changes only when the user 0067 * releases the slider. 0068 */ 0069 Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking) 0070 0071 /** 0072 * This property holds the page step. 0073 * 0074 * The larger of two natural steps that a slider provides and 0075 * typically corresponds to the user pressing PageUp or PageDown. 0076 * 0077 * Defaults to 5 (5% of the voltage). 0078 */ 0079 Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep) 0080 0081 /** 0082 * This property holds the single step. 0083 * 0084 * The smaller of two natural steps that a slider provides and 0085 * typically corresponds to the user pressing an arrow key. 0086 * 0087 * Defaults to 1 (1% of the voltage). 0088 */ 0089 Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep) 0090 0091 /** 0092 * This property holds whether the mute button/icon next to the slider is visible. 0093 * 0094 * By default the mute button/icon is visible. 0095 */ 0096 Q_PROPERTY(bool muteVisible READ isMuteVisible WRITE setMuteVisible) 0097 0098 /** 0099 * \brief the icon size used for the mute button/icon. 0100 * 0101 * The default size is defined by the GUI style. 0102 */ 0103 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) 0104 public: 0105 /** 0106 * Constructs a new volume slider with a \p parent. 0107 */ 0108 explicit VolumeSlider(QWidget *parent = nullptr); 0109 explicit VolumeSlider(AudioOutput *, QWidget *parent = nullptr); 0110 ~VolumeSlider() override; 0111 0112 bool hasTracking() const; 0113 void setTracking(bool tracking); 0114 int pageStep() const; 0115 void setPageStep(int milliseconds); 0116 int singleStep() const; 0117 void setSingleStep(int milliseconds); 0118 bool isMuteVisible() const; 0119 QSize iconSize() const; 0120 qreal maximumVolume() const; 0121 Qt::Orientation orientation() const; 0122 AudioOutput *audioOutput() const; 0123 0124 public Q_SLOTS: 0125 void setMaximumVolume(qreal); 0126 void setOrientation(Qt::Orientation); 0127 void setMuteVisible(bool); 0128 void setIconSize(const QSize &size); 0129 0130 /** 0131 * Sets the audio output object to be controlled by this slider. 0132 */ 0133 void setAudioOutput(Phonon::AudioOutput *); 0134 0135 protected: 0136 VolumeSliderPrivate *const k_ptr; 0137 0138 private: 0139 Q_PRIVATE_SLOT(k_ptr, void _k_sliderChanged(int)) 0140 Q_PRIVATE_SLOT(k_ptr, void _k_volumeChanged(qreal)) 0141 Q_PRIVATE_SLOT(k_ptr, void _k_mutedChanged(bool)) 0142 Q_PRIVATE_SLOT(k_ptr, void _k_buttonClicked()) 0143 Q_PRIVATE_SLOT(k_ptr, void _k_sliderPressed()) 0144 Q_PRIVATE_SLOT(k_ptr, void _k_sliderReleased()) 0145 }; 0146 0147 } // namespace Phonon 0148 0149 #endif //QT_NO_PHONON_VOLUMESLIDER 0150 0151 0152 // vim: sw=4 ts=4 et 0153 #endif // PHONON_UI_VOLUMESLIDER_H