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 color curves.
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 "adjustcurvestoolplugin.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 "adjustcurvestool.h"
37
38 namespace DigikamEditorAdjustCurvesToolPlugin
39 {
40
AdjustCurvesToolPlugin(QObject * const parent)41 AdjustCurvesToolPlugin::AdjustCurvesToolPlugin(QObject* const parent)
42 : DPluginEditor(parent)
43 {
44 }
45
~AdjustCurvesToolPlugin()46 AdjustCurvesToolPlugin::~AdjustCurvesToolPlugin()
47 {
48 }
49
name() const50 QString AdjustCurvesToolPlugin::name() const
51 {
52 return i18nc("@title", "Adjust Curves");
53 }
54
iid() const55 QString AdjustCurvesToolPlugin::iid() const
56 {
57 return QLatin1String(DPLUGIN_IID);
58 }
59
icon() const60 QIcon AdjustCurvesToolPlugin::icon() const
61 {
62 return QIcon::fromTheme(QLatin1String("adjustcurves"));
63 }
64
description() const65 QString AdjustCurvesToolPlugin::description() const
66 {
67 return i18nc("@info", "A tool to adjust color curves");
68 }
69
details() const70 QString AdjustCurvesToolPlugin::details() const
71 {
72 return i18nc("@info", "This Image Editor tool can adjust the color curves from image.");
73 }
74
authors() const75 QList<DPluginAuthor> AdjustCurvesToolPlugin::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 AdjustCurvesToolPlugin::setup(QObject* const parent)
85 {
86 DPluginAction* const ac = new DPluginAction(parent);
87 ac->setIcon(icon());
88 ac->setText(i18nc("@action", "Curves Adjust..."));
89 ac->setObjectName(QLatin1String("editorwindow_color_adjustcurves"));
90 // NOTE: Photoshop 7 use CTRL+M (but it's used in KDE to toogle menu bar).
91 ac->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_C);
92 ac->setActionCategory(DPluginAction::EditorColors);
93
94 connect(ac, SIGNAL(triggered(bool)),
95 this, SLOT(slotAdjustCurvesTool()));
96
97 addAction(ac);
98 }
99
slotAdjustCurvesTool()100 void AdjustCurvesToolPlugin::slotAdjustCurvesTool()
101 {
102 EditorWindow* const editor = dynamic_cast<EditorWindow*>(sender()->parent());
103
104 if (editor)
105 {
106 AdjustCurvesTool* const tool = new AdjustCurvesTool(editor);
107 tool->setPlugin(this);
108 editor->loadTool(tool);
109 }
110 }
111
112 } // namespace DigikamEditorAdjustCurvesToolPlugin
113