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 emulate film color
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 "filmtoolplugin.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 "filmtool.h"
37 
38 namespace DigikamEditorFilmToolPlugin
39 {
40 
FilmToolPlugin(QObject * const parent)41 FilmToolPlugin::FilmToolPlugin(QObject* const parent)
42     : DPluginEditor(parent)
43 {
44 }
45 
~FilmToolPlugin()46 FilmToolPlugin::~FilmToolPlugin()
47 {
48 }
49 
name() const50 QString FilmToolPlugin::name() const
51 {
52     return i18nc("@title", "Color Negative Film");
53 }
54 
iid() const55 QString FilmToolPlugin::iid() const
56 {
57     return QLatin1String(DPLUGIN_IID);
58 }
59 
icon() const60 QIcon FilmToolPlugin::icon() const
61 {
62     return QIcon::fromTheme(QLatin1String("colorneg"));
63 }
64 
description() const65 QString FilmToolPlugin::description() const
66 {
67     return i18nc("@info", "A tool to emulate color negative film");
68 }
69 
details() const70 QString FilmToolPlugin::details() const
71 {
72     return i18nc("@info", "This Image Editor tool can emulate color negative film from image.");
73 }
74 
authors() const75 QList<DPluginAuthor> FilmToolPlugin::authors() const
76 {
77     return QList<DPluginAuthor>()
78             << DPluginAuthor(QString::fromUtf8("Matthias Welwarsky"),
79                              QString::fromUtf8("matthias at welwarsky dot de"),
80                              QString::fromUtf8("(C) 2012"))
81             ;
82 }
83 
setup(QObject * const parent)84 void FilmToolPlugin::setup(QObject* const parent)
85 {
86     DPluginAction* const ac = new DPluginAction(parent);
87     ac->setIcon(icon());
88     ac->setText(i18nc("@action", "Color Negative..."));
89     ac->setObjectName(QLatin1String("editorwindow_color_film"));
90     ac->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_I);
91     ac->setActionCategory(DPluginAction::EditorColors);
92 
93     connect(ac, SIGNAL(triggered(bool)),
94             this, SLOT(slotFilmTool()));
95 
96     addAction(ac);
97 }
98 
slotFilmTool()99 void FilmToolPlugin::slotFilmTool()
100 {
101     EditorWindow* const editor = dynamic_cast<EditorWindow*>(sender()->parent());
102 
103     if (editor)
104     {
105         FilmTool* const tool = new FilmTool(editor);
106         tool->setPlugin(this);
107         editor->loadTool(tool);
108     }
109 }
110 
111 } // namespace DigikamEditorFilmToolPlugin
112