Krita Source Code Documentation
Loading...
Searching...
No Matches
KisCompositeOpListConnectionHelper.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
7
8#include <QMetaObject>
9#include <QMetaProperty>
11#include <kis_assert.h>
12#include "kis_cmb_composite.h"
13
15{
17{
18 Q_OBJECT
19public:
20
22 : QObject(parent),
23 m_listWidget(parent)
24 {
25 connect(parent, &KisCompositeOpListWidget::clicked,
27 }
28public Q_SLOTS:
32
33 void slotPropertyChanged(const QString &id) {
35 }
36
37Q_SIGNALS:
38 void sigWidgetChanged(const QString &id);
39
40private:
42};
43
44void connectControl(KisCompositeOpListWidget *widget, QObject *source, const char *property)
45{
46 const QMetaObject* meta = source->metaObject();
47 QMetaProperty prop = meta->property(meta->indexOfProperty(property));
48
49 KIS_SAFE_ASSERT_RECOVER_RETURN(prop.hasNotifySignal());
50
51 QMetaMethod signal = prop.notifySignal();
52
53 KIS_SAFE_ASSERT_RECOVER_RETURN(signal.parameterCount() >= 1);
54 KIS_SAFE_ASSERT_RECOVER_RETURN(signal.parameterType(0) == QMetaType::type("QString"));
55
57
58 const QMetaObject* dstMeta = helper->metaObject();
59
60 QMetaMethod updateSlot = dstMeta->method(
61 dstMeta->indexOfSlot("slotPropertyChanged(QString)"));
62 QObject::connect(source, signal, helper, updateSlot);
63
64 helper->slotPropertyChanged(prop.read(source).value<QString>());
65
66 if (prop.isWritable()) {
67 QObject::connect(helper, &ConnectCompositeOpListWidgetHelper::sigWidgetChanged, [prop, source] (const QString &value) { prop.write(source, QVariant::fromValue(value)); });
68 }
69}
70
71}
72
73#include "KisCompositeOpListConnectionHelper.moc"
float value(const T *src, size_t ch)
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void setCompositeOp(const KoID &id)
static const KoCompositeOpRegistry & instance()
QString id() const
Definition KoID.cpp:63
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
void connectControl(KisCompositeOpListWidget *widget, QObject *source, const char *property)