1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "segmentproperties.h"
5#include "splineeditor.h"
6
7SegmentProperties::SegmentProperties(QWidget *parent) :
8 QWidget(parent), m_splineEditor(nullptr), m_blockSignals(false)
9{
10 QVBoxLayout *layout = new QVBoxLayout(this);
11 layout->setContentsMargins(QMargins());
12 layout->setSpacing(2);
13 setLayout(layout);
14 {
15 QWidget *widget = new QWidget(this);
16 m_ui_pane_c1.setupUi(widget);
17 m_ui_pane_c1.label->setText("c1");
18 m_ui_pane_c1.smooth->setVisible(false);
19 layout->addWidget(widget);
20
21 connect(m_ui_pane_c1.p1_x, &QDoubleSpinBox::valueChanged, this, &SegmentProperties::c1Updated);
22 connect(m_ui_pane_c1.p1_y, &QDoubleSpinBox::valueChanged, this, &SegmentProperties::c1Updated);
23 }
24 {
25 QWidget *widget = new QWidget(this);
26 m_ui_pane_c2.setupUi(widget);
27 m_ui_pane_c2.label->setText("c2");
28 m_ui_pane_c2.smooth->setVisible(false);
29 layout->addWidget(widget);
30
31 connect(m_ui_pane_c2.p1_x, &QDoubleSpinBox::valueChanged, this, &SegmentProperties::c2Updated);
32 connect(m_ui_pane_c2.p1_y, &QDoubleSpinBox::valueChanged, this, &SegmentProperties::c2Updated);
33 }
34 {
35 QWidget *widget = new QWidget(this);
36 m_ui_pane_p.setupUi(widget);
37 m_ui_pane_p.label->setText("p1");
38 layout->addWidget(widget);
39
40 connect(m_ui_pane_p.smooth, &QCheckBox::toggled, this, &SegmentProperties::pUpdated);
41 connect(m_ui_pane_p.p1_x, &QDoubleSpinBox::valueChanged, this, &SegmentProperties::pUpdated);
42 connect(m_ui_pane_p.p1_y, &QDoubleSpinBox::valueChanged, this, &SegmentProperties::pUpdated);
43 }
44}
45
46void SegmentProperties::c1Updated()
47{
48 if (m_splineEditor && !m_blockSignals) {
49 QPointF c1(m_ui_pane_c1.p1_x->value(), m_ui_pane_c1.p1_y->value());
50 m_splineEditor->setControlPoint(index: m_segment * 3, point: c1);
51 }
52}
53
54void SegmentProperties::c2Updated()
55{
56 if (m_splineEditor && !m_blockSignals) {
57 QPointF c2(m_ui_pane_c2.p1_x->value(), m_ui_pane_c2.p1_y->value());
58 m_splineEditor->setControlPoint(index: m_segment * 3 + 1, point: c2);
59 }
60}
61
62void SegmentProperties::pUpdated()
63{
64 if (m_splineEditor && !m_blockSignals) {
65 QPointF p(m_ui_pane_p.p1_x->value(), m_ui_pane_p.p1_y->value());
66 bool smooth = m_ui_pane_p.smooth->isChecked();
67 m_splineEditor->setControlPoint(index: m_segment * 3 + 2, point: p);
68 m_splineEditor->setSmooth(index: m_segment, smooth);
69 }
70}
71
72void SegmentProperties::invalidate()
73{
74 m_blockSignals = true;
75
76 m_ui_pane_p.label->setText(QLatin1Char('p') + QString::number(m_segment));
77 m_ui_pane_p.smooth->setChecked(m_smooth);
78 m_ui_pane_p.smooth->parentWidget()->setEnabled(!m_last);
79
80 m_ui_pane_c1.p1_x->setValue(m_points.at(0).x());
81 m_ui_pane_c1.p1_y->setValue(m_points.at(0).y());
82
83 m_ui_pane_c2.p1_x->setValue(m_points.at(1).x());
84 m_ui_pane_c2.p1_y->setValue(m_points.at(1).y());
85
86 m_ui_pane_p.p1_x->setValue(m_points.at(2).x());
87 m_ui_pane_p.p1_y->setValue(m_points.at(2).y());
88
89 m_blockSignals = false;
90}
91
92#include "moc_segmentproperties.cpp"
93

source code of qtdeclarative/tools/qmleasing/segmentproperties.cpp