Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_multinode_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/******************************************************************/
10/* MultinodePropertyConnectorInterface */
11/******************************************************************/
12
16
17void MultinodePropertyConnectorInterface::connectValueChangedSignal(const QObject *receiver, const char *method, Qt::ConnectionType type) {
18 connect(this, SIGNAL(sigValueChanged()), receiver, method, type);
20}
21
25
27{
28 Q_UNUSED(widget);
29}
30
31/******************************************************************/
32/* MultinodePropertyBaseConnector */
33/******************************************************************/
34
39
41 m_ignoreBox = ignoreBox;
42
44 m_ignoreBox->setEnabled(false);
45 m_ignoreBox->setChecked(true);
46
48 m_ignoreBox->setVisible(false);
49 }
50 } else {
51 connect(m_ignoreBox, SIGNAL(stateChanged(int)), SLOT(slotIgnoreCheckBoxChanged(int)));
52 m_ignoreBox->setEnabled(true);
53 m_ignoreBox->setChecked(!m_parent->isIgnored());
54 }
55}
56
57#include <QEvent>
58
59struct AutoEnabler : public QObject {
60 Q_OBJECT
61public:
62 AutoEnabler(QObject *watched, KisMultinodePropertyInterface *property, QObject *parent)
63 : QObject(parent), m_watched(watched), m_property(property)
64 {
65 watched->installEventFilter(this);
66 }
67
68 bool eventFilter(QObject *watched, QEvent * event) override {
69 if (watched != m_watched) return false;
70 if (!m_property->isIgnored()) return false;
71
72 if (event->type() == QEvent::MouseButtonPress ||
73 event->type() == QEvent::TabletPress) {
74
75 Q_EMIT enableWidget(true);
76 }
77
78 return false;
79 }
80Q_SIGNALS:
81 void enableWidget(bool value);
82
83private:
84 QObject *m_watched;
86};
87
89{
91
92 AutoEnabler *enabler = new AutoEnabler(widget, m_parent, this);
93 connect(enabler, SIGNAL(enableWidget(bool)), m_ignoreBox, SLOT(setChecked(bool)));
94}
95
97 m_parent->setIgnored(state != Qt::Checked);
98}
99
101 if (!m_ignoreBox) return;
102
103 if (m_ignoreBox->isChecked() != !m_parent->isIgnored()) {
104 m_ignoreBox->setChecked(!m_parent->isIgnored());
105 }
106}
107
108/******************************************************************/
109/* KisMultinodePropertyInterface */
110/******************************************************************/
111
115
119
120#include "kis_multinode_property.moc"
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
virtual void setIgnored(bool value)=0
virtual bool savedValuesDiffer() const =0
virtual bool haveTheOnlyNode() const =0
virtual bool isIgnored() const =0
MultinodePropertyBaseConnector(KisMultinodePropertyInterface *parent)
void connectAutoEnableWidget(QWidget *widget) override
KisMultinodePropertyInterface * m_parent
void slotIgnoreCheckBoxChanged(int state) override
void connectIgnoreCheckBox(QCheckBox *ignoreBox) override
virtual void connectAutoEnableWidget(QWidget *widget)
void connectValueChangedSignal(const QObject *receiver, const char *method, Qt::ConnectionType type=Qt::AutoConnection)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
KisMultinodePropertyInterface * m_property
void enableWidget(bool value)
bool eventFilter(QObject *watched, QEvent *event) override
AutoEnabler(QObject *watched, KisMultinodePropertyInterface *property, QObject *parent)