Krita

DoubleParseSpinBox.h
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#ifndef LIBKIS_DOUBLEPARSESPINBOX_H
8#define LIBKIS_DOUBLEPARSESPINBOX_H
9
10#include "kis_double_parse_spin_box.h"
11
12#include "kritalibkis_export.h"
13#include "libkis.h"
14
15/**
16 * @brief A wrapper around KisDoubleParseSpinBox, which is a cleverer
17 * doubleSpinBox, able to parse arithmetic expressions. The widget itself is
18 * accessed with the widget() function.
19 *
20 * Use this spinbox instead of the basic one from Qt if you want it to be able
21 * to parse arithmetic expressions.
22 */
23class KRITALIBKIS_EXPORT DoubleParseSpinBox : public QObject
24{
25 Q_OBJECT
26 Q_DISABLE_COPY(DoubleParseSpinBox)
27
28public:
29 explicit DoubleParseSpinBox();
30 ~DoubleParseSpinBox() override;
31
32
33public Q_SLOTS:
34 /**
35 * @brief Get the internal KisDoubleParseSpinBox as a QWidget, so it may be
36 * added to a UI
37 *
38 * @return the internal KisDoubleParseSpinBox as a QWidget
39 */
40 QDoubleSpinBox* widget() const;
41
42 /**
43 * @brief This is a reimplementation of @ref QDoubleSpinBox::stepBy that
44 * uses @ref setValue
45 * @param steps Number of steps that the value should change
46 */
47 void stepBy(int steps);
48 /**
49 * @brief Set the value of the spinbox
50 *
51 * This reimplementation also tries to clear the current expression and
52 * warning message whenever possible. This will happen when the new value
53 * is different from the current one and the line edit has not the focus
54 * or it is read-only. One can force the reset also by passing true to the
55 * @p overwriteExpression parameter.
56 *
57 * @param value The new value
58 * @param overwriteExpression Get if the expression in the edit field
59 * (and the warning message) should be reset to reflect the new value.
60 * The default is false so that if the user is editing the expression
61 * it won't be disrupted by any default call to this function
62 */
63 void setValue(double value, bool overwriteExpression = false);
64 /**
65 * @brief Get if the last expression entered is a valid one
66 * @retval true if the last expression entered is valid
67 * @retval false otherwise
68 */
69 bool isLastValid() const;
70 /**
71 * @brief This virtual function is similar to cleanText(). But child classes
72 * may reimplement it to further process ("clean up") the expression.
73 * @return The processed expression
74 */
75 virtual QString veryCleanText() const;
76
78 /**
79 * @brief signal emitted when the last parsed expression is not valid.
80 */
81 void errorWhileParsing(const QString &expr) const;
82 /**
83 * @brief signal emitted when the last parsed expression is valid and
84 * the expression before was not valid.
85 */
86 void noMoreParsingError() const;
87
89
90private:
91 struct Private;
92 Private *const d;
93
94};
95
96#endif // LIBKIS_DOUBLEPARSESPINBOX_H
A wrapper around KisDoubleParseSpinBox, which is a cleverer doubleSpinBox, able to parse arithmetic e...
void noMoreParsingError() const
signal emitted when the last parsed expression is valid and the expression before was not valid.
void errorWhileParsing(const QString &expr) const
signal emitted when the last parsed expression is not valid.
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.