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

A widget with several options to select an angle. More...

#include <KisAngleSelector.h>

+ Inheritance diagram for KisAngleSelector:

Classes

struct  Private
 

Public Types

enum  FlipOptionsMode { FlipOptionsMode_NoFlipOptions , FlipOptionsMode_MenuButton , FlipOptionsMode_Buttons , FlipOptionsMode_ContextMenu }
 Options to select how the flip options should be presented. More...
 

Public Slots

void reset ()
 Sets the current angle to the reset angle.
 
void setAngle (qreal newAngle)
 Sets the current angle.
 

Signals

void angleChanged (qreal angle)
 

Public Member Functions

qreal angle () const
 Gets the current angle.
 
qreal closestCoterminalAngleInRange (qreal angle, bool *ok=nullptr) const
 Gets the closest coterminal angle to the provided angle that is in the range established.
 
int decimals () const
 Gets the number of decimals (precision) used by the angle.
 
void flip (Qt::Orientations orientations)
 Flips the angle horizontally, vertically, or both.
 
FlipOptionsMode flipOptionsMode () const
 Gets the mode in which the flip options should be shown.
 
KisAngleGauge::IncreasingDirection increasingDirection () const
 Gets the direction in which the angle increases in the angle gauge.
 
bool isUsingFlatSpinBox () const
 Gets if the spin box is flat (no border or background)
 
 KisAngleSelector (QWidget *parent=0)
 Construct a new KisAngleSelector widget.
 
qreal maximum () const
 Gets the maximum value for the angle.
 
qreal minimum () const
 Gets the minimum value for the angle.
 
QString prefix () const
 Gets the prefix shown in the spin box.
 
qreal resetAngle () const
 Gets the angle that is used to reset the current angle.
 
void setDecimals (int newNumberOfDecimals)
 Sets the number of decimals (precision) used by the angle.
 
void setFlipOptionsMode (FlipOptionsMode newMode)
 Sets the mode in which the flip options should be shown.
 
void setIncreasingDirection (KisAngleGauge::IncreasingDirection newIncreasingDirection)
 Sets the increasing direction in the angle gauge.
 
void setMaximum (qreal newMaximum)
 Sets the maximum value for the angle.
 
void setMinimum (qreal newMinimum)
 Sets the minimum value for the angle.
 
void setPrefix (const QString &newPrefix)
 Sets the prefix shown in the spin box.
 
void setRange (qreal newMinimum, qreal newMaximum)
 Sets the minimum and maximum values for the angle.
 
void setResetAngle (qreal newResetAngle)
 Sets the angle that is used to reset the current angle.
 
void setSnapAngle (qreal newSnapAngle)
 Sets the angle to which multiples the selected angle will snap.
 
void setWidgetsHeight (int newHeight)
 Sets the common height of the widgets inside this angle selector. Use 0 to reset widgets to default height.
 
void setWrapping (bool newWrapping)
 Sets if the angle should wrap pass the minimum or maximum angles.
 
qreal snapAngle () const
 Gets the angle to which multiples the selected angle will snap.
 
void useFlatSpinBox (bool newUseFlatSpinBox)
 Sets if the spin box should be flat.
 
int widgetsHeight () const
 Gets the common height of the widgets inside this angle selector.
 
bool wrapping () const
 Gets if the angle should wrap pass the minimum or maximum angles.
 
 ~KisAngleSelector ()
 

Static Public Member Functions

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.
 
static qreal flipAngle (qreal angle, qreal minimum, qreal maximum, Qt::Orientations orientations, bool *ok=nullptr)
 Flips an angle horizontally, vertically, or both.
 
static qreal flipAngle (qreal angle, Qt::Orientations orientations)
 Flips an angle horizontally, vertically, or both.
 

Private Member Functions

bool event (QEvent *e) override
 
bool eventFilter (QObject *o, QEvent *e) override
 

Private Attributes

const QScopedPointer< Private > m_d
 

Detailed Description

A widget with several options to select an angle.

This widget is a combination of a KisAngleGauge and a spin box, along with some flipping options

Definition at line 60 of file KisAngleSelector.h.

Member Enumeration Documentation

◆ FlipOptionsMode

Options to select how the flip options should be presented.

See also
flipOptionsMode() const
setFlipOptionsMode(FlipOptionsMode newMode)
Enumerator
FlipOptionsMode_NoFlipOptions 

There is no flip options available.

FlipOptionsMode_MenuButton 

The flip options are shown as a menu accessible via a options button.

FlipOptionsMode_Buttons 

The flip options are shown as individual buttons.

FlipOptionsMode_ContextMenu 

The flip options are shown only as a context menu when right-clicking the gauge widget.

The options are shown in the context menu also if the mode is FlipOptionsMode_MenuButton or FlipOptionsMode_Buttons but with this mode there will be no additional buttons

Definition at line 70 of file KisAngleSelector.h.

71 {
93 };
@ FlipOptionsMode_NoFlipOptions
There is no flip options available.
@ FlipOptionsMode_MenuButton
The flip options are shown as a menu accessible via a options button.
@ FlipOptionsMode_ContextMenu
The flip options are shown only as a context menu when right-clicking the gauge widget.
@ FlipOptionsMode_Buttons
The flip options are shown as individual buttons.

Constructor & Destructor Documentation

◆ KisAngleSelector()

KisAngleSelector::KisAngleSelector ( QWidget * parent = 0)
explicit

Construct a new KisAngleSelector widget.

Parameters
parentthe parent widget

Definition at line 194 of file KisAngleSelector.cpp.

195 : QWidget(parent)
196 , m_d(new Private)
197{
198 m_d->q = this;
199
200 QHBoxLayout *mainLayout = new QHBoxLayout;
201 mainLayout->setSpacing(5);
202 mainLayout->setContentsMargins(0, 0, 0, 0);
203
204 m_d->angleGauge = new KisAngleGauge(this);
205 m_d->angleGauge->installEventFilter(this);
206
207 m_d->spinBox = new KisAngleSelectorSpinBox(this);
208 m_d->spinBox->setSuffix(i18nc("Degrees symbol", "˚"));
209 m_d->spinBox->setRange(0, 360);
210 m_d->spinBox->setWrapping(true);
211
212 m_d->actionFlipHorizontally = new QAction(this);
213 m_d->actionFlipHorizontally->setText(
214 i18nc(
215 "Flips the angle horizontally, around the vertical axis",
216 "Flip the angle horizontally"
217 )
218 );
219 m_d->actionFlipVertically = new QAction(this);
220 m_d->actionFlipVertically->setText(
221 i18nc(
222 "Flips the angle vertically, around the horizontal axis",
223 "Flip the angle vertically"
224 )
225 );
226 m_d->actionFlipHorizontallyAndVertically = new QAction(this);
227 m_d->actionFlipHorizontallyAndVertically->setText(
228 i18nc(
229 "Flips the angle horizontally and vertically",
230 "Flip the angle horizontally and vertically"
231 )
232 );
233 QAction *menuSeparator = new QAction(this);
234 menuSeparator->setSeparator(true);
235 m_d->actionResetAngle = new QAction(this);
236 m_d->actionResetAngle->setText(
237 i18nc(
238 "Reset the angle to a predefined value",
239 "Reset angle"
240 )
241 );
242 m_d->menuFlip = new QMenu(this);
243 m_d->menuFlip->addAction(m_d->actionFlipHorizontally);
244 m_d->menuFlip->addAction(m_d->actionFlipVertically);
245 m_d->menuFlip->addAction(m_d->actionFlipHorizontallyAndVertically);
246 m_d->menuFlip->addAction(menuSeparator);
247 m_d->menuFlip->addAction(m_d->actionResetAngle);
248
249 QHBoxLayout *layoutFlipButtons = new QHBoxLayout;
250 layoutFlipButtons->setSpacing(1);
251 layoutFlipButtons->setContentsMargins(0, 0, 0, 0);
252
253 m_d->toolButtonFlipOptions = new QToolButton(this);
254 m_d->toolButtonFlipOptions->setPopupMode(QToolButton::InstantPopup);
255 m_d->toolButtonFlipOptions->setAutoRaise(true);
256 m_d->toolButtonFlipOptions->setIcon(KisIconUtils::loadIcon("view-choose"));
257 m_d->toolButtonFlipOptions->setStyleSheet("QToolButton::menu-indicator { image: none; }");
258 m_d->toolButtonFlipOptions->setMenu(m_d->menuFlip);
259 m_d->toolButtonFlipOptions->setFocusPolicy(Qt::StrongFocus);
260
261 m_d->toolButtonFlipHorizontally = new QToolButton(this);
262 m_d->toolButtonFlipHorizontally->setAutoRaise(true);
263 m_d->toolButtonFlipHorizontally->setIcon(KisIconUtils::loadIcon("flip_angle_h"));
264 m_d->toolButtonFlipHorizontally->setIconSize(QSize(20, 20));
265 m_d->toolButtonFlipHorizontally->setToolTip(m_d->actionFlipHorizontally->text());
266 m_d->toolButtonFlipHorizontally->setFocusPolicy(Qt::StrongFocus);
267
268 m_d->toolButtonFlipVertically = new QToolButton(this);
269 m_d->toolButtonFlipVertically->setAutoRaise(true);
270 m_d->toolButtonFlipVertically->setIcon(KisIconUtils::loadIcon("flip_angle_v"));
271 m_d->toolButtonFlipVertically->setIconSize(QSize(20, 20));
272 m_d->toolButtonFlipVertically->setToolTip(m_d->actionFlipVertically->text());
273 m_d->toolButtonFlipVertically->setFocusPolicy(Qt::StrongFocus);
274
275 m_d->toolButtonFlipHorizontallyAndVertically = new QToolButton(this);
276 m_d->toolButtonFlipHorizontallyAndVertically->setAutoRaise(true);
277 m_d->toolButtonFlipHorizontallyAndVertically->setIcon(KisIconUtils::loadIcon("flip_angle_hv"));
278 m_d->toolButtonFlipHorizontallyAndVertically->setIconSize(QSize(20, 20));
279 m_d->toolButtonFlipHorizontallyAndVertically->setToolTip(m_d->actionFlipHorizontallyAndVertically->text());
280 m_d->toolButtonFlipHorizontallyAndVertically->setFocusPolicy(Qt::StrongFocus);
281
282 layoutFlipButtons->addWidget(m_d->toolButtonFlipOptions);
283 layoutFlipButtons->addWidget(m_d->toolButtonFlipHorizontally);
284 layoutFlipButtons->addWidget(m_d->toolButtonFlipVertically);
285 layoutFlipButtons->addWidget(m_d->toolButtonFlipHorizontallyAndVertically);
286
287 mainLayout->addWidget(m_d->angleGauge);
288 mainLayout->addWidget(m_d->spinBox);
289 mainLayout->addLayout(layoutFlipButtons);
290
291 setLayout(mainLayout);
292
293 setTabOrder(m_d->angleGauge, m_d->spinBox);
294 setTabOrder(m_d->spinBox, m_d->toolButtonFlipOptions);
295 setTabOrder(m_d->toolButtonFlipOptions, m_d->toolButtonFlipHorizontally);
296 setTabOrder(m_d->toolButtonFlipHorizontally, m_d->toolButtonFlipVertically);
297 setTabOrder(m_d->toolButtonFlipVertically, m_d->toolButtonFlipHorizontallyAndVertically);
298
301
302 using namespace std::placeholders;
303 connect(
304 m_d->angleGauge,
306 this,
307 std::bind(&Private::on_angleGauge_angleChanged, m_d.data(), _1)
308 );
309 connect(
310 m_d->spinBox,
311 QOverload<double>::of(&KisDoubleParseSpinBox::valueChanged),
312 this,
313 std::bind(&Private::on_spinBox_valueChanged, m_d.data(), _1)
314 );
315 connect(
316 m_d->actionFlipHorizontally,
317 &QAction::triggered,
318 this,
320 );
321 connect(
322 m_d->actionFlipVertically,
323 &QAction::triggered,
324 this,
326 );
327 connect(
328 m_d->actionFlipHorizontallyAndVertically,
329 &QAction::triggered,
330 this,
332 );
333 connect(m_d->actionResetAngle, SIGNAL(triggered()), SLOT(reset()));
334 connect(m_d->toolButtonFlipHorizontally, SIGNAL(clicked()), m_d->actionFlipHorizontally, SLOT(trigger()));
335 connect(m_d->toolButtonFlipVertically, SIGNAL(clicked()), m_d->actionFlipVertically, SLOT(trigger()));
336 connect(m_d->toolButtonFlipHorizontallyAndVertically, SIGNAL(clicked()), m_d->actionFlipHorizontallyAndVertically, SLOT(trigger()));
337}
A circular widget that allows to choose an angle.
void angleChanged(qreal angle)
Signal emitted when the angle has changed.
void setFlipOptionsMode(FlipOptionsMode newMode)
Sets the mode in which the flip options should be shown.
void setWidgetsHeight(int newHeight)
Sets the common height of the widgets inside this angle selector. Use 0 to reset widgets to default h...
void reset()
Sets the current angle to the reset angle.
const QScopedPointer< Private > m_d
QIcon loadIcon(const QString &name)
void on_spinBox_valueChanged(double value)
void on_actionFlipHorizontallyAndVertically_triggered()
void on_angleGauge_angleChanged(qreal angle)

References KisAngleGauge::angleChanged(), FlipOptionsMode_Buttons, KisIconUtils::loadIcon(), m_d, KisAngleSelector::Private::on_actionFlipHorizontally_triggered(), KisAngleSelector::Private::on_actionFlipHorizontallyAndVertically_triggered(), KisAngleSelector::Private::on_actionFlipVertically_triggered(), KisAngleSelector::Private::on_angleGauge_angleChanged(), KisAngleSelector::Private::on_spinBox_valueChanged(), reset(), setFlipOptionsMode(), and setWidgetsHeight().

◆ ~KisAngleSelector()

KisAngleSelector::~KisAngleSelector ( )

Definition at line 339 of file KisAngleSelector.cpp.

340{}

Member Function Documentation

◆ angle()

qreal KisAngleSelector::angle ( ) const

Gets the current angle.

Returns
The current angle
See also
setAngle(qreal)

Definition at line 342 of file KisAngleSelector.cpp.

343{
344 return m_d->spinBox->value();
345}

References m_d.

◆ angleChanged

void KisAngleSelector::angleChanged ( qreal angle)
signal

◆ closestCoterminalAngleInRange() [1/2]

qreal KisAngleSelector::closestCoterminalAngleInRange ( qreal angle,
bool * ok = nullptr ) const

Gets the closest coterminal angle to the provided angle that is in the range established.

A coterminal angle to the provided angle is one that differs in size by an integer multiple of a turn (360 degrees)

Parameters
angleThe reference angle for which the function will try to find a coterminal angle
[out]okThis parameter will be set to true if a coterminal angle exists in the specified range, or to false otherwise
Returns
The closest coterminal angle in the specified range if one exists, or the closest value in the range (the minimum or maximum) otherwise. If the reference angle is already in the range then it is returned

Definition at line 528 of file KisAngleSelector.cpp.

529{
530 return closestCoterminalAngleInRange(angle, m_d->spinBox->minimum(), m_d->spinBox->maximum(), ok);
531}
qreal angle() const
Gets the current angle.
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.

References angle(), closestCoterminalAngleInRange(), and m_d.

◆ closestCoterminalAngleInRange() [2/2]

qreal KisAngleSelector::closestCoterminalAngleInRange ( qreal angle,
qreal minimum,
qreal maximum,
bool * ok = nullptr )
static

Gets the closest coterminal angle to the provided angle that is in the range provided.

A coterminal angle to the provided angle is one that differs in size by an integer multiple of a turn (360 degrees)

Parameters
angleThe reference angle for which the function will try to find a coterminal angle
minimumThe range's lower bound
maximumThe range's upper bound
[out]okThis parameter will be set to true if a coterminal angle exists in the provided range, or to false otherwise
Returns
The closest coterminal angle in the provided range if one exists, or the closest value in the range (the minimum or maximum) otherwise. If the reference angle is already in the range then it is returned

Definition at line 500 of file KisAngleSelector.cpp.

501{
502 bool hasCoterminalAngleInRange = true;
503
504 if (angle < minimum) {
505 const qreal d = minimum - angle;
506 const qreal cycles = std::floor(d / 360.0) + 1;
507 angle += cycles * 360.0;
508 if (angle > maximum) {
509 hasCoterminalAngleInRange = false;
510 angle = minimum;
511 }
512 } else if (angle > maximum) {
513 const qreal d = angle - maximum;
514 const qreal cycles = std::floor(d / 360.0) + 1;
515 angle -= cycles * 360.0;
516 if (angle < minimum) {
517 hasCoterminalAngleInRange = false;
518 angle = maximum;
519 }
520 }
521
522 if (ok) {
523 *ok = hasCoterminalAngleInRange;
524 }
525 return angle;
526}
qreal maximum() const
Gets the maximum value for the angle.
qreal minimum() const
Gets the minimum value for the angle.

References angle(), maximum(), and minimum().

◆ decimals()

int KisAngleSelector::decimals ( ) const

Gets the number of decimals (precision) used by the angle.

If you want to simulate integer angles, set it to 0. The default is 2.

Returns
The number of decimals being used
See also
setDecimals(int)

Definition at line 357 of file KisAngleSelector.cpp.

358{
359 return m_d->spinBox->decimals();
360}

References m_d.

◆ event()

bool KisAngleSelector::event ( QEvent * e)
overrideprivate

Definition at line 584 of file KisAngleSelector.cpp.

585{
586 if (e->type() == QEvent::PaletteChange) {
587 // For some reason the spinbox, that uses stylesheets, doesn't update
588 // on palette changes, so we reset the stylesheet to force an update.
589 // Calling m_d->spinBox->update() doesn't work
590 m_d->spinBox->refreshStyle();
591 } else if (e->type() == QEvent::StyleChange || e->type() == QEvent::FontChange) {
592 // Temporarily reset the spin box style so that we can get its
593 // height size hint
594 m_d->spinBox->refreshStyle();
595 m_d->resizeWidgets();
596 }
597 return QWidget::event(e);
598}

References m_d.

◆ eventFilter()

bool KisAngleSelector::eventFilter ( QObject * o,
QEvent * e )
overrideprivate

Definition at line 600 of file KisAngleSelector.cpp.

601{
602 QWidget *w = qobject_cast<QWidget*>(o);
603 if (w != m_d->angleGauge || !w->isEnabled() || !e || e->type() != QEvent::ContextMenu) {
604 return false;
605 }
606 QContextMenuEvent *cme = static_cast<QContextMenuEvent*>(e);
607
608 m_d->menuFlip->exec(cme->globalPos());
609 return true;
610}

References m_d.

◆ flip()

void KisAngleSelector::flip ( Qt::Orientations orientations)

Flips the angle horizontally, vertically, or both.

This function will always try to set the closest angle to the stablished one that satisfies the flipping requirements

Parameters
orientationsFlags indicating in which directions the angle should be flipped

Definition at line 575 of file KisAngleSelector.cpp.

576{
577 bool ok = false;
578 qreal flippedAngle = flipAngle(angle(), minimum(), maximum(), orientations, &ok);
579 if (ok) {
580 setAngle(flippedAngle);
581 }
582}
static qreal flipAngle(qreal angle, Qt::Orientations orientations)
Flips an angle horizontally, vertically, or both.
void setAngle(qreal newAngle)
Sets the current angle.

References angle(), flipAngle(), maximum(), minimum(), and setAngle().

◆ flipAngle() [1/2]

qreal KisAngleSelector::flipAngle ( qreal angle,
qreal minimum,
qreal maximum,
Qt::Orientations orientations,
bool * ok = nullptr )
static

Flips an angle horizontally, vertically, or both.

This function will always try to get the closest angle to the provided one that satisfies the flipping requirements

Parameters
angleThe angle to be flipped
minimumThe lower bound of the valid range
maximumThe upper bound of the valid range
orientationsFlags indicating in which directions the angle should be flipped
[out]okThis parameter will be set to true if the flipped angle is in the provided range, or to false otherwise
Returns
The flipped angle if it lies in the provided range or the closest value in the range (the minimum or maximum) otherwise

Definition at line 570 of file KisAngleSelector.cpp.

571{
572 return closestCoterminalAngleInRange(flipAngle(angle, orientations), minimum, maximum, ok);
573}

References angle(), closestCoterminalAngleInRange(), flipAngle(), maximum(), and minimum().

◆ flipAngle() [2/2]

qreal KisAngleSelector::flipAngle ( qreal angle,
Qt::Orientations orientations )
static

Flips an angle horizontally, vertically, or both.

This function will always try to get the closest angle to the provided one that satisfies the flipping requirements

Parameters
angleThe angle to be flipped
orientationsFlags indicating in which directions the angle should be flipped
Returns
The flipped angle

Definition at line 533 of file KisAngleSelector.cpp.

534{
535 if ((orientations & Qt::Horizontal) && (orientations & Qt::Vertical)) {
536 angle += 180.0;
537 } else if (orientations & Qt::Horizontal) {
538 qreal a = std::fmod(angle, 360.0);
539 if (a < 0) {
540 a += 360.0;
541 }
542 if (a > 270.0) {
543 angle -= 2.0 * (a - 270.0);
544 } else if (a > 180.0) {
545 angle += 2.0 * (270.0 - a);
546 } else if (a > 90.0) {
547 angle -= 2.0 * (a - 90.0);
548 } else {
549 angle += 2.0 * (90.0 - a);
550 }
551 } else if (orientations & Qt::Vertical) {
552 qreal a = std::fmod(angle, 360.0);
553 if (a < 0) {
554 a += 360.0;
555 }
556 if (a > 270.0) {
557 angle += 2.0 * (360.0 - a);
558 } else if (a > 180.0) {
559 angle -= 2.0 * (a - 180.0);
560 } else if (a > 90.0) {
561 angle += 2.0 * (180.0 - a);
562 } else {
563 angle -= 2.0 * a;
564 }
565 }
566
567 return angle;
568}

References angle().

◆ flipOptionsMode()

KisAngleSelector::FlipOptionsMode KisAngleSelector::flipOptionsMode ( ) const

Gets the mode in which the flip options should be shown.

The default is FlipOptions::FlipOptionsMode_Buttons

Returns
The mode in which the flip options should be shown.
See also
setFlipOptionsMode(FlipOptionsMode)
FlipOptionsMode

Definition at line 382 of file KisAngleSelector.cpp.

383{
384 return m_d->flipOptionsMode;
385}

References m_d.

◆ increasingDirection()

KisAngleGauge::IncreasingDirection KisAngleSelector::increasingDirection ( ) const

Gets the direction in which the angle increases in the angle gauge.

Returns
The direction in which the angle increases
See also
KisAngleGauge::IncreasingDirection
setIncreasingDirection(KisAngleGauge::IncreasingDirection)

Definition at line 392 of file KisAngleSelector.cpp.

393{
394 return m_d->angleGauge->increasingDirection();
395}

References m_d.

◆ isUsingFlatSpinBox()

bool KisAngleSelector::isUsingFlatSpinBox ( ) const

Gets if the spin box is flat (no border or background)

Returns
True if the spin box is flat, false otherwise
See also
useFlatSpinBox(bool)

Definition at line 397 of file KisAngleSelector.cpp.

398{
399 return m_d->spinBox->isFlat();
400}

References m_d.

◆ maximum()

qreal KisAngleSelector::maximum ( ) const

Gets the maximum value for the angle.

The default is 360

Returns
The maximum value for the angle
See also
setMaximum(qreal)
setRange(qreal, qreal)

Definition at line 362 of file KisAngleSelector.cpp.

363{
364 return m_d->spinBox->maximum();
365}

References m_d.

◆ minimum()

qreal KisAngleSelector::minimum ( ) const

Gets the minimum value for the angle.

The default is 0

Returns
The minimum value for the angle
See also
setMinimum(qreal)
setRange(qreal, qreal)

Definition at line 367 of file KisAngleSelector.cpp.

368{
369 return m_d->spinBox->minimum();
370}

References m_d.

◆ prefix()

QString KisAngleSelector::prefix ( ) const

Gets the prefix shown in the spin box.

Returns
The prefix shown in the spin box
See also
setPrefix(const QString&)

Definition at line 372 of file KisAngleSelector.cpp.

373{
374 return m_d->spinBox->prefix();
375}

References m_d.

◆ reset

void KisAngleSelector::reset ( )
slot

Sets the current angle to the reset angle.

See also
resetAngle() const
setResetAngle(qreal) const

Definition at line 495 of file KisAngleSelector.cpp.

496{
497 m_d->angleGauge->reset();
498}

References m_d.

◆ resetAngle()

qreal KisAngleSelector::resetAngle ( ) const

Gets the angle that is used to reset the current angle.

This angle is used when the user double clicks on the widget

Returns
The angle that is used to reset the current angle
See also
setResetAngle(qreal)

Definition at line 352 of file KisAngleSelector.cpp.

353{
354 return m_d->angleGauge->resetAngle();
355}

References m_d.

◆ setAngle

void KisAngleSelector::setAngle ( qreal newAngle)
slot

Sets the current angle.

Parameters
newAnglethe new angle
See also
angle() const

Definition at line 402 of file KisAngleSelector.cpp.

403{
404 KisSignalsBlocker angleGaugeSignalsBlocker(m_d->angleGauge);
405 KisSignalsBlocker spinBoxSignalsBlocker(m_d->spinBox);
406
407 const qreal oldAngle = m_d->spinBox->value();
408
409 m_d->spinBox->setValue(newAngle);
410 m_d->angleGauge->setAngle(m_d->spinBox->value());
411
412 if (qFuzzyCompare(oldAngle, m_d->spinBox->value())) {
413 return;
414 }
415
416 Q_EMIT angleChanged(m_d->spinBox->value());
417}
void angleChanged(qreal angle)
static bool qFuzzyCompare(half p1, half p2)

References angleChanged(), m_d, and qFuzzyCompare().

◆ setDecimals()

void KisAngleSelector::setDecimals ( int newNumberOfDecimals)

Sets the number of decimals (precision) used by the angle.

Parameters
newNumberOfDecimalsthe new number of decimals used by the angle
See also
decimals() const

Definition at line 429 of file KisAngleSelector.cpp.

430{
431 m_d->spinBox->setDecimals(newNumberOfDecimals);
432}

References m_d.

◆ setFlipOptionsMode()

void KisAngleSelector::setFlipOptionsMode ( FlipOptionsMode newMode)

Sets the mode in which the flip options should be shown.

Parameters
newMinimumthe new mode in which the flip options should be shown
See also
flipOptionsMode() const
FlipOptionsMode

Definition at line 459 of file KisAngleSelector.cpp.

460{
461 m_d->flipOptionsMode = newMode;
462
463 m_d->toolButtonFlipOptions->setVisible(newMode == FlipOptionsMode_MenuButton);
464
465 bool useButtons = newMode == FlipOptionsMode_Buttons;
466 m_d->toolButtonFlipHorizontally->setVisible(useButtons);
467 m_d->toolButtonFlipVertically->setVisible(useButtons);
468 m_d->toolButtonFlipHorizontallyAndVertically->setVisible(useButtons);
469
470 bool showMenus = newMode != FlipOptionsMode_NoFlipOptions;
471 m_d->actionFlipHorizontally->setVisible(showMenus);
472 m_d->actionFlipVertically->setVisible(showMenus);
473 m_d->actionFlipHorizontallyAndVertically->setVisible(showMenus);
474}

References FlipOptionsMode_Buttons, FlipOptionsMode_MenuButton, FlipOptionsMode_NoFlipOptions, and m_d.

◆ setIncreasingDirection()

void KisAngleSelector::setIncreasingDirection ( KisAngleGauge::IncreasingDirection newIncreasingDirection)

Sets the increasing direction in the angle gauge.

Parameters
newIncreasingDirectionThe new increasing direction
See also
IncreasingDirection
increasingDirection() const

Definition at line 485 of file KisAngleSelector.cpp.

486{
487 m_d->angleGauge->setIncreasingDirection(newIncreasingDirection);
488}

References m_d.

◆ setMaximum()

void KisAngleSelector::setMaximum ( qreal newMaximum)

Sets the maximum value for the angle.

Parameters
newMaximumthe new maximum value for the angle
See also
maximum() const
setRange(qreal, qreal)

Definition at line 434 of file KisAngleSelector.cpp.

435{
436 m_d->spinBox->setMaximum(newMaximum);
437}

References m_d.

◆ setMinimum()

void KisAngleSelector::setMinimum ( qreal newMinimum)

Sets the minimum value for the angle.

Parameters
newMinimumthe new minimum value for the angle
See also
minimum() const
setRange(qreal, qreal)

Definition at line 439 of file KisAngleSelector.cpp.

440{
441 m_d->spinBox->setMinimum(newMinimum);
442}

References m_d.

◆ setPrefix()

void KisAngleSelector::setPrefix ( const QString & newPrefix)

Sets the prefix shown in the spin box.

Parameters
newPrefixthe new prefix for the spin box
See also
prefix() const

Definition at line 449 of file KisAngleSelector.cpp.

450{
451 m_d->spinBox->setPrefix(newPrefix);
452}

References m_d.

◆ setRange()

void KisAngleSelector::setRange ( qreal newMinimum,
qreal newMaximum )

Sets the minimum and maximum values for the angle.

Parameters
newMinimumthe new minimum value for the angle
newMaximumthe new maximum value for the angle
See also
minimum() const
maximum() const
setMinimum(qreal)
setMaximum(qreal)

Definition at line 444 of file KisAngleSelector.cpp.

445{
446 m_d->spinBox->setRange(newMinimum, newMaximum);
447}

References m_d.

◆ setResetAngle()

void KisAngleSelector::setResetAngle ( qreal newResetAngle)

Sets the angle that is used to reset the current angle.

Parameters
newResetAnglethe new angle that is used to reset the current angle
See also
resetAngle() const

Definition at line 424 of file KisAngleSelector.cpp.

425{
426 m_d->angleGauge->setResetAngle(newResetAngle);
427}

References m_d.

◆ setSnapAngle()

void KisAngleSelector::setSnapAngle ( qreal newSnapAngle)

Sets the angle to which multiples the selected angle will snap.

Parameters
newSnapAnglethe new angle to which multiples the selected angle will snap
See also
snapAngle() const

Definition at line 419 of file KisAngleSelector.cpp.

420{
421 m_d->angleGauge->setSnapAngle(newSnapAngle);
422}

References m_d.

◆ setWidgetsHeight()

void KisAngleSelector::setWidgetsHeight ( int newHeight)

Sets the common height of the widgets inside this angle selector. Use 0 to reset widgets to default height.

Parameters
newHeightthe new height of the internal widgets (angle gauge, spin box, etc.)
See also
widgetsHeight() const

Definition at line 476 of file KisAngleSelector.cpp.

477{
478 if (newHeight < 0) {
479 return;
480 }
481 m_d->commonWidgetsHeight = newHeight;
482 m_d->resizeWidgets();
483}

References m_d.

◆ setWrapping()

void KisAngleSelector::setWrapping ( bool newWrapping)

Sets if the angle should wrap pass the minimum or maximum angles.

Parameters
newWrappingtrue if the angle should wrap pass the minimum or maximum angles, false otherwise
See also
wrapping() const

Definition at line 454 of file KisAngleSelector.cpp.

455{
456 m_d->spinBox->setWrapping(newWrapping);
457}

References m_d.

◆ snapAngle()

qreal KisAngleSelector::snapAngle ( ) const

Gets the angle to which multiples the selected angle will snap.

The default snap angle is 15 degrees so the selected angle will snap to its multiples (0, 15, 30, 45, etc.)

Returns
The angle to which multiples the selected angle will snap
See also
setSnapAngle(qreal)

Definition at line 347 of file KisAngleSelector.cpp.

348{
349 return m_d->angleGauge->snapAngle();
350}

References m_d.

◆ useFlatSpinBox()

void KisAngleSelector::useFlatSpinBox ( bool newUseFlatSpinBox)

Sets if the spin box should be flat.

Parameters
newUseFlatSpinBoxTrue if the spin box should be flat, false otherwise
See also
isUsingFlatSpinBox() const

Definition at line 490 of file KisAngleSelector.cpp.

491{
492 m_d->spinBox->setFlat(newUseFlatSpinBox);
493}

References m_d.

◆ widgetsHeight()

int KisAngleSelector::widgetsHeight ( ) const

Gets the common height of the widgets inside this angle selector.

Returns
The height of the internal widgets (angle gauge, spin box, etc.). Returns 0 if each widget has its default height.
See also
setWidgetsHeight(int)

Definition at line 387 of file KisAngleSelector.cpp.

388{
389 return m_d->commonWidgetsHeight;
390}

References m_d.

◆ wrapping()

bool KisAngleSelector::wrapping ( ) const

Gets if the angle should wrap pass the minimum or maximum angles.

Returns
True if the angle should wrap pass the minimum or maximum angles, false otherwise
See also
setWrapping(bool)

Definition at line 377 of file KisAngleSelector.cpp.

378{
379 return m_d->spinBox->wrapping();
380}

References m_d.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisAngleSelector::m_d
private

Definition at line 366 of file KisAngleSelector.h.


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