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);
60 ui->sizeSlider->init(
tr(
"Width"), SpinSlider::EXPONENT, SpinSlider::INTEGER, StrokeTool::WIDTH_MIN, StrokeTool::WIDTH_MAX);
61 ui->sizeSlider->setValue(settings.value(
"brushWidth",
"3").toDouble());
62 ui->brushSpinBox->setValue(settings.value(
"brushWidth",
"3").toDouble());
64 ui->featherSlider->init(
tr(
"Feather"), SpinSlider::LOG, SpinSlider::INTEGER, StrokeTool::FEATHER_MIN, StrokeTool::FEATHER_MAX);
65 ui->featherSlider->setValue(settings.value(
"brushFeather",
"5").toDouble());
66 ui->featherSpinBox->setValue(settings.value(
"brushFeather",
"5").toDouble());
69void ToolOptionWidget::updateUI()
71 BaseTool* currentTool = editor()->tools()->currentTool();
72 Q_ASSERT(currentTool);
74 setVisibility(currentTool);
78 if (currentTool->isPropertyEnabled(WIDTH))
82 if (currentTool->isPropertyEnabled(FEATHER))
84 setPenFeather(p.feather);
86 setUseFeather(p.useFeather);
87 setPressure(p.pressure);
88 setPenInvisibility(p.invisibility);
89 setPreserveAlpha(p.preserveAlpha);
90 setVectorMergeEnabled(p.vectorMergeEnabled);
92 setStabilizerLevel(p.stabilizerLevel);
93 setFillContour(p.useFillContour);
94 setShowSelectionInfo(p.showSelectionInfo);
95 setClosedPath(p.closedPolylinePath);
98void ToolOptionWidget::createUI()
101void ToolOptionWidget::makeConnectionToEditor(
Editor* editor)
103 auto toolManager = editor->tools();
111 connect(ui->sizeSlider, &SpinSlider::valueChanged, toolManager, &ToolManager::setWidth);
112 connect(ui->featherSlider, &SpinSlider::valueChanged, toolManager, &ToolManager::setFeather);
115 connect(ui->brushSpinBox, spinboxValueChanged, toolManager, &ToolManager::setWidth);
116 clearFocusOnFinished(ui->brushSpinBox);
117 connect(ui->featherSpinBox, spinboxValueChanged, toolManager, &ToolManager::setFeather);
118 clearFocusOnFinished(ui->featherSpinBox);
131 connect(toolManager, &ToolManager::toolChanged,
this, &ToolOptionWidget::onToolChanged);
132 connect(toolManager, &ToolManager::toolPropertyChanged,
this, &ToolOptionWidget::onToolPropertyChanged);
135void ToolOptionWidget::onToolPropertyChanged(ToolType, ToolPropertyType ePropertyType)
137 const Properties& p = editor()->tools()->currentTool()->properties;
139 switch (ePropertyType)
141 case WIDTH: setPenWidth(p.width);
break;
142 case FEATHER: setPenFeather(p.feather);
break;
143 case USEFEATHER: setUseFeather(p.useFeather);
break;
144 case PRESSURE: setPressure(p.pressure);
break;
145 case INVISIBILITY: setPenInvisibility(p.invisibility);
break;
146 case PRESERVEALPHA: setPreserveAlpha(p.preserveAlpha);
break;
147 case VECTORMERGE: setVectorMergeEnabled(p.vectorMergeEnabled);
break;
148 case ANTI_ALIASING: setAA(p.useAA);
break;
149 case STABILIZATION: setStabilizerLevel(p.stabilizerLevel);
break;
150 case FILLCONTOUR: setFillContour(p.useFillContour);
break;
151 case SHOWSELECTIONINFO: setShowSelectionInfo(p.showSelectionInfo);
break;
152 case BEZIER: setBezier(p.bezier_state);
break;
153 case CLOSEDPATH: setClosedPath(p.closedPolylinePath);
break;
154 case CAMERAPATH: {
break; }
155 case TOLERANCE:
break;
156 case USETOLERANCE:
break;
157 case BUCKETFILLEXPAND:
break;
158 case USEBUCKETFILLEXPAND:
break;
159 case BUCKETFILLLAYERREFERENCEMODE:
break;
160 case FILL_MODE:
break;
167void ToolOptionWidget::setVisibility(
BaseTool* tool)
169 Q_ASSERT(mBucketOptionsWidget);
170 Q_ASSERT(mCameraOptionsWidget);
174 if (tool->type() == BUCKET)
179 else if (tool->type() == CAMERA)
189 ui->sizeSlider->setVisible(tool->isPropertyEnabled(WIDTH));
190 ui->brushSpinBox->setVisible(tool->isPropertyEnabled(WIDTH));
191 ui->featherSlider->setVisible(tool->isPropertyEnabled(FEATHER));
192 ui->featherSpinBox->setVisible(tool->isPropertyEnabled(FEATHER));
193 ui->useFeatherBox->setVisible(tool->isPropertyEnabled(USEFEATHER));
194 ui->useBezierBox->setVisible(tool->isPropertyEnabled(BEZIER));
195 ui->useClosedPathBox->setVisible(tool->isPropertyEnabled(CLOSEDPATH));
196 ui->usePressureBox->setVisible(tool->isPropertyEnabled(PRESSURE));
197 ui->makeInvisibleBox->setVisible(tool->isPropertyEnabled(INVISIBILITY));
198 ui->preserveAlphaBox->setVisible(tool->isPropertyEnabled(PRESERVEALPHA));
199 ui->useAABox->setVisible(tool->isPropertyEnabled(ANTI_ALIASING));
200 ui->stabilizerLabel->setVisible(tool->isPropertyEnabled(STABILIZATION));
201 ui->inpolLevelsCombo->setVisible(tool->isPropertyEnabled(STABILIZATION));
202 ui->fillContourBox->setVisible(tool->isPropertyEnabled(FILLCONTOUR));
203 ui->showInfoBox->setVisible(tool->isPropertyEnabled(SHOWSELECTIONINFO));
205 auto currentLayerType = editor()->layers()->currentLayer()->type();
206 auto propertyType = editor()->tools()->currentTool()->type();
208 if (currentLayerType == Layer::VECTOR)
210 switch (propertyType)
213 ui->sizeSlider->setVisible(
false);
214 ui->brushSpinBox->setVisible(
false);
215 ui->usePressureBox->setVisible(
false);
216 ui->featherSlider->setVisible(
false);
217 ui->featherSpinBox->setVisible(
false);
218 ui->useFeatherBox->setVisible(
false);
221 ui->sizeSlider->setVisible(
false);
222 ui->brushSpinBox->setVisible(
false);
223 ui->usePressureBox->setVisible(
false);
226 ui->sizeSlider->setLabel(
tr(
"Width"));
227 ui->useAABox->setVisible(
false);
233 switch (propertyType)
236 ui->fillContourBox->setVisible(
false);
239 ui->brushSpinBox->setVisible(
false);
240 ui->sizeSlider->setVisible(
false);
244 ui->sizeSlider->setVisible(
false);
245 ui->brushSpinBox->setVisible(
false);
246 ui->usePressureBox->setVisible(
false);
247 ui->featherSlider->setVisible(
false);
248 ui->featherSpinBox->setVisible(
false);
249 ui->useFeatherBox->setVisible(
false);
252 ui->makeInvisibleBox->setVisible(
false);
258void ToolOptionWidget::onToolChanged(ToolType)
263void ToolOptionWidget::setPenWidth(qreal width)
266 ui->sizeSlider->setEnabled(
true);
267 ui->sizeSlider->setValue(
width);
270 ui->brushSpinBox->setEnabled(
true);
271 ui->brushSpinBox->setValue(
width);
274void ToolOptionWidget::setPenFeather(qreal featherValue)
277 ui->featherSlider->setEnabled(
true);
278 ui->featherSlider->setValue(featherValue);
281 ui->featherSpinBox->setEnabled(
true);
282 ui->featherSpinBox->setValue(featherValue);
285void ToolOptionWidget::setUseFeather(
bool useFeather)
288 ui->useFeatherBox->setEnabled(
true);
289 ui->useFeatherBox->setChecked(useFeather);
292void ToolOptionWidget::setPenInvisibility(
int x)
295 ui->makeInvisibleBox->setEnabled(
true);
296 ui->makeInvisibleBox->setChecked(
x > 0);
299void ToolOptionWidget::setPressure(
int x)
302 ui->usePressureBox->setEnabled(
true);
303 ui->usePressureBox->setChecked(
x > 0);
306void ToolOptionWidget::setPreserveAlpha(
int x)
309 ui->preserveAlphaBox->setEnabled(
true);
310 ui->preserveAlphaBox->setChecked(
x > 0);
313void ToolOptionWidget::setVectorMergeEnabled(
int x)
316 ui->vectorMergeBox->setEnabled(
true);
317 ui->vectorMergeBox->setChecked(
x > 0);
320void ToolOptionWidget::setAA(
int x)
323 ui->useAABox->setEnabled(
true);
324 ui->useAABox->setVisible(
false);
326 auto layerType = editor()->layers()->currentLayer()->type();
328 if (layerType == Layer::BITMAP)
332 ui->useAABox->setEnabled(
false);
333 ui->useAABox->setVisible(
false);
337 ui->useAABox->setVisible(
true);
339 ui->useAABox->setChecked(
x > 0);
343void ToolOptionWidget::setStabilizerLevel(
int x)
345 ui->inpolLevelsCombo->setCurrentIndex(qBound(0,
x, ui->inpolLevelsCombo->count() - 1));
348void ToolOptionWidget::setFillContour(
int useFill)
351 ui->fillContourBox->setEnabled(
true);
352 ui->fillContourBox->setChecked(useFill > 0);
355void ToolOptionWidget::setBezier(
bool useBezier)
358 ui->useBezierBox->setChecked(useBezier);
361void ToolOptionWidget::setClosedPath(
bool useClosedPath)
364 ui->useClosedPathBox->setChecked(useClosedPath);
367void ToolOptionWidget::setShowSelectionInfo(
bool showSelectionInfo)
370 ui->showInfoBox->setChecked(showSelectionInfo);
373void ToolOptionWidget::disableAllOptions()
375 ui->sizeSlider->hide();
376 ui->brushSpinBox->hide();
377 ui->featherSlider->hide();
378 ui->featherSpinBox->hide();
379 ui->useFeatherBox->hide();
380 ui->useBezierBox->hide();
381 ui->useClosedPathBox->hide();
382 ui->usePressureBox->hide();
383 ui->makeInvisibleBox->hide();
384 ui->preserveAlphaBox->hide();
385 ui->vectorMergeBox->hide();
386 ui->useAABox->hide();
387 ui->inpolLevelsCombo->hide();
388 ui->fillContourBox->hide();
389 ui->showInfoBox->hide();
390 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)