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

#include <KisAngleSelector.h>

+ Inheritance diagram for KisAngleSelectorSpinBox:

Classes

struct  Private
 

Public Member Functions

bool isFlat () const
 
 KisAngleSelectorSpinBox (QWidget *parent=0)
 
QSize minimumSizeHint () const override
 
void refreshStyle ()
 
void setFlat (bool newFlat)
 
void setRange (double min, double max)
 
QSize sizeHint () const override
 
double valueFromText (const QString &text) const override
 
 ~KisAngleSelectorSpinBox () override
 
- Public Member Functions inherited from KisDoubleParseSpinBox
bool isLastValid () const
 Get if the last expression entered is a valid one.
 
 KisDoubleParseSpinBox (QWidget *parent=0)
 
void setValue (double value, bool overwriteExpression=false)
 Set the value of the spinbox.
 
void stepBy (int steps) override
 This is a reimplementation of QDoubleSpinBox::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.
 
 ~KisDoubleParseSpinBox () override
 

Protected Member Functions

void enterEvent (QEnterEvent *e) override
 
void focusInEvent (QFocusEvent *e) override
 
void focusOutEvent (QFocusEvent *e) override
 
void leaveEvent (QEvent *e) override
 
- Protected Member Functions inherited from KisDoubleParseSpinBox
QString textFromValue (double value) const override
 
QValidator::State validate (QString &input, int &pos) const override
 
double valueFromText (const QString &text) const override
 

Private Attributes

const QScopedPointer< Privatem_d
 

Additional Inherited Members

- Signals inherited from KisDoubleParseSpinBox
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.
 

Detailed Description

Definition at line 27 of file KisAngleSelector.h.

Constructor & Destructor Documentation

◆ KisAngleSelectorSpinBox()

KisAngleSelectorSpinBox::KisAngleSelectorSpinBox ( QWidget * parent = 0)

Definition at line 52 of file KisAngleSelector.cpp.

53 : KisDoubleParseSpinBox(parent)
54 , m_d(new Private)
55{
56 m_d->q = this;
57 m_d->isFlat = false;
58 m_d->hasFocus = false;
59 m_d->isHovered = false;
60 m_d->updateStyleSheet();
61}
const QScopedPointer< Private > m_d
KisDoubleParseSpinBox(QWidget *parent=0)

References m_d.

◆ ~KisAngleSelectorSpinBox()

KisAngleSelectorSpinBox::~KisAngleSelectorSpinBox ( )
override

Definition at line 63 of file KisAngleSelector.cpp.

64{}

Member Function Documentation

◆ enterEvent()

void KisAngleSelectorSpinBox::enterEvent ( QEnterEvent * e)
overrideprotected

Definition at line 91 of file KisAngleSelector.cpp.

93{
94 m_d->isHovered = true;
95 m_d->updateStyleSheet();
96 KisDoubleParseSpinBox::enterEvent(e);
97}

◆ focusInEvent()

void KisAngleSelectorSpinBox::focusInEvent ( QFocusEvent * e)
overrideprotected

Definition at line 106 of file KisAngleSelector.cpp.

107{
108 m_d->hasFocus = true;
109 m_d->updateStyleSheet();
110 KisDoubleParseSpinBox::focusInEvent(e);
111}

References m_d.

◆ focusOutEvent()

void KisAngleSelectorSpinBox::focusOutEvent ( QFocusEvent * e)
overrideprotected

Definition at line 113 of file KisAngleSelector.cpp.

114{
115 m_d->hasFocus = false;
116 m_d->updateStyleSheet();
117 KisDoubleParseSpinBox::focusOutEvent(e);
118}

References m_d.

◆ isFlat()

bool KisAngleSelectorSpinBox::isFlat ( ) const

Definition at line 78 of file KisAngleSelector.cpp.

79{
80 return m_d->isFlat;
81}

References m_d.

◆ leaveEvent()

void KisAngleSelectorSpinBox::leaveEvent ( QEvent * e)
overrideprotected

Definition at line 99 of file KisAngleSelector.cpp.

100{
101 m_d->isHovered = false;
102 m_d->updateStyleSheet();
103 KisDoubleParseSpinBox::leaveEvent(e);
104}

References m_d.

◆ minimumSizeHint()

QSize KisAngleSelectorSpinBox::minimumSizeHint ( ) const
override

Definition at line 120 of file KisAngleSelector.cpp.

121{
122 if (m_d->cachedSizeHint.isEmpty()) {
123 ensurePolished();
124
125 const QFontMetrics fm(fontMetrics());
126 int h = lineEdit()->minimumSizeHint().height();
127 int w = 0;
128
129 QString s;
130 QString fixedContent = prefix() + suffix() + QLatin1Char(' ');
131 s = textFromValue(minimum());
132 s.truncate(18);
133 s += fixedContent;
134 w = qMax(w, fm.horizontalAdvance(s));
135 s = textFromValue(maximum());
136 s.truncate(18);
137 s += fixedContent;
138 w = qMax(w, fm.horizontalAdvance(s));
139
140 w += 2; // cursor blinking space
141
142 QStyleOptionSpinBox option;
143 initStyleOption(&option);
144
145 QSize hint(w, h);
146
148 m_d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &option, hint, &tmp);
149 }
150
151 return m_d->cachedSizeHint;
152}
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
QString textFromValue(double value) const override

References m_d, and KisDoubleParseSpinBox::textFromValue().

◆ refreshStyle()

void KisAngleSelectorSpinBox::refreshStyle ( )

Definition at line 159 of file KisAngleSelector.cpp.

160{
161 m_d->cachedSizeHint = QSize();
162 updateGeometry();
163 m_d->updateStyleSheet();
164}

References m_d.

◆ setFlat()

void KisAngleSelectorSpinBox::setFlat ( bool newFlat)

Definition at line 83 of file KisAngleSelector.cpp.

84{
85 m_d->isFlat = newFlat;
86 m_d->updateStyleSheet();
87}

References m_d.

◆ setRange()

void KisAngleSelectorSpinBox::setRange ( double min,
double max )

Definition at line 66 of file KisAngleSelector.cpp.

67{
68 m_d->cachedSizeHint = QSize();
69 KisDoubleParseSpinBox::setRange(min, max);
70}

References m_d.

◆ sizeHint()

QSize KisAngleSelectorSpinBox::sizeHint ( ) const
override

Definition at line 154 of file KisAngleSelector.cpp.

155{
156 return minimumSizeHint();
157}
QSize minimumSizeHint() const override

References minimumSizeHint().

◆ valueFromText()

double KisAngleSelectorSpinBox::valueFromText ( const QString & text) const
override

Definition at line 72 of file KisAngleSelector.cpp.

73{
74 const double v = KisDoubleParseSpinBox::valueFromText(text);
75 return KisAngleSelector::closestCoterminalAngleInRange(v, minimum(), maximum());
76}
qreal v
static qreal closestCoterminalAngleInRange(qreal angle, qreal minimum, qreal maximum, bool *ok=nullptr)
Gets the closest coterminal angle to the provided angle that is in the range provided.
double valueFromText(const QString &text) const override

References KisAngleSelector::closestCoterminalAngleInRange(), v, and KisDoubleParseSpinBox::valueFromText().

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisAngleSelectorSpinBox::m_d
private

Definition at line 51 of file KisAngleSelector.h.


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