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);
75 if (currentTool->isPropertyEnabled(WIDTH))
79 if (currentTool->isPropertyEnabled(FEATHER))
81 setPenFeather(p.feather);
83 setUseFeather(p.useFeather);
84 setPressure(p.pressure);
85 setPenInvisibility(p.invisibility);
86 setPreserveAlpha(p.preserveAlpha);
87 setVectorMergeEnabled(p.vectorMergeEnabled);
89 setStabilizerLevel(p.stabilizerLevel);
90 setFillContour(p.useFillContour);
91 setShowSelectionInfo(p.showSelectionInfo);
92 setClosedPath(p.closedPolylinePath);
95void ToolOptionWidget::createUI()
98void ToolOptionWidget::makeConnectionToEditor(
Editor* editor)
100 auto toolManager = editor->tools();
108 connect(ui->sizeSlider, &SpinSlider::valueChanged, toolManager, &ToolManager::setWidth);
109 connect(ui->featherSlider, &SpinSlider::valueChanged, toolManager, &ToolManager::setFeather);
112 connect(ui->brushSpinBox, spinboxValueChanged, toolManager, &ToolManager::setWidth);
113 clearFocusOnFinished(ui->brushSpinBox);
114 connect(ui->featherSpinBox, spinboxValueChanged, toolManager, &ToolManager::setFeather);
115 clearFocusOnFinished(ui->featherSpinBox);
128 connect(toolManager, &ToolManager::toolChanged,
this, &ToolOptionWidget::onToolChanged);
129 connect(toolManager, &ToolManager::toolPropertyChanged,
this, &ToolOptionWidget::onToolPropertyChanged);
132void ToolOptionWidget::onToolPropertyChanged(ToolType, ToolPropertyType ePropertyType)
134 const Properties& p = editor()->tools()->currentTool()->properties;
136 switch (ePropertyType)
138 case WIDTH: setPenWidth(p.width);
break;
139 case FEATHER: setPenFeather(p.feather);
break;
140 case USEFEATHER: setUseFeather(p.useFeather);
break;
141 case PRESSURE: setPressure(p.pressure);
break;
142 case INVISIBILITY: setPenInvisibility(p.invisibility);
break;
143 case PRESERVEALPHA: setPreserveAlpha(p.preserveAlpha);
break;
144 case VECTORMERGE: setVectorMergeEnabled(p.vectorMergeEnabled);
break;
145 case ANTI_ALIASING: setAA(p.useAA);
break;
146 case STABILIZATION: setStabilizerLevel(p.stabilizerLevel);
break;
147 case FILLCONTOUR: setFillContour(p.useFillContour);
break;
148 case SHOWSELECTIONINFO: setShowSelectionInfo(p.showSelectionInfo);
break;
149 case BEZIER: setBezier(p.bezier_state);
break;
150 case CLOSEDPATH: setClosedPath(p.closedPolylinePath);
break;
151 case CAMERAPATH: {
break; }
152 case TOLERANCE:
break;
153 case USETOLERANCE:
break;
154 case BUCKETFILLEXPAND:
break;
155 case USEBUCKETFILLEXPAND:
break;
156 case BUCKETFILLLAYERREFERENCEMODE:
break;
157 case FILL_MODE:
break;
164void ToolOptionWidget::setVisibility(
BaseTool* tool)
166 Q_ASSERT(mBucketOptionsWidget);
167 Q_ASSERT(mCameraOptionsWidget);
171 if (tool->type() == BUCKET)
176 else if (tool->type() == CAMERA)
186 ui->sizeSlider->setVisible(tool->isPropertyEnabled(WIDTH));
187 ui->brushSpinBox->setVisible(tool->isPropertyEnabled(WIDTH));
188 ui->featherSlider->setVisible(tool->isPropertyEnabled(FEATHER));
189 ui->featherSpinBox->setVisible(tool->isPropertyEnabled(FEATHER));
190 ui->useFeatherBox->setVisible(tool->isPropertyEnabled(USEFEATHER));
191 ui->useBezierBox->setVisible(tool->isPropertyEnabled(BEZIER));
192 ui->useClosedPathBox->setVisible(tool->isPropertyEnabled(CLOSEDPATH));
193 ui->usePressureBox->setVisible(tool->isPropertyEnabled(PRESSURE));
194 ui->makeInvisibleBox->setVisible(tool->isPropertyEnabled(INVISIBILITY));
195 ui->preserveAlphaBox->setVisible(tool->isPropertyEnabled(PRESERVEALPHA));
196 ui->useAABox->setVisible(tool->isPropertyEnabled(ANTI_ALIASING));
197 ui->stabilizerLabel->setVisible(tool->isPropertyEnabled(STABILIZATION));
198 ui->inpolLevelsCombo->setVisible(tool->isPropertyEnabled(STABILIZATION));
199 ui->fillContourBox->setVisible(tool->isPropertyEnabled(FILLCONTOUR));
200 ui->showInfoBox->setVisible(tool->isPropertyEnabled(SHOWSELECTIONINFO));
202 auto currentLayerType = editor()->layers()->currentLayer()->type();
203 auto propertyType = editor()->tools()->currentTool()->type();
205 if (currentLayerType == Layer::VECTOR)
207 switch (propertyType)
210 ui->sizeSlider->setVisible(
false);
211 ui->brushSpinBox->setVisible(
false);
212 ui->usePressureBox->setVisible(
false);
213 ui->featherSlider->setVisible(
false);
214 ui->featherSpinBox->setVisible(
false);
215 ui->useFeatherBox->setVisible(
false);
218 ui->sizeSlider->setVisible(
false);
219 ui->brushSpinBox->setVisible(
false);
220 ui->usePressureBox->setVisible(
false);
223 ui->sizeSlider->setLabel(
tr(
"Width"));
224 ui->useAABox->setVisible(
false);
230 switch (propertyType)
233 ui->fillContourBox->setVisible(
false);
236 ui->brushSpinBox->setVisible(
false);
237 ui->sizeSlider->setVisible(
false);
241 ui->sizeSlider->setVisible(
false);
242 ui->brushSpinBox->setVisible(
false);
243 ui->usePressureBox->setVisible(
false);
244 ui->featherSlider->setVisible(
false);
245 ui->featherSpinBox->setVisible(
false);
246 ui->useFeatherBox->setVisible(
false);
249 ui->makeInvisibleBox->setVisible(
false);
255void ToolOptionWidget::onToolChanged(ToolType)
260void ToolOptionWidget::setPenWidth(qreal width)
263 ui->sizeSlider->setEnabled(
true);
264 ui->sizeSlider->setValue(
width);
267 ui->brushSpinBox->setEnabled(
true);
268 ui->brushSpinBox->setValue(
width);
271void ToolOptionWidget::setPenFeather(qreal featherValue)
274 ui->featherSlider->setEnabled(
true);
275 ui->featherSlider->setValue(featherValue);
278 ui->featherSpinBox->setEnabled(
true);
279 ui->featherSpinBox->setValue(featherValue);
282void ToolOptionWidget::setUseFeather(
bool useFeather)
285 ui->useFeatherBox->setEnabled(
true);
286 ui->useFeatherBox->setChecked(useFeather);
289void ToolOptionWidget::setPenInvisibility(
int x)
292 ui->makeInvisibleBox->setEnabled(
true);
293 ui->makeInvisibleBox->setChecked(
x > 0);
296void ToolOptionWidget::setPressure(
int x)
299 ui->usePressureBox->setEnabled(
true);
300 ui->usePressureBox->setChecked(
x > 0);
303void ToolOptionWidget::setPreserveAlpha(
int x)
306 ui->preserveAlphaBox->setEnabled(
true);
307 ui->preserveAlphaBox->setChecked(
x > 0);
310void ToolOptionWidget::setVectorMergeEnabled(
int x)
313 ui->vectorMergeBox->setEnabled(
true);
314 ui->vectorMergeBox->setChecked(
x > 0);
317void ToolOptionWidget::setAA(
int x)
320 ui->useAABox->setEnabled(
true);
321 ui->useAABox->setVisible(
false);
323 auto layerType = editor()->layers()->currentLayer()->type();
325 if (layerType == Layer::BITMAP)
329 ui->useAABox->setEnabled(
false);
330 ui->useAABox->setVisible(
false);
334 ui->useAABox->setVisible(
true);
336 ui->useAABox->setChecked(
x > 0);
340void ToolOptionWidget::setStabilizerLevel(
int x)
342 ui->inpolLevelsCombo->setCurrentIndex(qBound(0,
x, ui->inpolLevelsCombo->count() - 1));
345void ToolOptionWidget::setFillContour(
int useFill)
348 ui->fillContourBox->setEnabled(
true);
349 ui->fillContourBox->setChecked(useFill > 0);
352void ToolOptionWidget::setBezier(
bool useBezier)
355 ui->useBezierBox->setChecked(useBezier);
358void ToolOptionWidget::setClosedPath(
bool useClosedPath)
361 ui->useClosedPathBox->setChecked(useClosedPath);
364void ToolOptionWidget::setShowSelectionInfo(
bool showSelectionInfo)
367 ui->showInfoBox->setChecked(showSelectionInfo);
370void ToolOptionWidget::disableAllOptions()
372 ui->sizeSlider->hide();
373 ui->brushSpinBox->hide();
374 ui->featherSlider->hide();
375 ui->featherSpinBox->hide();
376 ui->useFeatherBox->hide();
377 ui->useBezierBox->hide();
378 ui->useClosedPathBox->hide();
379 ui->usePressureBox->hide();
380 ui->makeInvisibleBox->hide();
381 ui->preserveAlphaBox->hide();
382 ui->vectorMergeBox->hide();
383 ui->useAABox->hide();
384 ui->inpolLevelsCombo->hide();
385 ui->fillContourBox->hide();
386 ui->showInfoBox->hide();
387 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)