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}
 
KoGroupButtonbuttonModeMoveGutterEndPoint {nullptr}
 
KoGroupButtonbuttonModeRemoveGutter {nullptr}
 
qreal resolution {1.0}
 
QString toolId {""}
 
Ui_KisToolKnifeOptionsWidget * ui {nullptr}
 

Detailed Description

Definition at line 30 of file KisToolKnifeOptionsWidget.cpp.

Constructor & Destructor Documentation

◆ Private()

KisToolKnifeOptionsWidget::Private::Private ( )
inline

Definition at line 31 of file KisToolKnifeOptionsWidget.cpp.

32 {
33 }

Member Function Documentation

◆ getCurrentUnit()

KoUnit KisToolKnifeOptionsWidget::Private::getCurrentUnit ( )
inline

Definition at line 186 of file KisToolKnifeOptionsWidget.cpp.

186 {
187 return KoUnit::fromSymbol(ui->thickGapWidth->suffix().trimmed());
188 }
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 156 of file KisToolKnifeOptionsWidget.cpp.

156 {
157 switch(type) {
159 return GutterWidthsConfig(getCurrentUnit(), resolution, getThickGapWidth(), ui->gutterWidthAngleSpinBox->value());
161 return GutterWidthsConfig(getCurrentUnit(), resolution, getThinGapWidth(), ui->gutterWidthAngleSpinBox->value());
163 return GutterWidthsConfig(getCurrentUnit(), resolution, getSpecialGapWidth(), ui->gutterWidthAngleSpinBox->value());
165 return GutterWidthsConfig(getCurrentUnit(), resolution, getWidthHorizontal(), getWidthVertical(), getWidthDiagonal(), ui->gutterWidthAngleSpinBox->value());
166 default:
167 return GutterWidthsConfig(getCurrentUnit(), resolution, getSpecialGapWidth(), ui->gutterWidthAngleSpinBox->value());
168 }
169 }

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 60 of file KisToolKnifeOptionsWidget.cpp.

61 {
62 if (ui->thickGapWidthRadioButton->isChecked()) {
64 } else if (ui->thinGapWidthRadioButton->isChecked()) {
66 } else if (ui->specialGapWidthRadioButton->isChecked()) {
68 } else { // if (ui->automaticGapWidthRadioButton->isChecked())
70 }
71 }

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

◆ getSpecialGapWidth()

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

Definition at line 55 of file KisToolKnifeOptionsWidget.cpp.

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

References ui.

◆ getThickGapWidth()

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

Definition at line 45 of file KisToolKnifeOptionsWidget.cpp.

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

References ui.

◆ getThinGapWidth()

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

Definition at line 50 of file KisToolKnifeOptionsWidget.cpp.

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

References ui.

◆ getToolMode()

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

◆ getWidthDiagonal()

qreal KisToolKnifeOptionsWidget::Private::getWidthDiagonal ( )
inline

Definition at line 150 of file KisToolKnifeOptionsWidget.cpp.

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

References getWidthForType(), and ui.

◆ getWidthForType()

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

Definition at line 129 of file KisToolKnifeOptionsWidget.cpp.

129 {
130 switch(type) {
132 return getThickGapWidth();
134 return getThinGapWidth();
136 return getSpecialGapWidth();
137 default: // this handles automatic, too...
138 return getSpecialGapWidth();
139 }
140 }

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

◆ getWidthHorizontal()

qreal KisToolKnifeOptionsWidget::Private::getWidthHorizontal ( )
inline

Definition at line 142 of file KisToolKnifeOptionsWidget.cpp.

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

References getWidthForType(), and ui.

◆ getWidthVertical()

qreal KisToolKnifeOptionsWidget::Private::getWidthVertical ( )
inline

Definition at line 146 of file KisToolKnifeOptionsWidget.cpp.

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

References getWidthForType(), and ui.

◆ readFromConfig()

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

Definition at line 223 of file KisToolKnifeOptionsWidget.cpp.

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

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

◆ setUnit()

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

Definition at line 190 of file KisToolKnifeOptionsWidget.cpp.

190 {
191 if (ui->unitsCombobox->currentData() != unit) {
192 int index = ui->unitsCombobox->findData(unit);
193 if (index != -1) {
194 ui->unitsCombobox->setCurrentIndex(index);
195 }
196 }
197
198 KoUnit unitBefore = KoUnit::fromSymbol(ui->thickGapWidth->suffix().trimmed());
199 bool success;
200 KoUnit unitNow = KoUnit::fromSymbol(unit.trimmed(), &success);
201
202 if (!success || unit.trimmed() == "" || unitNow.type() == unitBefore.type()) {
203 return;
204 }
205
206 ui->thickGapWidth->setSuffix(" " + unitNow.symbol());
207 ui->thinGapWidth->setSuffix(" " + unitNow.symbol());
208 ui->customGapWidth->setSuffix(" " + unitNow.symbol());
209
210 ui->thickGapWidth->setValue(KoUnit::convertFromUnitToUnit(ui->thickGapWidth->value(), unitBefore, unitNow, resolution));
211 ui->thinGapWidth->setValue(KoUnit::convertFromUnitToUnit(ui->thinGapWidth->value(), unitBefore, unitNow, resolution));
212 ui->customGapWidth->setValue(KoUnit::convertFromUnitToUnit(ui->customGapWidth->value(), unitBefore, unitNow, resolution));
213
214 }
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 111 of file KisToolKnifeOptionsWidget.cpp.

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

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

◆ widthTypeFromString()

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

Definition at line 73 of file KisToolKnifeOptionsWidget.cpp.

73 {
74 if (type == "thick") {
76 } else if (type == "thin") {
78 } else if (type == "special") {
80 } else if (type == "automatic") {
82 } else {
83 // default
85 }
86 }

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

◆ widthTypeToString()

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

Definition at line 88 of file KisToolKnifeOptionsWidget.cpp.

88 {
89 switch(type) {
91 return "thick";
92 break;
94 return "thin";
95 break;
97 return "special";
98 break;
100 return "automatic";
101 break;
102 default:
104 }
106 return "thick";
107 }
#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 253 of file KisToolKnifeOptionsWidget.cpp.

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

36{nullptr};

◆ buttonModeMoveGutterEndPoint

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

Definition at line 38 of file KisToolKnifeOptionsWidget.cpp.

38{nullptr};

◆ buttonModeRemoveGutter

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

Definition at line 37 of file KisToolKnifeOptionsWidget.cpp.

37{nullptr};

◆ resolution

qreal KisToolKnifeOptionsWidget::Private::resolution {1.0}

Definition at line 39 of file KisToolKnifeOptionsWidget.cpp.

39{1.0};

◆ toolId

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

Definition at line 41 of file KisToolKnifeOptionsWidget.cpp.

41{""};

◆ ui

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

Definition at line 35 of file KisToolKnifeOptionsWidget.cpp.

35{nullptr};

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