Krita Source Code Documentation
Loading...
Searching...
No Matches
IntParseSpinBox Class Reference

A wrapper around KisIntParseSpinBox, which is a cleverer SpinBox, able to parse arithmetic expressions. The widget itself is accessed with the widget() function. More...

#include <IntParseSpinBox.h>

+ Inheritance diagram for IntParseSpinBox:

Public Slots

bool isLastValid () const
 Get if the last expression entered is a valid one.
 
void setValue (int value, bool overwriteExpression=false)
 Set the value of the spinbox.
 
void stepBy (int steps)
 This is a reimplementation of QSpinBox::stepBy that uses setValue.
 
virtual QString veryCleanText () const
 This virtual function is similar to cleanText(). But child classes may reimplement it to further process ("clean up") the expression.
 
QSpinBox * widget () const
 Get the internal KisIntParseSpinBox as a QWidget, so it may be added to a UI.
 

Signals

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.
 

Public Member Functions

 IntParseSpinBox ()
 
 ~IntParseSpinBox () override
 

Private Attributes

Private *const d
 

Detailed Description

A wrapper around KisIntParseSpinBox, which is a cleverer SpinBox, able to parse arithmetic expressions. The widget itself is accessed with the widget() function.

Use this spinbox instead of the basic one from Qt if you want it to be able to parse arithmetic expressions.

Definition at line 23 of file IntParseSpinBox.h.

Constructor & Destructor Documentation

◆ IntParseSpinBox()

IntParseSpinBox::IntParseSpinBox ( )
explicit

Definition at line 16 of file IntParseSpinBox.cpp.

17 : QObject()
18 , d(new Private)
19{
21
22 // Forward signals from KisIntParseSpinBox to IntParseSpinBox
23 connect(d->widget, SIGNAL(errorWhileParsing(QString)), this, SIGNAL(errorWhileParsing(QString)));
24 connect(d->widget, SIGNAL(noMoreParsingError()), this, SIGNAL(noMoreParsingError()));
25}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void errorWhileParsing(const QString &expr) const
signal emitted when the last parsed expression is not valid.
Private *const d
void noMoreParsingError() const
signal emitted when the last parsed expression is valid and the expression before was not valid.
The KisIntParseSpinBox class is a cleverer SpinBox, able to parse arithmetic expressions.

References connect(), d, errorWhileParsing(), noMoreParsingError(), and krita::IntParseSpinBox::Private::widget.

◆ ~IntParseSpinBox()

IntParseSpinBox::~IntParseSpinBox ( )
override

Definition at line 27 of file IntParseSpinBox.cpp.

28{
29 delete d;
30}

References d.

Member Function Documentation

◆ errorWhileParsing

void IntParseSpinBox::errorWhileParsing ( const QString & expr) const
signal

signal emitted when the last parsed expression is not valid.

◆ isLastValid

bool IntParseSpinBox::isLastValid ( ) const
slot

Get if the last expression entered is a valid one.

Return values
trueif the last expression entered is valid
falseotherwise

Definition at line 47 of file IntParseSpinBox.cpp.

48{
49 return d->widget->isLastValid();
50}
bool isLastValid() const
Get if the last expression entered is a valid one.

References d, KisIntParseSpinBox::isLastValid(), and krita::IntParseSpinBox::Private::widget.

◆ noMoreParsingError

void IntParseSpinBox::noMoreParsingError ( ) const
signal

signal emitted when the last parsed expression is valid and the expression before was not valid.

◆ setValue

void IntParseSpinBox::setValue ( int value,
bool overwriteExpression = false )
slot

Set the value of the spinbox.

This reimplementation also tries to clear the current expression and warning message whenever possible. This will happen when the new value is different from the current one and the line edit has not the focus or it is read-only. One can force the reset also by passing true to the overwriteExpression parameter.

Parameters
valueThe new value
overwriteExpressionGet if the expression in the edit field (and the warning message) should be reset to reflect the new value. The default is false so that if the user is editing the expression it won't be disrupted by any default call to this function

Definition at line 42 of file IntParseSpinBox.cpp.

43{
44 d->widget->setValue(value, overwriteExpression);
45}
float value(const T *src, size_t ch)
void setValue(int value, bool overwriteExpression=false)
Set the value of the spinbox.

References d, KisIntParseSpinBox::setValue(), value(), and krita::IntParseSpinBox::Private::widget.

◆ stepBy

void IntParseSpinBox::stepBy ( int steps)
slot

This is a reimplementation of QSpinBox::stepBy that uses setValue.

Parameters
stepsNumber of steps that the value should change

Definition at line 37 of file IntParseSpinBox.cpp.

38{
39 d->widget->stepBy(steps);
40}
void stepBy(int steps) override
This is a reimplementation of QSpinBox::stepBy that uses setValue.

References d, KisIntParseSpinBox::stepBy(), and krita::IntParseSpinBox::Private::widget.

◆ veryCleanText

QString IntParseSpinBox::veryCleanText ( ) const
virtualslot

This virtual function is similar to cleanText(). But child classes may reimplement it to further process ("clean up") the expression.

Returns
The processed expression

Definition at line 52 of file IntParseSpinBox.cpp.

53{
54 return d->widget->veryCleanText();
55}
virtual QString veryCleanText() const
This virtual function is similar to cleanText(). But child classes may reimplement it to further proc...

References d, KisIntParseSpinBox::veryCleanText(), and krita::IntParseSpinBox::Private::widget.

◆ widget

QSpinBox * IntParseSpinBox::widget ( ) const
slot

Get the internal KisIntParseSpinBox as a QWidget, so it may be added to a UI.

Returns
the internal KisIntParseSpinBox as a QWidget

Definition at line 32 of file IntParseSpinBox.cpp.

33{
34 return d->widget;
35}

References d, and krita::IntParseSpinBox::Private::widget.

Member Data Documentation

◆ d

Private* const IntParseSpinBox::d
private

Definition at line 90 of file IntParseSpinBox.h.


The documentation for this class was generated from the following files: