From 0059f6af74b53bde7914e64352b3f64cd30f5f18 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 4 May 2021 15:36:35 +0200 Subject: [PATCH] QmlDesigner: Define RegExpValidator in HelperWidgets In Qt 6 there is no RegExpValidator anymore. To support both Qt 5 and Qt 6 we register our own RegExpValidator in HelperWidgets if we compile with Qt 6. Change-Id: I7e66cbf3e29dd034a1c96a22e233058cb7a892e3 Reviewed-by: Miikka Heikkinen Reviewed-by: Thomas Hartmann --- .../RegExpValidator.qml | 6 +++++ .../quick2propertyeditorview.cpp | 26 ++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 share/qtcreator/qmldesigner/propertyEditorQmlSources/RegExpValidator.qml diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/RegExpValidator.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/RegExpValidator.qml new file mode 100644 index 00000000000..f9ace424d9e --- /dev/null +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/RegExpValidator.qml @@ -0,0 +1,6 @@ +import QtQuick 2.15 + +RegularExpressionValidator { + id: root + property alias regExp: root.regularExpression +} diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp index 7032a26ef76..92ac7fdf8f1 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp @@ -25,22 +25,23 @@ #include "quick2propertyeditorview.h" -#include "propertyeditorvalue.h" +#include "aligndistribute.h" +#include "annotationeditor/annotationeditor.h" +#include "bindingeditor/actioneditor.h" +#include "bindingeditor/bindingeditor.h" #include "fileresourcesmodel.h" #include "gradientmodel.h" -#include "gradientpresetdefaultlistmodel.h" #include "gradientpresetcustomlistmodel.h" +#include "gradientpresetdefaultlistmodel.h" #include "itemfiltermodel.h" -#include "simplecolorpalettemodel.h" -#include "bindingeditor/bindingeditor.h" -#include "bindingeditor/actioneditor.h" -#include "annotationeditor/annotationeditor.h" -#include "qmlanchorbindingproxy.h" -#include "theme.h" -#include "aligndistribute.h" #include "propertyeditorcontextobject.h" -#include "tooltip.h" +#include "propertyeditorqmlbackend.h" +#include "propertyeditorvalue.h" +#include "qmlanchorbindingproxy.h" #include "richtexteditor/richtexteditorproxy.h" +#include "simplecolorpalettemodel.h" +#include "theme.h" +#include "tooltip.h" namespace QmlDesigner { @@ -71,6 +72,11 @@ void Quick2PropertyEditorView::registerQmlTypes() Tooltip::registerDeclarativeType(); EasingCurveEditor::registerDeclarativeType(); RichTextEditorProxy::registerDeclarativeType(); + QUrl regExpUrl = QUrl::fromLocalFile(PropertyEditorQmlBackend::propertyEditorResourcesPath() + + "/RegExpValidator.qml"); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qmlRegisterType(regExpUrl, "HelperWidgets", 2, 0, "RegExpValidator"); +#endif } }