17#include "tooloptionwidget.h"
18#include "ui_tooloptions.h"
23#include "cameraoptionswidget.h"
24#include "bucketoptionswidget.h"
25#include "spinslider.h"
29#include "layermanager.h"
30#include "stroketool.h"
31#include "toolmanager.h"
35 setWindowTitle(tr(
"Options",
"Window title of tool option panel like pen width, feather etc.."));
38 setWidget(innerWidget);
39 ui =
new Ui::ToolOptions;
40 ui->setupUi(innerWidget);
43ToolOptionWidget::~ToolOptionWidget()
48void ToolOptionWidget::initUI()
52 ui->horizontalLayout_2->addWidget(mBucketOptionsWidget);
53 ui->horizontalLayout_2->addWidget(mCameraOptionsWidget);
57 ui->sizeSlider->init(
tr(
"Width"), SpinSlider::EXPONENT, SpinSlider::INTEGER, StrokeTool::WIDTH_MIN, StrokeTool::WIDTH_MAX);
58 ui->sizeSlider->setValue(settings.value(
"brushWidth",
"3").toDouble());
59 ui->brushSpinBox->setValue(settings.value(
"brushWidth",
"3").toDouble());
61 ui->featherSlider->init(
tr(
"Feather"), SpinSlider::LOG, SpinSlider::INTEGER, StrokeTool::FEATHER_MIN, StrokeTool::FEATHER_MAX);
62 ui->featherSlider->setValue(settings.value(
"brushFeather",
"5").toDouble());
63 ui->featherSpinBox->setValue(settings.value(
"brushFeather",
"5").toDouble());
66void ToolOptionWidget::updateUI()
68 BaseTool* currentTool = editor()->tools()->currentTool();
69 Q_ASSERT(currentTool);
71 setVisibility(currentTool);
76 setPenFeather(p.feather);
77 setUseFeather(p.useFeather);
78 setPressure(p.pressure);
79 setPenInvisibility(p.invisibility);
80 setPreserveAlpha(p.preserveAlpha);
81 setVectorMergeEnabled(p.vectorMergeEnabled);
83 setStabilizerLevel(p.stabilizerLevel);
84 setFillContour(p.useFillContour);
85 setShowSelectionInfo(p.showSelectionInfo);
88void ToolOptionWidget::createUI()
91void ToolOptionWidget::makeConnectionToEditor(
Editor* editor)
93 auto toolManager = editor->tools();
100 connect(ui->sizeSlider, &SpinSlider::valueChanged, toolManager, &ToolManager::setWidth);
101 connect(ui->featherSlider, &SpinSlider::valueChanged, toolManager, &ToolManager::setFeather);
104 connect(ui->brushSpinBox, spinboxValueChanged, toolManager, &ToolManager::setWidth);
105 clearFocusOnFinished(ui->brushSpinBox);
106 connect(ui->featherSpinBox, spinboxValueChanged, toolManager, &ToolManager::setFeather);
107 clearFocusOnFinished(ui->featherSpinBox);
120 connect(toolManager, &ToolManager::toolChanged,
this, &ToolOptionWidget::onToolChanged);
121 connect(toolManager, &ToolManager::toolPropertyChanged,
this, &ToolOptionWidget::onToolPropertyChanged);
124void ToolOptionWidget::onToolPropertyChanged(ToolType, ToolPropertyType ePropertyType)
126 const Properties& p = editor()->tools()->currentTool()->properties;
128 switch (ePropertyType)
130 case WIDTH: setPenWidth(p.width);
break;
131 case FEATHER: setPenFeather(p.feather);
break;
132 case USEFEATHER: setUseFeather(p.useFeather);
break;
133 case PRESSURE: setPressure(p.pressure);
break;
134 case INVISIBILITY: setPenInvisibility(p.invisibility);
break;
135 case PRESERVEALPHA: setPreserveAlpha(p.preserveAlpha);
break;
136 case VECTORMERGE: setVectorMergeEnabled(p.vectorMergeEnabled);
break;
137 case ANTI_ALIASING: setAA(p.useAA);
break;
138 case STABILIZATION: setStabilizerLevel(p.stabilizerLevel);
break;
139 case FILLCONTOUR: setFillContour(p.useFillContour);
break;
140 case SHOWSELECTIONINFO: setShowSelectionInfo(p.showSelectionInfo);
break;
141 case BEZIER: setBezier(p.bezier_state);
break;
142 case CAMERAPATH: {
break; }
143 case TOLERANCE:
break;
144 case USETOLERANCE:
break;
145 case BUCKETFILLEXPAND:
break;
146 case USEBUCKETFILLEXPAND:
break;
147 case BUCKETFILLLAYERREFERENCEMODE:
break;
148 case FILL_MODE:
break;
155void ToolOptionWidget::setVisibility(
BaseTool* tool)
157 Q_ASSERT(mBucketOptionsWidget);
158 Q_ASSERT(mCameraOptionsWidget);
162 if (tool->type() == BUCKET)
167 else if (tool->type() == CAMERA)
177 ui->sizeSlider->setVisible(tool->isPropertyEnabled(WIDTH));
178 ui->brushSpinBox->setVisible(tool->isPropertyEnabled(WIDTH));
179 ui->featherSlider->setVisible(tool->isPropertyEnabled(FEATHER));
180 ui->featherSpinBox->setVisible(tool->isPropertyEnabled(FEATHER));
181 ui->useFeatherBox->setVisible(tool->isPropertyEnabled(USEFEATHER));
182 ui->useBezierBox->setVisible(tool->isPropertyEnabled(BEZIER));
183 ui->usePressureBox->setVisible(tool->isPropertyEnabled(PRESSURE));
184 ui->makeInvisibleBox->setVisible(tool->isPropertyEnabled(INVISIBILITY));
185 ui->preserveAlphaBox->setVisible(tool->isPropertyEnabled(PRESERVEALPHA));
186 ui->useAABox->setVisible(tool->isPropertyEnabled(ANTI_ALIASING));
187 ui->stabilizerLabel->setVisible(tool->isPropertyEnabled(STABILIZATION));
188 ui->inpolLevelsCombo->setVisible(tool->isPropertyEnabled(STABILIZATION));
189 ui->fillContourBox->setVisible(tool->isPropertyEnabled(FILLCONTOUR));
190 ui->showInfoBox->setVisible(tool->isPropertyEnabled(SHOWSELECTIONINFO));
192 auto currentLayerType = editor()->layers()->currentLayer()->type();
193 auto propertyType = editor()->tools()->currentTool()->type();
195 if (currentLayerType == Layer::VECTOR)
197 switch (propertyType)
200 ui->sizeSlider->setVisible(
false);
201 ui->brushSpinBox->setVisible(
false);
202 ui->usePressureBox->setVisible(
false);
203 ui->featherSlider->setVisible(
false);
204 ui->featherSpinBox->setVisible(
false);
205 ui->useFeatherBox->setVisible(
false);
208 ui->sizeSlider->setVisible(
false);
209 ui->brushSpinBox->setVisible(
false);
210 ui->usePressureBox->setVisible(
false);
213 ui->sizeSlider->setLabel(
tr(
"Width"));
214 ui->useAABox->setVisible(
false);
220 switch (propertyType)
223 ui->fillContourBox->setVisible(
false);
226 ui->brushSpinBox->setVisible(
false);
227 ui->sizeSlider->setVisible(
false);
231 ui->sizeSlider->setVisible(
false);
232 ui->brushSpinBox->setVisible(
false);
233 ui->usePressureBox->setVisible(
false);
234 ui->featherSlider->setVisible(
false);
235 ui->featherSpinBox->setVisible(
false);
236 ui->useFeatherBox->setVisible(
false);
239 ui->makeInvisibleBox->setVisible(
false);
245void ToolOptionWidget::onToolChanged(ToolType)
250void ToolOptionWidget::setPenWidth(qreal width)
253 ui->sizeSlider->setEnabled(
true);
254 ui->sizeSlider->setValue(
width);
257 ui->brushSpinBox->setEnabled(
true);
258 ui->brushSpinBox->setValue(
width);
261void ToolOptionWidget::setPenFeather(qreal featherValue)
264 ui->featherSlider->setEnabled(
true);
265 ui->featherSlider->setValue(featherValue);
268 ui->featherSpinBox->setEnabled(
true);
269 ui->featherSpinBox->setValue(featherValue);
272void ToolOptionWidget::setUseFeather(
bool useFeather)
275 ui->useFeatherBox->setEnabled(
true);
276 ui->useFeatherBox->setChecked(useFeather);
279void ToolOptionWidget::setPenInvisibility(
int x)
282 ui->makeInvisibleBox->setEnabled(
true);
283 ui->makeInvisibleBox->setChecked(
x > 0);
286void ToolOptionWidget::setPressure(
int x)
289 ui->usePressureBox->setEnabled(
true);
290 ui->usePressureBox->setChecked(
x > 0);
293void ToolOptionWidget::setPreserveAlpha(
int x)
296 ui->preserveAlphaBox->setEnabled(
true);
297 ui->preserveAlphaBox->setChecked(
x > 0);
300void ToolOptionWidget::setVectorMergeEnabled(
int x)
303 ui->vectorMergeBox->setEnabled(
true);
304 ui->vectorMergeBox->setChecked(
x > 0);
307void ToolOptionWidget::setAA(
int x)
310 ui->useAABox->setEnabled(
true);
311 ui->useAABox->setVisible(
false);
313 auto layerType = editor()->layers()->currentLayer()->type();
315 if (layerType == Layer::BITMAP)
319 ui->useAABox->setEnabled(
false);
320 ui->useAABox->setVisible(
false);
324 ui->useAABox->setVisible(
true);
326 ui->useAABox->setChecked(
x > 0);
330void ToolOptionWidget::setStabilizerLevel(
int x)
332 ui->inpolLevelsCombo->setCurrentIndex(qBound(0,
x, ui->inpolLevelsCombo->count() - 1));
335void ToolOptionWidget::setFillContour(
int useFill)
338 ui->fillContourBox->setEnabled(
true);
339 ui->fillContourBox->setChecked(useFill > 0);
342void ToolOptionWidget::setBezier(
bool useBezier)
345 ui->useBezierBox->setChecked(useBezier);
348void ToolOptionWidget::setShowSelectionInfo(
bool showSelectionInfo)
351 ui->showInfoBox->setChecked(showSelectionInfo);
354void ToolOptionWidget::disableAllOptions()
356 ui->sizeSlider->hide();
357 ui->brushSpinBox->hide();
358 ui->featherSlider->hide();
359 ui->featherSpinBox->hide();
360 ui->useFeatherBox->hide();
361 ui->useBezierBox->hide();
362 ui->usePressureBox->hide();
363 ui->makeInvisibleBox->hide();
364 ui->preserveAlphaBox->hide();
365 ui->vectorMergeBox->hide();
366 ui->useAABox->hide();
367 ui->inpolLevelsCombo->hide();
368 ui->fillContourBox->hide();
369 ui->showInfoBox->hide();
370 ui->stabilizerLabel->hide();
void activated(int index)
void valueChanged(double d)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString tr(const char *sourceText, const char *disambiguation, int n)