Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_double_parse_spin_box.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 * SPDX-FileCopyrightText: 2016 Laurent Valentin Jospin <laurent.valentin@famillejospin.ch>
4 * SPDX-FileCopyrightText: 2021 Deif Lou <ginoba@gmail.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KISDOUBLEPARSESPINBOX_H
10#define KISDOUBLEPARSESPINBOX_H
11
12#include <QDoubleSpinBox>
13#include <QScopedPointer>
14
15#include <kritawidgetutils_export.h>
16
17template <typename SpinBoxTypeTP, typename BaseSpinBoxTypeTP>
19
25class KRITAWIDGETUTILS_EXPORT KisDoubleParseSpinBox : public QDoubleSpinBox
26{
27 Q_OBJECT
28public:
29 KisDoubleParseSpinBox(QWidget *parent = 0);
30 ~KisDoubleParseSpinBox() override;
31
37 void stepBy(int steps) override;
53 void setValue(double value, bool overwriteExpression = false);
59 bool isLastValid() const;
65 virtual QString veryCleanText() const;
66
67Q_SIGNALS:
71 void errorWhileParsing(const QString &expr) const;
76 void noMoreParsingError() const;
77
78protected:
79 QValidator::State validate(QString &input, int &pos) const override;
80 double valueFromText(const QString &text) const override;
81 QString textFromValue(double value) const override;
82
83private:
84 template <typename SpinBoxTypeTP, typename BaseSpinBoxTypeTP>
86 QScopedPointer<KisParseSpinBoxPrivate<KisDoubleParseSpinBox, QDoubleSpinBox>> d;
87};
88
89#endif // KISDOUBLEPARSESPINBOX_H
float value(const T *src, size_t ch)
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
void errorWhileParsing(const QString &expr) const
signal emitted when the last parsed expression is not valid.
QScopedPointer< KisParseSpinBoxPrivate< KisDoubleParseSpinBox, QDoubleSpinBox > > d
void noMoreParsingError() const
signal emitted when the last parsed expression is valid and the expression before was not valid.