| 1 | /* This file is part of the KDE project |
| 2 | Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.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 SWIFTSLIDER_H |
| 24 | #define SWIFTSLIDER_H |
| 25 | |
| 26 | #include <QSlider> |
| 27 | #include <QTimer> |
| 28 | |
| 29 | #if !defined(QT_NO_PHONON_SEEKSLIDER) && !defined(QT_NO_PHONON_VOLUMESLIDER) |
| 30 | |
| 31 | namespace Phonon |
| 32 | { |
| 33 | |
| 34 | /** \class SwiftSlider swiftslider_p.h phonon/SwiftSlider |
| 35 | * \short Modified QSlider that allows sudden/quick moves instead of stepped moves ("Click'n'Go" QSlider) |
| 36 | * |
| 37 | * This is an internal class used by SeekSlider and VolumeSlider. |
| 38 | * |
| 39 | * Ricardo Villalba, the original author of MySlider.cpp (from the SMPlayer project) |
| 40 | * gave his permission for the inclusion of this code inside Phonon by |
| 41 | * switching MySlider.cpp to the LGPLv2.1+ license. |
| 42 | * See http://smplayer.svn.sourceforge.net/viewvc/smplayer/smplayer/trunk/src/myslider.cpp?revision=2406&view=markup |
| 43 | * |
| 44 | * The original discussion about a "Click'n'Go QSlider": http://lists.trolltech.com/qt-interest/2006-11/msg00363.html |
| 45 | * |
| 46 | * \ingroup PhononWidgets |
| 47 | */ |
| 48 | class SwiftSlider : public QSlider |
| 49 | { |
| 50 | Q_OBJECT |
| 51 | public: |
| 52 | SwiftSlider(Qt::Orientation orientation, QWidget * parent); |
| 53 | ~SwiftSlider() override; |
| 54 | |
| 55 | signals: |
| 56 | void scrollStart(); |
| 57 | void scrollEnd(); |
| 58 | |
| 59 | private: |
| 60 | void mousePressEvent(QMouseEvent *event) override; |
| 61 | void wheelEvent(QWheelEvent *event) override; |
| 62 | inline int pick(const QPoint &pt) const; |
| 63 | int pixelPosToRangeValue(int pos) const; |
| 64 | |
| 65 | QTimer m_wheelTimer; |
| 66 | }; |
| 67 | |
| 68 | } // namespace Phonon |
| 69 | |
| 70 | #endif //QT_NO_PHONON_VOLUMESLIDER && QT_NO_PHONON_VOLUMESLIDER |
| 71 | |
| 72 | #endif //SWIFTSLIDER_H |
| 73 | |