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

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