File indexing completed on 2023-05-30 11:30:51
0001 /** 0002 * Copyright (c) 2003-2009 Mark Kretschmann <kretschmann@kde.org> 0003 * Copyright (c) 2005 Gabor Lehel <illissius@gmail.com> 0004 * Copyright (c) 2008 Dan Meltzer <parallelgrapefruit@gmail.com> 0005 * Copyright (c) 2021 Michael Pyne <mpyne@kde.org> 0006 * 0007 * This program is free software; you can redistribute it and/or modify it under 0008 * the terms of the GNU General Public License as published by the Free Software 0009 * Foundation; either version 2 of the License, or (at your option) any later 0010 * version. 0011 * 0012 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0013 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0014 * PARTICULAR PURPOSE. See the GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License along with 0017 * this program. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef SLIDERWIDGET_H 0021 #define SLIDERWIDGET_H 0022 0023 #include <QPixmap> 0024 #include <QSlider> 0025 0026 class QPalette; 0027 class QTimer; 0028 0029 class Slider : public QSlider 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit Slider( Qt::Orientation, uint max = 0, QWidget* parent = 0 ); 0035 0036 protected: 0037 virtual void wheelEvent( QWheelEvent* ) override; 0038 QRectF sliderHandleRect( const QRectF &slider, qreal percent ) const; 0039 0040 void paintCustomSlider( QPainter *p ); 0041 0042 bool m_usingCustomStyle; 0043 0044 static const int s_borderWidth = 6; 0045 static const int s_borderHeight = 6; 0046 0047 static const int s_sliderInsertX = 5; 0048 static const int s_sliderInsertY = 5; 0049 0050 private: 0051 QPixmap m_topLeft; 0052 QPixmap m_topRight; 0053 QPixmap m_top; 0054 QPixmap m_bottomRight; 0055 QPixmap m_right; 0056 QPixmap m_bottomLeft; 0057 QPixmap m_bottom; 0058 QPixmap m_left; 0059 0060 Q_DISABLE_COPY( Slider ) 0061 }; 0062 0063 class VolumeSlider : public Slider 0064 { 0065 Q_OBJECT 0066 0067 public: 0068 explicit VolumeSlider( uint max, QWidget *parent, bool customStyle = true ); 0069 0070 // VolumePopupButton needs to access this 0071 virtual void wheelEvent( QWheelEvent *e ) override; 0072 0073 protected: 0074 virtual void paintEvent( QPaintEvent* ) override; 0075 virtual void contextMenuEvent( QContextMenuEvent* ) override; 0076 0077 signals: 0078 void volumeChanged( float ); 0079 private slots: 0080 void emitVolumeChanged( int ); 0081 0082 private: 0083 Q_DISABLE_COPY( VolumeSlider ) 0084 }; 0085 0086 class TimeSlider : public Slider 0087 { 0088 Q_OBJECT 0089 0090 public: 0091 explicit TimeSlider( QWidget *parent ); 0092 0093 protected: 0094 virtual void paintEvent( QPaintEvent* ) override; 0095 virtual void sliderChange( SliderChange change ) override; 0096 0097 private: 0098 Q_DISABLE_COPY( TimeSlider ) 0099 0100 int m_knobX; // The position of the current indicator. 0101 }; 0102 0103 #endif 0104