Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_uniform_paintop_property.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QVariant>
10#include "kis_debug.h"
12
14{
15 Private(Type _type, SubType _subType, const KoID &_id, KisPaintOpSettingsSP _settings)
16 : type(_type)
17 , subType(_subType)
18 , id(_id)
19 , settings(_settings)
20 , isReadingValue(false)
21 , isWritingValue(false)
22 {
23 }
24
28
29 QVariant value;
30
34};
35
37 : QObject(parent)
38 , m_d(new Private(type, subType, id, settings))
40}
41
43 : QObject(parent)
44 , m_d(new Private(type, SubType_None, id, settings))
45{
46}
47
49 : QObject(parent)
50 , m_d(new Private(Bool, SubType_None, id, settings))
51{
52}
53
57
59{
60 return m_d->id.id();
61}
62
64{
65 return m_d->id.name();
66}
67
72
77
79{
80 return m_d->value;
81}
82
84{
85 return nullptr;
86}
87
89{
90 if (m_d->value == value) return;
91 m_d->value = value;
92
93 Q_EMIT valueChanged(value);
94
95 if (!m_d->isReadingValue) {
96 m_d->isWritingValue = true;
98 m_d->isWritingValue = false;
99 }
100}
101
103{
104 if (m_d->isWritingValue) return;
105
106 m_d->isReadingValue = true;
108 m_d->isReadingValue = false;
109}
110
112{
113 // correct conversion weak-to-strong shared pointer
114 return m_d->settings ? m_d->settings : KisPaintOpSettingsSP();
115}
116
118{
119 return true;
120}
121
125
129
131
132template class KRITAIMAGE_EXPORT_INSTANCE
float value(const T *src, size_t ch)
void valueChanged(const QVariant &value)
void setValue(const QVariant &value)
KisUniformPaintOpProperty(Type type, SubType subType, const KoID &id, KisPaintOpSettingsRestrictedSP settings, QObject *parent)
KisPaintOpSettingsSP settings() const
SubType
Hint to guess what this property is used for.
const QScopedPointer< Private > m_d
Definition KoID.h:30
#define KRITAIMAGE_EXPORT_INSTANCE
KisPinnedSharedPtr< KisPaintOpSettings > KisPaintOpSettingsSP
Definition kis_types.h:242
Private(Type _type, SubType _subType, const KoID &_id, KisPaintOpSettingsSP _settings)