Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSampleScreenColor.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 killy |0veufOrever <80536642@qq.com>
3 * SPDX-FileCopyrightText: 2023 Deif Lou <ginoba@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
9
11#include <kpluginfactory.h>
12#include <kis_action.h>
14#include <KisViewManager.h>
15
16K_PLUGIN_FACTORY_WITH_JSON(KisSampleScreenColorFactory, "kritasamplescreencolor.json", registerPlugin<KisSampleScreenColor>();)
17
18KisSampleScreenColor::KisSampleScreenColor(QObject *parent, const QVariantList &)
19 : KisActionPlugin(parent)
20{
21 KisAction *action = createAction("sample_screen_color");
22 connect(action, &QAction::triggered, [this](){ slotSampleScreenColor(false); });
23
24 action = createAction("sample_screen_color_real_canvas");
25 connect(action, &QAction::triggered, [this](){ slotSampleScreenColor(true); });
26}
27
30
32{
34 // The action will cancel the previous one if it is still active
36 // If the new action type is the same as the previous, cancelling is
37 // enough, so we return. Otherwise, a new operation is started
38 if (sampleRealCanvas == m_lastSampleRealCanvas) {
39 return;
40 }
41 }
42
43 m_lastSampleRealCanvas = sampleRealCanvas;
46 m_screenColorSampler->setCurrentColor(viewManager()->canvasResourceProvider()->fgColor());
47 // screenColorSampler is a temporary top level widget own by no other
48 // QObject, so it must be automatically deleted when it is closed
49 m_screenColorSampler->setAttribute(Qt::WA_DeleteOnClose);
51 [this](KoColor sampledColor)
52 {
53 viewManager()->canvasResourceProvider()->slotSetFGColor(sampledColor);
54 m_screenColorSampler->close();
55 m_screenColorSampler = nullptr;
56 }
57 );
59 [this](KoColor sampledColor)
60 {
61 viewManager()->canvasResourceProvider()->slotSetFGColor(sampledColor);
62 }
63 );
65}
66
67#include "KisSampleScreenColor.moc"
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QPointer< KisViewManager > viewManager() const
KisScreenColorSampler * m_screenColorSampler
void slotSampleScreenColor(bool sampleRealCanvas)
KisSampleScreenColor(QObject *parent, const QVariantList &)
The KisScreenColorSampler class Based on the original QColorDialog's screen color picker,...
void sigNewColorHovered(KoColor c)
void sigNewColorSampled(KoColor c)
void setPerformRealColorSamplingOfCanvas(bool enable)
K_PLUGIN_FACTORY_WITH_JSON(KritaASCCDLFactory, "kritaasccdl.json", registerPlugin< KritaASCCDL >();) KritaASCCDL