Krita

IntParseSpinBox.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_INTPARSESPINBOX_H
8#define LIBKIS_INTPARSESPINBOX_H
9
10#include "kis_int_parse_spin_box.h"
11
12#include "kritalibkis_export.h"
13#include "libkis.h"
14
15/**
16 * @brief A wrapper around KisIntParseSpinBox, which is a cleverer SpinBox,
17 * able to parse arithmetic expressions. The widget itself is accessed with
18 * 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 IntParseSpinBox : public QObject
24{
25 Q_OBJECT
26 Q_DISABLE_COPY(IntParseSpinBox)
27
28public:
29 explicit IntParseSpinBox();
30 ~IntParseSpinBox() override;
31
32public Q_SLOTS:
33
34 /**
35 * @brief Get the internal KisIntParseSpinBox as a QWidget, so it may be
36 * added to a UI
37 *
38 * @return the internal KisIntParseSpinBox as a QWidget
39 */
40 QSpinBox* widget() const;
41
42 /**
43 * @brief This is a reimplementation of @ref QSpinBox::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(int 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
88private:
89 struct Private;
90 Private *const d;
91
92};
93
94#endif // LIBKIS_INTPARSESPINBOX_H
A wrapper around KisIntParseSpinBox, which is a cleverer SpinBox, able to parse arithmetic expression...
void errorWhileParsing(const QString &expr) const
signal emitted when the last parsed expression is not valid.
void noMoreParsingError() const
signal emitted when the last parsed expression is valid and the expression before was 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.