Commit deda6fbc authored by Boudewijn Rempt's avatar Boudewijn Rempt

Extract a base class for settings/widgets combos that want a preview to

be updated. Next: make that base class delayed and use it in KisPaintOpPreset

svn path=/trunk/koffice/; revision=853312
parent afac03ad
......@@ -55,7 +55,6 @@ set(kritaimage_LIB_SRCS
commands/kis_selection_commands.cc
filter/kis_filter.cc
filter/kis_filter_configuration.cc
filter/kis_filter_config_widget.cc
filter/kis_filter_job.cpp
filter/kis_filter_registry.cc
generator/kis_generator.cpp
......@@ -70,6 +69,7 @@ set(kritaimage_LIB_SRCS
kis_bottom_up_update_strategy.cpp
kis_boundary.cc
kis_clone_layer.cpp
kis_config_widget.cpp
kis_convolution_kernel.cc
kis_convolution_painter.cc
kis_effect_mask.cc
......
......@@ -31,7 +31,7 @@
#include "KoID.h"
#include "kis_types.h"
#include "filter/kis_filter_config_widget.h"
#include "kis_config_widget.h"
struct KisFilterConfiguration::Private {
QString name;
......
......@@ -75,7 +75,7 @@ KisFilterConfiguration * KisBaseProcessor::defaultConfiguration(const KisPaintDe
return fc;
}
KisFilterConfigWidget * KisBaseProcessor::createConfigurationWidget(QWidget *, const KisPaintDeviceSP, const KisImageSP) const
KisConfigWidget * KisBaseProcessor::createConfigurationWidget(QWidget *, const KisPaintDeviceSP, const KisImageSP) const
{
return 0;
}
......
......@@ -39,7 +39,7 @@ class KoUpdater;
class KisBookmarkedConfigurationManager;
class KisFilterConfiguration;
class KisFilterConfigWidget;
class KisConfigWidget;
/**
* Base class for classes that process areas of pixels.
......@@ -118,7 +118,7 @@ public:
* @param parent the Qt owner widget of this widget
* @param dev the paintdevice this filter will act on
*/
virtual KisFilterConfigWidget * createConfigurationWidget(QWidget * parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisConfigWidget * createConfigurationWidget(QWidget * parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
// "Support" functions
public:
/**
......
......@@ -16,15 +16,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "filter/kis_filter_config_widget.h"
#include "kis_config_widget.h"
KisFilterConfigWidget::KisFilterConfigWidget(QWidget * parent, Qt::WFlags f)
KisConfigWidget::KisConfigWidget(QWidget * parent, Qt::WFlags f)
: QWidget(parent, f)
{
}
KisFilterConfigWidget::~KisFilterConfigWidget()
KisConfigWidget::~KisConfigWidget()
{
}
#include "kis_filter_config_widget.moc"
#include "kis_config_widget.moc"
/*
* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org)
* Copyright (c) 2004-2006 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
......@@ -15,41 +16,44 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_FILTER_CONFIG_WIDGET_H_
#define _KIS_FILTER_CONFIG_WIDGET_H_
#ifndef _KIS_CONFIG_WIDGET_H_
#define _KIS_CONFIG_WIDGET_H_
#include <QWidget>
#include <krita_export.h>
class KisFilterConfiguration;
class KisPropertiesConfiguration;
/**
* Empty base class. Filters can build their own configuration widgets that
* inherit this class. The configuration widget can emit sigPleaseUpdatePreview
* when it wants the preview in the filter dialog to be updated.
* Empty base class. Configurable resources like filters, paintops etc.
* can build their own configuration widgets that inherit this class.
* The configuration widget should emit sigPleaseUpdatePreview
* when it wants a preview updated.
*
* Also, this class is designed to have a single instance of a certain configuration
* widget that can be reset and unset
*/
class KRITAIMAGE_EXPORT KisFilterConfigWidget : public QWidget
class KRITAIMAGE_EXPORT KisConfigWidget : public QWidget
{
Q_OBJECT
protected:
KisFilterConfigWidget(QWidget * parent, Qt::WFlags f = 0);
KisConfigWidget(QWidget * parent, Qt::WFlags f = 0);
public:
virtual ~KisFilterConfigWidget();
virtual ~KisConfigWidget();
/**
* @param config the configuration for this filter widget.
* @param config the configuration for this configuration widget.
*/
virtual void setConfiguration(KisFilterConfiguration * config) = 0;
virtual void setConfiguration(KisPropertiesConfiguration * config) = 0;
/**
* @return the filter configuration
* @return the configuration
*/
virtual KisFilterConfiguration* configuration() const = 0;
virtual KisPropertiesConfiguration* configuration() const = 0;
signals:
......
......@@ -22,28 +22,28 @@
#include "filter/kis_filter_configuration.h"
#include "filter/kis_filter_config_widget.h"
#include "kis_config_widget.h"
class TestWidget : public KisFilterConfigWidget
class TestWidget : public KisConfigWidget
{
public:
TestWidget()
: KisFilterConfigWidget(0) {
: KisConfigWidget(0) {
}
void setConfiguration(KisFilterConfiguration*) {
void setConfiguration( KisPropertiesConfiguration *) {
}
KisFilterConfiguration* configuration() const {
KisPropertiesConfiguration * configuration() const {
return 0;
}
};
void KisFilterConfigWidgetTest::testCreation()
void KisConfigWidgetTest::testCreation()
{
TestWidget test;
}
QTEST_KDEMAIN(KisFilterConfigWidgetTest, GUI)
QTEST_KDEMAIN(KisConfigWidgetTest, GUI)
#include "kis_filter_config_widget_test.moc"
......@@ -21,7 +21,7 @@
#include <QtTest/QtTest>
class KisFilterConfigWidgetTest : public QObject
class KisConfigWidgetTest : public QObject
{
Q_OBJECT
private slots:
......
......@@ -45,7 +45,7 @@ KisBlurFilter::KisBlurFilter() : KisFilter(id(), CategoryBlur, i18n("&Blur..."))
setColorSpaceIndependence(FULLY_INDEPENDENT);
}
KisFilterConfigWidget * KisBlurFilter::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP, const KisImageSP image) const
KisConfigWidget * KisBlurFilter::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP, const KisImageSP image) const
{
Q_UNUSED(image)
return new KisWdgBlur(parent);
......
......@@ -42,7 +42,7 @@ public:
virtual KisFilterConfiguration* factoryConfiguration(const KisPaintDeviceSP) const;
public:
KisFilterConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
KisConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
int overlapMarginNeeded(const KisFilterConfiguration* /*c*/) const;
};
......
......@@ -36,7 +36,7 @@
#include "ui_wdgblur.h"
KisWdgBlur::KisWdgBlur(QWidget * parent) : KisFilterConfigWidget(parent)
KisWdgBlur::KisWdgBlur(QWidget * parent) : KisConfigWidget(parent)
{
m_widget = new Ui_WdgBlur();
m_widget->setupUi(this);
......@@ -51,7 +51,7 @@ KisWdgBlur::KisWdgBlur(QWidget * parent) : KisFilterConfigWidget(parent)
connect(widget()->cbShape, SIGNAL(activated(int)), SIGNAL(sigPleaseUpdatePreview()));
}
KisFilterConfiguration* KisWdgBlur::configuration() const
KisPropertiesConfiguration* KisWdgBlur::configuration() const
{
KisFilterConfiguration* config = new KisFilterConfiguration("blur", 1);
config->setProperty("halfWidth", widget()->intHalfWidth->value());
......@@ -62,7 +62,7 @@ KisFilterConfiguration* KisWdgBlur::configuration() const
return config;
}
void KisWdgBlur::setConfiguration(KisFilterConfiguration* config)
void KisWdgBlur::setConfiguration(KisPropertiesConfiguration* config)
{
QVariant value;
if (config->getProperty("shape", value)) {
......
......@@ -21,12 +21,12 @@
#ifndef _KIS_WDG_BLUR_H_
#define _KIS_WDG_BLUR_H_
#include <filter/kis_filter_config_widget.h>
#include <kis_config_widget.h>
class KisFilter;
class Ui_WdgBlur;
class KisWdgBlur : public KisFilterConfigWidget
class KisWdgBlur : public KisConfigWidget
{
Q_OBJECT
public:
......@@ -34,8 +34,8 @@ public:
inline const Ui_WdgBlur* widget() const {
return m_widget;
}
virtual void setConfiguration(KisFilterConfiguration*);
virtual KisFilterConfiguration* configuration() const;
virtual void setConfiguration(KisPropertiesConfiguration*);
virtual KisPropertiesConfiguration* configuration() const;
private slots:
......
......@@ -375,7 +375,7 @@ void KisFilterBumpmap::process(KisConstProcessingInformation srcInfo,
delete [] bm_row3;
}
KisFilterConfigWidget * KisFilterBumpmap::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image) const
KisConfigWidget * KisFilterBumpmap::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image) const
{
KisBumpmapConfigWidget * w = new KisBumpmapConfigWidget(dev, image, parent);
......@@ -384,7 +384,7 @@ KisFilterConfigWidget * KisFilterBumpmap::createConfigurationWidget(QWidget* par
KisBumpmapConfigWidget::KisBumpmapConfigWidget(const KisPaintDeviceSP dev, const KisImageSP image, QWidget * parent, Qt::WFlags f)
: KisFilterConfigWidget(parent, f)
: KisConfigWidget(parent, f)
, m_device(dev)
, m_image(image)
{
......@@ -406,7 +406,7 @@ KisBumpmapConfigWidget::KisBumpmapConfigWidget(const KisPaintDeviceSP dev, const
}
void KisBumpmapConfigWidget::setConfiguration(KisFilterConfiguration * cfg)
void KisBumpmapConfigWidget::setConfiguration(KisPropertiesConfiguration * cfg)
{
if (!cfg) return;
......@@ -439,7 +439,7 @@ void KisBumpmapConfigWidget::setConfiguration(KisFilterConfiguration * cfg)
}
}
KisFilterConfiguration* KisBumpmapConfigWidget::configuration() const
KisPropertiesConfiguration* KisBumpmapConfigWidget::configuration() const
{
KisFilterConfiguration * cfg = new KisFilterConfiguration("bumpmap", 2);
//cfg->setProperty("bumpmap", m_page->txtSourceLayer->text());
......
......@@ -27,7 +27,7 @@
#include <kis_types.h>
#include <filter/kis_filter.h>
#include "filter/kis_filter_config_widget.h"
#include "kis_config_widget.h"
#include "ui_wdgbumpmap.h"
......@@ -96,11 +96,11 @@ public:
return false;
}
virtual KisFilterConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisFilterConfiguration* factoryConfiguration(const KisPaintDeviceSP) const;
};
class KisBumpmapConfigWidget : public KisFilterConfigWidget
class KisBumpmapConfigWidget : public KisConfigWidget
{
Q_OBJECT
......@@ -109,8 +109,8 @@ public:
KisBumpmapConfigWidget(const KisPaintDeviceSP dev, const KisImageSP image, QWidget * parent, Qt::WFlags f = 0);
virtual ~KisBumpmapConfigWidget() {}
void setConfiguration(KisFilterConfiguration * config);
KisFilterConfiguration* configuration() const;
void setConfiguration(KisPropertiesConfiguration* config);
KisPropertiesConfiguration* configuration() const;
BumpmapWidget * m_page;
......
......@@ -712,7 +712,7 @@ bool KisCImgFilter::process()
return true;
}
KisFilterConfigWidget * KisCImgFilter::createConfigurationWidget(QWidget* parent, KisPaintDeviceSP, const KisImageSP) const
KisConfigWidget * KisCImgFilter::createConfigurationWidget(QWidget* parent, KisPaintDeviceSP, const KisImageSP) const
{
return new KisCImgconfigWidget(parent);
}
......@@ -726,6 +726,6 @@ KisFilterConfiguration* KisCImgFilter::configuration(QWidget* nwidget)
return cfg;
} else {
return widget->configuration();
return static_cast<KisFilterConfiguration*>(widget->configuration());
}
}
......@@ -22,7 +22,7 @@
#define _KIS_CIMG_FILTER_H_
#include "filter/kis_filter.h"
#include "filter/kis_filter_config_widget.h"
#include "kis_config_widget.h"
#include <filter/kis_filter_configuration.h>
#include <kis_selection.h>
#include <kis_paint_device.h>
......@@ -74,9 +74,9 @@ public:
}
public:
virtual KisFilterConfigWidget * createConfigurationWidget(QWidget* parent, KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisConfigWidget * createConfigurationWidget(QWidget* parent, KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisFilterConfiguration * configuration(QWidget*);
virtual KisFilterConfiguration * configuration() {
virtual KisPropertiesConfiguration * configuration() {
return new KisCImgFilterConfiguration();
}
private:
......
......@@ -32,7 +32,7 @@
#include "kis_cimg_filter.h"
KisCImgconfigWidget::KisCImgconfigWidget(QWidget * parent, Qt::WFlags f)
: KisFilterConfigWidget(parent, f)
: KisConfigWidget(parent, f)
{
m_page = new WdgCImg(this);
Q_CHECK_PTR(m_page);
......@@ -55,7 +55,7 @@ KisCImgconfigWidget::KisCImgconfigWidget(QWidget * parent, Qt::WFlags f)
}
KisFilterConfiguration* KisCImgconfigWidget::configuration() const
KisPropertiesConfiguration* KisCImgconfigWidget::configuration() const
{
KisCImgFilterConfiguration * cfg = new KisCImgFilterConfiguration();
Q_CHECK_PTR(cfg);
......@@ -75,7 +75,7 @@ KisFilterConfiguration* KisCImgconfigWidget::configuration() const
}
void KisCImgconfigWidget::setConfiguration(KisFilterConfiguration * config)
void KisCImgconfigWidget::setConfiguration(KisPropertiesConfiguration * config)
{
KisCImgFilterConfiguration * cfg = dynamic_cast<KisCImgFilterConfiguration*>(config);
if (!cfg) return;
......
......@@ -24,7 +24,7 @@
#include "ui_wdg_cimg.h"
#include "filter/kis_filter.h"
#include "filter/kis_filter_config_widget.h"
#include "kis_config_widget.h"
class WdgCImg : public QWidget, public Ui::WdgCImg
{
......@@ -36,7 +36,7 @@ public:
}
};
class KisCImgconfigWidget : public KisFilterConfigWidget
class KisCImgconfigWidget : public KisConfigWidget
{
Q_OBJECT
......@@ -48,8 +48,8 @@ public:
public:
KisFilterConfiguration* configuration() const;
void setConfiguration(KisFilterConfiguration * config);
KisPropertiesConfiguration* configuration() const;
void setConfiguration(KisPropertiesConfiguration* config);
private:
WdgCImg * m_page;
......
......@@ -44,7 +44,7 @@ KisFilterColorToAlpha::KisFilterColorToAlpha() : KisFilter(id(), CategoryColors,
setColorSpaceIndependence(FULLY_INDEPENDENT);
}
KisFilterConfigWidget * KisFilterColorToAlpha::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP, const KisImageSP image) const
KisConfigWidget * KisFilterColorToAlpha::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP, const KisImageSP image) const
{
Q_UNUSED(image);
return new KisWdgColorToAlpha(parent);
......
......@@ -45,7 +45,7 @@ public:
public:
virtual KisFilterConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisFilterConfiguration* factoryConfiguration(const KisPaintDeviceSP dev) const;
};
......
......@@ -33,7 +33,7 @@
#include "ui_wdgcolortoalphabase.h"
KisWdgColorToAlpha::KisWdgColorToAlpha(QWidget * parent) : KisFilterConfigWidget(parent)
KisWdgColorToAlpha::KisWdgColorToAlpha(QWidget * parent) : KisConfigWidget(parent)
{
m_widget = new Ui_WdgColorToAlphaBase();
m_widget->setupUi(this);
......@@ -41,7 +41,7 @@ KisWdgColorToAlpha::KisWdgColorToAlpha(QWidget * parent) : KisFilterConfigWidget
connect(m_widget->intThreshold, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
}
void KisWdgColorToAlpha::setConfiguration(KisFilterConfiguration* config)
void KisWdgColorToAlpha::setConfiguration(KisPropertiesConfiguration* config)
{
QVariant value;
if (config->getProperty("targetcolor", value)) {
......@@ -52,7 +52,7 @@ void KisWdgColorToAlpha::setConfiguration(KisFilterConfiguration* config)
}
}
KisFilterConfiguration* KisWdgColorToAlpha::configuration() const
KisPropertiesConfiguration* KisWdgColorToAlpha::configuration() const
{
KisFilterConfiguration* config = new KisFilterConfiguration("colortoalpha", 1);
config->setProperty("targetcolor", widget()->colorTarget->color());
......
......@@ -21,12 +21,12 @@
#ifndef _KIS_WDG_COLOR_TO_ALPHA_H_
#define _KIS_WDG_COLOR_TO_ALPHA_H_
#include <filter/kis_filter_config_widget.h>
#include <kis_config_widget.h>
class KisFilter;
class Ui_WdgColorToAlphaBase;
class KisWdgColorToAlpha : public KisFilterConfigWidget
class KisWdgColorToAlpha : public KisConfigWidget
{
Q_OBJECT
public:
......@@ -34,8 +34,8 @@ public:
inline const Ui_WdgColorToAlphaBase* widget() const {
return m_widget;
}
virtual void setConfiguration(KisFilterConfiguration*);
virtual KisFilterConfiguration* configuration() const;
virtual void setConfiguration(KisPropertiesConfiguration*);
virtual KisPropertiesConfiguration* configuration() const;
private:
Ui_WdgColorToAlphaBase* m_widget;
};
......
......@@ -40,7 +40,7 @@
#include "KoColorTransformation.h"
#include "KoCompositeOp.h"
#include "filter/kis_filter_config_widget.h"
#include "kis_config_widget.h"
#include "kis_bookmarked_configuration_manager.h"
#include "kis_paint_device.h"
......@@ -169,7 +169,7 @@ KisBrightnessContrastFilter::KisBrightnessContrastFilter()
}
KisFilterConfigWidget * KisBrightnessContrastFilter::createConfigurationWidget(QWidget *parent, const KisPaintDeviceSP dev, const KisImageSP image) const
KisConfigWidget * KisBrightnessContrastFilter::createConfigurationWidget(QWidget *parent, const KisPaintDeviceSP dev, const KisImageSP image) const
{
Q_UNUSED(image);
return new KisBrightnessContrastConfigWidget(parent, dev);
......@@ -272,7 +272,7 @@ void KisBrightnessContrastFilter::process(KisConstProcessingInformation srcInfo,
}
KisBrightnessContrastConfigWidget::KisBrightnessContrastConfigWidget(QWidget * parent, KisPaintDeviceSP dev, Qt::WFlags f)
: KisFilterConfigWidget(parent, f)
: KisConfigWidget(parent, f)
{
int i;
int height;
......@@ -356,7 +356,7 @@ KisBrightnessContrastFilterConfiguration * KisBrightnessContrastConfigWidget::co
return cfg;
}
void KisBrightnessContrastConfigWidget::setConfiguration(KisFilterConfiguration * config)
void KisBrightnessContrastConfigWidget::setConfiguration(KisPropertiesConfiguration * config)
{
KisBrightnessContrastFilterConfiguration * cfg = dynamic_cast<KisBrightnessContrastFilterConfiguration *>(config);
Q_ASSERT(cfg);
......
......@@ -24,7 +24,7 @@
#include <QList>
#include "filter/kis_filter.h"
#include "filter/kis_filter_config_widget.h"
#include "kis_config_widget.h"
#include "ui_wdg_brightness_contrast.h"
#include <filter/kis_filter_configuration.h>
#include <kis_selection.h>
......@@ -85,8 +85,8 @@ public:
}
virtual KisFilterConfiguration* factoryConfiguration(const KisPaintDeviceSP) const;
virtual KisFilterConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisFilterConfiguration * configuration() {
virtual KisConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image = 0) const;
virtual KisPropertiesConfiguration * configuration() {
return new KisBrightnessContrastFilterConfiguration();
}
......@@ -94,7 +94,7 @@ public:
};
class KisBrightnessContrastConfigWidget : public KisFilterConfigWidget
class KisBrightnessContrastConfigWidget : public KisConfigWidget
{
public:
......@@ -102,7 +102,7 @@ public:
virtual ~KisBrightnessContrastConfigWidget() {}
virtual KisBrightnessContrastFilterConfiguration * configuration() const;
virtual void setConfiguration(KisFilterConfiguration * config);
virtual void setConfiguration(KisPropertiesConfiguration* config);
WdgBrightnessContrast * m_page;
};
......
......@@ -35,7 +35,7 @@ KisHSVAdjustmentFilter::KisHSVAdjustmentFilter()
setSupportsIncrementalPainting(false);
}
KisFilterConfigWidget * KisHSVAdjustmentFilter::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image) const
KisConfigWidget * KisHSVAdjustmentFilter::createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, const KisImageSP image) const
{
Q_UNUSED(dev);
Q_UNUSED(image);
......@@ -99,7 +99,7 @@ KisFilterConfiguration* KisHSVAdjustmentFilter::factoryConfiguration(const KisPa
}
KisHSVConfigWidget::KisHSVConfigWidget(QWidget * parent, Qt::WFlags f) : KisFilterConfigWidget(parent, f)
KisHSVConfigWidget::KisHSVConfigWidget(QWidget * parent, Qt::WFlags f) : KisConfigWidget(parent, f)
{
m_page = new Ui_WdgHSVAdjustment();
m_page->setupUi(this);
......@@ -113,7 +113,7 @@ KisHSVConfigWidget::~KisHSVConfigWidget()
delete m_page;
}
KisFilterConfiguration * KisHSVConfigWidget::configuration() const
KisPropertiesConfiguration * KisHSVConfigWidget::configuration() const
{
KisFilterConfiguration* c = new KisFilterConfiguration(KisHSVAdjustmentFilter::id().id(), 0);
c->setProperty("h", m_page->hue->value());
......@@ -122,7 +122,7 @@ KisFilterConfiguration * KisHSVConfigWidget::configuration() const
return c;
}
void KisHSVConfigWidget::setConfiguration(KisFilterConfiguration * config)
void KisHSVConfigWidget::setConfiguration(KisPropertiesConfiguration * config)
{
m_page->hue->setValue(config->getInt("h", 0));
m_page->saturation->setValue(config->getInt("s", 0));
......