File indexing completed on 2024-04-21 03:42:19

0001 /*
0002     SPDX-FileCopyrightText: 2017 Robert Lancaster <rlancaste@gmail.com>
0003 
0004     Based on an idea discussed in the QT Centre: https://www.qtcentre.org/threads/47535-QDoubleSpinBox-with-nonlinear-values
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include <QDoubleSpinBox>
0012 
0013 class NonLinearDoubleSpinBox : public QDoubleSpinBox
0014 {
0015         Q_OBJECT
0016     public:
0017         explicit NonLinearDoubleSpinBox(QWidget *parent = Q_NULLPTR);
0018 
0019         void stepBy(int steps) override;
0020         void setRecommendedValues(QList<double> values);
0021         void addRecommendedValue(double v);
0022         QList<double> getRecommendedValues();
0023         QString getRecommendedValuesString();
0024 
0025     private:
0026         QList<double> m_Values;
0027         int m_idx { -1 };
0028         void updateRecommendedValues();
0029 };