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< Privatem_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 std::bind(&Private::on_angleGauge_angleChanged, m_d.data(), _1)
307 );
308 connect(
309 m_d->spinBox,
310 QOverload<double>::of(&KisDoubleParseSpinBox::valueChanged),
311 std::bind(&Private::on_spinBox_valueChanged, m_d.data(), _1)
312 );
313 connect(
314 m_d->actionFlipHorizontally,
315 &QAction::triggered,
317 );
318 connect(
319 m_d->actionFlipVertically,
320 &QAction::triggered,
322 );
323 connect(
324 m_d->actionFlipHorizontallyAndVertically,
325 &QAction::triggered,
327 );
328 connect(m_d->actionResetAngle, SIGNAL(triggered()), SLOT(reset()));
329 connect(m_d->toolButtonFlipHorizontally, SIGNAL(clicked()), m_d->actionFlipHorizontally, SLOT(trigger()));
330 connect(m_d->toolButtonFlipVertically, SIGNAL(clicked()), m_d->actionFlipVertically, SLOT(trigger()));
331 connect(m_d->toolButtonFlipHorizontallyAndVertically, SIGNAL(clicked()), m_d->actionFlipHorizontallyAndVertically, SLOT(trigger()));
332}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
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(), connect(), 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 334 of file KisAngleSelector.cpp.

335{}

Member Function Documentation

◆ angle()

qreal KisAngleSelector::angle ( ) const

Gets the current angle.

Returns
The current angle
See also
setAngle(qreal)

Definition at line 337 of file KisAngleSelector.cpp.

338{
339 return m_d->spinBox->value();
340}

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 523 of file KisAngleSelector.cpp.

524{
525 return closestCoterminalAngleInRange(angle, m_d->spinBox->minimum(), m_d->spinBox->maximum(), ok);
526}
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 495 of file KisAngleSelector.cpp.

496{
497 bool hasCoterminalAngleInRange = true;
498
499 if (angle < minimum) {
500 const qreal d = minimum - angle;
501 const qreal cycles = std::floor(d / 360.0) + 1;
502 angle += cycles * 360.0;
503 if (angle > maximum) {
504 hasCoterminalAngleInRange = false;
505 angle = minimum;
506 }
507 } else if (angle > maximum) {
508 const qreal d = angle - maximum;
509 const qreal cycles = std::floor(d / 360.0) + 1;
510 angle -= cycles * 360.0;
511 if (angle < minimum) {
512 hasCoterminalAngleInRange = false;
513 angle = maximum;
514 }
515 }
516
517 if (ok) {
518 *ok = hasCoterminalAngleInRange;
519 }
520 return angle;
521}
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 352 of file KisAngleSelector.cpp.

353{
354 return m_d->spinBox->decimals();
355}

References m_d.

◆ event()

bool KisAngleSelector::event ( QEvent * e)
overrideprivate

Definition at line 579 of file KisAngleSelector.cpp.

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

References m_d.

◆ eventFilter()

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

Definition at line 595 of file KisAngleSelector.cpp.

596{
597 QWidget *w = qobject_cast<QWidget*>(o);
598 if (w != m_d->angleGauge || !w->isEnabled() || !e || e->type() != QEvent::ContextMenu) {
599 return false;
600 }
601 QContextMenuEvent *cme = static_cast<QContextMenuEvent*>(e);
602
603 m_d->menuFlip->exec(cme->globalPos());
604 return true;
605}

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 570 of file KisAngleSelector.cpp.

571{
572 bool ok = false;
573 qreal flippedAngle = flipAngle(angle(), minimum(), maximum(), orientations, &ok);
574 if (ok) {
575 setAngle(flippedAngle);
576 }
577}
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 565 of file KisAngleSelector.cpp.

566{
567 return closestCoterminalAngleInRange(flipAngle(angle, orientations), minimum, maximum, ok);
568}

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 528 of file KisAngleSelector.cpp.

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

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 377 of file KisAngleSelector.cpp.

378{
379 return m_d->flipOptionsMode;
380}

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 387 of file KisAngleSelector.cpp.

388{
389 return m_d->angleGauge->increasingDirection();
390}

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 392 of file KisAngleSelector.cpp.

393{
394 return m_d->spinBox->isFlat();
395}

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 357 of file KisAngleSelector.cpp.

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

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 362 of file KisAngleSelector.cpp.

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

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 367 of file KisAngleSelector.cpp.

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

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 490 of file KisAngleSelector.cpp.

491{
492 m_d->angleGauge->reset();
493}

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 347 of file KisAngleSelector.cpp.

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

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 397 of file KisAngleSelector.cpp.

398{
399 KisSignalsBlocker angleGaugeSignalsBlocker(m_d->angleGauge);
400 KisSignalsBlocker spinBoxSignalsBlocker(m_d->spinBox);
401
402 const qreal oldAngle = m_d->spinBox->value();
403
404 m_d->spinBox->setValue(newAngle);
405 m_d->angleGauge->setAngle(m_d->spinBox->value());
406
407 if (qFuzzyCompare(oldAngle, m_d->spinBox->value())) {
408 return;
409 }
410
411 Q_EMIT angleChanged(m_d->spinBox->value());
412}
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 424 of file KisAngleSelector.cpp.

425{
426 m_d->spinBox->setDecimals(newNumberOfDecimals);
427}

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 454 of file KisAngleSelector.cpp.

455{
456 m_d->flipOptionsMode = newMode;
457
458 m_d->toolButtonFlipOptions->setVisible(newMode == FlipOptionsMode_MenuButton);
459
460 bool useButtons = newMode == FlipOptionsMode_Buttons;
461 m_d->toolButtonFlipHorizontally->setVisible(useButtons);
462 m_d->toolButtonFlipVertically->setVisible(useButtons);
463 m_d->toolButtonFlipHorizontallyAndVertically->setVisible(useButtons);
464
465 bool showMenus = newMode != FlipOptionsMode_NoFlipOptions;
466 m_d->actionFlipHorizontally->setVisible(showMenus);
467 m_d->actionFlipVertically->setVisible(showMenus);
468 m_d->actionFlipHorizontallyAndVertically->setVisible(showMenus);
469}

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 480 of file KisAngleSelector.cpp.

481{
482 m_d->angleGauge->setIncreasingDirection(newIncreasingDirection);
483}

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 429 of file KisAngleSelector.cpp.

430{
431 m_d->spinBox->setMaximum(newMaximum);
432}

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 434 of file KisAngleSelector.cpp.

435{
436 m_d->spinBox->setMinimum(newMinimum);
437}

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 444 of file KisAngleSelector.cpp.

445{
446 m_d->spinBox->setPrefix(newPrefix);
447}

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 439 of file KisAngleSelector.cpp.

440{
441 m_d->spinBox->setRange(newMinimum, newMaximum);
442}

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 419 of file KisAngleSelector.cpp.

420{
421 m_d->angleGauge->setResetAngle(newResetAngle);
422}

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 414 of file KisAngleSelector.cpp.

415{
416 m_d->angleGauge->setSnapAngle(newSnapAngle);
417}

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 471 of file KisAngleSelector.cpp.

472{
473 if (newHeight < 0) {
474 return;
475 }
476 m_d->commonWidgetsHeight = newHeight;
477 m_d->resizeWidgets();
478}

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 449 of file KisAngleSelector.cpp.

450{
451 m_d->spinBox->setWrapping(newWrapping);
452}

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 342 of file KisAngleSelector.cpp.

343{
344 return m_d->angleGauge->snapAngle();
345}

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 485 of file KisAngleSelector.cpp.

486{
487 m_d->spinBox->setFlat(newUseFlatSpinBox);
488}

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 382 of file KisAngleSelector.cpp.

383{
384 return m_d->commonWidgetsHeight;
385}

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 372 of file KisAngleSelector.cpp.

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

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: