1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2018-07-30
7  * Description : image editor plugin to reduce vignetting
8  *
9  * Copyright (C) 2018-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * ============================================================ */
22 
23 #include "antivignettingtoolplugin.h"
24 
25 // Qt includes
26 
27 #include <QPointer>
28 
29 // KDE includes
30 
31 #include <klocalizedstring.h>
32 
33 // Local includes
34 
35 #include "editorwindow.h"
36 #include "antivignettingtool.h"
37 
38 namespace DigikamEditorAntivignettingToolPlugin
39 {
40 
AntiVignettingToolPlugin(QObject * const parent)41 AntiVignettingToolPlugin::AntiVignettingToolPlugin(QObject* const parent)
42     : DPluginEditor(parent)
43 {
44 }
45 
~AntiVignettingToolPlugin()46 AntiVignettingToolPlugin::~AntiVignettingToolPlugin()
47 {
48 }
49 
name() const50 QString AntiVignettingToolPlugin::name() const
51 {
52     return i18nc("@title", "Vignetting Correction");
53 }
54 
iid() const55 QString AntiVignettingToolPlugin::iid() const
56 {
57     return QLatin1String(DPLUGIN_IID);
58 }
59 
icon() const60 QIcon AntiVignettingToolPlugin::icon() const
61 {
62     return QIcon::fromTheme(QLatin1String("antivignetting"));
63 }
64 
description() const65 QString AntiVignettingToolPlugin::description() const
66 {
67     return i18nc("@info", "A tool to correct vignetting");
68 }
69 
details() const70 QString AntiVignettingToolPlugin::details() const
71 {
72     return i18nc("@info", "This Image Editor tool correct vignetting from an image.");
73 }
74 
authors() const75 QList<DPluginAuthor> AntiVignettingToolPlugin::authors() const
76 {
77     return QList<DPluginAuthor>()
78             << DPluginAuthor(QString::fromUtf8("Julien Narboux"),
79                              QString::fromUtf8("julien at narboux dot fr"),
80                              QString::fromUtf8("(C) 2010"))
81             << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
82                              QString::fromUtf8("caulier dot gilles at gmail dot com"),
83                              QString::fromUtf8("(C) 2004-2021"))
84             ;
85 }
86 
setup(QObject * const parent)87 void AntiVignettingToolPlugin::setup(QObject* const parent)
88 {
89     DPluginAction* const ac = new DPluginAction(parent);
90     ac->setIcon(icon());
91     ac->setText(i18nc("@action", "Vignetting Correction..."));
92     ac->setObjectName(QLatin1String("editorwindow_enhance_antivignetting"));
93     ac->setActionCategory(DPluginAction::EditorEnhance);
94 
95     connect(ac, SIGNAL(triggered(bool)),
96             this, SLOT(slotAntiVignetting()));
97 
98     addAction(ac);
99 }
100 
slotAntiVignetting()101 void AntiVignettingToolPlugin::slotAntiVignetting()
102 {
103     EditorWindow* const editor = dynamic_cast<EditorWindow*>(sender()->parent());
104 
105     if (editor)
106     {
107         AntiVignettingTool* const tool = new AntiVignettingTool(editor);
108         tool->setPlugin(this);
109         editor->loadTool(tool);
110     }
111 }
112 
113 } // namespace DigikamEditorAntivignettingToolPlugin
114