Commit 667c944a authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix switching presets in erase mode + "save temporary tweaks" option

We should keep the saved eraser and brush size values in the preset itself,
not in an ad-hoc variable

Ref T1835
parent 5206690c
......@@ -208,6 +208,29 @@ QString KisPaintOpSettings::effectivePaintOpCompositeOp() const
return !eraserMode() ? paintOpCompositeOp() : COMPOSITE_ERASE;
}
qreal KisPaintOpSettings::savedEraserSize() const
{
return getDouble("SavedEraserSize", 0.0);
}
void KisPaintOpSettings::setSavedEraserSize(qreal value)
{
setProperty("SavedEraserSize", value);
setPropertyNotSaved("SavedEraserSize");
}
qreal KisPaintOpSettings::savedBrushSize() const
{
return getDouble("SavedBrushSize", 0.0);
}
void KisPaintOpSettings::setSavedBrushSize(qreal value)
{
setProperty("SavedBrushSize", value);
setPropertyNotSaved("SavedBrushSize");
}
QString KisPaintOpSettings::modelName() const
{
return d->modelName;
......
......@@ -196,13 +196,17 @@ public:
void setEraserMode(bool value);
bool eraserMode() const;
qreal savedEraserSize() const;
void setSavedEraserSize(qreal value);
qreal savedBrushSize() const;
void setSavedBrushSize(qreal value);
QString effectivePaintOpCompositeOp() const;
void setPreset(KisPaintOpPresetWSP preset);
KisPaintOpPresetWSP preset() const;
/**
* @return filename of the 3D brush model, empty if no brush is set
*/
......
......@@ -139,8 +139,6 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
m_eraseAction = m_viewManager->actionManager()->createAction("erase_action");
m_eraseModeButton->setDefaultAction(m_eraseAction);
m_eraserBrushSize = 0; // brush size changed when using erase mode
m_reloadButton = new QToolButton(this);
m_reloadButton->setFixedSize(iconsize, iconsize);
......@@ -801,45 +799,34 @@ void KisPaintopBox::slotColorSpaceChanged(const KoColorSpace* colorSpace)
void KisPaintopBox::slotToggleEraseMode(bool checked)
{
const bool oldEraserMode = m_resourceProvider->eraserMode();
m_resourceProvider->setEraserMode(checked);
m_optionWidget->setConfiguration(m_resourceProvider->currentPreset()->settings().data());
if (checked)
{
//add an option to enable eraser brush size
if (m_eraserBrushSizeEnabled==true)
{
// remember brush size. set the eraser size to the normal brush size if not set
m_normalBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
if (qFuzzyIsNull(m_eraserBrushSize))
m_eraserBrushSize = m_normalBrushSize;
}
else
{
m_normalBrushSize = m_eraserBrushSize;
m_eraserBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
}
}
KisPaintOpSettingsSP settings = m_resourceProvider->currentPreset()->settings();
m_optionWidget->setConfiguration(settings.data());
else
{
if (m_eraserBrushSizeEnabled==true)
{
// save eraser brush size as m_eraserBrushSize (they are all the same, so just grab the first one)
m_eraserBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
}
else
{
m_normalBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
}
}
if (oldEraserMode != checked && m_eraserBrushSizeEnabled) {
const qreal currentSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
// remember brush size. set the eraser size to the normal brush size if not set
if (checked) {
settings->setSavedBrushSize(currentSize);
if (qFuzzyIsNull(settings->savedEraserSize())) {
settings->setSavedEraserSize(currentSize);
}
} else {
settings->setSavedEraserSize(currentSize);
if (qFuzzyIsNull(settings->savedBrushSize())) {
settings->setSavedBrushSize(currentSize);
}
}
//update value in UI (this is the main place the value is 'stored' in memory)
qreal updateSize = checked ? m_eraserBrushSize : m_normalBrushSize;
m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->setValue(updateSize);
m_sliderChooser[1]->getWidget<KisDoubleSliderSpinBox>("size")->setValue(updateSize);
m_sliderChooser[2]->getWidget<KisDoubleSliderSpinBox>("size")->setValue(updateSize);
//update value in UI (this is the main place the value is 'stored' in memory)
qreal updateSize = checked ? settings->savedEraserSize() : settings->savedBrushSize();
m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->setValue(updateSize);
m_sliderChooser[1]->getWidget<KisDoubleSliderSpinBox>("size")->setValue(updateSize);
m_sliderChooser[2]->getWidget<KisDoubleSliderSpinBox>("size")->setValue(updateSize);
}
}
void KisPaintopBox::slotSetCompositeMode(int index)
......
......@@ -188,9 +188,6 @@ private:
QString m_currCompositeOpID;
KisNodeWSP m_previousNode;
qreal m_normalBrushSize; // when toggling between eraser mode
qreal m_eraserBrushSize;
KisAction* m_hMirrorAction;
KisAction* m_vMirrorAction;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment