File indexing completed on 2024-05-12 04:33:22

0001 /*
0002  * SPDX-FileCopyrightText: 2007-2011 Kare Sars <kare.sars@iki .fi>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #ifndef LABELED_FSLIDER_H
0008 #define LABELED_FSLIDER_H
0009 
0010 #include "ksaneoptionwidget.h"
0011 
0012 // Qt includes
0013 #include <QSlider>
0014 #include <QDoubleSpinBox>
0015 
0016 /**
0017  *@author Kåre Särs
0018  */
0019 
0020 namespace KSaneIface
0021 {
0022 
0023 /**
0024  * A combination of a label a slider and a spinbox.
0025  * The slider is connected to the spinbox so that they have the same value.
0026  */
0027 class LabeledFSlider : public KSaneOptionWidget
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032 
0033     /**
0034      * Create the slider.
0035      *
0036      * \param parent parent widget
0037      * \param text is the text describing the slider value. If the text
0038      *        contains a '&', a buddy for the slider will be created.
0039      * \param min minimum slider value
0040      * \param max maximum slider value
0041      * \param step is the step between values.
0042      */
0043     LabeledFSlider(QWidget *parent, const QString &text,
0044                    double min, double max, double step);
0045 
0046     LabeledFSlider(QWidget *parent, KSaneCore::Option *option);
0047     ~LabeledFSlider() override;
0048 
0049     /**
0050      * \return the slider value.
0051      */
0052     double value() const;
0053     double step() const;
0054 
0055 public Q_SLOTS:
0056 
0057     /** Set the slider/spinbox value */
0058     void setValue(const QVariant &value);
0059     void setRange(double min, double max);
0060     void setStep(double step);
0061     /** Set the unit */
0062     void setSuffix(const QString &text);
0063 
0064 private Q_SLOTS:
0065 
0066     /**
0067      * Sync the values and emit valueChanged()
0068      */
0069     // FIXME this has to be changes later
0070     void syncValues(int);
0071     void syncValues(double);
0072     void fixValue();
0073 
0074 Q_SIGNALS:
0075 
0076     /**
0077      * Emit the slider value changes
0078      */
0079     void valueChanged(const QVariant &val);
0080 
0081 private:
0082     void initFSlider(double minValue, double maxValue, double stepValue);
0083 
0084     QSlider        *m_slider;
0085     QDoubleSpinBox *m_spinb;
0086     double          m_fstep;
0087     int             m_istep;
0088 };
0089 
0090 }  // NameSpace KSaneIface
0091 
0092 #endif // LABELED_SFSLIDER_H