| 1 | /* This file is part of the KDE project |
| 2 | Copyright (C) 2006-2007 Matthias Kretz <kretz@kde.org> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) version 3, or any |
| 8 | later version accepted by the membership of KDE e.V. (or its |
| 9 | successor approved by the membership of KDE e.V.), Nokia Corporation |
| 10 | (or its successors, if any) and the KDE Free Qt Foundation, which shall |
| 11 | act as a proxy defined in Section 6 of version 3 of the license. |
| 12 | |
| 13 | This library is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | Lesser General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU Lesser General Public |
| 19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | #ifndef VOLUMESLIDER_P_H |
| 24 | #define VOLUMESLIDER_P_H |
| 25 | |
| 26 | #include <QPointer> |
| 27 | #include <QBoxLayout> |
| 28 | #include <QIcon> |
| 29 | #include <QLabel> |
| 30 | #include <QPixmap> |
| 31 | #include <QStyle> |
| 32 | #include <QToolButton> |
| 33 | |
| 34 | #include "factory_p.h" |
| 35 | #include "phonondefs_p.h" |
| 36 | #include "platform_p.h" |
| 37 | #include "swiftslider_p.h" |
| 38 | |
| 39 | #ifndef QT_NO_PHONON_VOLUMESLIDER |
| 40 | |
| 41 | namespace Phonon |
| 42 | { |
| 43 | class VolumeSliderPrivate |
| 44 | { |
| 45 | P_DECLARE_PUBLIC(VolumeSlider) |
| 46 | protected: |
| 47 | VolumeSliderPrivate(VolumeSlider *parent) |
| 48 | : q_ptr(parent), |
| 49 | layout(QBoxLayout::LeftToRight, parent), |
| 50 | slider(Qt::Horizontal, parent), |
| 51 | muteButton(parent), |
| 52 | volumeIcon(Platform::icon(name: QLatin1String("player-volume" ), style: parent->style())), |
| 53 | mutedIcon(Platform::icon(name: QLatin1String("player-volume-muted" ), style: parent->style())), |
| 54 | output(nullptr), |
| 55 | ignoreVolumeChangeAction(false), |
| 56 | ignoreVolumeChangeObserve(true), |
| 57 | sliderPressed(false) |
| 58 | { |
| 59 | slider.setRange(min: 0, max: 100); |
| 60 | slider.setPageStep(5); |
| 61 | slider.setSingleStep(1); |
| 62 | |
| 63 | muteButton.setIcon(volumeIcon); |
| 64 | muteButton.setAutoRaise(true); |
| 65 | layout.setContentsMargins(QMargins()); |
| 66 | layout.setSpacing(2); |
| 67 | layout.addWidget(&muteButton, stretch: 0, alignment: Qt::AlignVCenter); |
| 68 | layout.addWidget(&slider, stretch: 0, alignment: Qt::AlignVCenter); |
| 69 | |
| 70 | slider.setEnabled(false); |
| 71 | muteButton.setEnabled(false); |
| 72 | |
| 73 | if (volumeIcon.isNull()) { |
| 74 | muteButton.setVisible(false); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | VolumeSlider *q_ptr; |
| 79 | |
| 80 | void _k_sliderChanged(int); |
| 81 | void _k_volumeChanged(qreal); |
| 82 | void _k_mutedChanged(bool); |
| 83 | void _k_buttonClicked(); |
| 84 | void _k_sliderPressed(); |
| 85 | void _k_sliderReleased(); |
| 86 | |
| 87 | private: |
| 88 | QBoxLayout layout; |
| 89 | SwiftSlider slider; |
| 90 | QToolButton muteButton; |
| 91 | QIcon volumeIcon; |
| 92 | QIcon mutedIcon; |
| 93 | |
| 94 | QPointer<AudioOutput> output; |
| 95 | bool ignoreVolumeChangeAction; |
| 96 | bool ignoreVolumeChangeObserve; |
| 97 | bool sliderPressed; |
| 98 | }; |
| 99 | } // namespace Phonon |
| 100 | |
| 101 | #endif //QT_NO_PHONON_VOLUMESLIDER |
| 102 | |
| 103 | #endif // VOLUMESLIDER_P_H |
| 104 | // vim: sw=4 sts=4 et tw=100 |
| 105 | |