File indexing completed on 2021-12-21 13:28:00

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 <QList>
0024 #include <QPixmap>
0025 #include <QSlider>
0026 #include <QVector>
0027 
0028 class QPalette;
0029 class QTimer;
0030 
0031 class Slider : public QSlider
0032 {
0033     Q_OBJECT
0034 
0035     public:
0036     explicit Slider( Qt::Orientation, uint max = 0, QWidget* parent = 0 );
0037 
0038 protected:
0039     virtual void wheelEvent( QWheelEvent* ) override;
0040     QRectF sliderHandleRect( const QRectF &slider, qreal percent ) const;
0041 
0042     void paintCustomSlider( QPainter *p );
0043 
0044     bool m_usingCustomStyle;
0045 
0046     static const int s_borderWidth = 6;
0047     static const int s_borderHeight = 6;
0048 
0049     static const int s_sliderInsertX = 5;
0050     static const int s_sliderInsertY = 5;
0051 
0052 private:
0053     QPixmap m_topLeft;
0054     QPixmap m_topRight;
0055     QPixmap m_top;
0056     QPixmap m_bottomRight;
0057     QPixmap m_right;
0058     QPixmap m_bottomLeft;
0059     QPixmap m_bottom;
0060     QPixmap m_left;
0061 
0062     Q_DISABLE_COPY( Slider )
0063 };
0064 
0065 class VolumeSlider : public Slider
0066 {
0067     Q_OBJECT
0068 
0069     public:
0070     explicit VolumeSlider( uint max, QWidget *parent, bool customStyle = true );
0071 
0072     // VolumePopupButton needs to access this
0073     virtual void wheelEvent( QWheelEvent *e ) override;
0074 
0075 protected:
0076     virtual void paintEvent( QPaintEvent* ) override;
0077     virtual void contextMenuEvent( QContextMenuEvent* ) override;
0078 
0079 signals:
0080     void volumeChanged( float );
0081 private slots:
0082     void emitVolumeChanged( int );
0083 
0084 private:
0085     Q_DISABLE_COPY( VolumeSlider )
0086 };
0087 
0088 class TimeSlider : public Slider
0089 {
0090     Q_OBJECT
0091 
0092 public:
0093     explicit TimeSlider( QWidget *parent );
0094 
0095 protected:
0096     virtual void paintEvent( QPaintEvent* ) override;
0097     virtual void sliderChange( SliderChange change ) override;
0098 
0099 private:
0100     Q_DISABLE_COPY( TimeSlider )
0101 
0102     int m_knobX; // The position of the current indicator.
0103 };
0104 
0105 #endif
0106