[calligra] krita/ui/widgets: bring back preset proxy adapter, now the preset strip only shows preset for the paintop
Boudewijn Rempt
boud at valdyas.org
Sun Sep 29 08:48:56 UTC 2013
I yayed too early... It seems I cannot filter by tag in the preset docker anymore :-(
On Sunday 29 September 2013 Sep 00:40:37 Sven Langkamp wrote:
> Git commit e02e34d22bae1d8beee80cd54e584d2fac7e78a7 by Sven Langkamp.
> Committed on 29/09/2013 at 00:37.
> Pushed by langkamp into branch 'master'.
>
> bring back preset proxy adapter, now the preset strip only shows preset for the paintop
> BUG:324402
>
> M +1 -0 krita/ui/widgets/kis_paintop_presets_popup.cpp
> M +46 -1 krita/ui/widgets/kis_preset_chooser.cpp
> M +2 -0 krita/ui/widgets/kis_preset_chooser.h
> M +5 -0 krita/ui/widgets/kis_preset_selector_strip.cpp
> M +2 -0 krita/ui/widgets/kis_preset_selector_strip.h
>
> http://commits.kde.org/calligra/e02e34d22bae1d8beee80cd54e584d2fac7e78a7
>
> diff --git a/krita/ui/widgets/kis_paintop_presets_popup.cpp b/krita/ui/widgets/kis_paintop_presets_popup.cpp
> index e324cac..5379c59 100644
> --- a/krita/ui/widgets/kis_paintop_presets_popup.cpp
> +++ b/krita/ui/widgets/kis_paintop_presets_popup.cpp
> @@ -286,6 +286,7 @@ void KisPaintOpPresetsPopup::setPaintOpList(const QList< KisPaintOpFactory* >& l
> void KisPaintOpPresetsPopup::setCurrentPaintOp(const QString& paintOpId)
> {
> m_d->uiWdgPaintOpPresetSettings.paintopList->setCurrent(paintOpId);
> + m_d->uiWdgPaintOpPresetSettings.presetWidget->setPresetFilter(paintOpId);
> }
>
> QString KisPaintOpPresetsPopup::currentPaintOp()
> diff --git a/krita/ui/widgets/kis_preset_chooser.cpp b/krita/ui/widgets/kis_preset_chooser.cpp
> index c5a598b..822efc7 100644
> --- a/krita/ui/widgets/kis_preset_chooser.cpp
> +++ b/krita/ui/widgets/kis_preset_chooser.cpp
> @@ -113,6 +113,45 @@ void KisPresetDelegate::paint(QPainter * painter, const QStyleOptionViewItem & o
> painter->restore();
> }
>
> +class KisPresetProxyAdapter : public KoResourceServerAdapter<KisPaintOpPreset>
> +{
> +
> +public:
> + KisPresetProxyAdapter(KoResourceServer< KisPaintOpPreset >* resourceServer)
> + : KoResourceServerAdapter<KisPaintOpPreset>(resourceServer)
> + {
> + }
> + virtual ~KisPresetProxyAdapter() {}
> +
> + virtual QList< KoResource* > resources() {
> +
> + QList<KisPaintOpPreset*> serverResources = resourceServer()->resources();
> + QList<KoResource*> resources;
> + foreach( KisPaintOpPreset* preset, serverResources ) {
> + if( m_paintopID.isEmpty() || preset->paintOp().id() == m_paintopID) {
> + resources.append( preset );
> + }
> + }
> + return resources;
> + }
> +
> + ///Set id for paintop to be accept by the proxy model, if not filter is set all
> + ///presets will be shown.
> + void setPresetFilter(const QString& paintOpId)
> + {
> + m_paintopID = paintOpId;
> + invalidate();
> + }
> +
> + ///Resets the model connected to the adapter
> + void invalidate() {
> + emitRemovingResource(0);
> + }
> +
> +private:
> + QString m_paintopID;
> +};
> +
> KisPresetChooser::KisPresetChooser(QWidget *parent, const char *name)
> : QWidget(parent)
> {
> @@ -121,7 +160,7 @@ KisPresetChooser::KisPresetChooser(QWidget *parent, const char *name)
> layout->setMargin(0);
> KoResourceServer<KisPaintOpPreset> * rserver = KisResourceServerProvider::instance()->paintOpPresetServer();
>
> - m_adapter = new KoResourceServerAdapter<KisPaintOpPreset>(rserver);
> + m_adapter = new KisPresetProxyAdapter(rserver);
>
> m_chooser = new KoResourceItemChooser(m_adapter, this);
> QString knsrcFile = "kritapresets.knsrc";
> @@ -214,5 +253,11 @@ KoResourceItemChooser *KisPresetChooser::itemChooser()
> return m_chooser;
> }
>
> +void KisPresetChooser::setPresetFilter(const QString& paintOpId)
> +{
> + static_cast<KisPresetProxyAdapter*>(m_adapter)->setPresetFilter(paintOpId);
> +}
> +
> +
> #include "kis_preset_chooser.moc"
>
> diff --git a/krita/ui/widgets/kis_preset_chooser.h b/krita/ui/widgets/kis_preset_chooser.h
> index c5c10fd..3deeaee 100644
> --- a/krita/ui/widgets/kis_preset_chooser.h
> +++ b/krita/ui/widgets/kis_preset_chooser.h
> @@ -63,6 +63,8 @@ public:
>
> KoResourceItemChooser *itemChooser();
>
> + void setPresetFilter(const QString& paintOpId);
> +
> signals:
> void resourceSelected(KoResource * resource);
>
> diff --git a/krita/ui/widgets/kis_preset_selector_strip.cpp b/krita/ui/widgets/kis_preset_selector_strip.cpp
> index 2d06050..b8c09b2 100644
> --- a/krita/ui/widgets/kis_preset_selector_strip.cpp
> +++ b/krita/ui/widgets/kis_preset_selector_strip.cpp
> @@ -47,6 +47,11 @@ KisPresetSelectorStrip::~KisPresetSelectorStrip()
> {
> }
>
> +void KisPresetSelectorStrip::setPresetFilter(const QString& paintOpId)
> +{
> + smallPresetChooser->setPresetFilter(paintOpId);
> +}
> +
> void KisPresetSelectorStrip::on_leftScrollBtn_pressed()
> {
> // Deciding how far beyond the left margin (10 pixels) was an arbitrary decision
> diff --git a/krita/ui/widgets/kis_preset_selector_strip.h b/krita/ui/widgets/kis_preset_selector_strip.h
> index 580a9cc..1f09f41 100644
> --- a/krita/ui/widgets/kis_preset_selector_strip.h
> +++ b/krita/ui/widgets/kis_preset_selector_strip.h
> @@ -45,6 +45,8 @@ public:
> KisPresetSelectorStrip(QWidget *parent);
> virtual ~KisPresetSelectorStrip();
>
> + void setPresetFilter(const QString& paintOpId);
> +
> private slots:
> /// Scrolls the strip's item view to the left
> void on_leftScrollBtn_pressed();
--
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl
More information about the kimageshop
mailing list