aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-02-07 10:52:42 +0100
committerUlf Hermann <ulf.hermann@qt.io>2023-02-15 14:04:44 +0100
commit82cda71298e3eea40f7379b412b0a36fe401b48a (patch)
tree4125e70f6c0e6129f2ceb922ca284dd80833c18d
parent75a41f0773b840419369c9395610caca7748b9eb (diff)
Controls: Use PlatformDialogHelper for enums in DialogButtonBox
Since we're already using 3 of the 4 enums in PlatformDialogHelper, we can just as well declare PlatformDialogHelper as extended namespace and avoid all the fiddling with Q_ENUMS and QFLAGS. As an additional upside, we get code using those enums to compile to C++ this way. Pick-to: 6.5 Fixes: QTBUG-110933 Change-Id: I60bfc15c94133be368fa98ee1b3a0ab7a2bc53ef Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates/qquickdialogbuttonbox_p.h6
-rw-r--r--tests/auto/qml/qmlcppcodegen/CMakeLists.txt4
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt1
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/dialogButtonBox.qml8
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp17
5 files changed, 29 insertions, 7 deletions
diff --git a/src/quicktemplates/qquickdialogbuttonbox_p.h b/src/quicktemplates/qquickdialogbuttonbox_p.h
index 02cdd3bb63..543773e413 100644
--- a/src/quicktemplates/qquickdialogbuttonbox_p.h
+++ b/src/quicktemplates/qquickdialogbuttonbox_p.h
@@ -35,9 +35,9 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialogButtonBox : public QQuickCont
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
// 2.5 (Qt 5.12)
Q_PROPERTY(QPlatformDialogHelper::ButtonLayout buttonLayout READ buttonLayout WRITE setButtonLayout RESET resetButtonLayout NOTIFY buttonLayoutChanged FINAL REVISION(2, 5))
- Q_FLAGS(QPlatformDialogHelper::StandardButtons)
QML_NAMED_ELEMENT(DialogButtonBox)
QML_ATTACHED(QQuickDialogButtonBoxAttached)
+ QML_EXTENDED_NAMESPACE(QPlatformDialogHelper)
QML_ADDED_IN_VERSION(2, 1)
public:
@@ -66,9 +66,6 @@ public:
static QQuickDialogButtonBoxAttached *qmlAttachedProperties(QObject *object);
- // 2.5 (Qt 5.12)
- Q_ENUMS(QPlatformDialogHelper::ButtonLayout)
-
QPlatformDialogHelper::ButtonLayout buttonLayout() const;
void setButtonLayout(QPlatformDialogHelper::ButtonLayout layout);
void resetButtonLayout();
@@ -113,7 +110,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialogButtonBoxAttached : public QO
Q_OBJECT
Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox NOTIFY buttonBoxChanged FINAL)
Q_PROPERTY(QPlatformDialogHelper::ButtonRole buttonRole READ buttonRole WRITE setButtonRole NOTIFY buttonRoleChanged FINAL)
- Q_ENUMS(QPlatformDialogHelper::ButtonRole)
public:
explicit QQuickDialogButtonBoxAttached(QObject *parent = nullptr);
diff --git a/tests/auto/qml/qmlcppcodegen/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/CMakeLists.txt
index 8644e00cde..e2a939ac87 100644
--- a/tests/auto/qml/qmlcppcodegen/CMakeLists.txt
+++ b/tests/auto/qml/qmlcppcodegen/CMakeLists.txt
@@ -8,7 +8,7 @@ qt_internal_add_test(tst_qmlcppcodegen
tst_qmlcppcodegen.cpp
LIBRARIES
Qt::QmlPrivate
- Qt::Gui
+ Qt::GuiPrivate
codegen_test_module
codegen_test_moduleplugin
)
@@ -18,7 +18,7 @@ qt_internal_add_test(tst_qmlcppcodegen_interpreted
tst_qmlcppcodegen.cpp
LIBRARIES
Qt::QmlPrivate
- Qt::Gui
+ Qt::GuiPrivate
codegen_test_module
codegen_test_moduleplugin
DEFINES
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
index 0737d77005..f80dac60fb 100644
--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
@@ -83,6 +83,7 @@ set(qml_files
deadShoeSize.qml
deadStoreLoop.qml
dialog.qml
+ dialogButtonBox.qml
dynamicscene.qml
enumConversion.qml
enumInvalid.qml
diff --git a/tests/auto/qml/qmlcppcodegen/data/dialogButtonBox.qml b/tests/auto/qml/qmlcppcodegen/data/dialogButtonBox.qml
new file mode 100644
index 0000000000..b30e0124c8
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/dialogButtonBox.qml
@@ -0,0 +1,8 @@
+pragma Strict
+import QtQuick.Controls.Basic
+
+ApplicationWindow {
+ footer: DialogButtonBox {
+ standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 400075c08d..222d4cb245 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -12,6 +12,7 @@
#include <QtTest>
#include <QtQml>
#include <QtGui/qcolor.h>
+#include <QtGui/qpa/qplatformdialoghelper.h>
#if QT_CONFIG(process)
#include <QtCore/qprocess.h>
@@ -164,6 +165,7 @@ private slots:
void dateConversions();
void valueTypeBehavior();
void invisibleSingleton();
+ void dialogButtonBox();
};
void tst_QmlCppCodegen::initTestCase()
@@ -3211,6 +3213,21 @@ void tst_QmlCppCodegen::invisibleSingleton()
QCOMPARE(o->property("c"), QVariant(QMetaType::fromName("QColor")));
}
+void tst_QmlCppCodegen::dialogButtonBox()
+{
+ QQmlEngine engine;
+ const QUrl copy(u"qrc:/qt/qml/TestTypes/dialogButtonBox.qml"_s);
+ QQmlComponent c(&engine, copy);
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+ QObject *footer = o->property("footer").value<QObject *>();
+ QVERIFY(footer);
+
+ QCOMPARE(footer->property("standardButtons").value<QPlatformDialogHelper::StandardButton>(),
+ QPlatformDialogHelper::Ok | QPlatformDialogHelper::Cancel);
+}
+
QTEST_MAIN(tst_QmlCppCodegen)
#include "tst_qmlcppcodegen.moc"