From kde-commits Fri Nov 16 06:56:52 2012 From: Alexander Dymo Date: Fri, 16 Nov 2012 06:56:52 +0000 To: kde-commits Subject: [digikam] /: Add "Color Effects" (solarize, vivid, neon, find edges) to the list of batch queue mana Message-Id: <20121116065652.3B3EFA6091 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=135304902302199 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 batc= h queue manager tools. Refactor the code to extract color effects settings widget into its own cla= ss 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 [Li= cense: GPL (v2+)] A +62 -0 utilities/queuemanager/basetools/filters/colorfx.h [Lice= nse: 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.c= pp ${CMAKE_CURRENT_SOURCE_DIR}/libs/dimg/filters/fx/distortionfxfilte= r.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/co= lorfxtool.cpp index 10a3d67..8f2758e 100644 --- a/imageplugins/filters/colorfxtool.cpp +++ b/imageplugins/filters/colorfxtool.cpp @@ -54,15 +54,11 @@ #include #include = -// LibKDcraw includes - -#include -#include - // 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 S= cale"); -const QString ColorFxTool::Private::configEffectTypeEntry("EffectType"); -const QString ColorFxTool::Private::configLevelAdjustmentEntry("LevelAdjus= tment"); -const QString ColorFxTool::Private::configIterationAdjustmentEntry("Iterat= ionAdjustment"); = // -------------------------------------------------------- = @@ -143,49 +120,7 @@ ColorFxTool::ColorFxTool(QObject* const parent) = // ------------------------------------------------------------- = - d->effectTypeLabel =3D new QLabel(i18n("Type:")); - d->effectType =3D 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("

Select the effect type to apply t= o the image here.

" - "

Solarize: simulates solari= zation of photograph.

" - "

Vivid: simulates the Velvi= a(tm) slide film colors.

" - "

Neon: coloring the edges i= n a photograph to " - "reproduce a fluorescent light effect= .

" - "

Find Edges: detects the ed= ges in a photograph " - "and their strength.

")); - - d->levelLabel =3D new QLabel(i18nc("level of the effect", "Level:")); - d->levelInput =3D 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 =3D new QLabel(i18n("Iteration:")); - d->iterationInput =3D 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 E= dges effects.")); - - // ------------------------------------------------------------- - - QGridLayout* mainLayout =3D 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 =3D 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.readEn= try(d->configHistogramScaleEntry, (int)LogScaleHistogram)); = - d->effectType->setCurrentIndex(group.readEntry(d->configEffectTypeEntr= y, d->effectType->defaultIndex())); - d->levelInput->setValue(group.readEntry(d->configLevelAdjustmentEntry,= d->levelInput->defaultValue())); - d->iterationInput->setValue(group.readEntry(d->configIterationAdjustme= ntEntry, d->iterationInput->defaultValue())); - slotEffectTypeChanged(d->effectType->currentIndex()); //check for ena= ble/disable of iteration + d->settingsView->readSettings(group); } = void ColorFxTool::writeSettings() @@ -239,27 +167,14 @@ void ColorFxTool::writeSettings() group.writeEntry(d->configHistogramChannelEntry, (int)d->gboxSettin= gs->histogramBox()->channel()); group.writeEntry(d->configHistogramScaleEntry, (int)d->gboxSettin= gs->histogramBox()->scale()); = - group.writeEntry(d->configEffectTypeEntry, d->effectType->cur= rentIndex()); - group.writeEntry(d->configLevelAdjustmentEntry, d->levelInput->val= ue()); - 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 D= Color& 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 =3D d->levelInput->value(); - int f =3D d->iterationInput->value(); - int e =3D d->effectType->currentIndex(); + d->settingsView->disable(); + ColorFXContainer prm =3D d->settingsView->settings(); + ImageIface* const iface =3D d->previewWidget->imageIface(); DImg image =3D 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 =3D d->levelInput->value(); - int f =3D d->iterationInput->value(); - int e =3D d->effectType->currentIndex(); + d->settingsView->disable(); + ColorFXContainer prm =3D 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 =3D 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/colo= rfxtool.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 =3D type; - m_level =3D level; - m_iterations =3D iterations; + m_settings =3D 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.i= terations); break; = case FindEdges: - findEdges(&m_orgImage, &m_destImage, m_level, m_iterations); + findEdges(&m_orgImage, &m_destImage, m_settings.level, m_setti= ngs.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 =3D action.parameter("type").toInt(); - m_iterations =3D action.parameter("iteration").toInt(); - m_level =3D action.parameter("level").toInt(); + m_settings.colorFXType =3D action.parameter("type").toInt(); + m_settings.iterations =3D action.parameter("iteration").toInt(); + m_settings.level =3D action.parameter("level").toInt(); } = } // namespace DigikamFxFiltersImagePlugin diff --git a/libs/dimg/filters/fx/colorfxfilter.h b/libs/dimg/filters/fx/co= lorfxfilter.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 =3D 0; // ColorFXFilter::Solarize + level =3D 0; + iterations =3D 2; + }; + + ~ColorFXContainer() {}; + +public: + + int colorFXType; + int level; + int iterations; +}; + + class DIGIKAM_EXPORT ColorFXFilter : public DImgThreadedFilter { = public: = explicit ColorFXFilter(QObject* const parent =3D 0); - explicit ColorFXFilter(DImg* const orgImage, QObject* const parent, - int colorFXType =3D Solarize, int level =3D 25,= int iterations =3D 2); + explicit ColorFXFilter(DImg* const orgImage, QObject* const parent, co= nst ColorFXContainer& settings=3DColorFXContainer()); + ~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/f= x/colorfxsettings.cpp new file mode 100644 index 0000000..e66acf0 --- /dev/null +++ b/libs/dimg/filters/fx/colorfxsettings.cpp @@ -0,0 +1,276 @@ +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * 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 + * + * 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. + * + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ +#include "colorfxsettings.moc" + +// Qt includes + +#include +#include + +// KDE includes + +#include +#include + +#include +#include + +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::configLevelAdjustmentE= ntry("LevelAdjustment"); +const QString ColorFXSettings::ColorFXSettingsPriv::configIterationAdjustm= entEntry("IterationAdjustment"); + + +// -------------------------------------------------------- + +ColorFXSettings::ColorFXSettings(QWidget* parent) + : QWidget(parent), + d(new ColorFXSettingsPriv) +{ + QGridLayout* grid =3D new QGridLayout(parent); + + d->effectTypeLabel =3D new QLabel(i18n("Type:")); + d->effectType =3D 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("

Select the effect type to apply t= o the image here.

" + "

Solarize: simulates solari= zation of photograph.

" + "

Vivid: simulates the Velvi= a(tm) slide film colors.

" + "

Neon: coloring the edges i= n a photograph to " + "reproduce a fluorescent light effect= .

" + "

Find Edges: detects the ed= ges in a photograph " + "and their strength.

")); + + d->levelLabel =3D new QLabel(i18nc("level of the effect", "Level:")); + d->levelInput =3D 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 =3D new QLabel(i18n("Iteration:")); + d->iterationInput =3D 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 E= dges 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 =3D d->effectType->currentIndex(); + prm.level =3D d->levelInput->value(); + prm.iterations =3D 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 =3D defaultSettings(); + + d->effectType->setCurrentIndex(group.readEntry(d->configEffectTypeEntr= y, d->effectType->defaultIndex())); + d->levelInput->setValue(group.readEntry(d->configLevelAdjustmentEntry,= d->levelInput->defaultValue())); + d->iterationInput->setValue(group.readEntry(d->configIterationAdjustme= ntEntry, d->iterationInput->defaultValue())); + + setSettings(prm); +} + +void ColorFXSettings::writeSettings(KConfigGroup& group) +{ + ColorFXContainer prm =3D settings(); + + group.writeEntry(d->configEffectTypeEntry, d->effectType->cur= rentIndex()); + group.writeEntry(d->configLevelAdjustmentEntry, d->levelInput->val= ue()); + 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 @@ +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * 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 + * + * 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. + * + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ + +#ifndef COLORFXSETTINGS_H +#define COLORFXSETTINGS_H + +// Local includes + +#include + +// KDE includes + +#include + +// 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/utiliti= es/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 @@ +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * 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 + * + * 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. + * + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ + +#include "colorfx.moc" + +// KDE includes + +#include +#include + +// 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 =3D new QWidget; + m_settingsView =3D 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 =3D 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 =3D settings()["colorFXType"].toInt(); + prm.level =3D settings()["level"].toInt(); + prm.iterations =3D settings()["iterations"].toInt(); + m_settingsView->setSettings(prm); +} + +void ColorFX::slotSettingsChanged() +{ + BatchToolSettings prm; + ColorFXContainer currentPrm =3D 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 =3D settings()["colorFXType"].toInt(); + prm.level =3D settings()["level"].toInt(); + prm.iterations =3D 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 @@ +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * 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 + * + * 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. + * + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ + +#ifndef COLORFX_H_ +#define COLORFX_H_ + +#include "batchtool.h" + + +namespace Digikam +{ + +class ColorFXSettings; + +class ColorFX : public BatchTool +{ + Q_OBJECT + +public: + + explicit ColorFX(QObject* parent =3D 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/utiliti= es/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 par= ent) = // Filters registerTool(new FilmGrain(this)); + registerTool(new ColorFX(this)); } = BatchToolsManager::~BatchToolsManager()