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

#include <KoAspectButton.h>

+ Inheritance diagram for KoAspectButton:

Public Slots

void buttonReleased ()
 
void setKeepAspectRatio (bool keep)
 

Signals

void keepAspectRatioChanged (bool keep)
 

Public Member Functions

bool keepAspectRatio () const
 Returns of keeping aspect ratio is on or off.
 
 KoAspectButton (QWidget *parent)
 constructor
 
 Private ()
 
 ~KoAspectButton () override
 

Public Attributes

bool keepAspect
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Additional Inherited Members

- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Detailed Description

This button gives a visual indication of weather the 'aspect ratio' is locked. Typically you would use this alongside 2 spinboxes with a value like a width and height.

Definition at line 14 of file KoAspectButton.cpp.

Constructor & Destructor Documentation

◆ KoAspectButton()

KoAspectButton::KoAspectButton ( QWidget * parent)
explicit

constructor

Definition at line 24 of file KoAspectButton.cpp.

25 : QToolButton(parent),
26 d( new Private() )
27{
28 setIconSize(QSize(9, 24));
29 setFixedSize(19, 34);
30 setAutoRaise(true);
31
32 connect(this, SIGNAL(released()), this, SLOT(buttonReleased()));
33
34 setKeepAspectRatio(false);
35}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void setKeepAspectRatio(bool keep)
Private *const d

References buttonReleased(), connect(), and setKeepAspectRatio().

◆ ~KoAspectButton()

KoAspectButton::~KoAspectButton ( )
override

Definition at line 37 of file KoAspectButton.cpp.

38{
39 delete d;
40}

References d.

Member Function Documentation

◆ buttonReleased

void KoAspectButton::buttonReleased ( )
slot

Definition at line 42 of file KoAspectButton.cpp.

42 {
43 if(! isEnabled())
44 return;
45 setKeepAspectRatio(!d->keepAspect);
46}

References d, and setKeepAspectRatio().

◆ keepAspectRatio()

bool KoAspectButton::keepAspectRatio ( ) const

Returns of keeping aspect ratio is on or off.

Definition at line 58 of file KoAspectButton.cpp.

59{
60 return d->keepAspect;
61}

References d.

◆ keepAspectRatioChanged

void KoAspectButton::keepAspectRatioChanged ( bool keep)
signal

This signal is emitted every time the button changes value, either by user interaction or by programmatically setting it.

◆ Private()

KoAspectButton::Private ( )
inline

Definition at line 17 of file KoAspectButton.cpp.

18 : keepAspect(true)
19 {
20 }

◆ setKeepAspectRatio

void KoAspectButton::setKeepAspectRatio ( bool keep)
slot

Set the visual indicator to be locked or not. This also emits the keepAspectRatioChanged if the value has changed.

Parameters
keepif true, lock the aspect ratio.

Definition at line 48 of file KoAspectButton.cpp.

48 {
49 this->setIcon(on ? KisIconUtils::loadIcon("chain-icon") : KisIconUtils::loadIcon("chain-broken-icon"));
50 update();
51
52 if(d->keepAspect != on) {
53 d->keepAspect = on;
54 Q_EMIT keepAspectRatioChanged(d->keepAspect);
55 }
56}
void keepAspectRatioChanged(bool keep)
QIcon loadIcon(const QString &name)
bool update(QSpinBox *spinBox)

References d, keepAspectRatioChanged(), and KisIconUtils::loadIcon().

Member Data Documentation

◆ d

Private* const KoAspectButton::d
private

Definition at line 47 of file KoAspectButton.h.

◆ keepAspect

bool KoAspectButton::keepAspect

Definition at line 21 of file KoAspectButton.cpp.


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