colorrange.cc 2.42 KB
Newer Older
1
/*
2
 * colorrange.h -- Part of Krita
3 4 5
 *
 * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org)
 *
Boudewijn Rempt's avatar
Boudewijn Rempt committed
6 7 8 9
 *  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 of the License, or
 *  (at your option) any later version.
10
 *
Boudewijn Rempt's avatar
Boudewijn Rempt committed
11 12 13 14
 *  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.
15
 *
Boudewijn Rempt's avatar
Boudewijn Rempt committed
16 17
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 20
 */

Boudewijn Rempt's avatar
Boudewijn Rempt committed
21 22
#include "colorrange.h"

23 24 25 26 27

#include <math.h>

#include <stdlib.h>

28
#include <QSlider>
29
#include <QPoint>
30 31 32

#include <klocale.h>
#include <kiconloader.h>
33
#include <kcomponentdata.h>
34 35
#include <kmessagebox.h>
#include <kstandarddirs.h>
36
#include <kis_debug.h>
37
#include <kgenericfactory.h>
38
#include <kactioncollection.h>
39

Adrian Page's avatar
Adrian Page committed
40 41 42 43 44
#include "kis_image.h"
#include "kis_layer.h"
#include "kis_paint_device.h"
#include "kis_global.h"
#include "kis_types.h"
45
#include "kis_view2.h"
Adrian Page's avatar
Adrian Page committed
46 47
#include "kis_selection.h"
#include "kis_selection_manager.h"
Boudewijn Rempt's avatar
Boudewijn Rempt committed
48

49 50 51
#include "dlg_colorrange.h"

typedef KGenericFactory<ColorRange> ColorRangeFactory;
Boudewijn Rempt's avatar
Boudewijn Rempt committed
52
K_EXPORT_COMPONENT_FACTORY(kritacolorrange, ColorRangeFactory("krita"))
53

54
ColorRange::ColorRange(QObject *parent, const QStringList &)
Boudewijn Rempt's avatar
Boudewijn Rempt committed
55
        : KParts::Plugin(parent)
56
{
57
    if (parent->inherits("KisView2")) {
58
        setComponentData(ColorRangeFactory::componentData());
59

Boudewijn Rempt's avatar
Boudewijn Rempt committed
60 61
        setXMLFile(KStandardDirs::locate("data", "kritaplugins/colorrange.rc"),
                   true);
62
        m_view = dynamic_cast<KisView2*>(parent);
Boudewijn Rempt's avatar
Boudewijn Rempt committed
63 64
        QAction *action  = new KAction(i18n("&Color Range..."), this);
        actionCollection()->addAction("colorrange", action);
Adrian Page's avatar
Adrian Page committed
65
        connect(action, SIGNAL(triggered()), this, SLOT(slotActivated()));
66
        m_view->selectionManager()->addSelectionAction(action);
67
    }
68 69 70 71 72 73 74 75
}

ColorRange::~ColorRange()
{
}

void ColorRange::slotActivated()
{
76
    KisPaintDeviceSP layer = m_view->activeDevice();
77
    if (!layer) return;
78

79 80
    DlgColorRange * dlgColorRange = new DlgColorRange(m_view, layer, m_view, "ColorRange");
    Q_CHECK_PTR(dlgColorRange);
81

82
    dlgColorRange->exec();
83 84 85 86
}

#include "colorrange.moc"