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 VOLUMESLIDER_P_H 0024 #define VOLUMESLIDER_P_H 0025 0026 #include <QPointer> 0027 #include <QBoxLayout> 0028 #include <QIcon> 0029 #include <QLabel> 0030 #include <QPixmap> 0031 #include <QStyle> 0032 #include <QToolButton> 0033 0034 #include "factory_p.h" 0035 #include "phonondefs_p.h" 0036 #include "platform_p.h" 0037 #include "swiftslider_p.h" 0038 0039 #ifndef QT_NO_PHONON_VOLUMESLIDER 0040 0041 namespace Phonon 0042 { 0043 class VolumeSliderPrivate 0044 { 0045 P_DECLARE_PUBLIC(VolumeSlider) 0046 protected: 0047 VolumeSliderPrivate(VolumeSlider *parent) 0048 : q_ptr(parent), 0049 layout(QBoxLayout::LeftToRight, parent), 0050 slider(Qt::Horizontal, parent), 0051 muteButton(parent), 0052 volumeIcon(Platform::icon(QLatin1String("player-volume"), parent->style())), 0053 mutedIcon(Platform::icon(QLatin1String("player-volume-muted"), parent->style())), 0054 output(nullptr), 0055 ignoreVolumeChangeAction(false), 0056 ignoreVolumeChangeObserve(true), 0057 sliderPressed(false) 0058 { 0059 slider.setRange(0, 100); 0060 slider.setPageStep(5); 0061 slider.setSingleStep(1); 0062 0063 muteButton.setIcon(volumeIcon); 0064 muteButton.setAutoRaise(true); 0065 layout.setContentsMargins(QMargins()); 0066 layout.setSpacing(2); 0067 layout.addWidget(&muteButton, 0, Qt::AlignVCenter); 0068 layout.addWidget(&slider, 0, Qt::AlignVCenter); 0069 0070 slider.setEnabled(false); 0071 muteButton.setEnabled(false); 0072 0073 if (volumeIcon.isNull()) { 0074 muteButton.setVisible(false); 0075 } 0076 } 0077 0078 VolumeSlider *q_ptr; 0079 0080 void _k_sliderChanged(int); 0081 void _k_volumeChanged(qreal); 0082 void _k_mutedChanged(bool); 0083 void _k_buttonClicked(); 0084 void _k_sliderPressed(); 0085 void _k_sliderReleased(); 0086 0087 private: 0088 QBoxLayout layout; 0089 SwiftSlider slider; 0090 QToolButton muteButton; 0091 QIcon volumeIcon; 0092 QIcon mutedIcon; 0093 0094 QPointer<AudioOutput> output; 0095 bool ignoreVolumeChangeAction; 0096 bool ignoreVolumeChangeObserve; 0097 bool sliderPressed; 0098 }; 0099 } // namespace Phonon 0100 0101 #endif //QT_NO_PHONON_VOLUMESLIDER 0102 0103 #endif // VOLUMESLIDER_P_H 0104 // vim: sw=4 sts=4 et tw=100