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 convert to Black and White
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 "bwsepiatoolplugin.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 "bwsepiatool.h"
37
38 namespace DigikamEditorBWSepiaToolPlugin
39 {
40
BWSepiaToolPlugin(QObject * const parent)41 BWSepiaToolPlugin::BWSepiaToolPlugin(QObject* const parent)
42 : DPluginEditor(parent)
43 {
44 }
45
~BWSepiaToolPlugin()46 BWSepiaToolPlugin::~BWSepiaToolPlugin()
47 {
48 }
49
name() const50 QString BWSepiaToolPlugin::name() const
51 {
52 return i18nc("@title", "Black and White");
53 }
54
iid() const55 QString BWSepiaToolPlugin::iid() const
56 {
57 return QLatin1String(DPLUGIN_IID);
58 }
59
icon() const60 QIcon BWSepiaToolPlugin::icon() const
61 {
62 return QIcon::fromTheme(QLatin1String("bwtonal"));
63 }
64
description() const65 QString BWSepiaToolPlugin::description() const
66 {
67 return i18nc("@info", "A tool to convert to black and white");
68 }
69
details() const70 QString BWSepiaToolPlugin::details() const
71 {
72 return i18nc("@info", "This Image Editor tool can convert image to black and white.");
73 }
74
authors() const75 QList<DPluginAuthor> BWSepiaToolPlugin::authors() const
76 {
77 return QList<DPluginAuthor>()
78 << DPluginAuthor(QString::fromUtf8("Renchi Raju"),
79 QString::fromUtf8("renchi dot raju at gmail dot com"),
80 QString::fromUtf8("(C) 2004-2005"))
81 << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
82 QString::fromUtf8("caulier dot gilles at gmail dot com"),
83 QString::fromUtf8("(C) 2006-2021"))
84 ;
85 }
86
setup(QObject * const parent)87 void BWSepiaToolPlugin::setup(QObject* const parent)
88 {
89 DPluginAction* const ac = new DPluginAction(parent);
90 ac->setIcon(icon());
91 ac->setText(i18nc("@action", "Black && White..."));
92 ac->setObjectName(QLatin1String("editorwindow_color_blackwhite"));
93 ac->setActionCategory(DPluginAction::EditorColors);
94
95 connect(ac, SIGNAL(triggered(bool)),
96 this, SLOT(slotBWSepia()));
97
98 addAction(ac);
99 }
100
slotBWSepia()101 void BWSepiaToolPlugin::slotBWSepia()
102 {
103 EditorWindow* const editor = dynamic_cast<EditorWindow*>(sender()->parent());
104
105 if (editor)
106 {
107 BWSepiaTool* const tool = new BWSepiaTool(editor);
108 tool->setPlugin(this);
109 editor->loadTool(tool);
110 }
111 }
112
113 } // namespace DigikamEditorBWSepiaToolPlugin
114