File indexing completed on 2025-01-05 04:02:08

0001 // vim: set tabstop=4 shiftwidth=4 expandtab:
0002 /*
0003 Gwenview: an image viewer
0004 Copyright 2011 Aurélien Gâteau <agateau@kde.org>
0005 
0006 This program is free software; you can redistribute it and/or
0007 modify it under the terms of the GNU General Public License
0008 as published by the Free Software Foundation; either version 2
0009 of the License, or (at your option) any later version.
0010 
0011 This program is distributed in the hope that it will be useful,
0012 but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 GNU General Public License for more details.
0015 
0016 You should have received a copy of the GNU General Public License
0017 along with this program; if not, write to the Free Software
0018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
0019 
0020 */
0021 #ifndef HUDSLIDER_H
0022 #define HUDSLIDER_H
0023 
0024 // Local
0025 
0026 // KF
0027 
0028 // Qt
0029 #include <QAbstractSlider>
0030 #include <QGraphicsWidget>
0031 
0032 namespace Gwenview
0033 {
0034 struct HudSliderPrivate;
0035 /**
0036  * A QGraphicsView slider.
0037  * Provides more-or-less the same API as QSlider.
0038  */
0039 class HudSlider : public QGraphicsWidget
0040 {
0041     Q_OBJECT
0042 public:
0043     explicit HudSlider(QGraphicsItem *parent = nullptr);
0044     ~HudSlider() override;
0045 
0046     void setRange(int min, int max);
0047     void setPageStep(int step);
0048     void setSingleStep(int step);
0049     void setValue(int value);
0050 
0051     int sliderPosition() const;
0052     void setSliderPosition(int);
0053 
0054     bool isSliderDown() const;
0055 
0056     void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override;
0057 
0058     void triggerAction(QAbstractSlider::SliderAction);
0059 
0060 Q_SIGNALS:
0061     void valueChanged(int);
0062     void actionTriggered(int);
0063 
0064 protected:
0065     void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
0066     void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
0067     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
0068     void wheelEvent(QGraphicsSceneWheelEvent *event) override;
0069     void keyPressEvent(QKeyEvent *event) override;
0070     void keyReleaseEvent(QKeyEvent *event) override;
0071 
0072 private Q_SLOTS:
0073     void doRepeatAction(int time = 50);
0074 
0075 private:
0076     HudSliderPrivate *const d;
0077 };
0078 
0079 } // namespace
0080 
0081 #endif /* HUDSLIDER_H */