Commit 06d70193 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Don't update brush chooser on zoom change

Brush chooser should update itself only when the preset is changed.
Updating on zooming makes the zooming slow.

This bug is **not** present in krita/4.3

BUG:419328
parent cc48cc53
......@@ -840,12 +840,13 @@ void KisPaintopBox::slotCanvasResourceChanged(int key, const QVariant &value)
resourceSelected(preset);
}
/**
* Update currently selected preset in both the popup widgets
*/
m_presetsChooserPopup->canvasResourceChanged(preset);
m_presetsPopup->currentPresetChanged(preset);
if (key == KisCanvasResourceProvider::CurrentPaintOpPreset) {
/**
* Update currently selected preset in both the popup widgets
*/
m_presetsChooserPopup->canvasResourceChanged(preset);
m_presetsPopup->currentPresetChanged(preset);
}
if (key == KisCanvasResourceProvider::CurrentCompositeOp) {
if (m_resourceProvider->currentCompositeOp() != m_currCompositeOpID) {
......
......@@ -327,6 +327,10 @@ KisPresetChooser::KisPresetChooser(QWidget *parent, const char *name)
this, SLOT(slotScrollerStateChanged(QScroller::State)));
}
}
connect(m_chooser, SIGNAL(resourceSelected(KoResourceSP )),
this, SLOT(slotResourceWasSelected(KoResourceSP )));
connect(m_chooser, SIGNAL(resourceSelected(KoResourceSP )),
this, SIGNAL(resourceSelected(KoResourceSP )));
connect(m_chooser, SIGNAL(resourceClicked(KoResourceSP )),
......@@ -371,6 +375,30 @@ void KisPresetChooser::notifyConfigChanged()
updateViewSettings();
}
void KisPresetChooser::slotResourceWasSelected(KoResourceSP resource)
{
m_currentPresetConnections.clear();
if (!resource) return;
KisPaintOpPresetSP preset = resource.dynamicCast<KisPaintOpPreset>();
KIS_SAFE_ASSERT_RECOVER_RETURN(preset);
m_currentPresetConnections.addUniqueConnection(
preset->updateProxy(), SIGNAL(sigSettingsChanged()),
this, SLOT(slotCurrentPresetChanged()));
}
void KisPresetChooser::slotCurrentPresetChanged()
{
KoResourceSP currentResource = m_chooser->currentResource();
if (!currentResource) return;
QModelIndex index = m_paintOpFilterModel->indexFromResource(currentResource);
emit m_paintOpFilterModel->dataChanged(index,
index,
{Qt::UserRole + KisResourceModel::Thumbnail});
}
void KisPresetChooser::updateViewSettings()
{
if (m_mode == THUMBNAIL) {
......
......@@ -26,6 +26,7 @@
#include <KoResource.h>
#include <KoID.h>
#include "kis_signal_auto_connection.h"
class KoAbstractResourceServerAdapter;
class KisPresetDelegate;
......@@ -85,6 +86,8 @@ public Q_SLOTS:
private Q_SLOTS:
void notifyConfigChanged();
void slotResourceWasSelected(KoResourceSP resource);
void slotCurrentPresetChanged();
protected:
void resizeEvent(QResizeEvent* event) override;
......@@ -97,6 +100,7 @@ private:
class PaintOpFilterModel;
QPointer<PaintOpFilterModel> m_paintOpFilterModel;
KisSignalAutoConnectionsStore m_currentPresetConnections;
};
#endif // KIS_ITEM_CHOOSER_H_
......
......@@ -70,15 +70,17 @@ void PresetDockerDock::setCanvas(KoCanvasBase *canvas)
canvasResourceChanged();
}
void PresetDockerDock::canvasResourceChanged(int /*key*/, const QVariant& /*v*/)
void PresetDockerDock::canvasResourceChanged(int key, const QVariant& /*v*/)
{
if (m_canvas && m_canvas->resourceManager()) {
if (sender()) sender()->blockSignals(true);
KisPaintOpPresetSP preset = m_canvas->resourceManager()->resource(KisCanvasResourceProvider::CurrentPaintOpPreset).value<KisPaintOpPresetSP>();
if(preset)
m_presetChooser->canvasResourceChanged(preset);
if (sender()) sender()->blockSignals(false);
m_presetChooser->updateViewSettings();
if (key == KisCanvasResourceProvider::CurrentPaintOpPreset) {
if (m_canvas && m_canvas->resourceManager()) {
if (sender()) sender()->blockSignals(true);
KisPaintOpPresetSP preset = m_canvas->resourceManager()->resource(KisCanvasResourceProvider::CurrentPaintOpPreset).value<KisPaintOpPresetSP>();
if(preset)
m_presetChooser->canvasResourceChanged(preset);
if (sender()) sender()->blockSignals(false);
m_presetChooser->updateViewSettings();
}
}
}
......
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