Commit 6bfbc8a3 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fixed the rest of bugs in Dirty Presets

1) Now Save/Reload buttons are enabled/disabled correctly depending
   on the status of the currently selected preset
2) Instead of marking the preset name with pink color now it i sjust typed
   in italic.
3) Fixed random switched between dirty/clean states of the preset
parent 8c929b4f
......@@ -41,7 +41,8 @@ QVariant KisLockedPropertiesProxy::getProperty(const QString &name) const
KisPaintOpSettings* t = dynamic_cast<KisPaintOpSettings*>(temp);
if (t->preset()) {
bool saveDirtyState = t->preset()->isPresetDirty();
// restores the dirty state on returns automagically
KisPaintOpPreset::DirtyStateSaver dirtyStateSaver(t->preset().data());
if (m_lockedProperties->lockedProperties()) {
if (m_lockedProperties->lockedProperties()->hasProperty(name)) {
......@@ -51,7 +52,6 @@ QVariant KisLockedPropertiesProxy::getProperty(const QString &name) const
temp->setProperty(name + "_previous", m_parent->getProperty(name));
}
temp->setProperty(name, m_lockedProperties->lockedProperties()->getProperty(name));
t->preset()->setPresetDirty(saveDirtyState);
return m_lockedProperties->lockedProperties()->getProperty(name);
} else {
if (m_parent->hasProperty(name + "_previous")) {
......@@ -61,8 +61,6 @@ QVariant KisLockedPropertiesProxy::getProperty(const QString &name) const
}
}
}
t->preset()->setPresetDirty(saveDirtyState);
}
return m_parent->getProperty(name);
}
......@@ -72,7 +70,9 @@ void KisLockedPropertiesProxy::setProperty(const QString & name, const QVariant
KisPropertiesConfiguration* temp = const_cast<KisPropertiesConfiguration*>(m_parent);
KisPaintOpSettings* t = dynamic_cast<KisPaintOpSettings*>(temp);
if (t->preset()) {
bool saveDirtyState = t->preset()->isPresetDirty();
// restores the dirty state on returns automagically
KisPaintOpPreset::DirtyStateSaver dirtyStateSaver(t->preset().data());
if (m_lockedProperties->lockedProperties()) {
if (m_lockedProperties->lockedProperties()->hasProperty(name)) {
m_lockedProperties->lockedProperties()->setProperty(name, value);
......@@ -80,7 +80,6 @@ void KisLockedPropertiesProxy::setProperty(const QString & name, const QVariant
if (!m_parent->hasProperty(name + "_previous")) {
t->setProperty(name + "_previous", m_parent->getProperty(name));
}
t->preset()->setPresetDirty(saveDirtyState);
return;
}
}
......
......@@ -113,7 +113,8 @@ void KisPaintOpPreset::setSettings(KisPaintOpSettingsSP settings)
Q_ASSERT(settings);
Q_ASSERT(!settings->getString("paintop", "").isEmpty());
bool saveDirtyPreset = isPresetDirty();
DirtyStateSaver dirtyStateSaver(this);
if (settings) {
m_d->settings = settings->clone();
m_d->settings->setPreset(KisPaintOpPresetWSP(this));
......@@ -121,8 +122,6 @@ void KisPaintOpPreset::setSettings(KisPaintOpSettingsSP settings)
m_d->settings = 0;
m_d->settings->setPreset(0);
}
setPresetDirty(saveDirtyPreset);
setValid(m_d->settings);
}
......
......@@ -82,6 +82,27 @@ public:
bool isPresetDirty() const;
/**
* Never use manual save/restore calls to
* isPresetDirty()/setPresetDirty()! They will lead to
* hard-to-tack-down bugs when the dirty state will not be
* restored on jumps like 'return', 'break' or exception.
*/
class DirtyStateSaver {
public:
DirtyStateSaver(KisPaintOpPreset *preset)
: m_preset(preset), m_isDirty(preset->isPresetDirty())
{
}
~DirtyStateSaver() {
m_preset->setPresetDirty(m_isDirty);
}
private:
KisPaintOpPreset *m_preset;
bool m_isDirty;
};
protected:
......
......@@ -41,11 +41,34 @@
#include<kis_types.h>
struct KisPaintOpSettings::Private {
Private() : disableDirtyNotifications(false) {}
KisNodeWSP node;
QPointer<KisPaintOpSettingsWidget> settingsWidget;
QString modelName;
KisPaintOpPresetWSP preset;
bool disableDirtyNotifications;
class DirtyNotificationsLocker {
public:
DirtyNotificationsLocker(KisPaintOpSettings::Private *d)
: m_d(d),
m_oldNotificationsState(d->disableDirtyNotifications)
{
m_d->disableDirtyNotifications = true;
}
~DirtyNotificationsLocker() {
m_d->disableDirtyNotifications = m_oldNotificationsState;
}
private:
KisPaintOpSettings::Private *m_d;
bool m_oldNotificationsState;
Q_DISABLE_COPY(DirtyNotificationsLocker);
};
};
......@@ -211,32 +234,29 @@ QPainterPath KisPaintOpSettings::ellipseOutline(qreal width, qreal height, qreal
void KisPaintOpSettings::setCanvasRotation(qreal angle)
{
Private::DirtyNotificationsLocker locker(d.data());
setProperty("runtimeCanvasRotation", angle);
setPropertyNotSaved("runtimeCanvasRotation");
if (this->preset()) {
this->preset()->setPresetDirty(false);
}
}
void KisPaintOpSettings::setCanvasMirroring(bool xAxisMirrored, bool yAxisMirrored)
{
Private::DirtyNotificationsLocker locker(d.data());
setProperty("runtimeCanvasMirroredX", xAxisMirrored);
setPropertyNotSaved("runtimeCanvasMirroredX");
setProperty("runtimeCanvasMirroredY", yAxisMirrored);
setPropertyNotSaved("runtimeCanvasMirroredY");
if (this->preset()) {
this->preset()->setPresetDirty(false);
}
}
void KisPaintOpSettings::setProperty(const QString & name, const QVariant & value)
{
if (value != KisPropertiesConfiguration::getProperty(name)) {
if (this->preset()) {
this->preset()->setPresetDirty(true);
}
if (value != KisPropertiesConfiguration::getProperty(name) &&
!d->disableDirtyNotifications && this->preset()) {
this->preset()->setPresetDirty(true);
}
KisPropertiesConfiguration::setProperty(name, value);
......
......@@ -23,16 +23,7 @@
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
......@@ -184,7 +175,7 @@
<item>
<widget class="QLineEdit" name="txtPreset">
<property name="toolTip">
<string>Current Brush Preset. Pink in Color whenever the preset has modified settings. Stays the same if original settings are loaded.</string>
<string>Current Brush Preset. Typed in italic when the preset has unsaved settings.</string>
</property>
</widget>
</item>
......
......@@ -299,6 +299,7 @@ bool KisConfig::useDirtyPresets() const
void KisConfig::setUseDirtyPresets(bool value)
{
m_cfg.writeEntry("useDirtyPresets",value);
KisConfigNotifier::instance()->notifyConfigChanged();
}
bool KisConfig::useEraserBrushSize() const
{
......@@ -307,6 +308,7 @@ bool KisConfig::useEraserBrushSize() const
void KisConfig::setUseEraserBrushSize(bool value)
{
m_cfg.writeEntry("useEraserBrushSize",value);
KisConfigNotifier::instance()->notifyConfigChanged();
}
......
......@@ -311,7 +311,6 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
connect(m_presetsPopup , SIGNAL(paintopActivated(QString)) , SLOT(slotSetPaintop(QString)));
connect(m_presetsPopup , SIGNAL(savePresetClicked()) , SLOT(slotSaveActivePreset()));
connect(m_presetsPopup , SIGNAL(defaultPresetClicked()) , SLOT(slotSetupDefaultPreset()));
connect(m_presetsPopup , SIGNAL(presetNameLineEditChanged(QString)) , SLOT(slotWatchPresetNameLineEdit(QString)));
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)));
......@@ -460,7 +459,6 @@ void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP pr
QString pixFilename = KisFactory::componentData().dirs()->findResource("kis_images", paintOp->pixmap());
m_settingsWidget->setIcon(QIcon(pixFilename));
m_resourceProvider->setPaintOpPreset(preset);
m_presetsPopup->setCurrentPaintOp(paintop.id());
......@@ -511,9 +509,9 @@ KisPaintOpPresetSP KisPaintopBox::activePreset(const KoID& paintOp)
void KisPaintopBox::updateCompositeOp(QString compositeOpID, bool localUpdate)
{
if (m_optionWidget) {
m_optionWidget->blockSignals(true);
}
if (!m_optionWidget) return;
KisSignalsBlocker blocker(m_optionWidget);
KisNodeSP node = m_resourceProvider->currentNode();
if (node && node->paintDevice()) {
......@@ -540,7 +538,6 @@ void KisPaintopBox::updateCompositeOp(QString compositeOpID, bool localUpdate)
m_currCompositeOpID = compositeOpID;
}
}
m_optionWidget->blockSignals(false);
}
void KisPaintopBox::setWidgetState(int flags)
......@@ -620,9 +617,7 @@ void KisPaintopBox::slotCanvasResourceChanged(int /*key*/, const QVariant& /*v*/
resourceSelected(preset.data());
}
m_presetsChooserPopup->canvasResourceChanged(preset.data(), preset);
if (preset) {
m_presetsPopup->setReloadEnabled(preset->isPresetDirty());
}
if (m_resourceProvider->currentCompositeOp() != m_currCompositeOpID) {
QString compositeOp = m_resourceProvider->currentCompositeOp();
......@@ -653,10 +648,11 @@ void KisPaintopBox::slotSaveActivePreset()
KisPaintOpPresetSP newPreset = curPreset->clone();
KisPaintOpPresetResourceServer * rServer = KisResourceServerProvider::instance()->paintOpPresetServer();
QString saveLocation = rServer->saveLocation();
QString name = m_presetsPopup->getPresetName();
QString presetName = m_presetsPopup->getPresetName();
QString presetFilename = saveLocation + presetName + newPreset->defaultFileExtension();
QStringList tags;
KisPaintOpPresetSP resource = rServer->resourceByName(name);
KisPaintOpPresetSP resource = rServer->resourceByName(presetName);
if (resource) {
tags = rServer->assignedTagsList(resource.data());
......@@ -665,18 +661,18 @@ void KisPaintopBox::slotSaveActivePreset()
}
newPreset->setImage(m_presetsPopup->cutOutOverlay());
newPreset->setFilename(saveLocation + name + newPreset->defaultFileExtension());
newPreset->setName(name);
m_presetsPopup->changeSavePresetButtonText(true);
newPreset->setFilename(presetFilename);
newPreset->setName(presetName);
newPreset->setPresetDirty(false);
m_presetsPopup->resourceSelected(newPreset.data());
rServer->addResource(newPreset);
foreach(const QString & tag, tags) {
rServer->addTag(newPreset.data(), tag);
}
m_favoriteResourceManager->setBlockUpdates(false);
restoreResource(newPreset.data());
m_favoriteResourceManager->setBlockUpdates(false);
}
void KisPaintopBox::slotUpdatePreset()
......@@ -812,12 +808,6 @@ void KisPaintopBox::slotSetCompositeMode(int index)
}
}
void KisPaintopBox::slotWatchPresetNameLineEdit(const QString& text)
{
KisPaintOpPresetResourceServer * rServer = KisResourceServerProvider::instance()->paintOpPresetServer();
m_presetsPopup->changeSavePresetButtonText(rServer->resourceByName(text) != 0);
}
void KisPaintopBox::slotHorizontalMirrorChanged(bool value)
{
m_resourceProvider->setMirrorHorizontal(value);
......@@ -835,8 +825,8 @@ void KisPaintopBox::sliderChanged(int n)
if (!m_optionWidget) // widget will not exist if the are no documents open
return;
KisSignalsBlocker blocker(m_optionWidget);
m_optionWidget->blockSignals(true);
m_optionWidget->writeConfiguration(const_cast<KisPaintOpSettings*>(m_resourceProvider->currentPreset()->settings().data()));
qreal opacity = m_sliderChooser[n]->getWidget<KisDoubleSliderSpinBox>("opacity")->value();
qreal flow = m_sliderChooser[n]->getWidget<KisDoubleSliderSpinBox>("flow")->value();
......@@ -865,19 +855,18 @@ void KisPaintopBox::sliderChanged(int n)
delete propertiesProxy;
m_optionWidget->setConfiguration(m_resourceProvider->currentPreset()->settings().data());
} else m_resourceProvider->setOpacity(opacity);
m_optionWidget->blockSignals(false);
} else {
m_resourceProvider->setOpacity(opacity);
}
if (m_presetsEnabled) {
m_optionWidget->setConfiguration(m_resourceProvider->currentPreset()->settings().data());
KisLockedPropertiesProxy *propertiesProxy = KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(m_resourceProvider->currentPreset()->settings());
propertiesProxy->setProperty("OpacityValue", opacity);
delete propertiesProxy;
}
if (!m_dirtyPresetsEnabled) {
m_resourceProvider->currentPreset()->setPresetDirty(false);
}
m_presetsPopup->resourceSelected(m_resourceProvider->currentPreset().data());
m_presetsPopup->resourceSelected(m_resourceProvider->currentPreset().data());
}
void KisPaintopBox::slotSlider1Changed()
......@@ -1020,7 +1009,7 @@ void KisPaintopBox::toggleHighlightedButton(QToolButton* m_tool)
}
void KisPaintopBox::slotReloadPreset()
{
m_optionWidget->blockSignals(true);
KisSignalsBlocker blocker(m_optionWidget);
//Here using the name and fetching the preset from the server was the only way the load was working. Otherwise it was not loading.
KisPaintOpPresetResourceServer * rserver = KisResourceServerProvider::instance()->paintOpPresetServer();
......@@ -1033,14 +1022,10 @@ void KisPaintopBox::slotReloadPreset()
m_presetsPopup->resourceSelected(preset.data());
}
slotUpdatePreset();
m_optionWidget->blockSignals(false);
}
void KisPaintopBox::slotConfigurationItemChanged() // Called only when UI is changed and not when preset is changed
{
m_optionWidget->writeConfiguration(const_cast<KisPaintOpSettings*>(m_resourceProvider->currentPreset()->settings().data()));
if (!m_dirtyPresetsEnabled) {
m_resourceProvider->currentPreset()->setPresetDirty(false);
}
m_presetsPopup->resourceSelected(m_resourceProvider->currentPreset().data());
m_presetsPopup->updateViewSettings();
}
......@@ -1062,23 +1047,25 @@ void KisPaintopBox::slotSaveLockedOptionToPreset(KisPropertiesConfiguration* p)
void KisPaintopBox::slotDropLockedOption(KisPropertiesConfiguration* p)
{
KisSignalsBlocker blocker(m_optionWidget);
KisPaintOpPresetSP preset = m_resourceProvider->currentPreset();
m_optionWidget->blockSignals(true);
bool saveDirtyPreset = m_resourceProvider->currentPreset()->isPresetDirty();
QMapIterator<QString, QVariant> i(p->getProperties());
while (i.hasNext()) {
i.next();
if (m_resourceProvider->currentPreset()->settings()->hasProperty(i.key() + "_previous")) {
m_resourceProvider->currentPreset()->settings()->setProperty(i.key(), m_resourceProvider->currentPreset()->settings()->getProperty(i.key() + "_previous"));
m_resourceProvider->currentPreset()->settings()->removeProperty(i.key() + "_previous");
}
{
KisPaintOpPreset::DirtyStateSaver dirtySaver(preset.data());
QMapIterator<QString, QVariant> i(p->getProperties());
while (i.hasNext()) {
i.next();
if (preset->settings()->hasProperty(i.key() + "_previous")) {
preset->settings()->setProperty(i.key(), preset->settings()->getProperty(i.key() + "_previous"));
preset->settings()->removeProperty(i.key() + "_previous");
}
}
m_optionWidget->setConfiguration(preset->settings());
}
m_optionWidget->setConfiguration(m_resourceProvider->currentPreset()->settings());
m_resourceProvider->currentPreset()->setPresetDirty(saveDirtyPreset);
slotUpdatePreset();
m_optionWidget->blockSignals(false);
slotUpdatePreset();
}
void KisPaintopBox::slotDirtyPresetToggled(bool value)
{
......
......@@ -142,7 +142,6 @@ private slots:
void slotToggleEraseMode(bool checked);
void slotSetCompositeMode(int index);
void slotSetPaintop(const QString& paintOpId);
void slotWatchPresetNameLineEdit(const QString& text);
void slotHorizontalMirrorChanged(bool value);
void slotVerticalMirrorChanged(bool value);
void slotSlider1Changed();
......
......@@ -46,6 +46,8 @@
#include <kis_node.h>
#include "kis_config.h"
#include "kis_resource_server_provider.h"
struct KisPaintOpPresetsPopup::Private
{
......@@ -123,30 +125,25 @@ KisPaintOpPresetsPopup::KisPaintOpPresetsPopup(KisCanvasResourceProvider * resou
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()));
connect(m_d->uiWdgPaintOpPresetSettings.txtPreset, SIGNAL(textChanged(QString)),
this, SIGNAL(presetNameLineEditChanged(QString)));
SLOT(slotWatchPresetNameLineEdit()));
connect(m_d->uiWdgPaintOpPresetSettings.paintopList, SIGNAL(activated(QString)),
this, SIGNAL(paintopActivated(QString)));
connect(m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser, SIGNAL(resourceSelected(KoResource*)),
this, SIGNAL(signalResourceSelected(KoResource*)));
connect(m_d->uiWdgPaintOpPresetSettings.bnSave, SIGNAL(clicked()),
m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser, SLOT(updateViewSettings()));
connect(m_d->uiWdgPaintOpPresetSettings.reload, SIGNAL(clicked()),
m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser, SLOT(updateViewSettings()));
connect(m_d->uiWdgPaintOpPresetSettings.dirtyPresetCheckBox, SIGNAL(toggled(bool)),
this, SLOT(slotDirtyPresetToggled(bool)));
KisConfig cfg;
m_d->detached = !cfg.paintopPopupDetached();
m_d->ignoreHideEvents = false;
......@@ -155,8 +152,6 @@ KisPaintOpPresetsPopup::KisPaintOpPresetsPopup(KisCanvasResourceProvider * resou
m_d->uiWdgPaintOpPresetSettings.scratchpadControls->setVisible(cfg.scratchpadVisible());
m_d->detachedGeometry = QRect(100, 100, 0, 0);
m_d->uiWdgPaintOpPresetSettings.dirtyPresetCheckBox->setChecked(cfg.useDirtyPresets());
slotDirtyPresetToggled(cfg.useDirtyPresets());
m_d->uiWdgPaintOpPresetSettings.reload->setEnabled(false);
m_d->uiWdgPaintOpPresetSettings.eraserBrushSizeCheckBox->setChecked(cfg.useEraserBrushSize());
}
......@@ -172,15 +167,6 @@ KisPaintOpPresetsPopup::~KisPaintOpPresetsPopup()
delete m_d;
}
void KisPaintOpPresetsPopup::slotCheckPresetValidity()
{
if (m_d->settingsWidget) {
m_d->uiWdgPaintOpPresetSettings.bnSave->setEnabled( m_d->settingsWidget->presetIsValid() );
m_d->uiWdgPaintOpPresetSettings.txtPreset->setEnabled( m_d->settingsWidget->presetIsValid() );
}
}
void KisPaintOpPresetsPopup::setPaintOpSettingsWidget(QWidget * widget)
{
if (m_d->settingsWidget) {
......@@ -192,8 +178,6 @@ void KisPaintOpPresetsPopup::setPaintOpSettingsWidget(QWidget * widget)
m_d->settingsWidget = static_cast<KisPaintOpSettingsWidget*>(widget);
if (m_d->settingsWidget){
connect(m_d->settingsWidget,SIGNAL(sigConfigurationItemChanged()),this,SLOT(slotCheckPresetValidity()));
slotCheckPresetValidity();
if (m_d->settingsWidget->supportScratchBox()) {
showScratchPad();
}
......@@ -216,27 +200,34 @@ void KisPaintOpPresetsPopup::setPaintOpSettingsWidget(QWidget * widget)
}
}
void KisPaintOpPresetsPopup::changeSavePresetButtonText(bool change)
void KisPaintOpPresetsPopup::slotWatchPresetNameLineEdit()
{
QString text = m_d->uiWdgPaintOpPresetSettings.txtPreset->text();
KisPaintOpPresetResourceServer * rServer = KisResourceServerProvider::instance()->paintOpPresetServer();
bool overwrite = rServer->resourceByName(text) != 0;
if (change) {
m_d->uiWdgPaintOpPresetSettings.bnSave->setText(i18n("Overwrite Preset"));
KisPaintOpPresetSP preset = m_d->resourceProvider->currentPreset();
}
else {
m_d->uiWdgPaintOpPresetSettings.bnSave->setEnabled(true);
m_d->uiWdgPaintOpPresetSettings.bnSave->setText(i18n("Save to Presets"));
bool btnSaveAvailable = preset->valid() &&
(preset->isPresetDirty() | !overwrite);
}
}
QString btnText = overwrite ? i18n("Overwrite Preset") : i18n("Save to Presets");
m_d->uiWdgPaintOpPresetSettings.bnSave->setText(btnText);
m_d->uiWdgPaintOpPresetSettings.bnSave->setEnabled(btnSaveAvailable);
QString KisPaintOpPresetsPopup::getPresetName() const
{
m_d->uiWdgPaintOpPresetSettings.reload->setVisible(true);
m_d->uiWdgPaintOpPresetSettings.reload->setEnabled(btnSaveAvailable && overwrite);
return m_d->uiWdgPaintOpPresetSettings.txtPreset->text();
QFont font = m_d->uiWdgPaintOpPresetSettings.txtPreset->font();
font.setItalic(btnSaveAvailable);
m_d->uiWdgPaintOpPresetSettings.txtPreset->setFont(font);
}
QString KisPaintOpPresetsPopup::getPresetName() const
{
return m_d->uiWdgPaintOpPresetSettings.txtPreset->text();
}
QImage KisPaintOpPresetsPopup::cutOutOverlay()
......@@ -305,23 +296,8 @@ void KisPaintOpPresetsPopup::showScratchPad()
void KisPaintOpPresetsPopup::resourceSelected(KoResource* resource)
{
KisPaintOpPreset* preset = dynamic_cast<KisPaintOpPreset*>(resource);
QPalette palette;
if(preset->isPresetDirty())
{
palette.setColor(QPalette::Base, QColor(255,200,200));
palette.setColor(QPalette::Text, Qt::black);
m_d->uiWdgPaintOpPresetSettings.txtPreset->setPalette(palette);
m_d->uiWdgPaintOpPresetSettings.bnSave->setEnabled(true);
m_d->uiWdgPaintOpPresetSettings.reload->setEnabled(true);
}
else
{
m_d->uiWdgPaintOpPresetSettings.txtPreset->setPalette(palette);
m_d->uiWdgPaintOpPresetSettings.bnSave->setEnabled(false);
m_d->uiWdgPaintOpPresetSettings.reload->setEnabled(false);
}
m_d->uiWdgPaintOpPresetSettings.txtPreset->setText(resource->name());
slotWatchPresetNameLineEdit();
}
void KisPaintOpPresetsPopup::setPaintOpList(const QList< KisPaintOpFactory* >& list)
......@@ -387,18 +363,10 @@ void KisPaintOpPresetsPopup::slotSwitchScratchpad(bool visible)
KisConfig cfg;
cfg.setScratchpadVisible(visible);
}
void KisPaintOpPresetsPopup::setReloadEnabled(bool value)
{
m_d->uiWdgPaintOpPresetSettings.reload->setEnabled(value);
}
void KisPaintOpPresetsPopup::updateViewSettings()
{
m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser->updateViewSettings();
}
void KisPaintOpPresetsPopup::slotDirtyPresetToggled(bool value)
{
m_d->uiWdgPaintOpPresetSettings.reload->setVisible(value);
}
#include "kis_paintop_presets_popup.moc"
......@@ -49,12 +49,6 @@ public:
void setPaintOpSettingsWidget(QWidget * widget);
/**
* changes the "save to preset" button text to "override preset"
* and highlites the preset name lineedit
*/
void changeSavePresetButtonText(bool change);
/**
* @return the name entered in the preset name lineedit
*/
......@@ -77,8 +71,6 @@ public:
bool detached() const;
void setReloadEnabled(bool value);
void updateViewSettings();
protected:
......@@ -87,16 +79,15 @@ protected:
void showEvent(QShowEvent *);
public slots:
void slotWatchPresetNameLineEdit();
void switchDetached(bool show = true);
void hideScratchPad();
void showScratchPad();
void resourceSelected(KoResource* resource);
void slotDirtyPresetToggled(bool value);
signals:
void savePresetClicked();
void defaultPresetClicked();
void presetNameLineEditChanged(const QString& presetName);
void paintopActivated(const QString& presetName);
void signalResourceSelected(KoResource* resource);
void reloadPresetClicked();
......@@ -106,7 +97,6 @@ signals:
void sizeChanged();
private slots:
void slotCheckPresetValidity();
void slotSwitchPresetStrip(bool visible);
void slotSwitchScratchpad(bool visible);
......
......@@ -43,6 +43,7 @@
#include "kis_global.h"
#include "kis_slider_spin_box.h"
#include "kis_config.h"
#include "kis_config_notifier.h"
......@@ -50,7 +51,7 @@
class KisPresetDelegate : public QAbstractItemDelegate
{
public:
KisPresetDelegate(QObject * parent = 0) : QAbstractItemDelegate(parent), m_showText(false) {}
KisPresetDelegate(QObject * parent = 0) : QAbstractItemDelegate(parent), m_showText(false), m_useDirtyPresets(false) {}
virtual ~KisPresetDelegate() {}
/// reimplemented
virtual void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const;
......@@ -63,8 +64,13 @@ public:
m_showText = showText;
}
void setUseDirtyPresets(bool value) {
m_useDirtyPresets = value;
}
private:
bool m_showText;
bool m_useDirtyPresets;
};
void KisPresetDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
......@@ -94,7 +100,7 @@ void KisPresetDelegate::paint(QPainter * painter, const QStyleOptionViewItem & o
painter->drawText(pixSize.width() + 10, option.rect.y() + option.rect.height() - 10, preset->name());
}
if(preset->isPresetDirty())
if(m_useDirtyPresets && preset->isPresetDirty())
{
KIcon *i = new KIcon("addlayer");
QPixmap pixmap = i->pixmap(QSize(15,15));
......@@ -180,7 +186,10 @@ KisPresetChooser::KisPresetChooser(QWidget *parent, const char *name)
this, SIGNAL(resourceSelected(KoResource*)));
m_mode = THUMBNAIL;
updateViewSettings();
connect(KisConfigNotifier::instance(), SIGNAL(configChanged()),
SLOT(notifyConfigChanged()));
notifyConfigChanged();
}
KisPresetChooser::~KisPresetChooser()
......@@ -213,6 +222,13 @@ void KisPresetChooser::resizeEvent(QResizeEvent* event)
updateViewSettings();
}
void KisPresetChooser::notifyConfigChanged()
{
KisConfig cfg;
m_delegate->setUseDirtyPresets(cfg.useDirtyPresets());
updateViewSettings();
}
void KisPresetChooser::updateViewSettings()
{
if (m_mode == THUMBNAIL) {
......
......@@ -71,6 +71,9 @@ signals:
public slots:
void updateViewSettings();
private slots:
void notifyConfigChanged();
protected:
virtual void resizeEvent(QResizeEvent* event);
......
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