QmlDesigner: Fix signal name prefix removal

Only remove the first to characters of a signal name, if it matches
the regular expression.

Task-number: QDS-11385
Change-Id: Icc61f2c5281c15842729f67d3b0498c80637ceb1
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Henning Gruendl
2023-11-24 16:48:50 +01:00
committed by Henning Gründl
parent fceb1a2e63
commit d0fccdc025

View File

@@ -25,6 +25,7 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QMessageBox> #include <QMessageBox>
#include <QRegularExpression>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTableView> #include <QTableView>
#include <QTextCursor> #include <QTextCursor>
@@ -859,6 +860,11 @@ QString removeOnFromSignalName(const QString &signal)
{ {
if (signal.isEmpty()) if (signal.isEmpty())
return {}; return {};
static const QRegularExpression rx("^on[A-Z]");
if (!rx.match(signal).hasMatch())
return signal;
QString ret = signal; QString ret = signal;
ret.remove(0, 2); ret.remove(0, 2);
ret[0] = ret.at(0).toLower(); ret[0] = ret.at(0).toLower();