Warning, file /graphics/glaxnimate/src/gui/widgets/smaller_spinbox.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QDoubleSpinBox>
0010 
0011 namespace glaxnimate::gui {
0012 
0013 class SmallerSpinBox : public QDoubleSpinBox
0014 {
0015 public:
0016     SmallerSpinBox(bool adaptive, QWidget* parent = nullptr)
0017         : QDoubleSpinBox(parent)
0018     {
0019         setMinimum(-999'999.99); // '); lupdate is sometimes weird
0020         setMaximum(+999'999.99); // '); lupdate is sometimes weird
0021         setValue(0);
0022         setDecimals(2);
0023         
0024         setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
0025         resize(sizeHint());
0026         
0027 #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
0028         if ( adaptive )
0029             setStepType(QAbstractSpinBox::AdaptiveDecimalStepType);
0030 #endif
0031     }
0032     
0033     QSize sizeHint() const override
0034     {
0035         QSize sh = QDoubleSpinBox::sizeHint();
0036         sh.setWidth(get_spin_size(this));
0037         return sh;
0038     }
0039     
0040     static int get_spin_size(const QAbstractSpinBox* box);
0041 };
0042 
0043 
0044 class SmallerSpinBoxInt : public QSpinBox
0045 {
0046 public:
0047     SmallerSpinBoxInt(QWidget* parent = nullptr)
0048         : QSpinBox(parent)
0049     {
0050         setMinimum(-999'999); // '); lupdate is sometimes weird
0051         setMaximum(+999'999); // '); lupdate is sometimes weird
0052         setValue(0);
0053         
0054         setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
0055         resize(sizeHint());
0056     }
0057     
0058     QSize sizeHint() const override
0059     {
0060         QSize sh = QSpinBox::sizeHint();
0061         sh.setWidth(SmallerSpinBox::get_spin_size(this));
0062         return sh;
0063     }
0064 };
0065 
0066 } // namespace glaxnimate::gui