Krita Source Code Documentation
Loading...
Searching...
No Matches
KisToolKnifeOptionsWidget::Private Struct Reference

Public Member Functions

KoUnit getCurrentUnit ()
 
GutterWidthsConfig getCurrentWidthsConfig (KisToolKnifeOptionsWidget::GapWidthType type)
 
KisToolKnifeOptionsWidget::GapWidthType getCurrentWidthType ()
 
qreal getSpecialGapWidth (void)
 
qreal getThickGapWidth (void)
 
qreal getThinGapWidth (void)
 
KisToolKnifeOptionsWidget::ToolMode getToolMode ()
 
qreal getWidthDiagonal ()
 
qreal getWidthForType (KisToolKnifeOptionsWidget::GapWidthType type)
 
qreal getWidthHorizontal ()
 
qreal getWidthVertical ()
 
 Private ()
 
void readFromConfig (QString groupId)
 
void setTypeToCombobox (KisToolKnifeOptionsWidget::GapWidthType type, QComboBox *combobox)
 
void setUnit (QString unit)
 
void setWidthTypeFromString (QString typeStr)
 
KisToolKnifeOptionsWidget::GapWidthType widthTypeFromString (QString type)
 
QString widthTypeToString (KisToolKnifeOptionsWidget::GapWidthType type)
 
void writeToConfig (QString groupId)
 

Public Attributes

KoGroupButtonbuttonModeAddGutter {nullptr}
 
KoGroupButtonbuttonModeRemoveGutter {nullptr}
 
qreal resolution {1.0}
 
QString toolId {""}
 
Ui_KisToolKnifeOptionsWidget * ui {nullptr}
 

Detailed Description

Definition at line 29 of file KisToolKnifeOptionsWidget.cpp.

Constructor & Destructor Documentation

◆ Private()

KisToolKnifeOptionsWidget::Private::Private ( )
inline

Definition at line 30 of file KisToolKnifeOptionsWidget.cpp.

31 {
32 }

Member Function Documentation

◆ getCurrentUnit()

KoUnit KisToolKnifeOptionsWidget::Private::getCurrentUnit ( )
inline

Definition at line 185 of file KisToolKnifeOptionsWidget.cpp.

185 {
186 return KoUnit::fromSymbol(ui->thickGapWidth->suffix().trimmed());
187 }
static KoUnit fromSymbol(const QString &symbol, bool *ok=0)
Definition KoUnit.cpp:271

References KoUnit::fromSymbol(), and ui.

◆ getCurrentWidthsConfig()

GutterWidthsConfig KisToolKnifeOptionsWidget::Private::getCurrentWidthsConfig ( KisToolKnifeOptionsWidget::GapWidthType type)
inline

Definition at line 155 of file KisToolKnifeOptionsWidget.cpp.

155 {
156 switch(type) {
158 return GutterWidthsConfig(getCurrentUnit(), resolution, getThickGapWidth(), ui->gutterWidthAngleSpinBox->value());
160 return GutterWidthsConfig(getCurrentUnit(), resolution, getThinGapWidth(), ui->gutterWidthAngleSpinBox->value());
162 return GutterWidthsConfig(getCurrentUnit(), resolution, getSpecialGapWidth(), ui->gutterWidthAngleSpinBox->value());
164 return GutterWidthsConfig(getCurrentUnit(), resolution, getWidthHorizontal(), getWidthVertical(), getWidthDiagonal(), ui->gutterWidthAngleSpinBox->value());
165 default:
166 return GutterWidthsConfig(getCurrentUnit(), resolution, getSpecialGapWidth(), ui->gutterWidthAngleSpinBox->value());
167 }
168 }

References KisToolKnifeOptionsWidget::Automatic, getCurrentUnit(), getSpecialGapWidth(), getThickGapWidth(), getThinGapWidth(), getWidthDiagonal(), getWidthHorizontal(), getWidthVertical(), resolution, KisToolKnifeOptionsWidget::Special, KisToolKnifeOptionsWidget::Thick, KisToolKnifeOptionsWidget::Thin, and ui.

◆ getCurrentWidthType()

KisToolKnifeOptionsWidget::GapWidthType KisToolKnifeOptionsWidget::Private::getCurrentWidthType ( )
inline

Definition at line 59 of file KisToolKnifeOptionsWidget.cpp.

60 {
61 if (ui->thickGapWidthRadioButton->isChecked()) {
63 } else if (ui->thinGapWidthRadioButton->isChecked()) {
65 } else if (ui->specialGapWidthRadioButton->isChecked()) {
67 } else { // if (ui->automaticGapWidthRadioButton->isChecked())
69 }
70 }

References KisToolKnifeOptionsWidget::Automatic, KisToolKnifeOptionsWidget::Special, KisToolKnifeOptionsWidget::Thick, KisToolKnifeOptionsWidget::Thin, and ui.

◆ getSpecialGapWidth()

qreal KisToolKnifeOptionsWidget::Private::getSpecialGapWidth ( void )
inline

Definition at line 54 of file KisToolKnifeOptionsWidget.cpp.

55 {
56 return ui->customGapWidth->value();
57 }

References ui.

◆ getThickGapWidth()

qreal KisToolKnifeOptionsWidget::Private::getThickGapWidth ( void )
inline

Definition at line 44 of file KisToolKnifeOptionsWidget.cpp.

45 {
46 return ui->thickGapWidth->value();
47 }

References ui.

◆ getThinGapWidth()

qreal KisToolKnifeOptionsWidget::Private::getThinGapWidth ( void )
inline

Definition at line 49 of file KisToolKnifeOptionsWidget.cpp.

50 {
51 return ui->thinGapWidth->value();
52 }

References ui.

◆ getToolMode()

KisToolKnifeOptionsWidget::ToolMode KisToolKnifeOptionsWidget::Private::getToolMode ( )
inline

Definition at line 172 of file KisToolKnifeOptionsWidget.cpp.

172 {
173 if (buttonModeAddGutter && buttonModeAddGutter->isChecked()) {
175 } else if (buttonModeRemoveGutter && buttonModeRemoveGutter->isChecked()) {
177 //} else if (buttonModeMoveGutterEndPoint && buttonModeMoveGutterEndPoint->isChecked()) {
178 // return KisToolKnifeOptionsWidget::MoveGutterEndPoint;
179 } else {
180 // default
182 }
183 }

References KisToolKnifeOptionsWidget::AddGutter, buttonModeAddGutter, buttonModeRemoveGutter, and KisToolKnifeOptionsWidget::RemoveGutter.

◆ getWidthDiagonal()

qreal KisToolKnifeOptionsWidget::Private::getWidthDiagonal ( )
inline

Definition at line 149 of file KisToolKnifeOptionsWidget.cpp.

149 {
150 return getWidthForType(ui->automaticDiagonalCombobox->currentData().value<KisToolKnifeOptionsWidget::GapWidthType>());
151 }
qreal getWidthForType(KisToolKnifeOptionsWidget::GapWidthType type)

References getWidthForType(), and ui.

◆ getWidthForType()

qreal KisToolKnifeOptionsWidget::Private::getWidthForType ( KisToolKnifeOptionsWidget::GapWidthType type)
inline

Definition at line 128 of file KisToolKnifeOptionsWidget.cpp.

128 {
129 switch(type) {
131 return getThickGapWidth();
133 return getThinGapWidth();
135 return getSpecialGapWidth();
136 default: // this handles automatic, too...
137 return getSpecialGapWidth();
138 }
139 }

References getSpecialGapWidth(), getThickGapWidth(), getThinGapWidth(), KisToolKnifeOptionsWidget::Special, KisToolKnifeOptionsWidget::Thick, and KisToolKnifeOptionsWidget::Thin.

◆ getWidthHorizontal()

qreal KisToolKnifeOptionsWidget::Private::getWidthHorizontal ( )
inline

Definition at line 141 of file KisToolKnifeOptionsWidget.cpp.

141 {
142 return getWidthForType(ui->automaticHorizontalCombobox->currentData().value<KisToolKnifeOptionsWidget::GapWidthType>());
143 }

References getWidthForType(), and ui.

◆ getWidthVertical()

qreal KisToolKnifeOptionsWidget::Private::getWidthVertical ( )
inline

Definition at line 145 of file KisToolKnifeOptionsWidget.cpp.

145 {
146 return getWidthForType(ui->automaticVerticalCombobox->currentData().value<KisToolKnifeOptionsWidget::GapWidthType>());
147 }

References getWidthForType(), and ui.

◆ readFromConfig()

void KisToolKnifeOptionsWidget::Private::readFromConfig ( QString groupId)
inline

Definition at line 222 of file KisToolKnifeOptionsWidget.cpp.

222 {
223
224 KConfigGroup configGroup = KSharedConfig::openConfig()->group(groupId);
225
226 QString unitSymbol = configGroup.readEntry("gutter_unit_symbol", "px");
227 bool conversionSuccess;
228 KoUnit::fromSymbol(unitSymbol, &conversionSuccess);
229 if (!conversionSuccess) {
230 unitSymbol = "px";
231 }
232 setUnit(unitSymbol);
233
234 setWidthTypeFromString(configGroup.readEntry("current_gutter_width_type", "thick"));
235
236 ui->thickGapWidth->setValue(configGroup.readEntry("thick_gutter_width", 40.0f));
237 ui->thinGapWidth->setValue(configGroup.readEntry("thin_gutter_width", 15.0f));
238 ui->customGapWidth->setValue(configGroup.readEntry("special_gutter_width", 70.0f));
239
240 ui->gutterWidthAngleSpinBox->setValue(configGroup.readEntry("automatic_gutter_angle", 2.0f));
241
242 KisToolKnifeOptionsWidget::GapWidthType horizontalType = widthTypeFromString(configGroup.readEntry("automatic_horizontal_type", "thick"));
243 KisToolKnifeOptionsWidget::GapWidthType verticalType = widthTypeFromString(configGroup.readEntry("automatic_vertical_type", "thin"));
244 KisToolKnifeOptionsWidget::GapWidthType diagonalType = widthTypeFromString(configGroup.readEntry("automatic_diagonal_type", "thin"));
245
246 setTypeToCombobox(horizontalType, ui->automaticHorizontalCombobox);
247 setTypeToCombobox(verticalType, ui->automaticVerticalCombobox);
248 setTypeToCombobox(diagonalType, ui->automaticDiagonalCombobox);
249
250 }
void setTypeToCombobox(KisToolKnifeOptionsWidget::GapWidthType type, QComboBox *combobox)
KisToolKnifeOptionsWidget::GapWidthType widthTypeFromString(QString type)

References KoUnit::fromSymbol(), setTypeToCombobox(), setUnit(), setWidthTypeFromString(), ui, and widthTypeFromString().

◆ setTypeToCombobox()

void KisToolKnifeOptionsWidget::Private::setTypeToCombobox ( KisToolKnifeOptionsWidget::GapWidthType type,
QComboBox * combobox )
inline

Definition at line 215 of file KisToolKnifeOptionsWidget.cpp.

215 {
216 int index = combobox->findData(type);
217 if (index >= 0) {
218 combobox->setCurrentIndex(index);
219 }
220 }

◆ setUnit()

void KisToolKnifeOptionsWidget::Private::setUnit ( QString unit)
inline

Definition at line 189 of file KisToolKnifeOptionsWidget.cpp.

189 {
190 if (ui->unitsCombobox->currentData() != unit) {
191 int index = ui->unitsCombobox->findData(unit);
192 if (index != -1) {
193 ui->unitsCombobox->setCurrentIndex(index);
194 }
195 }
196
197 KoUnit unitBefore = KoUnit::fromSymbol(ui->thickGapWidth->suffix().trimmed());
198 bool success;
199 KoUnit unitNow = KoUnit::fromSymbol(unit.trimmed(), &success);
200
201 if (!success || unit.trimmed() == "" || unitNow.type() == unitBefore.type()) {
202 return;
203 }
204
205 ui->thickGapWidth->setSuffix(" " + unitNow.symbol());
206 ui->thinGapWidth->setSuffix(" " + unitNow.symbol());
207 ui->customGapWidth->setSuffix(" " + unitNow.symbol());
208
209 ui->thickGapWidth->setValue(KoUnit::convertFromUnitToUnit(ui->thickGapWidth->value(), unitBefore, unitNow, resolution));
210 ui->thinGapWidth->setValue(KoUnit::convertFromUnitToUnit(ui->thinGapWidth->value(), unitBefore, unitNow, resolution));
211 ui->customGapWidth->setValue(KoUnit::convertFromUnitToUnit(ui->customGapWidth->value(), unitBefore, unitNow, resolution));
212
213 }
static qreal convertFromUnitToUnit(const qreal value, const KoUnit &fromUnit, const KoUnit &toUnit, qreal factor=1.0)
Definition KoUnit.cpp:295
KoUnit::Type type() const
Definition KoUnit.h:118
QString symbol() const
Get the symbol string of the unit.
Definition KoUnit.cpp:347

References KoUnit::convertFromUnitToUnit(), KoUnit::fromSymbol(), resolution, KoUnit::symbol(), KoUnit::type(), and ui.

◆ setWidthTypeFromString()

void KisToolKnifeOptionsWidget::Private::setWidthTypeFromString ( QString typeStr)
inline

Definition at line 110 of file KisToolKnifeOptionsWidget.cpp.

110 {
113 ui->thickGapWidthRadioButton->setChecked(true);
114 } else if (type == KisToolKnifeOptionsWidget::Thin) {
115 ui->thinGapWidthRadioButton->setChecked(true);
116 } else if (type == KisToolKnifeOptionsWidget::Special) {
117 ui->specialGapWidthRadioButton->setChecked(true);
118 } else if (type == KisToolKnifeOptionsWidget::Automatic) {
119 ui->automaticGapWidthRadioButton->setChecked(true);
120 } else {
121 // default
122 ui->thickGapWidthRadioButton->setChecked(true);
123 }
124 }

References KisToolKnifeOptionsWidget::Automatic, KisToolKnifeOptionsWidget::Special, KisToolKnifeOptionsWidget::Thick, KisToolKnifeOptionsWidget::Thin, ui, and widthTypeFromString().

◆ widthTypeFromString()

KisToolKnifeOptionsWidget::GapWidthType KisToolKnifeOptionsWidget::Private::widthTypeFromString ( QString type)
inline

Definition at line 72 of file KisToolKnifeOptionsWidget.cpp.

72 {
73 if (type == "thick") {
75 } else if (type == "thin") {
77 } else if (type == "special") {
79 } else if (type == "automatic") {
81 } else {
82 // default
84 }
85 }

References KisToolKnifeOptionsWidget::Automatic, KisToolKnifeOptionsWidget::Special, KisToolKnifeOptionsWidget::Thick, and KisToolKnifeOptionsWidget::Thin.

◆ widthTypeToString()

QString KisToolKnifeOptionsWidget::Private::widthTypeToString ( KisToolKnifeOptionsWidget::GapWidthType type)
inline

Definition at line 87 of file KisToolKnifeOptionsWidget.cpp.

87 {
88 switch(type) {
90 return "thick";
91 break;
93 return "thin";
94 break;
96 return "special";
97 break;
99 return "automatic";
100 break;
101 default:
103 }
105 return "thick";
106 }
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References KisToolKnifeOptionsWidget::Automatic, KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KisToolKnifeOptionsWidget::Special, KisToolKnifeOptionsWidget::Thick, and KisToolKnifeOptionsWidget::Thin.

◆ writeToConfig()

void KisToolKnifeOptionsWidget::Private::writeToConfig ( QString groupId)
inline

Definition at line 252 of file KisToolKnifeOptionsWidget.cpp.

252 {
253
254 KConfigGroup configGroup = KSharedConfig::openConfig()->group(groupId);
255
256 configGroup.writeEntry("gutter_unit_symbol", getCurrentUnit().symbol());
257 configGroup.writeEntry("current_gutter_width_type", widthTypeToString(getCurrentWidthType()));
258
259 configGroup.writeEntry("thick_gutter_width", ui->thickGapWidth->value());
260 configGroup.writeEntry("thin_gutter_width", ui->thinGapWidth->value());
261 configGroup.writeEntry("special_gutter_width", ui->customGapWidth->value());
262
263 configGroup.writeEntry("automatic_gutter_angle", ui->gutterWidthAngleSpinBox->value());
264
265 configGroup.writeEntry("automatic_horizontal_type", widthTypeToString(ui->automaticHorizontalCombobox->currentData().value<KisToolKnifeOptionsWidget::GapWidthType>()));
266 configGroup.writeEntry("automatic_vertical_type", widthTypeToString(ui->automaticVerticalCombobox->currentData().value<KisToolKnifeOptionsWidget::GapWidthType>()));
267 configGroup.writeEntry("automatic_diagonal_type", widthTypeToString(ui->automaticDiagonalCombobox->currentData().value<KisToolKnifeOptionsWidget::GapWidthType>()));
268 }
QString widthTypeToString(KisToolKnifeOptionsWidget::GapWidthType type)
KisToolKnifeOptionsWidget::GapWidthType getCurrentWidthType()

References getCurrentUnit(), getCurrentWidthType(), ui, and widthTypeToString().

Member Data Documentation

◆ buttonModeAddGutter

KoGroupButton* KisToolKnifeOptionsWidget::Private::buttonModeAddGutter {nullptr}

Definition at line 35 of file KisToolKnifeOptionsWidget.cpp.

35{nullptr};

◆ buttonModeRemoveGutter

KoGroupButton* KisToolKnifeOptionsWidget::Private::buttonModeRemoveGutter {nullptr}

Definition at line 36 of file KisToolKnifeOptionsWidget.cpp.

36{nullptr};

◆ resolution

qreal KisToolKnifeOptionsWidget::Private::resolution {1.0}

Definition at line 38 of file KisToolKnifeOptionsWidget.cpp.

38{1.0};

◆ toolId

QString KisToolKnifeOptionsWidget::Private::toolId {""}

Definition at line 40 of file KisToolKnifeOptionsWidget.cpp.

40{""};

◆ ui

Ui_KisToolKnifeOptionsWidget* KisToolKnifeOptionsWidget::Private::ui {nullptr}

Definition at line 34 of file KisToolKnifeOptionsWidget.cpp.

34{nullptr};

The documentation for this struct was generated from the following file: