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

#include <kis_rectangle_constraint_widget.h>

+ Inheritance diagram for KisRectangleConstraintWidget:

Signals

void constraintsChanged (bool forceRatio, bool forceWidth, bool forceHeight, float ratio, float width, float height)
 

Public Member Functions

 KisRectangleConstraintWidget (QWidget *parentWidget, KisToolRectangleBase *tool, bool showRoundCornersGUI)
 

Protected Slots

void inputHeightChanged ()
 
void inputRatioChanged ()
 
void inputsChanged ()
 
void inputWidthChanged ()
 
void rectangleChanged (const QRectF &rect)
 
void slotReloadConfig ()
 
void slotRoundCornersAspectLockChanged ()
 
void slotRoundCornersChanged ()
 

Protected Attributes

KisAspectRatioLockerm_cornersAspectLocker
 
KisToolRectangleBasem_tool
 
Ui_WdgRectangleConstraints * m_widget
 

Detailed Description

Definition at line 14 of file kis_rectangle_constraint_widget.h.

Constructor & Destructor Documentation

◆ KisRectangleConstraintWidget()

KisRectangleConstraintWidget::KisRectangleConstraintWidget ( QWidget * parentWidget,
KisToolRectangleBase * tool,
bool showRoundCornersGUI )

Definition at line 14 of file kis_rectangle_constraint_widget.cpp.

15 : QWidget(parent)
16{
17 m_tool = tool;
18
19 setupUi(this);
20
21 connect(lockWidthButton, SIGNAL(toggled(bool)), this, SLOT(inputsChanged()));
22 connect(lockHeightButton, SIGNAL(toggled(bool)), this, SLOT(inputsChanged()));
23 connect(lockRatioButton, SIGNAL(toggled(bool)), this, SLOT(inputsChanged()));
24
25 QIcon lockedIcon = KisIconUtils::loadIcon("locked");
26 QIcon unlockedIcon = KisIconUtils::loadIcon("unlocked");
27 lockWidthButton->setIcon(lockWidthButton->isChecked() ? lockedIcon : unlockedIcon);
28 lockHeightButton->setIcon(lockHeightButton->isChecked() ? lockedIcon : unlockedIcon);
29 lockRatioButton->setIcon(lockRatioButton->isChecked() ? lockedIcon : unlockedIcon);
30
31 connect(intWidth, SIGNAL(valueChanged(int)), this, SLOT(inputWidthChanged()));
32 connect(intHeight, SIGNAL(valueChanged(int)), this, SLOT(inputHeightChanged()));
33 connect(doubleRatio, SIGNAL(valueChanged(double)), this, SLOT(inputRatioChanged()));
34
35 connect(this, SIGNAL(constraintsChanged(bool,bool,bool,float,float,float)), m_tool, SLOT(constraintsChanged(bool,bool,bool,float,float,float)));
36 connect(m_tool, SIGNAL(rectangleChanged(QRectF)), this, SLOT(rectangleChanged(QRectF)));
37
39 m_cornersAspectLocker->connectSpinBoxes(intRoundCornersX, intRoundCornersY, cornersAspectButton);
40
41 connect(m_cornersAspectLocker, SIGNAL(sliderValueChanged()), SLOT(slotRoundCornersChanged()));
42 connect(m_cornersAspectLocker, SIGNAL(aspectButtonChanged()), SLOT(slotRoundCornersAspectLockChanged()));
43
44 connect(m_tool, SIGNAL(sigRequestReloadConfig()), SLOT(slotReloadConfig()));
46
47 if (!showRoundCornersGUI) {
48 intRoundCornersX->setVisible(false);
49 intRoundCornersY->setVisible(false);
50 cornersAspectButton->setVisible(false);
51 }
52}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void connectSpinBoxes(SpinBoxType *spinOne, SpinBoxType *spinTwo, KoAspectButton *aspectButton)
void constraintsChanged(bool forceRatio, bool forceWidth, bool forceHeight, float ratio, float width, float height)
QIcon loadIcon(const QString &name)

References connect(), KisAspectRatioLocker::connectSpinBoxes(), constraintsChanged(), inputHeightChanged(), inputRatioChanged(), inputsChanged(), inputWidthChanged(), KisIconUtils::loadIcon(), m_cornersAspectLocker, m_tool, rectangleChanged(), slotReloadConfig(), slotRoundCornersAspectLockChanged(), and slotRoundCornersChanged().

Member Function Documentation

◆ constraintsChanged

void KisRectangleConstraintWidget::constraintsChanged ( bool forceRatio,
bool forceWidth,
bool forceHeight,
float ratio,
float width,
float height )
signal

◆ inputHeightChanged

void KisRectangleConstraintWidget::inputHeightChanged ( )
protectedslot

Definition at line 60 of file kis_rectangle_constraint_widget.cpp.

61{
62 lockHeightButton->setChecked(true);
64}

References inputsChanged().

◆ inputRatioChanged

void KisRectangleConstraintWidget::inputRatioChanged ( )
protectedslot

Definition at line 66 of file kis_rectangle_constraint_widget.cpp.

67{
68 lockRatioButton->setChecked(true);
70}

References inputsChanged().

◆ inputsChanged

void KisRectangleConstraintWidget::inputsChanged ( )
protectedslot

Definition at line 72 of file kis_rectangle_constraint_widget.cpp.

73{
74 Q_EMIT constraintsChanged(
75 lockRatioButton->isChecked(),
76 lockWidthButton->isChecked(),
77 lockHeightButton->isChecked(),
78 doubleRatio->value(),
79 intWidth->value(),
80 intHeight->value()
81 );
82 QIcon lockedIcon = KisIconUtils::loadIcon("locked");
83 QIcon unlockedIcon = KisIconUtils::loadIcon("unlocked");
84 lockWidthButton->setIcon(lockWidthButton->isChecked() ? lockedIcon : unlockedIcon);
85 lockHeightButton->setIcon(lockHeightButton->isChecked() ? lockedIcon : unlockedIcon);
86 lockRatioButton->setIcon(lockRatioButton->isChecked() ? lockedIcon : unlockedIcon);
87}

References constraintsChanged(), and KisIconUtils::loadIcon().

◆ inputWidthChanged

void KisRectangleConstraintWidget::inputWidthChanged ( )
protectedslot

Definition at line 54 of file kis_rectangle_constraint_widget.cpp.

55{
56 lockWidthButton->setChecked(true);
58}

References inputsChanged().

◆ rectangleChanged

void KisRectangleConstraintWidget::rectangleChanged ( const QRectF & rect)
protectedslot

Definition at line 119 of file kis_rectangle_constraint_widget.cpp.

120{
121 intWidth->blockSignals(true);
122 intHeight->blockSignals(true);
123 doubleRatio->blockSignals(true);
124
125 if (!lockWidthButton->isChecked()) intWidth->setValue(rect.width());
126 if (!lockHeightButton->isChecked()) intHeight->setValue(rect.height());
127
128 if (!lockRatioButton->isChecked() && !(rect.width() == 0 && rect.height() == 0)) {
129 doubleRatio->setValue(fabs(rect.width()) / fabs(rect.height()));
130 }
131
132 intWidth->blockSignals(false);
133 intHeight->blockSignals(false);
134 doubleRatio->blockSignals(false);
135}

◆ slotReloadConfig

void KisRectangleConstraintWidget::slotReloadConfig ( )
protectedslot

Definition at line 104 of file kis_rectangle_constraint_widget.cpp.

105{
106 KConfigGroup cfg = KSharedConfig::openConfig()->group(m_tool->toolId());
107
108 {
109 KisSignalsBlocker b(intRoundCornersX, intRoundCornersY, cornersAspectButton);
110 intRoundCornersX->setValue(cfg.readEntry("roundCornersX", 0));
111 intRoundCornersY->setValue(cfg.readEntry("roundCornersY", 0));
112 cornersAspectButton->setKeepAspectRatio(cfg.readEntry("roundCornersAspectLocked", true));
114 }
115
117}
Q_INVOKABLE QString toolId() const

References m_cornersAspectLocker, m_tool, slotRoundCornersChanged(), KoToolBase::toolId(), and KisAspectRatioLocker::updateAspect().

◆ slotRoundCornersAspectLockChanged

void KisRectangleConstraintWidget::slotRoundCornersAspectLockChanged ( )
protectedslot

Definition at line 98 of file kis_rectangle_constraint_widget.cpp.

99{
100 KConfigGroup cfg = KSharedConfig::openConfig()->group(m_tool->toolId());
101 cfg.writeEntry("roundCornersAspectLocked", cornersAspectButton->keepAspectRatio());
102}

References m_tool, and KoToolBase::toolId().

◆ slotRoundCornersChanged

void KisRectangleConstraintWidget::slotRoundCornersChanged ( )
protectedslot

Definition at line 89 of file kis_rectangle_constraint_widget.cpp.

90{
91 m_tool->roundCornersChanged(intRoundCornersX->value(), intRoundCornersY->value());
92
93 KConfigGroup cfg = KSharedConfig::openConfig()->group(m_tool->toolId());
94 cfg.writeEntry("roundCornersX", intRoundCornersX->value());
95 cfg.writeEntry("roundCornersY", intRoundCornersY->value());
96}
void roundCornersChanged(int rx, int ry)

References m_tool, KisToolRectangleBase::roundCornersChanged(), and KoToolBase::toolId().

Member Data Documentation

◆ m_cornersAspectLocker

KisAspectRatioLocker* KisRectangleConstraintWidget::m_cornersAspectLocker
protected

Definition at line 39 of file kis_rectangle_constraint_widget.h.

◆ m_tool

KisToolRectangleBase* KisRectangleConstraintWidget::m_tool
protected

Definition at line 37 of file kis_rectangle_constraint_widget.h.

◆ m_widget

Ui_WdgRectangleConstraints* KisRectangleConstraintWidget::m_widget
protected

Definition at line 38 of file kis_rectangle_constraint_widget.h.


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