[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [digikam] /: Add "Color Effects" (solarize, vivid, neon, find edges) to the list of batch queue mana
From:       Alexander Dymo <adymo () kdevelop ! org>
Date:       2012-11-16 6:56:52
Message-ID: 20121116065652.3B3EFA6091 () git ! kde ! org
[Download RAW message or body]

Git commit 414b3341e244e8241bc02a4e6d6a09e9e43ea0d0 by Alexander Dymo.
Committed on 08/11/2012 at 14:51.
Pushed by dymo into branch 'master'.

Add "Color Effects" (solarize, vivid, neon, find edges) to the list of batch queue manager tools.
Refactor the code to extract color effects settings widget into its own class
and use that in both color effects tool and queuemanager filter.

M  +1    -0    CMakeLists.txt
M  +1    -1    imageplugins/TODO
M  +21   -189  imageplugins/filters/colorfxtool.cpp
M  +0    -1    imageplugins/filters/colorfxtool.h
M  +13   -15   libs/dimg/filters/fx/colorfxfilter.cpp
M  +25   -5    libs/dimg/filters/fx/colorfxfilter.h
A  +276  -0    libs/dimg/filters/fx/colorfxsettings.cpp     [License: GPL (v2+)]
A  +81   -0    libs/dimg/filters/fx/colorfxsettings.h     [License: GPL (v2+)]
M  +1    -0    utilities/queuemanager/CMakeLists.txt
A  +113  -0    utilities/queuemanager/basetools/filters/colorfx.cpp     [License: GPL (v2+)]
A  +62   -0    utilities/queuemanager/basetools/filters/colorfx.h     [License: GPL (v2+)]
M  +2    -0    utilities/queuemanager/manager/batchtoolsmanager.cpp

http://commits.kde.org/digikam/414b3341e244e8241bc02a4e6d6a09e9e43ea0d0

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f13c40..3dcef22 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -861,6 +861,7 @@ IF(DIGIKAM_CAN_BE_COMPILED)
         ${CMAKE_CURRENT_SOURCE_DIR}/libs/dimg/filters/fx/blurfilter.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/libs/dimg/filters/fx/blurfxfilter.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/libs/dimg/filters/fx/colorfxfilter.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/libs/dimg/filters/fx/colorfxsettings.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/libs/dimg/filters/fx/distortionfxfilter.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/libs/dimg/filters/fx/charcoalfilter.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/libs/dimg/filters/fx/embossfilter.cpp
diff --git a/imageplugins/TODO b/imageplugins/TODO
index e7e20a8..39b58e7 100644
--- a/imageplugins/TODO
+++ b/imageplugins/TODO
@@ -23,7 +23,7 @@ decorate
   /texture                  DONE                 DONE                  TODO
 
 filters
-  /colorfx                  TODO                 TODO                  TODO
+  /colorfx                  TODO                 TODO                  DONE
   /charcoal                 DONE                 DONE                  TODO
   /distortionfx             DONE                 TODO                  TODO
   /emboss                   DONE                 DONE                  TODO
diff --git a/imageplugins/filters/colorfxtool.cpp b/imageplugins/filters/colorfxtool.cpp
index 10a3d67..8f2758e 100644
--- a/imageplugins/filters/colorfxtool.cpp
+++ b/imageplugins/filters/colorfxtool.cpp
@@ -54,15 +54,11 @@
 #include <kstandarddirs.h>
 #include <kvbox.h>
 
-// LibKDcraw includes
-
-#include <libkdcraw/rcombobox.h>
-#include <libkdcraw/rnuminput.h>
-
 // Local includes
 
 #include "dimg.h"
 #include "colorfxfilter.h"
+#include "colorfxsettings.h"
 #include "editortoolsettings.h"
 #include "histogrambox.h"
 #include "histogramwidget.h"
@@ -81,42 +77,23 @@ class ColorFxTool::Private
 public:
 
     Private() :
-        effectTypeLabel(0),
-        levelLabel(0),
-        iterationLabel(0),
-        effectType(0),
-        levelInput(0),
-        iterationInput(0),
         previewWidget(0),
-        gboxSettings(0)
+        gboxSettings(0),
+        settingsView(0)
     {}
 
     static const QString configGroupName;
     static const QString configHistogramChannelEntry;
     static const QString configHistogramScaleEntry;
-    static const QString configEffectTypeEntry;
-    static const QString configLevelAdjustmentEntry;
-    static const QString configIterationAdjustmentEntry;
-
-    QLabel*              effectTypeLabel;
-    QLabel*              levelLabel;
-    QLabel*              iterationLabel;
-
-    RComboBox*           effectType;
-
-    RIntNumInput*        levelInput;
-    RIntNumInput*        iterationInput;
 
     ImageGuideWidget*    previewWidget;
     EditorToolSettings*  gboxSettings;
+    ColorFXSettings*     settingsView;
 };
 
 const QString ColorFxTool::Private::configGroupName("coloreffect Tool");
 const QString ColorFxTool::Private::configHistogramChannelEntry("Histogram Channel");
 const QString ColorFxTool::Private::configHistogramScaleEntry("Histogram Scale");
-const QString ColorFxTool::Private::configEffectTypeEntry("EffectType");
-const QString ColorFxTool::Private::configLevelAdjustmentEntry("LevelAdjustment");
-const QString ColorFxTool::Private::configIterationAdjustmentEntry("IterationAdjustment");
 
 // --------------------------------------------------------
 
@@ -143,49 +120,7 @@ ColorFxTool::ColorFxTool(QObject* const parent)
 
     // -------------------------------------------------------------
 
-    d->effectTypeLabel = new QLabel(i18n("Type:"));
-    d->effectType      = new RComboBox();
-    d->effectType->addItem(i18n("Solarize"));
-    d->effectType->addItem(i18n("Vivid"));
-    d->effectType->addItem(i18n("Neon"));
-    d->effectType->addItem(i18n("Find Edges"));
-    d->effectType->setDefaultIndex(ColorFXFilter::Solarize);
-    d->effectType->setWhatsThis(i18n("<p>Select the effect type to apply to the image here.</p>"
-                                     "<p><b>Solarize</b>: simulates solarization of photograph.</p>"
-                                     "<p><b>Vivid</b>: simulates the Velvia(tm) slide film colors.</p>"
-                                     "<p><b>Neon</b>: coloring the edges in a photograph to "
-                                     "reproduce a fluorescent light effect.</p>"
-                                     "<p><b>Find Edges</b>: detects the edges in a photograph "
-                                     "and their strength.</p>"));
-
-    d->levelLabel = new QLabel(i18nc("level of the effect", "Level:"));
-    d->levelInput = new RIntNumInput();
-    d->levelInput->setRange(0, 100, 1);
-    d->levelInput->setSliderEnabled(true);
-    d->levelInput->setDefaultValue(0);
-    d->levelInput->setWhatsThis( i18n("Set here the level of the effect."));
-
-    d->iterationLabel = new QLabel(i18n("Iteration:"));
-    d->iterationInput = new RIntNumInput();
-    d->iterationInput->setRange(0, 100, 1);
-    d->iterationInput->setSliderEnabled(true);
-    d->iterationInput->setDefaultValue(0);
-    d->iterationInput->setWhatsThis( i18n("This value controls the number of iterations "
-                                          "to use with the Neon and Find Edges effects."));
-
-    // -------------------------------------------------------------
-
-    QGridLayout* mainLayout = new QGridLayout();
-    mainLayout->addWidget(d->effectTypeLabel, 0, 0, 1, 5);
-    mainLayout->addWidget(d->effectType,      1, 0, 1, 5);
-    mainLayout->addWidget(d->levelLabel,      2, 0, 1, 5);
-    mainLayout->addWidget(d->levelInput,      3, 0, 1, 5);
-    mainLayout->addWidget(d->iterationLabel,  4, 0, 1, 5);
-    mainLayout->addWidget(d->iterationInput,  5, 0, 1, 5);
-    mainLayout->setRowStretch(6, 10);
-    mainLayout->setMargin(d->gboxSettings->spacingHint());
-    mainLayout->setSpacing(d->gboxSettings->spacingHint());
-    d->gboxSettings->plainPage()->setLayout(mainLayout);
+    d->settingsView = new ColorFXSettings(d->gboxSettings->plainPage());
 
     // -------------------------------------------------------------
 
@@ -197,17 +132,13 @@ ColorFxTool::ColorFxTool(QObject* const parent)
     connect(d->previewWidget, SIGNAL(spotPositionChangedFromTarget(Digikam::DColor,QPoint)),
             this, SLOT(slotColorSelectedFromTarget(Digikam::DColor)));
 
-    connect(d->levelInput, SIGNAL(valueChanged(int)),
-            this, SLOT(slotTimer()));
-
-    connect(d->iterationInput, SIGNAL(valueChanged(int)),
-            this, SLOT(slotTimer()));
-
     connect(d->previewWidget, SIGNAL(signalResized()),
             this, SLOT(slotPreview()));
 
-    connect(d->effectType, SIGNAL(activated(int)),
-            this, SLOT(slotEffectTypeChanged(int)));
+    connect(d->settingsView, SIGNAL(signalSettingsChanged()),
+            this, SLOT(slotPreview()));
+    connect(d->settingsView, SIGNAL(signalLevelOrIterationChanged()),
+            this, SLOT(slotTimer()));
 }
 
 ColorFxTool::~ColorFxTool()
@@ -225,10 +156,7 @@ void ColorFxTool::readSettings()
     d->gboxSettings->histogramBox()->setScale((HistogramScale)group.readEntry(d->configHistogramScaleEntry,
  (int)LogScaleHistogram));
 
-    d->effectType->setCurrentIndex(group.readEntry(d->configEffectTypeEntry,       \
                d->effectType->defaultIndex()));
-    d->levelInput->setValue(group.readEntry(d->configLevelAdjustmentEntry,         \
                d->levelInput->defaultValue()));
-    d->iterationInput->setValue(group.readEntry(d->configIterationAdjustmentEntry, \
                d->iterationInput->defaultValue()));
-    slotEffectTypeChanged(d->effectType->currentIndex());  //check for enable/disable of iteration
+    d->settingsView->readSettings(group);
 }
 
 void ColorFxTool::writeSettings()
@@ -239,27 +167,14 @@ void ColorFxTool::writeSettings()
     group.writeEntry(d->configHistogramChannelEntry,    \
                (int)d->gboxSettings->histogramBox()->channel());
     group.writeEntry(d->configHistogramScaleEntry,      (int)d->gboxSettings->histogramBox()->scale());
 
-    group.writeEntry(d->configEffectTypeEntry,          d->effectType->currentIndex());
-    group.writeEntry(d->configLevelAdjustmentEntry,     d->levelInput->value());
-    group.writeEntry(d->configIterationAdjustmentEntry, d->iterationInput->value());
+    d->settingsView->writeSettings(group);
 
     group.sync();
 }
 
 void ColorFxTool::slotResetSettings()
 {
-    d->effectType->blockSignals(true);
-    d->levelInput->blockSignals(true);
-    d->iterationInput->blockSignals(true);
-
-    d->effectType->slotReset();
-    d->levelInput->slotReset();
-    d->iterationInput->slotReset();
-
-    d->effectType->blockSignals(false);
-    d->levelInput->blockSignals(false);
-    d->iterationInput->blockSignals(false);
-
+    d->settingsView->resetToDefault();
     slotPreview();
 }
 
@@ -268,88 +183,25 @@ void ColorFxTool::slotColorSelectedFromTarget(const DColor& color)
     d->gboxSettings->histogramBox()->histogram()->setHistogramGuideByColor(color);
 }
 
-void ColorFxTool::slotEffectTypeChanged(int type)
-{
-    d->levelInput->setEnabled(true);
-    d->levelLabel->setEnabled(true);
-
-    d->levelInput->blockSignals(true);
-    d->iterationInput->blockSignals(true);
-    d->levelInput->setRange(0, 100, 1);
-    d->levelInput->setSliderEnabled(true);
-    d->levelInput->setValue(25);
-
-    switch (type)
-    {
-        case ColorFXFilter::Solarize:
-            d->levelInput->setRange(0, 100, 1);
-            d->levelInput->setSliderEnabled(true);
-            d->levelInput->setValue(0);
-            d->iterationInput->setEnabled(false);
-            d->iterationLabel->setEnabled(false);
-            break;
-
-        case ColorFXFilter::Vivid:
-            d->levelInput->setRange(0, 50, 1);
-            d->levelInput->setSliderEnabled(true);
-            d->levelInput->setValue(5);
-            d->iterationInput->setEnabled(false);
-            d->iterationLabel->setEnabled(false);
-            break;
-
-        case ColorFXFilter::Neon:
-        case ColorFXFilter::FindEdges:
-            d->levelInput->setRange(0, 5, 1);
-            d->levelInput->setSliderEnabled(true);
-            d->levelInput->setValue(3);
-            d->iterationInput->setEnabled(true);
-            d->iterationLabel->setEnabled(true);
-            d->iterationInput->setRange(0, 5, 1);
-            d->iterationInput->setSliderEnabled(true);
-            d->iterationInput->setValue(2);
-            break;
-    }
-
-    d->levelInput->blockSignals(false);
-    d->iterationInput->blockSignals(false);
-
-    slotPreview();
-}
-
 void ColorFxTool::preparePreview()
 {
-    d->effectTypeLabel->setEnabled(false);
-    d->effectType->setEnabled(false);
-    d->levelInput->setEnabled(false);
-    d->levelLabel->setEnabled(false);
-    d->iterationInput->setEnabled(false);
-    d->iterationLabel->setEnabled(false);
-
-    int l                   = d->levelInput->value();
-    int f                   = d->iterationInput->value();
-    int e                   = d->effectType->currentIndex();
+    d->settingsView->disable();
+    ColorFXContainer prm = d->settingsView->settings();
+
     ImageIface* const iface = d->previewWidget->imageIface();
     DImg image              = iface->preview();
 
-    setFilter(new ColorFXFilter(&image, this, e, l, f));
+    setFilter(new ColorFXFilter(&image, this, prm));
 }
 
 void ColorFxTool::prepareFinal()
 {
-    d->effectTypeLabel->setEnabled(false);
-    d->effectType->setEnabled(false);
-    d->levelInput->setEnabled(false);
-    d->levelLabel->setEnabled(false);
-    d->iterationInput->setEnabled(false);
-    d->iterationLabel->setEnabled(false);
-
-    int l = d->levelInput->value();
-    int f = d->iterationInput->value();
-    int e = d->effectType->currentIndex();
+    d->settingsView->disable();
+    ColorFXContainer prm = d->settingsView->settings();
 
     ImageIface iface;
 
-    setFilter(new ColorFXFilter(iface.original(), this, e, l, f));
+    setFilter(new ColorFXFilter(iface.original(), this, prm));
 }
 
 void ColorFxTool::setPreviewImage()
@@ -369,7 +221,7 @@ void ColorFxTool::setFinalImage()
 
     QString name;
 
-    switch (d->effectType->currentIndex())
+    switch (d->settingsView->settings().colorFXType)
     {
         case ColorFXFilter::Solarize:
             name = i18n("Solarize");
@@ -393,27 +245,7 @@ void ColorFxTool::setFinalImage()
 
 void ColorFxTool::renderingFinished()
 {
-    d->effectTypeLabel->setEnabled(true);
-    d->effectType->setEnabled(true);
-    d->levelInput->setEnabled(true);
-    d->levelLabel->setEnabled(true);
-    d->iterationInput->setEnabled(true);
-    d->iterationLabel->setEnabled(true);
-
-    switch (d->effectType->currentIndex())
-    {
-        case ColorFXFilter::Solarize:
-        case ColorFXFilter::Vivid:
-            d->iterationInput->setEnabled(false);
-            d->iterationLabel->setEnabled(false);
-            break;
-
-        case ColorFXFilter::Neon:
-        case ColorFXFilter::FindEdges:
-            d->iterationInput->setEnabled(true);
-            d->iterationLabel->setEnabled(true);
-            break;
-    }
+    d->settingsView->enable();
 }
 
 }  // namespace DigikamFxFiltersImagePlugin
diff --git a/imageplugins/filters/colorfxtool.h b/imageplugins/filters/colorfxtool.h
index 07d1e3a..768425b 100644
--- a/imageplugins/filters/colorfxtool.h
+++ b/imageplugins/filters/colorfxtool.h
@@ -61,7 +61,6 @@ private:
 
 private Q_SLOTS:
 
-    void slotEffectTypeChanged(int type);
     void slotResetSettings();
     void slotColorSelectedFromTarget(const Digikam::DColor& color);
 
diff --git a/libs/dimg/filters/fx/colorfxfilter.cpp b/libs/dimg/filters/fx/colorfxfilter.cpp
index ee8dd3f..29d50ca 100644
--- a/libs/dimg/filters/fx/colorfxfilter.cpp
+++ b/libs/dimg/filters/fx/colorfxfilter.cpp
@@ -44,34 +44,32 @@ ColorFXFilter::ColorFXFilter(QObject* const parent)
     initFilter();
 }
 
-ColorFXFilter::ColorFXFilter(DImg* const orgImage, QObject* const parent, int type, int level, int \
iterations) +ColorFXFilter::ColorFXFilter(DImg* const orgImage, QObject* const parent, const \
ColorFXContainer& settings)  : DImgThreadedFilter(orgImage, parent, "ColorFX")
 {
-    m_colorFXType = type;
-    m_level = level;
-    m_iterations = iterations;
+    m_settings = settings;
 
     initFilter();
 }
 
 void ColorFXFilter::filterImage()
 {
-    switch (m_colorFXType)
+    switch (m_settings.colorFXType)
     {
         case Solarize:
-            solarize(&m_orgImage, &m_destImage, m_level);
+            solarize(&m_orgImage, &m_destImage, m_settings.level);
             break;
 
         case Vivid:
-            vivid(&m_orgImage, &m_destImage, m_level);
+            vivid(&m_orgImage, &m_destImage, m_settings.level);
             break;
 
         case Neon:
-            neon(&m_orgImage, &m_destImage, m_level, m_iterations);
+            neon(&m_orgImage, &m_destImage, m_settings.level, m_settings.iterations);
             break;
 
         case FindEdges:
-            findEdges(&m_orgImage, &m_destImage, m_level, m_iterations);
+            findEdges(&m_orgImage, &m_destImage, m_settings.level, m_settings.iterations);
             break;
     }
 }
@@ -365,18 +363,18 @@ FilterAction ColorFXFilter::filterAction()
     FilterAction action(FilterIdentifier(), CurrentVersion());
     action.setDisplayableName(DisplayableName());
 
-    action.addParameter("type", m_colorFXType);
-    action.addParameter("iteration", m_iterations);
-    action.addParameter("level", m_level);
+    action.addParameter("type", m_settings.colorFXType);
+    action.addParameter("iteration", m_settings.iterations);
+    action.addParameter("level", m_settings.level);
 
     return action;
 }
 
 void ColorFXFilter::readParameters(const FilterAction& action)
 {
-    m_colorFXType = action.parameter("type").toInt();
-    m_iterations  = action.parameter("iteration").toInt();
-    m_level       = action.parameter("level").toInt();
+    m_settings.colorFXType = action.parameter("type").toInt();
+    m_settings.iterations  = action.parameter("iteration").toInt();
+    m_settings.level       = action.parameter("level").toInt();
 }
 
 }  // namespace DigikamFxFiltersImagePlugin
diff --git a/libs/dimg/filters/fx/colorfxfilter.h b/libs/dimg/filters/fx/colorfxfilter.h
index 2cbd6cc..f99abd9 100644
--- a/libs/dimg/filters/fx/colorfxfilter.h
+++ b/libs/dimg/filters/fx/colorfxfilter.h
@@ -40,14 +40,36 @@ namespace Digikam
 
 class RandomNumberGenerator;
 
+class DIGIKAM_EXPORT ColorFXContainer
+{
+
+public:
+
+    ColorFXContainer()
+    {
+        colorFXType = 0; // ColorFXFilter::Solarize
+        level = 0;
+        iterations = 2;
+    };
+
+    ~ColorFXContainer() {};
+
+public:
+
+    int colorFXType;
+    int level;
+    int iterations;
+};
+
+
 class DIGIKAM_EXPORT ColorFXFilter : public DImgThreadedFilter
 {
 
 public:
 
     explicit ColorFXFilter(QObject* const parent = 0);
-    explicit ColorFXFilter(DImg* const orgImage, QObject* const parent,
-                           int colorFXType = Solarize, int level = 25, int iterations = 2);
+    explicit ColorFXFilter(DImg* const orgImage, QObject* const parent, const ColorFXContainer& \
settings=ColorFXContainer()); +
     ~ColorFXFilter() {};
 
     static QString          FilterIdentifier()
@@ -101,9 +123,7 @@ private:
 
 private:
 
-    int m_colorFXType;
-    int m_level;
-    int m_iterations;
+    ColorFXContainer m_settings;
 };
 
 }  // namespace Digikam
diff --git a/libs/dimg/filters/fx/colorfxsettings.cpp b/libs/dimg/filters/fx/colorfxsettings.cpp
new file mode 100644
index 0000000..e66acf0
--- /dev/null
+++ b/libs/dimg/filters/fx/colorfxsettings.cpp
@@ -0,0 +1,276 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date        : 2012-11-08
+ * Description : Color effects settings view.
+ *
+ * Copyright (C) 2012 by Alexander Dymo <adymo@kdevelop.org>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+#include "colorfxsettings.moc"
+
+// Qt includes
+
+#include <QGridLayout>
+#include <QLabel>
+
+// KDE includes
+
+#include <kdebug.h>
+#include <kdialog.h>
+
+#include <libkdcraw/rnuminput.h>
+#include <libkdcraw/rcombobox.h>
+
+namespace Digikam
+{
+
+class ColorFXSettings::ColorFXSettingsPriv
+{
+public:
+
+    ColorFXSettingsPriv() :
+        effectTypeLabel(0),
+        levelLabel(0),
+        iterationLabel(0),
+        effectType(0),
+        levelInput(0),
+        iterationInput(0)
+    {}
+
+    static const QString configEffectTypeEntry;
+    static const QString configLevelAdjustmentEntry;
+    static const QString configIterationAdjustmentEntry;
+
+    QLabel*              effectTypeLabel;
+    QLabel*              levelLabel;
+    QLabel*              iterationLabel;
+
+    RComboBox*           effectType;
+
+    RIntNumInput*        levelInput;
+    RIntNumInput*        iterationInput;
+};
+
+const QString ColorFXSettings::ColorFXSettingsPriv::configEffectTypeEntry("EffectType");
+const QString ColorFXSettings::ColorFXSettingsPriv::configLevelAdjustmentEntry("LevelAdjustment");
+const QString ColorFXSettings::ColorFXSettingsPriv::configIterationAdjustmentEntry("IterationAdjustment");
 +
+
+// --------------------------------------------------------
+
+ColorFXSettings::ColorFXSettings(QWidget* parent)
+    : QWidget(parent),
+      d(new ColorFXSettingsPriv)
+{
+    QGridLayout* grid = new QGridLayout(parent);
+
+    d->effectTypeLabel = new QLabel(i18n("Type:"));
+    d->effectType      = new RComboBox();
+    d->effectType->addItem(i18n("Solarize"));
+    d->effectType->addItem(i18n("Vivid"));
+    d->effectType->addItem(i18n("Neon"));
+    d->effectType->addItem(i18n("Find Edges"));
+    d->effectType->setDefaultIndex(ColorFXFilter::Solarize);
+    d->effectType->setWhatsThis(i18n("<p>Select the effect type to apply to the image here.</p>"
+                                     "<p><b>Solarize</b>: simulates solarization of photograph.</p>"
+                                     "<p><b>Vivid</b>: simulates the Velvia(tm) slide film colors.</p>"
+                                     "<p><b>Neon</b>: coloring the edges in a photograph to "
+                                     "reproduce a fluorescent light effect.</p>"
+                                     "<p><b>Find Edges</b>: detects the edges in a photograph "
+                                     "and their strength.</p>"));
+
+    d->levelLabel = new QLabel(i18nc("level of the effect", "Level:"));
+    d->levelInput = new RIntNumInput();
+    d->levelInput->setRange(0, 100, 1);
+    d->levelInput->setSliderEnabled(true);
+    d->levelInput->setDefaultValue(0);
+    d->levelInput->setWhatsThis( i18n("Set here the level of the effect."));
+
+    d->iterationLabel = new QLabel(i18n("Iteration:"));
+    d->iterationInput = new RIntNumInput();
+    d->iterationInput->setRange(0, 100, 1);
+    d->iterationInput->setSliderEnabled(true);
+    d->iterationInput->setDefaultValue(0);
+    d->iterationInput->setWhatsThis( i18n("This value controls the number of iterations "
+                                          "to use with the Neon and Find Edges effects."));
+
+
+    grid->addWidget(d->effectTypeLabel, 0, 0, 1, 5);
+    grid->addWidget(d->effectType,      1, 0, 1, 5);
+    grid->addWidget(d->levelLabel,      2, 0, 1, 5);
+    grid->addWidget(d->levelInput,      3, 0, 1, 5);
+    grid->addWidget(d->iterationLabel,  4, 0, 1, 5);
+    grid->addWidget(d->iterationInput,  5, 0, 1, 5);
+    grid->setRowStretch(6, 10);
+    grid->setMargin(KDialog::spacingHint());
+    grid->setSpacing(KDialog::spacingHint());
+
+    // -------------------------------------------------------------
+
+    connect(d->levelInput, SIGNAL(valueChanged(int)),
+            this, SIGNAL(signalLevelOrIterationChanged()));
+
+    connect(d->iterationInput, SIGNAL(valueChanged(int)),
+            this, SIGNAL(signalLevelOrIterationChanged()));
+
+    connect(d->effectType, SIGNAL(activated(int)),
+            this, SLOT(slotEffectTypeChanged(int)));
+}
+
+ColorFXSettings::~ColorFXSettings()
+{
+    delete d;
+}
+
+void ColorFXSettings::slotEffectTypeChanged(int type)
+{
+    d->levelInput->setEnabled(true);
+    d->levelLabel->setEnabled(true);
+
+    d->levelInput->blockSignals(true);
+    d->iterationInput->blockSignals(true);
+    d->levelInput->setRange(0, 100, 1);
+    d->levelInput->setSliderEnabled(true);
+    d->levelInput->setValue(25);
+
+    switch (type)
+    {
+        case ColorFXFilter::Solarize:
+            d->levelInput->setRange(0, 100, 1);
+            d->levelInput->setSliderEnabled(true);
+            d->levelInput->setValue(0);
+            d->iterationInput->setEnabled(false);
+            d->iterationLabel->setEnabled(false);
+            break;
+
+        case ColorFXFilter::Vivid:
+            d->levelInput->setRange(0, 50, 1);
+            d->levelInput->setSliderEnabled(true);
+            d->levelInput->setValue(5);
+            d->iterationInput->setEnabled(false);
+            d->iterationLabel->setEnabled(false);
+            break;
+
+        case ColorFXFilter::Neon:
+        case ColorFXFilter::FindEdges:
+            d->levelInput->setRange(0, 5, 1);
+            d->levelInput->setSliderEnabled(true);
+            d->levelInput->setValue(3);
+            d->iterationInput->setEnabled(true);
+            d->iterationLabel->setEnabled(true);
+            d->iterationInput->setRange(0, 5, 1);
+            d->iterationInput->setSliderEnabled(true);
+            d->iterationInput->setValue(2);
+            break;
+    }
+
+    d->levelInput->blockSignals(false);
+    d->iterationInput->blockSignals(false);
+
+    emit signalSettingsChanged();
+}
+
+
+ColorFXContainer ColorFXSettings::settings() const
+{
+    ColorFXContainer prm;
+    prm.colorFXType             = d->effectType->currentIndex();
+    prm.level                   = d->levelInput->value();
+    prm.iterations              = d->iterationInput->value();
+    return prm;
+}
+
+void ColorFXSettings::setSettings(const ColorFXContainer& settings)
+{
+    blockSignals(true);
+
+    d->effectType->setCurrentIndex(settings.colorFXType);
+    slotEffectTypeChanged(settings.colorFXType);
+
+    d->levelInput->setValue(settings.level);
+    d->iterationInput->setValue(settings.iterations);
+
+    blockSignals(false);
+}
+
+void ColorFXSettings::resetToDefault()
+{
+    setSettings(defaultSettings());
+}
+
+ColorFXContainer ColorFXSettings::defaultSettings() const
+{
+    return ColorFXContainer();
+}
+
+void ColorFXSettings::readSettings(KConfigGroup& group)
+{
+    ColorFXContainer prm;
+    ColorFXContainer defaultPrm = defaultSettings();
+
+    d->effectType->setCurrentIndex(group.readEntry(d->configEffectTypeEntry,       \
d->effectType->defaultIndex())); +    \
d->levelInput->setValue(group.readEntry(d->configLevelAdjustmentEntry,         \
d->levelInput->defaultValue())); +    \
d->iterationInput->setValue(group.readEntry(d->configIterationAdjustmentEntry, \
d->iterationInput->defaultValue())); +
+    setSettings(prm);
+}
+
+void ColorFXSettings::writeSettings(KConfigGroup& group)
+{
+    ColorFXContainer prm = settings();
+
+    group.writeEntry(d->configEffectTypeEntry,          d->effectType->currentIndex());
+    group.writeEntry(d->configLevelAdjustmentEntry,     d->levelInput->value());
+    group.writeEntry(d->configIterationAdjustmentEntry, d->iterationInput->value());
+}
+
+void ColorFXSettings::enable()
+{
+    d->effectTypeLabel->setEnabled(true);
+    d->effectType->setEnabled(true);
+    d->levelInput->setEnabled(true);
+    d->levelLabel->setEnabled(true);
+    d->iterationInput->setEnabled(true);
+    d->iterationLabel->setEnabled(true);
+
+    switch (d->effectType->currentIndex())
+    {
+        case ColorFXFilter::Solarize:
+        case ColorFXFilter::Vivid:
+            d->iterationInput->setEnabled(false);
+            d->iterationLabel->setEnabled(false);
+            break;
+
+        case ColorFXFilter::Neon:
+        case ColorFXFilter::FindEdges:
+            d->iterationInput->setEnabled(true);
+            d->iterationLabel->setEnabled(true);
+            break;
+    }
+}
+
+void ColorFXSettings::disable()
+{
+    d->effectTypeLabel->setEnabled(false);
+    d->effectType->setEnabled(false);
+    d->levelInput->setEnabled(false);
+    d->levelLabel->setEnabled(false);
+    d->iterationInput->setEnabled(false);
+    d->iterationLabel->setEnabled(false);
+}
+
+}  // namespace Digikam
diff --git a/libs/dimg/filters/fx/colorfxsettings.h b/libs/dimg/filters/fx/colorfxsettings.h
new file mode 100644
index 0000000..1ccd06f
--- /dev/null
+++ b/libs/dimg/filters/fx/colorfxsettings.h
@@ -0,0 +1,81 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date        : 2012-11-08
+ * Description : Color effects settings view.
+ *
+ * Copyright (C) 2012 by Alexander Dymo <adymo@kdevelop.org>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef COLORFXSETTINGS_H
+#define COLORFXSETTINGS_H
+
+// Local includes
+
+#include <QWidget>
+
+// KDE includes
+
+#include <kconfig.h>
+
+// Local includes
+
+#include "digikam_export.h"
+#include "colorfxfilter.h"
+
+namespace Digikam
+{
+
+class DIGIKAM_EXPORT ColorFXSettings : public QWidget
+{
+    Q_OBJECT
+
+public:
+
+    explicit ColorFXSettings(QWidget* parent);
+    ~ColorFXSettings();
+
+    ColorFXContainer defaultSettings() const;
+    void resetToDefault();
+
+    ColorFXContainer settings() const;
+    void setSettings(const ColorFXContainer& settings);
+
+    void readSettings(KConfigGroup& group);
+    void writeSettings(KConfigGroup& group);
+
+    void enable();
+    void disable();
+
+Q_SIGNALS:
+
+    void signalLevelOrIterationChanged();
+    void signalSettingsChanged();
+
+private Q_SLOTS:
+
+    void slotEffectTypeChanged(int type);
+
+private:
+
+    class ColorFXSettingsPriv;
+    ColorFXSettingsPriv* const d;
+};
+
+}  // namespace Digikam
+
+#endif /* COLORFXSETTINGS_H */
diff --git a/utilities/queuemanager/CMakeLists.txt b/utilities/queuemanager/CMakeLists.txt
index 8bc505d..561fa09 100644
--- a/utilities/queuemanager/CMakeLists.txt
+++ b/utilities/queuemanager/CMakeLists.txt
@@ -25,6 +25,7 @@ SET(libqueuemanager_SRCS
         ${CMAKE_CURRENT_SOURCE_DIR}/basetools/enhance/restoration.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/basetools/enhance/sharpen.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/basetools/filters/filmgrain.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/basetools/filters/colorfx.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/basetools/metadata/assigntemplate.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/basetools/metadata/removemetadata.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/basetools/transform/flip.cpp
diff --git a/utilities/queuemanager/basetools/filters/colorfx.cpp \
b/utilities/queuemanager/basetools/filters/colorfx.cpp new file mode 100644
index 0000000..72a3b35
--- /dev/null
+++ b/utilities/queuemanager/basetools/filters/colorfx.cpp
@@ -0,0 +1,113 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date        : 2012-11-08
+ * Description : a batch tool to apply color effects to images.
+ *
+ * Copyright (C) 2012 by Alexander Dymo <adymo@develop.org>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#include "colorfx.moc"
+
+// KDE includes
+
+#include <kdebug.h>
+#include <kiconloader.h>
+
+// Local includes
+
+#include "dimg.h"
+#include "colorfxfilter.h"
+#include "colorfxsettings.h"
+
+namespace Digikam
+{
+
+ColorFX::ColorFX(QObject* parent)
+    : BatchTool("ColorFX", FiltersTool, parent)
+{
+    setToolTitle(i18n("Color Effects"));
+    setToolDescription(i18n("Apply color effects"));
+    setToolIcon(KIcon(SmallIcon("colorfx")));
+
+    QWidget* box   = new QWidget;
+    m_settingsView = new ColorFXSettings(box);
+    m_settingsView->resetToDefault();
+    setSettingsWidget(box);
+
+    connect(m_settingsView, SIGNAL(signalSettingsChanged()),
+            this, SLOT(slotSettingsChanged()));
+    connect(m_settingsView, SIGNAL(signalLevelOrIterationChanged()),
+            this, SLOT(slotSettingsChanged()));
+}
+
+ColorFX::~ColorFX()
+{
+}
+
+BatchToolSettings ColorFX::defaultSettings()
+{
+    BatchToolSettings prm;
+    ColorFXContainer defaultPrm = m_settingsView->defaultSettings();
+
+    prm.insert("colorFXType", (int)defaultPrm.colorFXType);
+    prm.insert("level", (int)defaultPrm.level);
+    prm.insert("iterations", (int)defaultPrm.iterations);
+
+    return prm;
+}
+
+void ColorFX::slotAssignSettings2Widget()
+{
+    ColorFXContainer prm;
+    prm.colorFXType = settings()["colorFXType"].toInt();
+    prm.level       = settings()["level"].toInt();
+    prm.iterations  = settings()["iterations"].toInt();
+    m_settingsView->setSettings(prm);
+}
+
+void ColorFX::slotSettingsChanged()
+{
+    BatchToolSettings prm;
+    ColorFXContainer currentPrm = m_settingsView->settings();
+
+    prm.insert("colorFXType", (int)currentPrm.colorFXType);
+    prm.insert("level", (int)currentPrm.level);
+    prm.insert("iterations", (int)currentPrm.iterations);
+
+    BatchTool::slotSettingsChanged(prm);
+}
+
+bool ColorFX::toolOperations()
+{
+    if (!loadToDImg())
+    {
+        return false;
+    }
+
+    ColorFXContainer prm;
+    prm.colorFXType = settings()["colorFXType"].toInt();
+    prm.level       = settings()["level"].toInt();
+    prm.iterations  = settings()["iterations"].toInt();
+
+    ColorFXFilter fg(&image(), 0L, prm);
+    applyFilter(&fg);
+
+    return savefromDImg();
+}
+
+} // namespace Digikam
diff --git a/utilities/queuemanager/basetools/filters/colorfx.h \
b/utilities/queuemanager/basetools/filters/colorfx.h new file mode 100644
index 0000000..e706a49
--- /dev/null
+++ b/utilities/queuemanager/basetools/filters/colorfx.h
@@ -0,0 +1,62 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date        : 2012-11-08
+ * Description : a batch tool to apply color effects to images.
+ *
+ * Copyright (C) 2012 by Alexander Dymo <adymo@develop.org>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef COLORFX_H_
+#define COLORFX_H_
+
+#include "batchtool.h"
+
+
+namespace Digikam
+{
+
+class ColorFXSettings;
+
+class ColorFX : public BatchTool
+{
+    Q_OBJECT
+
+public:
+
+    explicit ColorFX(QObject* parent = 0);
+    ~ColorFX();
+
+    BatchToolSettings defaultSettings();
+
+private:
+
+    bool toolOperations();
+
+private Q_SLOTS:
+
+    void slotAssignSettings2Widget();
+    void slotSettingsChanged();
+
+private:
+
+    ColorFXSettings* m_settingsView;
+};
+
+} // namespace Digikam
+
+#endif /* COLORFX_H_ */
diff --git a/utilities/queuemanager/manager/batchtoolsmanager.cpp \
b/utilities/queuemanager/manager/batchtoolsmanager.cpp index 0f5ef8c..4f3c1df 100644
--- a/utilities/queuemanager/manager/batchtoolsmanager.cpp
+++ b/utilities/queuemanager/manager/batchtoolsmanager.cpp
@@ -50,6 +50,7 @@
 #include "whitebalance.h"
 #include "curvesadjust.h"
 #include "filmgrain.h"
+#include "colorfx.h"
 #include "localcontrast.h"
 #include "antivignetting.h"
 #include "invert.h"
@@ -124,6 +125,7 @@ BatchToolsManager::BatchToolsManager(QObject* const parent)
 
     // Filters
     registerTool(new FilmGrain(this));
+    registerTool(new ColorFX(this));
 }
 
 BatchToolsManager::~BatchToolsManager()


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic