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 adjust HSL
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 "hsltoolplugin.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 "hsltool.h"
37 
38 namespace DigikamEditorHSLToolPlugin
39 {
40 
HSLToolPlugin(QObject * const parent)41 HSLToolPlugin::HSLToolPlugin(QObject* const parent)
42     : DPluginEditor(parent)
43 {
44 }
45 
~HSLToolPlugin()46 HSLToolPlugin::~HSLToolPlugin()
47 {
48 }
49 
name() const50 QString HSLToolPlugin::name() const
51 {
52     return i18nc("@title", "HSL Correction");
53 }
54 
iid() const55 QString HSLToolPlugin::iid() const
56 {
57     return QLatin1String(DPLUGIN_IID);
58 }
59 
icon() const60 QIcon HSLToolPlugin::icon() const
61 {
62     return QIcon::fromTheme(QLatin1String("adjusthsl"));
63 }
64 
description() const65 QString HSLToolPlugin::description() const
66 {
67     return i18nc("@info", "A tool to fix Hue / Saturation / Lightness");
68 }
69 
details() const70 QString HSLToolPlugin::details() const
71 {
72     return i18nc("@info", "This Image Editor tool can adjust Hue / Saturation / Lightness from image.");
73 }
74 
authors() const75 QList<DPluginAuthor> HSLToolPlugin::authors() const
76 {
77     return QList<DPluginAuthor>()
78             << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
79                              QString::fromUtf8("caulier dot gilles at gmail dot com"),
80                              QString::fromUtf8("(C) 2004-2021"))
81             ;
82 }
83 
setup(QObject * const parent)84 void HSLToolPlugin::setup(QObject* const parent)
85 {
86     DPluginAction* const ac = new DPluginAction(parent);
87     ac->setIcon(icon());
88     ac->setText(i18nc("@action", "Hue/Saturation/Lightness..."));
89     ac->setObjectName(QLatin1String("editorwindow_color_hsl"));
90     // NOTE: Photoshop 7 use CTRL+U.
91     ac->setShortcut(Qt::CTRL + Qt::Key_U);
92     ac->setActionCategory(DPluginAction::EditorColors);
93 
94     connect(ac, SIGNAL(triggered(bool)),
95             this, SLOT(slotHSL()));
96 
97     addAction(ac);
98 }
99 
slotHSL()100 void HSLToolPlugin::slotHSL()
101 {
102     EditorWindow* const editor = dynamic_cast<EditorWindow*>(sender()->parent());
103 
104     if (editor)
105     {
106         HSLTool* const tool = new HSLTool(editor);
107         tool->setPlugin(this);
108         editor->loadTool(tool);
109     }
110 }
111 
112 } // namespace DigikamEditorHSLToolPlugin
113