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 setValuePt(double value, bool overWriteExpression = false);
82
84 void setMinimum(double min);
85
87 void setMinimumPt(double min);
88
90 void setMaximum(double max);
91
93 void setMaximumPt(double max);
94
96 void setLineStep(double step);
97
99 void setLineStepPt(double step);
100
102 void setMinMaxStep( double min, double max, double step );
103
105 void setMinMaxStepPt( double min, double max, double step );
106
112 QString textFromValue( double value ) const override;
113
115 QString veryCleanText() const override;
116
122 double valueFromText( const QString& str ) const override;
123
124 void setUnitChangeFromOutsideBehavior(bool toggle); //if set to false, setting the unit using KoUnit won't have any effect.
125
127 void setDisplayUnit(bool toggle);
128
129 void preventDecimalsChangeFromUnitManager(bool prevent);
130
131 void setDecimals(int prec);
132 void setSingleStep(double val);
133
134Q_SIGNALS:
136 void valueChangedPt( qreal );
137
138
139private:
140 class Private;
141 Private * const d;
142
143 QString detectUnit();
144 QString makeTextClean(QString const& txt) const;
145
146 //those functions are useful to sync the spinbox with its unitmanager.
148 void internalUnitChange(QString const& symbol);
149 void prepareUnitChange();
150
151 void contextMenuEvent(QContextMenuEvent *event) override;
152
153private Q_SLOTS:
154 // exists to do emits for valueChangedPt
155 void privateValueChanged();
156 void detectUnitChanges();
157 void disconnectExternalUnitManager();
158
159};
160
161#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...