Commit 0e9a993d authored by Dmitry Kazakov's avatar Dmitry Kazakov

Don't reset the paintop preset when seeing a new tool id

And don't reset it in general :)
parent 8f02ed57
......@@ -507,7 +507,7 @@ void KisViewManager::setCurrentView(KisView *view)
preset = rserver->resources().first();
}
if (preset) {
paintOpBox()->resourceSelected(preset.data());
paintOpBox()->restoreResource(preset.data());
}
}
......
......@@ -362,6 +362,17 @@ KisPaintopBox::~KisPaintopBox()
delete m_favoriteResourceManager;
}
void KisPaintopBox::restoreResource(KoResource* resource)
{
KisPaintOpPreset* preset = dynamic_cast<KisPaintOpPreset*>(resource);
if (preset) {
setCurrentPaintop(preset->paintOp(), preset);
m_presetsPopup->setPresetImage(preset->image());
m_presetsPopup->resourceSelected(resource);
}
}
void KisPaintopBox::resourceSelected(KoResource* resource)
{
KisPaintOpPreset* preset = dynamic_cast<KisPaintOpPreset*>(resource);
......@@ -369,7 +380,7 @@ void KisPaintopBox::resourceSelected(KoResource* resource)
if (!preset->settings()->isLoadable())
return;
bool saveDirtyPreset = preset->isPresetDirty();
setCurrentPaintop(preset->paintOp(), preset);
setCurrentPaintopAndReload(preset->paintOp(), preset);
m_optionWidget->writeConfiguration(const_cast<KisPaintOpSettings*>(m_resourceProvider->currentPreset()->settings().data()));
preset->setPresetDirty(saveDirtyPreset);
m_resourceProvider->currentPreset()->setPresetDirty(saveDirtyPreset);
......@@ -393,6 +404,17 @@ KoID KisPaintopBox::currentPaintop()
return m_resourceProvider->currentPreset()->paintOp();
}
void KisPaintopBox::setCurrentPaintopAndReload(const KoID& paintop, KisPaintOpPresetSP preset)
{
setCurrentPaintop(paintop, preset);
if (!m_dirtyPresetsEnabled) {
slotReloadPreset();
m_presetsPopup->resourceSelected(m_resourceProvider->currentPreset().data());
m_presetsPopup->updateViewSettings();
}
}
void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP preset)
{
if (m_resourceProvider->currentPreset()) {
......@@ -455,11 +477,6 @@ void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP pr
* so just call the slot directly
*/
slotUpdatePreset();
if (!m_dirtyPresetsEnabled) {
slotReloadPreset();
m_presetsPopup->resourceSelected(m_resourceProvider->currentPreset().data());
m_presetsPopup->updateViewSettings();
}
}
KoID KisPaintopBox::defaultPaintOp()
......@@ -573,10 +590,14 @@ void KisPaintopBox::slotInputDeviceChanged(const KoInputDevice& inputDevice)
{
TabletToolMap::iterator toolData = m_tabletToolMap.find(inputDevice);
if (toolData == m_tabletToolMap.end())
setCurrentPaintop(currentPaintop());
else
if (toolData == m_tabletToolMap.end()) {
KisPaintOpPresetSP preset =
m_resourceProvider->currentPreset()->clone();
m_resourceProvider->setPaintOpPreset(preset);
setCurrentPaintop(preset->paintOp(), preset);
} else {
setCurrentPaintop(toolData->paintOpID, toolData->preset);
}
m_currTabletToolID = TabletToolID(inputDevice);
}
......
......@@ -105,6 +105,8 @@ public:
KisPaintopBox(KisViewManager* view, QWidget* parent, const char* name);
~KisPaintopBox();
void restoreResource(KoResource* resource);
public slots:
void slotColorSpaceChanged(const KoColorSpace* colorSpace);
......@@ -112,12 +114,16 @@ public slots:
void slotCurrentNodeChanged(KisNodeSP node);
void slotCanvasResourceChanged(int key, const QVariant& v);
void resourceSelected(KoResource* resource);
KisFavoriteResourceManager *favoriteResourcesManager() { return m_favoriteResourceManager; }
private:
KoID currentPaintop();
void setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP preset = 0);
void setCurrentPaintopAndReload(const KoID& paintop, KisPaintOpPresetSP preset);
QPixmap paintopPixmap(const KoID& paintop);
KoID defaultPaintOp();
KisPaintOpPresetSP defaultPreset(const KoID& paintOp);
......
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