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

List:       kde-commits
Subject:    [digikam/development/3.0.0] imageplugins/enhance: factoring passive popup for image plugins.
From:       Gilles Caulier <caulier.gilles () gmail ! com>
Date:       2012-08-31 17:20:54
Message-ID: 20120831172054.0C8C1A6094 () git ! kde ! org
[Download RAW message or body]

Git commit 942d080461ac77be10a8ad7d364296efc1cf7f4e by Gilles Caulier.
Committed on 31/08/2012 at 19:20.
Pushed by cgilles into branch 'development/3.0.0'.

factoring passive popup for image plugins.
constify and polish

M  +40   -16   imageplugins/enhance/imageplugin_enhance.cpp
M  +2    -2    imageplugins/enhance/imageplugin_enhance.h
M  +38   -28   imageplugins/enhance/inpaintingtool.cpp
M  +4    -38   imageplugins/enhance/inpaintingtool.h
M  +0    -25   imageplugins/enhance/redeyetool.h

http://commits.kde.org/digikam/942d080461ac77be10a8ad7d364296efc1cf7f4e

diff --git a/imageplugins/enhance/imageplugin_enhance.cpp b/imageplugins/enhance/imageplugin_enhance.cpp
index b126268..c9645de 100644
--- a/imageplugins/enhance/imageplugin_enhance.cpp
+++ b/imageplugins/enhance/imageplugin_enhance.cpp
@@ -25,6 +25,7 @@
 
 // KDE includes
 
+#include <kpassivepopup.h>
 #include <klocale.h>
 #include <kgenericfactory.h>
 #include <klibloader.h>
@@ -59,11 +60,34 @@ namespace DigikamEnhanceImagePlugin
 K_PLUGIN_FACTORY( EnhanceFactory, registerPlugin<ImagePlugin_Enhance>(); )
 K_EXPORT_PLUGIN ( EnhanceFactory("digikamimageplugin_enhance") )
 
-class ImagePlugin_Enhance::ImagePlugin_EnhancePriv
+class EditorToolPassivePopup : public KPassivePopup
 {
 public:
 
-    ImagePlugin_EnhancePriv() :
+    EditorToolPassivePopup(QWidget* const parent)
+        : KPassivePopup(parent), m_parent(parent)
+    {
+    }
+
+protected:
+
+    virtual void positionSelf()
+    {
+        move(m_parent->x() + 30, m_parent->y() + 30);
+    }
+
+private:
+
+    QWidget* m_parent;
+};
+
+// -----------------------------------------------------------------------------------------------
+
+class ImagePlugin_Enhance::Private
+{
+public:
+
+    Private() :
         hotpixelsAction(0),
         lensdistortionAction(0),
         antivignettingAction(0),
@@ -93,7 +117,7 @@ public:
 
 ImagePlugin_Enhance::ImagePlugin_Enhance(QObject* const parent, const QVariantList&)
     : ImagePlugin(parent, "ImagePlugin_Enhance"),
-      d(new ImagePlugin_EnhancePriv)
+      d(new Private)
 {
     d->restorationAction = new KAction(KIcon("restoration"), i18n("Restoration..."), this);
     actionCollection()->addAction("imageplugin_restoration", d->restorationAction);
@@ -192,43 +216,43 @@ void ImagePlugin_Enhance::setEnabledActions(bool b)
 
 void ImagePlugin_Enhance::slotHotPixels()
 {
-    HotPixelsTool* tool = new HotPixelsTool(this);
+    HotPixelsTool* const tool = new HotPixelsTool(this);
     loadTool(tool);
 }
 
 void ImagePlugin_Enhance::slotLensDistortion()
 {
-    LensDistortionTool* tool = new LensDistortionTool(this);
+    LensDistortionTool* const tool = new LensDistortionTool(this);
     loadTool(tool);
 }
 
 void ImagePlugin_Enhance::slotRestoration()
 {
-    RestorationTool* tool = new RestorationTool(this);
+    RestorationTool* const tool = new RestorationTool(this);
     loadTool(tool);
 }
 
 void ImagePlugin_Enhance::slotBlur()
 {
-    BlurTool* tool = new BlurTool(this);
+    BlurTool* const tool = new BlurTool(this);
     loadTool(tool);
 }
 
 void ImagePlugin_Enhance::slotSharpen()
 {
-    SharpenTool* tool = new SharpenTool(this);
+    SharpenTool* const tool = new SharpenTool(this);
     loadTool(tool);
 }
 
 void ImagePlugin_Enhance::slotNoiseReduction()
 {
-    NoiseReductionTool* tool = new NoiseReductionTool(this);
+    NoiseReductionTool* const tool = new NoiseReductionTool(this);
     loadTool(tool);
 }
 
 void ImagePlugin_Enhance::slotLocalContrast()
 {
-    LocalContrastTool* tool = new LocalContrastTool(this);
+    LocalContrastTool* const tool = new LocalContrastTool(this);
     loadTool(tool);
 }
 
@@ -238,7 +262,7 @@ void ImagePlugin_Enhance::slotRedEye()
 
     if (!iface.selectedWidth() || !iface.selectedHeight())
     {
-        RedEyePassivePopup* popup = new RedEyePassivePopup(kapp->activeWindow());
+        EditorToolPassivePopup* popup = new EditorToolPassivePopup(kapp->activeWindow());
         popup->setView(i18n("Red-Eye Correction Tool"),
                        i18n("You need to select a region including the eyes to use "
                             "the red-eye correction tool"));
@@ -248,7 +272,7 @@ void ImagePlugin_Enhance::slotRedEye()
         return;
     }
 
-    RedEyeTool* tool = new RedEyeTool(this);
+    RedEyeTool* const tool = new RedEyeTool(this);
     loadTool(tool);
 }
 
@@ -261,7 +285,7 @@ void ImagePlugin_Enhance::slotInPainting()
 
     if (!w || !h)
     {
-        InPaintingPassivePopup* popup = new InPaintingPassivePopup(kapp->activeWindow());
+        EditorToolPassivePopup* popup = new EditorToolPassivePopup(kapp->activeWindow());
         popup->setView(i18n("In-Painting Photograph Tool"),
                        i18n("To use this tool, you need to select a region "
                             "to in-paint."));
@@ -271,21 +295,21 @@ void ImagePlugin_Enhance::slotInPainting()
         return;
     }
 
-    InPaintingTool* tool = new InPaintingTool(this);
+    InPaintingTool* const tool = new InPaintingTool(this);
     loadTool(tool);
 }
 
 void ImagePlugin_Enhance::slotLensAutoFix()
 {
 #ifdef HAVE_GLIB2
-    LensAutoFixTool* tool = new LensAutoFixTool(this);
+    LensAutoFixTool* const tool = new LensAutoFixTool(this);
     loadTool(tool);
 #endif // HAVE_GLIB2
 }
 
 void ImagePlugin_Enhance::slotAntiVignetting()
 {
-    AntiVignettingTool* tool = new AntiVignettingTool(this);
+    AntiVignettingTool* const tool = new AntiVignettingTool(this);
     loadTool(tool);
 }
 
diff --git a/imageplugins/enhance/imageplugin_enhance.h b/imageplugins/enhance/imageplugin_enhance.h
index 71a6a5a..b5af17a 100644
--- a/imageplugins/enhance/imageplugin_enhance.h
+++ b/imageplugins/enhance/imageplugin_enhance.h
@@ -65,8 +65,8 @@ private Q_SLOTS:
 
 private:
 
-    class ImagePlugin_EnhancePriv;
-    ImagePlugin_EnhancePriv* const d;
+    class Private;
+    Private* const d;
 };
 
 } // namespace DigikamEnhanceImagePlugin
diff --git a/imageplugins/enhance/inpaintingtool.cpp b/imageplugins/enhance/inpaintingtool.cpp
index e033456..7f10661 100644
--- a/imageplugins/enhance/inpaintingtool.cpp
+++ b/imageplugins/enhance/inpaintingtool.cpp
@@ -7,7 +7,7 @@
  * Description : a digiKam image editor plugin to inpaint
  *               a photograph
  *
- * Copyright (C) 2005-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ * Copyright (C) 2005-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -56,7 +56,6 @@
 #include <kiconloader.h>
 #include <klocale.h>
 #include <kmessagebox.h>
-#include <kpassivepopup.h>
 #include <kstandarddirs.h>
 #include <ktabwidget.h>
 #include <ktoolinvocation.h>
@@ -73,11 +72,22 @@
 namespace DigikamEnhanceImagePlugin
 {
 
-class InPaintingTool::InPaintingToolPriv
+class InPaintingTool::Private
 {
+
+public:
+
+    enum InPaintingFilteringPreset
+    {
+        NoPreset = 0,
+        RemoveSmallArtefact,
+        RemoveMediumArtefact,
+        RemoveLargeArtefact
+    };
+
 public:
 
-    InPaintingToolPriv() :
+    Private() :
         isComputed(false),
         mainTab(0),
         inpaintingTypeCB(0),
@@ -122,27 +132,27 @@ public:
 
     EditorToolSettings*     gboxSettings;
 };
-const QString InPaintingTool::InPaintingToolPriv::configGroupName("inpainting Tool");
-const QString InPaintingTool::InPaintingToolPriv::configFastApproxEntry("FastApprox");
-const QString InPaintingTool::InPaintingToolPriv::configInterpolationEntry("Interpolation");
-const QString InPaintingTool::InPaintingToolPriv::configAmplitudeEntry("Amplitude");
-const QString InPaintingTool::InPaintingToolPriv::configSharpnessEntry("Sharpness");
-const QString InPaintingTool::InPaintingToolPriv::configAnisotropyEntry("Anisotropy");
-const QString InPaintingTool::InPaintingToolPriv::configAlphaEntry("Alpha");
-const QString InPaintingTool::InPaintingToolPriv::configSigmaEntry("Sigma");
-const QString InPaintingTool::InPaintingToolPriv::configGaussPrecEntry("GaussPrec");
-const QString InPaintingTool::InPaintingToolPriv::configDlEntry("Dl");
-const QString InPaintingTool::InPaintingToolPriv::configDaEntry("Da");
-const QString InPaintingTool::InPaintingToolPriv::configIterationEntry("Iteration");
-const QString InPaintingTool::InPaintingToolPriv::configTileEntry("Tile");
-const QString InPaintingTool::InPaintingToolPriv::configBTileEntry("BTile");
-const QString InPaintingTool::InPaintingToolPriv::configPresetEntry("Preset");
+const QString InPaintingTool::Private::configGroupName("inpainting Tool");
+const QString InPaintingTool::Private::configFastApproxEntry("FastApprox");
+const QString InPaintingTool::Private::configInterpolationEntry("Interpolation");
+const QString InPaintingTool::Private::configAmplitudeEntry("Amplitude");
+const QString InPaintingTool::Private::configSharpnessEntry("Sharpness");
+const QString InPaintingTool::Private::configAnisotropyEntry("Anisotropy");
+const QString InPaintingTool::Private::configAlphaEntry("Alpha");
+const QString InPaintingTool::Private::configSigmaEntry("Sigma");
+const QString InPaintingTool::Private::configGaussPrecEntry("GaussPrec");
+const QString InPaintingTool::Private::configDlEntry("Dl");
+const QString InPaintingTool::Private::configDaEntry("Da");
+const QString InPaintingTool::Private::configIterationEntry("Iteration");
+const QString InPaintingTool::Private::configTileEntry("Tile");
+const QString InPaintingTool::Private::configBTileEntry("BTile");
+const QString InPaintingTool::Private::configPresetEntry("Preset");
 
 // --------------------------------------------------------
 
-InPaintingTool::InPaintingTool(QObject* parent)
+InPaintingTool::InPaintingTool(QObject* const parent)
     : EditorToolThreaded(parent),
-      d(new InPaintingToolPriv)
+      d(new Private)
 {
     setObjectName("inpainting");
     setToolName(i18n("In-painting"));
@@ -265,10 +275,10 @@ void InPaintingTool::readSettings()
     prm.btile      = group.readEntry(d->configBTileEntry,         defaults.btile);
     d->settingsWidget->setSettings(prm);
 
-    int p = group.readEntry(d->configPresetEntry, (int)NoPreset);
+    int p = group.readEntry(d->configPresetEntry, (int)Private::NoPreset);
     d->inpaintingTypeCB->setCurrentIndex(p);
 
-    if (p == NoPreset)
+    if (p == Private::NoPreset)
     {
         d->settingsWidget->setEnabled(true);
     }
@@ -304,7 +314,7 @@ void InPaintingTool::writeSettings()
 
 void InPaintingTool::slotResetValues(int i)
 {
-    if (i == NoPreset)
+    if (i == Private::NoPreset)
     {
         d->settingsWidget->setEnabled(true);
     }
@@ -323,18 +333,18 @@ void InPaintingTool::slotResetSettings()
 
     switch (d->inpaintingTypeCB->currentIndex())
     {
-        case RemoveSmallArtefact:
+        case Private::RemoveSmallArtefact:
             // We use default settings here.
             break;
 
-        case RemoveMediumArtefact:
+        case Private::RemoveMediumArtefact:
         {
             settings.amplitude = 50.0;
             settings.nbIter    = 50;
             break;
         }
 
-        case RemoveLargeArtefact:
+        case Private::RemoveLargeArtefact:
         {
             settings.amplitude = 100.0;
             settings.nbIter    = 100;
@@ -494,7 +504,7 @@ void InPaintingTool::slotLoadSettings()
 
     file.close();
     d->inpaintingTypeCB->blockSignals(true);
-    d->inpaintingTypeCB->setCurrentIndex(NoPreset);
+    d->inpaintingTypeCB->setCurrentIndex(Private::NoPreset);
     d->inpaintingTypeCB->blockSignals(false);
     d->settingsWidget->setEnabled(true);
 }
diff --git a/imageplugins/enhance/inpaintingtool.h b/imageplugins/enhance/inpaintingtool.h
index 5394c08..901912e 100644
--- a/imageplugins/enhance/inpaintingtool.h
+++ b/imageplugins/enhance/inpaintingtool.h
@@ -7,7 +7,7 @@
  * Description : a digiKam image editor plugin to inpaint
  *               a photograph
  *
- * Copyright (C) 2005-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ * Copyright (C) 2005-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -29,10 +29,6 @@
 
 #include <QString>
 
-// KDE includes
-
-#include <kpassivepopup.h>
-
 // Local includes
 
 #include "editortool.h"
@@ -42,33 +38,13 @@ using namespace Digikam;
 namespace DigikamEnhanceImagePlugin
 {
 
-class InPaintingPassivePopup : public KPassivePopup
-{
-public:
-
-    InPaintingPassivePopup(QWidget* parent) : KPassivePopup(parent), m_parent(parent) {}
-
-protected:
-
-    virtual void positionSelf()
-    {
-        move(m_parent->x() + 30, m_parent->y() + 30);
-    }
-
-private:
-
-    QWidget* m_parent;
-};
-
-//-----------------------------------------------------------
-
 class InPaintingTool : public EditorToolThreaded
 {
     Q_OBJECT
 
 public:
 
-    InPaintingTool(QObject* parent);
+    InPaintingTool(QObject* const parent);
     ~InPaintingTool();
 
 private Q_SLOTS:
@@ -90,18 +66,8 @@ private:
 
 private:
 
-    enum InPaintingFilteringPreset
-    {
-        NoPreset = 0,
-        RemoveSmallArtefact,
-        RemoveMediumArtefact,
-        RemoveLargeArtefact
-    };
-
-private:
-
-    class InPaintingToolPriv;
-    InPaintingToolPriv* const d;
+    class Private;
+    Private* const d;
 };
 
 }  // namespace DigikamEnhanceImagePlugin
diff --git a/imageplugins/enhance/redeyetool.h b/imageplugins/enhance/redeyetool.h
index 89dc841..4f41d33 100644
--- a/imageplugins/enhance/redeyetool.h
+++ b/imageplugins/enhance/redeyetool.h
@@ -25,10 +25,6 @@
 #ifndef REDEYETOOL_H
 #define REDEYETOOL_H
 
-// KDE includes
-
-#include <kpassivepopup.h>
-
 // Local includes
 
 #include "editortool.h"
@@ -46,27 +42,6 @@ using namespace Digikam;
 namespace DigikamEnhanceImagePlugin
 {
 
-class RedEyePassivePopup : public KPassivePopup
-{
-public:
-
-    RedEyePassivePopup(QWidget* const parent)
-        : KPassivePopup(parent), m_parent(parent)
-    {
-    }
-
-protected:
-
-    virtual void positionSelf()
-    {
-        move(m_parent->x() + 30, m_parent->y() + 30);
-    }
-
-private:
-
-    QWidget* m_parent;
-};
-
 class RedEyeTool : public EditorTool
 {
     Q_OBJECT
[prev in list] [next in list] [prev in thread] [next in thread] 

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