File indexing completed on 2024-04-21 04:43:20

0001 /*  This file is part of the KDE project
0002     Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.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 SWIFTSLIDER_H
0024 #define SWIFTSLIDER_H
0025 
0026 #include <QSlider>
0027 #include <QTimer>
0028 
0029 #if !defined(QT_NO_PHONON_SEEKSLIDER) && !defined(QT_NO_PHONON_VOLUMESLIDER)
0030 
0031 namespace Phonon
0032 {
0033 
0034 /** \class SwiftSlider swiftslider_p.h phonon/SwiftSlider
0035  * \short Modified QSlider that allows sudden/quick moves instead of stepped moves ("Click'n'Go" QSlider)
0036  *
0037  * This is an internal class used by SeekSlider and VolumeSlider.
0038  *
0039  * Ricardo Villalba, the original author of MySlider.cpp (from the SMPlayer project)
0040  * gave his permission for the inclusion of this code inside Phonon by
0041  * switching MySlider.cpp to the LGPLv2.1+ license.
0042  * See http://smplayer.svn.sourceforge.net/viewvc/smplayer/smplayer/trunk/src/myslider.cpp?revision=2406&view=markup
0043  *
0044  * The original discussion about a "Click'n'Go QSlider": http://lists.trolltech.com/qt-interest/2006-11/msg00363.html
0045  *
0046  * \ingroup PhononWidgets
0047  */
0048 class SwiftSlider : public QSlider
0049 {
0050     Q_OBJECT
0051 public:
0052     SwiftSlider(Qt::Orientation orientation, QWidget * parent);
0053     ~SwiftSlider() override;
0054 
0055 signals:
0056         void scrollStart();
0057         void scrollEnd();
0058 
0059 private:
0060     void mousePressEvent(QMouseEvent *event) override;
0061         void wheelEvent(QWheelEvent *event) override;
0062     inline int pick(const QPoint &pt) const;
0063         int pixelPosToRangeValue(int pos) const;
0064 
0065         QTimer m_wheelTimer;
0066 };
0067 
0068 } // namespace Phonon
0069 
0070 #endif //QT_NO_PHONON_VOLUMESLIDER && QT_NO_PHONON_VOLUMESLIDER
0071 
0072 #endif //SWIFTSLIDER_H