Commit 912243d6 authored by Timothée Giet's avatar Timothée Giet

Add an option for separate eraser brush size

Add an option in preset editor widget to enable eraser mode separate brush size.
Option is called "Eraser switch size". It is disabled by default as it makes lot of people confused for different reasons.
The setting is saved in user config so it's easy to keep it activated for those who want it.
parent 17ca4ce0
......@@ -241,6 +241,22 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="eraserBrushSizeCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Eraser switch size</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
......@@ -300,6 +300,15 @@ void KisConfig::setUseDirtyPresets(bool value)
{
m_cfg.writeEntry("useDirtyPresets",value);
}
bool KisConfig::useEraserBrushSize() const
{
return m_cfg.readEntry("useEraserBrushSize",false);
}
void KisConfig::setUseEraserBrushSize(bool value)
{
m_cfg.writeEntry("useEraserBrushSize",value);
}
const KoColorProfile *KisConfig::getScreenProfile(int screen)
{
......
......@@ -409,7 +409,9 @@ public:
bool useDirtyPresets() const;
void setUseDirtyPresets(bool value);
bool useEraserBrushSize() const;
void setUseEraserBrushSize(bool value);
template<class T>
void writeEntry(const QString& name, const T& value) {
m_cfg.writeEntry(name, value);
......
......@@ -91,6 +91,7 @@ KisPaintopBox::KisPaintopBox(KisView2 *view, QWidget *parent, const char *name)
, m_presetsEnabled(true)
, m_blockUpdate(false)
, m_dirtyPresetsEnabled(false)
, m_eraserBrushSizeEnabled(false)
{
Q_ASSERT(view != 0);
......@@ -99,6 +100,7 @@ KisPaintopBox::KisPaintopBox(KisView2 *view, QWidget *parent, const char *name)
setObjectName(name);
KisConfig cfg;
m_dirtyPresetsEnabled = cfg.useDirtyPresets();
m_eraserBrushSizeEnabled = cfg.useEraserBrushSize();
KAcceleratorManager::setNoAccel(this);
......@@ -303,6 +305,7 @@ KisPaintopBox::KisPaintopBox(KisView2 *view, QWidget *parent, const char *name)
connect(m_presetsPopup , SIGNAL(signalResourceSelected(KoResource*)), SLOT(resourceSelected(KoResource*)));
connect(m_presetsPopup , SIGNAL(reloadPresetClicked()) , SLOT(slotReloadPreset()));
connect(m_presetsPopup , SIGNAL(dirtyPresetToggled(bool)) , SLOT(slotDirtyPresetToggled(bool)));
connect(m_presetsPopup , SIGNAL(eraserBrushSizeToggled(bool)) , SLOT(slotEraserBrushSizeToggled(bool)));
connect(m_presetsChooserPopup, SIGNAL(resourceSelected(KoResource*)) , SLOT(resourceSelected(KoResource*)));
connect(m_resourceProvider , SIGNAL(sigNodeChanged(const KisNodeSP)) , SLOT(slotNodeChanged(const KisNodeSP)));
......@@ -741,19 +744,34 @@ void KisPaintopBox::slotToggleEraseMode(bool checked)
if (checked)
{
updateCompositeOp(COMPOSITE_ERASE);
// remember brush size. set the eraser size to the normal brush size if not set
normalBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
if (!eraserBrushSize)
eraserBrushSize = normalBrushSize;
//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
normalBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
if (!eraserBrushSize)
eraserBrushSize = normalBrushSize;
}
else
{
normalBrushSize = eraserBrushSize;
eraserBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
}
}
else
{
updateCompositeOp(m_prevCompositeOpID);
if (m_eraserBrushSizeEnabled==true)
{
// save eraser brush size as eraserBrushSize (they are all the same, so just grab the first one)
eraserBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
}
else
{
normalBrushSize = m_sliderChooser[0]->getWidget<KisDoubleSliderSpinBox>("size")->value();
}
}
......@@ -1055,3 +1073,9 @@ void KisPaintopBox::slotDirtyPresetToggled(bool value)
cfg.setUseDirtyPresets(m_dirtyPresetsEnabled);
}
void KisPaintopBox::slotEraserBrushSizeToggled(bool value)
{
m_eraserBrushSizeEnabled = value;
KisConfig cfg;
cfg.setUseEraserBrushSize(m_eraserBrushSizeEnabled);
}
......@@ -155,7 +155,7 @@ private slots:
void slotSaveLockedOptionToPreset(KisPropertiesConfiguration* p);
void slotDropLockedOption(KisPropertiesConfiguration* p);
void slotDirtyPresetToggled(bool);
void slotEraserBrushSizeToggled(bool);
private:
......@@ -225,6 +225,7 @@ private:
bool m_presetsEnabled;
bool m_blockUpdate;
bool m_dirtyPresetsEnabled;
bool m_eraserBrushSizeEnabled;
};
......
......@@ -120,7 +120,10 @@ KisPaintOpPresetsPopup::KisPaintOpPresetsPopup(KisCanvasResourceProvider * resou
connect(m_d->uiWdgPaintOpPresetSettings.dirtyPresetCheckBox, SIGNAL(toggled(bool)),
this, SIGNAL(dirtyPresetToggled(bool)));
connect(m_d->uiWdgPaintOpPresetSettings.eraserBrushSizeCheckBox, SIGNAL(toggled(bool)),
this, SIGNAL(eraserBrushSizeToggled(bool)));
connect(m_d->uiWdgPaintOpPresetSettings.bnDefaultPreset, SIGNAL(clicked()),
m_d->uiWdgPaintOpPresetSettings.txtPreset, SLOT(clear()));
......@@ -154,6 +157,7 @@ KisPaintOpPresetsPopup::KisPaintOpPresetsPopup(KisCanvasResourceProvider * resou
m_d->uiWdgPaintOpPresetSettings.dirtyPresetCheckBox->setChecked(cfg.useDirtyPresets());
slotDirtyPresetToggled(cfg.useDirtyPresets());
m_d->uiWdgPaintOpPresetSettings.reload->setEnabled(false);
m_d->uiWdgPaintOpPresetSettings.eraserBrushSizeCheckBox->setChecked(cfg.useEraserBrushSize());
}
......
......@@ -92,7 +92,7 @@ public slots:
void showScratchPad();
void resourceSelected(KoResource* resource);
void slotDirtyPresetToggled(bool value);
signals:
void savePresetClicked();
void defaultPresetClicked();
......@@ -101,7 +101,8 @@ signals:
void signalResourceSelected(KoResource* resource);
void reloadPresetClicked();
void dirtyPresetToggled(bool value);
void eraserBrushSizeToggled(bool value);
void sizeChanged();
private slots:
......
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