plugin_removeredeyes.cpp 2.79 KB
Newer Older
Andi Clemens's avatar
Andi Clemens committed
1
2
3
/* ============================================================
 *
 * This file is a part of kipi-plugins project
4
 * http://www.digikam.org
Andi Clemens's avatar
Andi Clemens committed
5
6
7
8
9
 *
 * Date        : 2008-06-08
 * Description : a kipi plugin to automatically detect
 *               and remove red eyes from images
 *
Andi Clemens's avatar
Andi Clemens committed
10
 * Copyright (C) 2008-2009 by Andi Clemens <andi dot clemens at googlemail dot com>
Andi Clemens's avatar
Andi Clemens committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * ============================================================ */

#include "plugin_removeredeyes.moc"

27
// KDE includes
Andi Clemens's avatar
Andi Clemens committed
28
29
30
31
32
33
34
35
36

#include <kaction.h>
#include <kactioncollection.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kgenericfactory.h>
#include <klibloader.h>
#include <klocale.h>

37
// LibKIPI includes
Andi Clemens's avatar
Andi Clemens committed
38
39
40
41

#include <libkipi/imagecollection.h>
#include <libkipi/interface.h>

42
// Local includes
Andi Clemens's avatar
Andi Clemens committed
43

Andi Clemens's avatar
Andi Clemens committed
44
#include "removeredeyeswindow.h"
Andi Clemens's avatar
Andi Clemens committed
45

Gilles Caulier's avatar
Gilles Caulier committed
46
47
48
namespace KIPIRemoveRedEyesPlugin
{

Andi Clemens's avatar
Andi Clemens committed
49
50
51
K_PLUGIN_FACTORY( RemoveRedEyesFactory, registerPlugin<Plugin_RemoveRedEyes>(); )
K_EXPORT_PLUGIN ( RemoveRedEyesFactory("kipiplugin_removeredeyes") )

Gilles Caulier's avatar
Gilles Caulier committed
52
53
Plugin_RemoveRedEyes::Plugin_RemoveRedEyes(QObject* const parent, const QVariantList& /*args*/)
    : Plugin(RemoveRedEyesFactory::componentData(), parent, "RemoveRedEyes"),
Andi Clemens's avatar
Andi Clemens committed
54
      m_action(0)
Andi Clemens's avatar
Andi Clemens committed
55
{
56
    kDebug(AREA_CODE_LOADING) << "Plugin_RemoveRedEyes plugin loaded";
Andi Clemens's avatar
Andi Clemens committed
57
58
}

Andi Clemens's avatar
Andi Clemens committed
59
void Plugin_RemoveRedEyes::setup(QWidget* widget)
Andi Clemens's avatar
Andi Clemens committed
60
{
Gilles Caulier's avatar
Gilles Caulier committed
61
    Plugin::setup(widget);
Andi Clemens's avatar
Andi Clemens committed
62

63
    m_action = actionCollection()->addAction("removeredeyes");
64
    m_action->setText(i18n("&Red-Eye Removal..."));
65
    m_action->setIcon(KIcon("draw-eraser"));
Andi Clemens's avatar
Andi Clemens committed
66

Andi Clemens's avatar
Andi Clemens committed
67
    connect(m_action, SIGNAL(triggered(bool)),
68
            this, SLOT(activate()));
Andi Clemens's avatar
Andi Clemens committed
69

70
71
    addAction(m_action);

Gilles Caulier's avatar
Gilles Caulier committed
72
    Interface* interface = dynamic_cast<Interface*> (parent());
Andi Clemens's avatar
Andi Clemens committed
73
74
75

    if (!interface)
    {
76
        kError() << "Kipi interface is null!";
Andi Clemens's avatar
Andi Clemens committed
77
78
        return;
    }
79
80
81

    connect(interface, SIGNAL(selectionChanged(bool)),
            m_action, SLOT(setEnabled(bool)));
Andi Clemens's avatar
Andi Clemens committed
82
83
}

Andi Clemens's avatar
Andi Clemens committed
84
85
86
87
Plugin_RemoveRedEyes::~Plugin_RemoveRedEyes()
{
}

88
void Plugin_RemoveRedEyes::activate()
Andi Clemens's avatar
Andi Clemens committed
89
{
Gilles Caulier's avatar
Gilles Caulier committed
90
    RemoveRedEyesWindow* window = new RemoveRedEyesWindow();
Andi Clemens's avatar
polish    
Andi Clemens committed
91
    window->show();
Andi Clemens's avatar
Andi Clemens committed
92
93
}

Gilles Caulier's avatar
Gilles Caulier committed
94
Category Plugin_RemoveRedEyes::category(KAction* action) const
Andi Clemens's avatar
Andi Clemens committed
95
{
Andi Clemens's avatar
Andi Clemens committed
96
    if (action == m_action)
Andi Clemens's avatar
Andi Clemens committed
97
    {
Gilles Caulier's avatar
Gilles Caulier committed
98
        return BatchPlugin;
Andi Clemens's avatar
Andi Clemens committed
99
    }
Andi Clemens's avatar
Andi Clemens committed
100

101
    kWarning() << "Unrecognized action for plugin category identification";
Gilles Caulier's avatar
Gilles Caulier committed
102
    return BatchPlugin; // no warning from compiler, please
Andi Clemens's avatar
Andi Clemens committed
103
}
Gilles Caulier's avatar
Gilles Caulier committed
104
105

} // namespace KIPIRemoveRedEyesPlugin