Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_double_parse_unit_spin_box.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Laurent Valentin Jospin <laurent.valentin@famillejospin.ch>
3 * SPDX-FileCopyrightText: 2021 Deif Lou <ginoba@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#ifndef KIS_DOUBLEPARSEUNITSPINBOX_H
9#define KIS_DOUBLEPARSEUNITSPINBOX_H
10
11#include <KoUnit.h>
12#include <QContextMenuEvent>
13
15#include "kritawidgetutils_export.h"
16
18
24class KRITAWIDGETUTILS_EXPORT KisDoubleParseUnitSpinBox : public KisDoubleParseSpinBox
25{
26
27 Q_OBJECT
28
29public:
30 KisDoubleParseUnitSpinBox(QWidget* parent = 0);
32
33 void setUnitManager(KisSpinBoxUnitManager* unitManager);
34
40 virtual void changeValue( double newValue );
41
47 void changeValuePt( double newValue );
48
52 virtual void setUnit(const KoUnit &unit);
53 virtual void setUnit(const QString & symbol);
54
60 void setReturnUnit(const QString & symbol);
61
66 QString returnUnit() const;
67
72 virtual void setDimensionType(int dim);
73
75 double value( ) const;
76
78 double valuePt( ) const;
79
81 void setMinimum(double min);
82
84 void setMinimumPt(double min);
85
87 void setMaximum(double max);
88
90 void setMaximumPt(double max);
91
93 void setLineStep(double step);
94
96 void setLineStepPt(double step);
97
99 void setMinMaxStep( double min, double max, double step );
100
102 void setMinMaxStepPt( double min, double max, double step );
103
109 QString textFromValue( double value ) const override;
110
112 QString veryCleanText() const override;
113
119 double valueFromText( const QString& str ) const override;
120
121 void setUnitChangeFromOutsideBehavior(bool toggle); //if set to false, setting the unit using KoUnit won't have any effect.
122
124 void setDisplayUnit(bool toggle);
125
126 void preventDecimalsChangeFromUnitManager(bool prevent);
127
128 void setDecimals(int prec);
129 void setSingleStep(double val);
130
131Q_SIGNALS:
133 void valueChangedPt( qreal );
134
135
136private:
137 class Private;
138 Private * const d;
139
140 QString detectUnit();
141 QString makeTextClean(QString const& txt) const;
142
143 //those functions are useful to sync the spinbox with its unitmanager.
145 void internalUnitChange(QString const& symbol);
146 void prepareUnitChange();
147
148 void contextMenuEvent(QContextMenuEvent *event) override;
149
150private Q_SLOTS:
151 // exists to do emits for valueChangedPt
152 void privateValueChanged();
153 void detectUnitChanges();
154 void disconnectExternalUnitManager();
155
156};
157
158#endif // KIS_DOUBLEPARSEUNITSPINBOX_H
float value(const T *src, size_t ch)
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
QString textFromValue(double value) const override
virtual QString veryCleanText() const
This virtual function is similar to cleanText(). But child classes may reimplement it to further proc...
double valueFromText(const QString &text) const override
The KisDoubleParseUnitSpinBox class is an evolution of the.
void valueChangedPt(qreal)
emitted like valueChanged in the parent, but this one emits the point value, or converted to another ...
The KisSpinBoxUnitManager class is an abstract interface for the unitspinboxes classes to manage diff...