Commit 15d14c2a authored by Boudewijn Rempt's avatar Boudewijn Rempt

Extract the preview timer logic from the filter dialog and put in the base config widget

svn path=/trunk/koffice/; revision=853929
parent 4d13a95e
This diff is collapsed.
......@@ -15,16 +15,30 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QTimer>
#include "kis_config_widget.h"
KisConfigWidget::KisConfigWidget(QWidget * parent, Qt::WFlags f)
: QWidget(parent, f)
{
m_timer.setSingleShot(true);
connect(&m_timer, SIGNAL(timeout()), SLOT(slotConfigChanged()));
connect(this, SIGNAL(sigConfigChanged()), SLOT(kickTimer()));
}
KisConfigWidget::~KisConfigWidget()
{
}
void KisConfigWidget::slotConfigChanged()
{
emit sigPleaseUpdatePreview();
}
void KisConfigWidget::kickTimer()
{
m_timer.start(50);
}
#include "kis_config_widget.moc"
......@@ -22,16 +22,21 @@
#include <QWidget>
#include <krita_export.h>
#include <QTimer>
class KisPropertiesConfiguration;
/**
* 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.
* The configuration widget should emit sigConfigChanged
* when it wants a preview updated; there is a timer that
* waits a little time to see if there are more changes coming
* and then emits sigPleaseUpdatePreview.
*
* Also, this class is designed to have a single instance of a certain configuration
* widget that can be reset and unset
* Also, this class is designed to have a single instance
* of a certain configuration widget that can be reset and
* unset
*/
class KRITAIMAGE_EXPORT KisConfigWidget : public QWidget
{
......@@ -58,10 +63,25 @@ public:
signals:
/**
* Subclasses should emit this signal whenever the preview should be
* be recalculated.
* emitted whenever it makes sense to update the preview
*/
void sigPleaseUpdatePreview();
/**
* Subclasses should emit this signal whenever the preview should be
* be recalculated. This kicks of a timer, so it's perfectly fine
* to connect this to the changed signals of the widgets in your configuration
* widget.
*/
void sigConfigChanged();
private slots:
void slotConfigChanged();
void kickTimer();
private:
QTimer m_timer;
};
......
......@@ -46,9 +46,9 @@ KisWdgBlur::KisWdgBlur(QWidget * parent) : KisConfigWidget(parent)
connect(widget()->intHalfWidth, SIGNAL(valueChanged(int)), this, SLOT(spinBoxHalfWidthChanged(int)));
connect(widget()->intHalfHeight, SIGNAL(valueChanged(int)), this, SLOT(spinBoxHalfHeightChanged(int)));
connect(widget()->intStrength, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intAngle, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->cbShape, SIGNAL(activated(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intStrength, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intAngle, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->cbShape, SIGNAL(activated(int)), SIGNAL(sigConfigChanged()));
}
KisPropertiesConfiguration* KisWdgBlur::configuration() const
......@@ -102,7 +102,7 @@ void KisWdgBlur::spinBoxHalfWidthChanged(int v)
widget()->intAngle->setEnabled(false);
else
widget()->intAngle->setEnabled(true);*/
emit sigPleaseUpdatePreview();
emit sigConfigChanged();
}
void KisWdgBlur::spinBoxHalfHeightChanged(int v)
......@@ -114,7 +114,7 @@ void KisWdgBlur::spinBoxHalfHeightChanged(int v)
widget()->intAngle->setEnabled(false);
else
widget()->intAngle->setEnabled(true);*/
emit sigPleaseUpdatePreview();
emit sigConfigChanged();
}
#include "kis_wdg_blur.moc"
......@@ -42,16 +42,16 @@ KisCImgconfigWidget::KisCImgconfigWidget(QWidget * parent, Qt::WFlags f)
l->addWidget(m_page);
connect(m_page->numDetail, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->numGradient, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->numTimeStep, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->numBlur, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->numBlurIterations, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->numAngularStep, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->numIntegralStep, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->numGaussian, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->chkLinearInterpolation, SIGNAL(toggled(bool)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->chkNormalize, SIGNAL(toggled(bool)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->numDetail, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(m_page->numGradient, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(m_page->numTimeStep, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(m_page->numBlur, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(m_page->numBlurIterations, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(m_page->numAngularStep, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(m_page->numIntegralStep, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(m_page->numGaussian, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(m_page->chkLinearInterpolation, SIGNAL(toggled(bool)), SIGNAL(sigConfigChanged()));
connect(m_page->chkNormalize, SIGNAL(toggled(bool)), SIGNAL(sigConfigChanged()));
}
......
......@@ -37,8 +37,8 @@ KisWdgColorToAlpha::KisWdgColorToAlpha(QWidget * parent) : KisConfigWidget(paren
{
m_widget = new Ui_WdgColorToAlphaBase();
m_widget->setupUi(this);
connect(m_widget->colorTarget, SIGNAL(changed(const QColor&)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_widget->intThreshold, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_widget->colorTarget, SIGNAL(changed(const QColor&)), SIGNAL(sigConfigChanged()));
connect(m_widget->intThreshold, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
}
void KisWdgColorToAlpha::setConfiguration(KisPropertiesConfiguration* config)
......
......@@ -290,7 +290,7 @@ KisBrightnessContrastConfigWidget::KisBrightnessContrastConfigWidget(QWidget * p
l->addWidget(m_page, 0, Qt::AlignTop);
height = 256;
connect(m_page->kCurve, SIGNAL(modified()), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->kCurve, SIGNAL(modified()), SIGNAL(sigConfigChanged()));
// Create the horizontal gradient label
QPixmap hgradientpix(256, 1);
......
......@@ -103,9 +103,9 @@ KisHSVConfigWidget::KisHSVConfigWidget(QWidget * parent, Qt::WFlags f) : KisConf
{
m_page = new Ui_WdgHSVAdjustment();
m_page->setupUi(this);
connect(m_page->hue, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->value, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->saturation, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->hue, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(m_page->value, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(m_page->saturation, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
}
KisHSVConfigWidget::~KisHSVConfigWidget()
......
......@@ -356,7 +356,7 @@ KisPerChannelConfigWidget::KisPerChannelConfigWidget(QWidget * parent, KisPaintD
l->addWidget(m_page);
height = 256;
connect(m_page->kCurve, SIGNAL(modified()), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page->kCurve, SIGNAL(modified()), SIGNAL(sigConfigChanged()));
// Fill in the channel chooser
QList<KoChannelInfo *> channels = dev->colorSpace()->channels();
......
......@@ -31,7 +31,7 @@ KisWdgFastColorTransfer::KisWdgFastColorTransfer(QWidget * parent) : KisConfigWi
{
m_widget = new Ui_WdgFastColorTransfer();
m_widget->setupUi(this);
connect(m_widget->fileNameURLRequester, SIGNAL(textChanged(const QString&)), this, SIGNAL(sigPleaseUpdatePreview()));
connect(m_widget->fileNameURLRequester, SIGNAL(textChanged(const QString&)), this, SIGNAL(sigConfigChanged()));
}
......
......@@ -34,11 +34,11 @@ KisWdgLensCorrection::KisWdgLensCorrection(KisFilter* /*nfilter*/, QWidget* pare
m_widget = new Ui_WdgLensCorrectionOptions();
m_widget->setupUi(this);
connect(widget()->intXCenter, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intYCenter, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->dblCorrectionNearCenter, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->dblCorrectionNearEdges, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->dblBrightness, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intXCenter, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intYCenter, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->dblCorrectionNearCenter, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(widget()->dblCorrectionNearEdges, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(widget()->dblBrightness, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
}
KisWdgLensCorrection::~KisWdgLensCorrection()
......
......@@ -188,9 +188,9 @@ KisLevelConfigWidget::KisLevelConfigWidget(QWidget * parent, KisPaintDeviceSP de
m_page.outblackspin->setValue(0);
m_page.outwhitespin->setValue(255);
connect(m_page.blackspin, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page.whitespin, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page.ingradient, SIGNAL(modifiedGamma(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page.blackspin, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(m_page.whitespin, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(m_page.ingradient, SIGNAL(modifiedGamma(double)), SIGNAL(sigConfigChanged()));
connect(m_page.blackspin, SIGNAL(valueChanged(int)), m_page.ingradient, SLOT(modifyBlack(int)));
connect(m_page.whitespin, SIGNAL(valueChanged(int)), m_page.ingradient, SLOT(modifyWhite(int)));
......@@ -201,8 +201,8 @@ KisLevelConfigWidget::KisLevelConfigWidget(QWidget * parent, KisPaintDeviceSP de
connect(m_page.ingradient, SIGNAL(modifiedGamma(double)), m_page.gammaspin, SLOT(setNum(double)));
connect(m_page.outblackspin, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page.outwhitespin, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_page.outblackspin, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(m_page.outwhitespin, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(m_page.outblackspin, SIGNAL(valueChanged(int)), m_page.outgradient, SLOT(modifyBlack(int)));
connect(m_page.outwhitespin, SIGNAL(valueChanged(int)), m_page.outgradient, SLOT(modifyWhite(int)));
......
......@@ -35,8 +35,8 @@ KisWdgNoise::KisWdgNoise(KisFilter* /*nfilter*/, QWidget* parent)
m_widget = new Ui_WdgNoiseOptions();
m_widget->setupUi(this);
connect(widget()->intLevel, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intOpacity, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intLevel, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intOpacity, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
m_seedThreshold = rand();
m_seedRed = rand();
m_seedGreen = rand();
......
......@@ -35,9 +35,9 @@ KisWdgRandomPick::KisWdgRandomPick(KisFilter* /*nfilter*/, QWidget* parent)
m_widget = new Ui_WdgRandomPickOptions();
m_widget->setupUi(this);
connect(widget()->intLevel, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intWindowSize, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intOpacity, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intLevel, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intWindowSize, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intOpacity, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
m_seedH = rand();
m_seedV = rand();
m_seedThreshold = rand();
......
......@@ -36,9 +36,9 @@ KisWdgUnsharp::KisWdgUnsharp(QWidget * parent) : KisConfigWidget(parent)
m_widget = new Ui_WdgUnsharp();
m_widget->setupUi(this);
connect(widget()->intHalfSize, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->doubleAmount, SIGNAL(valueChanged(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intThreshold, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intHalfSize, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->doubleAmount, SIGNAL(valueChanged(double)), SIGNAL(sigConfigChanged()));
connect(widget()->intThreshold, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
}
void KisWdgUnsharp::setConfiguration(KisPropertiesConfiguration* config)
......
......@@ -32,14 +32,14 @@ KisWdgWave::KisWdgWave(KisFilter* /*nfilter*/, QWidget* parent)
m_widget = new Ui_WdgWaveOptions();
m_widget->setupUi(this);
connect(widget()->intHWavelength, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intHShift, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intHAmplitude, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->cbHShape, SIGNAL(activated(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intVWavelength, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intVShift, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intVAmplitude, SIGNAL(valueChanged(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->cbVShape, SIGNAL(activated(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(widget()->intHWavelength, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intHShift, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intHAmplitude, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->cbHShape, SIGNAL(activated(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intVWavelength, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intVShift, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->intVAmplitude, SIGNAL(valueChanged(int)), SIGNAL(sigConfigChanged()));
connect(widget()->cbVShape, SIGNAL(activated(int)), SIGNAL(sigConfigChanged()));
}
KisWdgWave::~KisWdgWave()
......
......@@ -89,7 +89,6 @@ void KisAutoBrushWidget::paramChanged()
}
m_autoBrush = new KisAutoBrush(kas);
kDebug() << m_autoBrush;
m_brush = m_autoBrush->img();
......@@ -109,7 +108,6 @@ void KisAutoBrushWidget::paramChanged()
QPixmap p = QPixmap::fromImage(pi);
brushPreview->setIcon(QIcon(p));
kDebug() << m_autoBrush;
}
void KisAutoBrushWidget::spinBoxWidthChanged(int a)
{
......@@ -168,8 +166,6 @@ void KisAutoBrushWidget::linkFadeToggled(bool b)
KisBrushSP KisAutoBrushWidget::brush()
{
kDebug() << this;
kDebug() << m_autoBrush;
return m_autoBrush;
}
......
* make base settings widget with preview signal and use that in all paintop settings
* make paintop settings not own widget, but load/save from a single widget created by the factory
* refactor kisbrush based paintops to share the brush selector and various pressure curve responses through libpaintop
* move filter setting into libpaintop
* move paintop preview code to preset
......
......@@ -50,7 +50,7 @@ signals:
* Subclasses should emit this signal whenever the preview should be
* be recalculated.
*/
void sigPleaseUpdatePreview();
void sigConfigChanged();
};
......
......@@ -20,8 +20,6 @@
#include "kis_dlg_filter.h"
#include <QTimer>
// From krita/image
#include <filter/kis_filter.h>
#include <filter/kis_filter_configuration.h>
......@@ -44,7 +42,6 @@ struct KisFilterDialog::Private {
Ui_FilterDialog uiFilterDialog;
KisFilterMaskSP mask;
KisNodeSP node;
QTimer timer;
KisImageSP image;
};
......@@ -74,7 +71,7 @@ KisFilterDialog::KisFilterDialog(QWidget* parent, KisNodeSP node, KisImageSP ima
}
d->uiFilterDialog.filterSelection->setPaintDevice(d->node->paintDevice());
d->uiFilterDialog.filterSelection->setImage(d->image);
d->timer.setSingleShot(true);
connect(d->uiFilterDialog.pushButtonOk, SIGNAL(pressed()), SLOT(accept()));
connect(d->uiFilterDialog.pushButtonOk, SIGNAL(pressed()), SLOT(close()));
connect(d->uiFilterDialog.pushButtonOk, SIGNAL(pressed()), SLOT(apply()));
......@@ -82,9 +79,8 @@ KisFilterDialog::KisFilterDialog(QWidget* parent, KisNodeSP node, KisImageSP ima
connect(d->uiFilterDialog.pushButtonCancel, SIGNAL(pressed()), SLOT(close()));
connect(d->uiFilterDialog.pushButtonCancel, SIGNAL(pressed()), SLOT(reject()));
connect(d->uiFilterDialog.filterSelection, SIGNAL(configurationChanged()), SLOT(updatePreview()));
connect(d->uiFilterDialog.filterSelection, SIGNAL(configurationChanged()), SLOT(kickTimer()));
connect(&d->timer, SIGNAL(timeout()), SLOT(updatePreview()));
}
KisFilterDialog::~KisFilterDialog()
......@@ -140,9 +136,5 @@ void KisFilterDialog::createMask()
}
}
void KisFilterDialog::kickTimer()
{
d->timer.start(50);
}
#include "kis_dlg_filter.moc"
......@@ -52,10 +52,6 @@ protected slots:
void createMask();
private slots:
void kickTimer();
signals:
void sigPleaseApplyFilter(KisNodeSP, KisFilterConfiguration*);
......
......@@ -50,7 +50,7 @@ KisMultiBoolFilterWidget::KisMultiBoolFilterWidget(const QString & filterid, QWi
cb->setObjectName(iwparam[i].name);
cb->setChecked(iwparam[i].initvalue);
cb->setText(iwparam[i].label);
connect(cb, SIGNAL(toggled(bool)), SIGNAL(sigPleaseUpdatePreview()));
connect(cb, SIGNAL(toggled(bool)), SIGNAL(sigConfigChanged()));
widgetLayout->addWidget(cb);
m_boolWidgets.append(cb);
}
......
......@@ -81,7 +81,7 @@ KisMultiDoubleFilterWidget::KisMultiDoubleFilterWidget(const QString & filterid,
m_doubleWidgets[i]->setValue(dwparam[i].initvalue);
m_doubleWidgets[i]->cancelDelayedSignal();
connect(m_doubleWidgets[i], SIGNAL(valueChangedDelayed(double)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_doubleWidgets[i], SIGNAL(valueChangedDelayed(double)), SIGNAL(sigConfigChanged()));
QLabel* lbl = new QLabel(dwparam[i].label + ':', this);
widgetLayout->addWidget(lbl, i , 0);
......
......@@ -79,7 +79,7 @@ KisMultiIntegerFilterWidget::KisMultiIntegerFilterWidget(const QString & filteri
m_integerWidgets[i]->setValue(iwparam[i].initvalue);
m_integerWidgets[i]->cancelDelayedSignal();
connect(m_integerWidgets[i], SIGNAL(valueChangedDelayed(int)), SIGNAL(sigPleaseUpdatePreview()));
connect(m_integerWidgets[i], SIGNAL(valueChangedDelayed(int)), SIGNAL(sigConfigChanged()));
QLabel* lbl = new QLabel(iwparam[i].label + ':', this);
widgetLayout->addWidget(lbl, i , 0);
......
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