Commit 964ce144 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove the integration of KisIconWidget with KisResourceServerAdapter

This was actually unused: only the gradient button had the
KisResourceServerAdapter set, and the actual code for setting
the current resource has had a bug since the inception (it
would only set the new resource if it was the same as the old
resource), and it was plain and plumb superfluous since the
work was done by setResource.
parent a8ad9c6d
......@@ -84,10 +84,6 @@ KisControlFrame::KisControlFrame(KisViewManager *view, QWidget *parent, const ch
m_gradientWidget = new KisIconWidget(parent, "gradients");
m_gradientWidget->setToolTip(i18n("Gradients"));
m_gradientWidget->setFixedSize(32, 32);
KoResourceServer<KoAbstractGradient> * rserver = KoResourceServerProvider::instance()->gradientServer();
QSharedPointer<KoAbstractResourceServerAdapter> adapter (new KoResourceServerAdapter<KoAbstractGradient>(rserver));
m_gradientWidget->setResourceAdapter(adapter);
}
void KisControlFrame::setup(QWidget *parent)
......@@ -148,13 +144,13 @@ void KisControlFrame::slotUpdateDisplayRenderer()
void KisControlFrame::slotSetPattern(KoPattern * pattern)
{
m_patternWidget->slotSetItem(pattern);
m_patternWidget->setResource(pattern);
m_patternChooser->setCurrentPattern(pattern);
}
void KisControlFrame::slotSetGradient(KoAbstractGradient * gradient)
{
m_gradientWidget->slotSetItem(gradient);
m_gradientWidget->setResource(gradient);
}
void KisControlFrame::createPatternsChooser(KisViewManager * view)
......
......@@ -638,7 +638,7 @@ void KisPaintopBox::setCurrentPaintop(KisPaintOpPresetSP preset)
// load the current brush engine icon for the brush editor toolbar button
m_brushEditorPopupButton->slotSetItem(preset.data());
m_brushEditorPopupButton->setResource(preset.data());
m_presetsPopup->setCurrentPaintOpId(paintop.id());
......
......@@ -33,7 +33,7 @@ KisIconWidget::KisIconWidget(QWidget *parent, const char *name)
m_resource = 0;
}
void KisIconWidget::slotSetItem(KoResource * resource)
void KisIconWidget::setResource(KoResource * resource)
{
m_resource = resource;
update();
......@@ -88,25 +88,3 @@ void KisIconWidget::paintEvent(QPaintEvent *event)
p.setClipping(false);
}
void KisIconWidget::setResourceAdapter(QSharedPointer<KoAbstractResourceServerAdapter> adapter)
{
Q_ASSERT(adapter);
m_adapter = adapter;
m_adapter->connectToResourceServer();
connect(m_adapter.data(), SIGNAL(resourceChanged(KoResource*)), this, SLOT(slotAdapterResourceChanged(KoResource*)));
connect(m_adapter.data(), SIGNAL(removingResource(KoResource*)), this, SLOT(slotAdapterResourceRemoved(KoResource*)));
}
void KisIconWidget::slotAdapterResourceChanged(KoResource* resource)
{
if (m_resource == resource) {
update();
}
}
void KisIconWidget::slotAdapterResourceRemoved(KoResource* resource)
{
if (m_resource == resource) {
m_resource = 0;
}
}
......@@ -23,7 +23,6 @@
#include <kis_popup_button.h>
class KoResource;
class KoAbstractResourceServerAdapter;
/**
* The icon widget is used in the control box where the current color and brush
......@@ -36,22 +35,13 @@ class KisIconWidget : public KisPopupButton
public:
KisIconWidget(QWidget *parent = 0, const char *name = 0);
/**
* Set an resource server adapter that the widget will observe.
*/
void setResourceAdapter(QSharedPointer<KoAbstractResourceServerAdapter> adapter);
public Q_SLOTS:
void slotSetItem(KoResource * resource);
void slotAdapterResourceChanged(KoResource * resource);
void slotAdapterResourceRemoved(KoResource * resource);
void setResource(KoResource * resource);
protected:
void paintEvent(QPaintEvent *) override;
private:
KoResource *m_resource;
QSharedPointer<KoAbstractResourceServerAdapter> m_adapter;
};
#endif // KIS_ICONWIDGET_H_
......
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