Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_separate_channels_plugin.cc
Go to the documentation of this file.
1/*
2 * This file is part of the KDE project
3 *
4 * SPDX-FileCopyrightText: 2005 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
10
11#include <QApplication>
12
13#include <klocalizedstring.h>
14#include <kis_debug.h>
15#include <kpluginfactory.h>
16
17#include <KoProgressUpdater.h>
18#include <KoUpdater.h>
19#include <KoColorSpace.h>
20
21#include <KisViewManager.h>
22#include <kis_types.h>
23#include <kis_image.h>
24#include <kis_paint_device.h>
25#include <kis_layer.h>
26#include <kis_statusbar.h>
27#include <kis_node_manager.h>
29#include <kis_action.h>
31
33#include "dlg_separate.h"
34
35K_PLUGIN_FACTORY_WITH_JSON(KisSeparateChannelsPluginFactory, "kritaseparatechannels.json", registerPlugin<KisSeparateChannelsPlugin>();)
36
37KisSeparateChannelsPlugin::KisSeparateChannelsPlugin(QObject *parent, const QVariantList &)
38 : KisActionPlugin(parent)
39{
40 KisAction *action = createAction("separate");
41 connect(action, SIGNAL(triggered(bool)), SLOT(slotSeparate()));
42}
43
47
49{
50 KisImageSP image = viewManager()->image();
51 if (!image) return;
52
53 KisLayerSP l = viewManager()->nodeManager()->activeLayer();
54 if (!l) return;
55
57 if (!dev) return;
58
59 DlgSeparate * dlgSeparate = new DlgSeparate(dev->colorSpace()->name(),
60 image->colorSpace()->name(), viewManager()->mainWindowAsQWidget(), "Separate");
61 Q_CHECK_PTR(dlgSeparate);
62
63 dlgSeparate->setCaption(i18n("Separate Image"));
64
65 // If we're 8-bits, disable the downscale option
66 if (dev->pixelSize() == dev->channelCount()) {
67 dlgSeparate->enableDownscale(false);
68 }
69
70 if (dlgSeparate->exec() == QDialog::Accepted) {
71
72 KisCursorOverrideLock cursorLock(Qt::BusyCursor);
73
75 separator.separate(viewManager()->createUnthreadedUpdater(i18n("Separate Image")),
76 dlgSeparate->getAlphaOptions(),
77 dlgSeparate->getSource(),
78 dlgSeparate->getDownscale(),
79 dlgSeparate->getToColor(),
80 dlgSeparate->getActivateCurrentChannel());
81 }
82
83 delete dlgSeparate;
84
85}
86
87#include "kis_separate_channels_plugin.moc"
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
bool getDownscale()
void enableDownscale(bool enable)
enumSepSource getSource()
enumSepAlphaOptions getAlphaOptions()
bool getToColor()
bool getActivateCurrentChannel()
QPointer< KisViewManager > viewManager() const
void separate(KoUpdater *progress, enumSepAlphaOptions alphaOps, enumSepSource sourceOps, bool downscale, bool toColor, bool activateCurrentChannel)
const KoColorSpace * colorSpace() const
quint32 pixelSize() const
quint32 channelCount() const
const KoColorSpace * colorSpace() const
KisSeparateChannelsPlugin(QObject *parent, const QVariantList &)
virtual void setCaption(const QString &caption)
Definition KoDialog.cpp:498
K_PLUGIN_FACTORY_WITH_JSON(KritaASCCDLFactory, "kritaasccdl.json", registerPlugin< KritaASCCDL >();) KritaASCCDL
virtual KisPaintDeviceSP paintDevice() const =0