QmlDesigner: Drop static_cast from connections

These signals are not overloaded anymore in Qt 6.
Simplify widget creation in CurveEditorStyleDialog.

Change-Id: I4937db8c3dad10e7c0b2aa007739d71ae5992486
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
This commit is contained in:
Jarek Kobus
2022-11-02 16:42:40 +01:00
parent 1b6fd9f328
commit a43f5db582
2 changed files with 59 additions and 66 deletions

View File

@@ -82,73 +82,66 @@ CurveEditorStyleDialog::CurveEditorStyleDialog(CurveEditorStyle &style, QWidget
connect(m_printButton, &QPushButton::released, this, &CurveEditorStyleDialog::printStyle); connect(m_printButton, &QPushButton::released, this, &CurveEditorStyleDialog::printStyle);
auto intChanged = [this](int) { emitStyleChanged(); }; class WidgetAdder
auto doubleChanged = [this](double) { emitStyleChanged(); }; {
auto colorChanged = [this]() { emitStyleChanged(); }; public:
WidgetAdder(CurveEditorStyleDialog *dialog, QVBoxLayout *box)
auto intSignal = static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged); : m_dialog(dialog), m_box(box) {}
auto doubleSignal = static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged); void add(const QString &title, StyleEditor::ColorControl *widget) {
QObject::connect(widget, &StyleEditor::ColorControl::valueChanged,
connect(m_background, &StyleEditor::ColorControl::valueChanged, colorChanged); m_dialog, &CurveEditorStyleDialog::emitStyleChanged);
connect(m_backgroundAlternate, &StyleEditor::ColorControl::valueChanged, colorChanged); addToLayout(title, widget);
connect(m_fontColor, &StyleEditor::ColorControl::valueChanged, colorChanged); }
connect(m_gridColor, &StyleEditor::ColorControl::valueChanged, colorChanged); void add(const QString &title, QSpinBox *widget) {
connect(m_canvasMargin, doubleSignal, doubleChanged); QObject::connect(widget, &QSpinBox::valueChanged,
connect(m_zoomInWidth, intSignal, intChanged); m_dialog, &CurveEditorStyleDialog::emitStyleChanged);
connect(m_zoomInHeight, intSignal, intChanged); addToLayout(title, widget);
connect(m_timeAxisHeight, doubleSignal, doubleChanged); }
connect(m_timeOffsetLeft, doubleSignal, doubleChanged); void add(const QString &title, QDoubleSpinBox *widget) {
connect(m_timeOffsetRight, doubleSignal, doubleChanged); QObject::connect(widget, &QDoubleSpinBox::valueChanged,
connect(m_rangeBarColor, &StyleEditor::ColorControl::valueChanged, colorChanged); m_dialog, &CurveEditorStyleDialog::emitStyleChanged);
connect(m_rangeBarCapsColor, &StyleEditor::ColorControl::valueChanged, colorChanged); addToLayout(title, widget);
connect(m_valueAxisWidth, doubleSignal, doubleChanged); }
connect(m_valueOffsetTop, doubleSignal, doubleChanged); private:
connect(m_valueOffsetBottom, doubleSignal, doubleChanged); void addToLayout(const QString &title, QWidget *widget){
connect(m_handleSize, doubleSignal, doubleChanged); m_box->addLayout(createRow(title, widget));
connect(m_handleLineWidth, doubleSignal, doubleChanged); }
connect(m_handleColor, &StyleEditor::ColorControl::valueChanged, colorChanged); CurveEditorStyleDialog *m_dialog;
connect(m_handleSelectionColor, &StyleEditor::ColorControl::valueChanged, colorChanged); QVBoxLayout *m_box;
connect(m_keyframeSize, doubleSignal, doubleChanged); };
connect(m_keyframeColor, &StyleEditor::ColorControl::valueChanged, colorChanged);
connect(m_keyframeSelectionColor, &StyleEditor::ColorControl::valueChanged, colorChanged);
connect(m_curveWidth, doubleSignal, doubleChanged);
connect(m_curveColor, &StyleEditor::ColorControl::valueChanged, colorChanged);
connect(m_curveSelectionColor, &StyleEditor::ColorControl::valueChanged, colorChanged);
connect(m_treeMargins, doubleSignal, doubleChanged);
connect(m_playheadWidth, doubleSignal, doubleChanged);
connect(m_playheadRadius, doubleSignal, doubleChanged);
connect(m_playheadColor, &StyleEditor::ColorControl::valueChanged, colorChanged);
auto *box = new QVBoxLayout; auto *box = new QVBoxLayout;
box->addLayout(createRow("Background Color", m_background));
box->addLayout(createRow("Alternate Background Color", m_backgroundAlternate)); WidgetAdder adder(this, box);
box->addLayout(createRow("Font Color", m_fontColor)); adder.add("Background Color", m_background);
box->addLayout(createRow("Grid Color", m_gridColor)); adder.add("Alternate Background Color", m_backgroundAlternate);
box->addLayout(createRow("Canvas Margin", m_canvasMargin)); adder.add("Font Color", m_fontColor);
box->addLayout(createRow("Zoom In Width", m_zoomInWidth)); adder.add("Grid Color", m_gridColor);
box->addLayout(createRow("Zoom In Height", m_zoomInHeight)); adder.add("Canvas Margin", m_canvasMargin);
box->addLayout(createRow("Time Axis Height", m_timeAxisHeight)); adder.add("Zoom In Width", m_zoomInWidth);
box->addLayout(createRow("Time Axis Left Offset", m_timeOffsetLeft)); adder.add("Zoom In Height", m_zoomInHeight);
box->addLayout(createRow("Time Axis Right Offset", m_timeOffsetRight)); adder.add("Time Axis Height", m_timeAxisHeight);
box->addLayout(createRow("Range Bar Color", m_rangeBarColor)); adder.add("Time Axis Left Offset", m_timeOffsetLeft);
box->addLayout(createRow("Range Bar Caps Color", m_rangeBarCapsColor)); adder.add("Time Axis Right Offset", m_timeOffsetRight);
box->addLayout(createRow("Value Axis Width", m_valueAxisWidth)); adder.add("Range Bar Color", m_rangeBarColor);
box->addLayout(createRow("Value Axis Top Offset", m_valueOffsetTop)); adder.add("Range Bar Caps Color", m_rangeBarCapsColor);
box->addLayout(createRow("Value Axis Bottom Offset", m_valueOffsetBottom)); adder.add("Value Axis Width", m_valueAxisWidth);
box->addLayout(createRow("Handle Size", m_handleSize)); adder.add("Value Axis Top Offset", m_valueOffsetTop);
box->addLayout(createRow("Handle Line Width", m_handleLineWidth)); adder.add("Value Axis Bottom Offset", m_valueOffsetBottom);
box->addLayout(createRow("Handle Color", m_handleColor)); adder.add("Handle Size", m_handleSize);
box->addLayout(createRow("Handle Selection Color", m_handleSelectionColor)); adder.add("Handle Line Width", m_handleLineWidth);
box->addLayout(createRow("Keyframe Size", m_keyframeSize)); adder.add("Handle Color", m_handleColor);
box->addLayout(createRow("Keyframe Color", m_keyframeColor)); adder.add("Handle Selection Color", m_handleSelectionColor);
box->addLayout(createRow("Keyframe Selection Color", m_keyframeSelectionColor)); adder.add("Keyframe Size", m_keyframeSize);
box->addLayout(createRow("Curve Width", m_curveWidth)); adder.add("Keyframe Color", m_keyframeColor);
box->addLayout(createRow("Curve Color", m_curveColor)); adder.add("Keyframe Selection Color", m_keyframeSelectionColor);
box->addLayout(createRow("Curve Selection Color", m_curveSelectionColor)); adder.add("Curve Width", m_curveWidth);
box->addLayout(createRow("Treeview margins", m_treeMargins)); adder.add("Curve Color", m_curveColor);
box->addLayout(createRow("Playhead width", m_playheadWidth)); adder.add("Curve Selection Color", m_curveSelectionColor);
box->addLayout(createRow("Playhead radius", m_playheadRadius)); adder.add("Treeview margins", m_treeMargins);
box->addLayout(createRow("Playhead color", m_playheadColor)); adder.add("Playhead width", m_playheadWidth);
adder.add("Playhead radius", m_playheadRadius);
adder.add("Playhead color", m_playheadColor);
box->addWidget(m_printButton); box->addWidget(m_printButton);
setLayout(box); setLayout(box);

View File

@@ -31,7 +31,7 @@ QProcessUniquePointer puppetProcess(const QString &puppetPath,
puppetProcess.get(), puppetProcess.get(),
&QProcess::kill); &QProcess::kill);
QObject::connect(puppetProcess.get(), QObject::connect(puppetProcess.get(),
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), &QProcess::finished,
processFinishCallback); processFinishCallback);
if (forwardOutput == puppetMode || forwardOutput == "all") { if (forwardOutput == puppetMode || forwardOutput == "all") {