summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <[email protected]>2020-01-28 01:00:39 +0100
committerLiang Qi <[email protected]>2020-01-28 14:14:20 +0000
commit558fc903acc610769279da2737ad679aa9fd728d (patch)
treeebe36deb140e47ca32fea9b0753cde06f465a0fa
parent089d54f06ff327f5212cb08fdbcb540066357dd5 (diff)
parentbe8c257da9a264994243c120231965ff0008ef09 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/corelib/io/qsettings.cpp src/corelib/kernel/qvariant.cpp src/corelib/serialization/qjsoncbor.cpp src/corelib/serialization/qjsonvalue.cpp src/corelib/tools/tools.pri src/gui/image/qimage.cpp src/gui/kernel/qguivariant.cpp src/widgets/kernel/qshortcut.cpp tests/auto/tools/moc/allmocs_baseline_in.json tests/auto/tools/moc/tst_moc.cpp src/opengl/qglframebufferobject.cpp Done-With: Edward Welbourne <[email protected]> Done-With: Leander Beernaert <[email protected]> Change-Id: Ie7f5fa646c607fe70c314bf7195f7578ded1d271
-rw-r--r--examples/corelib/serialization/convert/cborconverter.cpp4
-rw-r--r--examples/corelib/serialization/convert/datastreamconverter.cpp6
-rw-r--r--examples/corelib/serialization/convert/textconverter.cpp6
-rw-r--r--examples/corelib/serialization/convert/xmlconverter.cpp20
-rw-r--r--examples/network/torrent/trackerclient.cpp2
-rw-r--r--examples/sql/doc/src/drilldown.qdoc2
-rw-r--r--examples/widgets/doc/src/gallery.qdoc2
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/window.cpp2
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp2
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.cpp2
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.cpp132
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.h2
-rw-r--r--mkspecs/features/create_cmake.prf6
-rw-r--r--mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in31
-rw-r--r--mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in22
-rw-r--r--qmake/generators/makefile.cpp16
-rw-r--r--qmake/generators/makefile.h2
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp5
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp40
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in24
-rw-r--r--src/corelib/Qt5CoreMacros.cmake66
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp6
-rw-r--r--src/corelib/doc/snippets/code/doc_src_properties.cpp1
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp10
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp4
-rw-r--r--src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp14
-rw-r--r--src/corelib/doc/snippets/qsignalmapper/buttonwidget.h4
-rw-r--r--src/corelib/doc/snippets/resource-system/mainwindow.cpp36
-rw-r--r--src/corelib/doc/snippets/statemachine/main.cpp13
-rw-r--r--src/corelib/doc/snippets/statemachine/main2.cpp15
-rw-r--r--src/corelib/doc/snippets/statemachine/main3.cpp2
-rw-r--r--src/corelib/doc/snippets/statemachine/main5.cpp14
-rw-r--r--src/corelib/doc/snippets/timers/analogclock.cpp2
-rw-r--r--src/corelib/doc/snippets/timers/timers.cpp6
-rw-r--r--src/corelib/doc/src/animation.qdoc4
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc6
-rw-r--r--src/corelib/doc/src/statemachine.qdoc4
-rw-r--r--src/corelib/global/qglobal.cpp4
-rw-r--r--src/corelib/global/qnamespace.h3
-rw-r--r--src/corelib/global/qnamespace.qdoc12
-rw-r--r--src/corelib/io/qbuffer.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp2
-rw-r--r--src/corelib/io/qsettings.cpp37
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp40
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp31
-rw-r--r--src/corelib/kernel/qmetaobject.h1
-rw-r--r--src/corelib/kernel/qmetaobject_p.h3
-rw-r--r--src/corelib/kernel/qmetatype.cpp3
-rw-r--r--src/corelib/kernel/qmetatype.h7
-rw-r--r--src/corelib/kernel/qmimedata.cpp72
-rw-r--r--src/corelib/kernel/qvariant.cpp494
-rw-r--r--src/corelib/kernel/qvariant_p.h4
-rw-r--r--src/corelib/serialization/qjsoncbor.cpp40
-rw-r--r--src/corelib/serialization/qjsondocument.cpp10
-rw-r--r--src/corelib/serialization/qjsonvalue.cpp28
-rw-r--r--src/corelib/serialization/qtextstream.cpp2
-rw-r--r--src/corelib/text/qlocale.cpp6
-rw-r--r--src/corelib/text/qlocale_unix.cpp12
-rw-r--r--src/corelib/text/qstringlist.cpp10
-rw-r--r--src/corelib/thread/qmutex.cpp2
-rw-r--r--src/corelib/thread/qthread.cpp6
-rw-r--r--src/corelib/thread/qthread_win.cpp2
-rw-r--r--src/corelib/time/qdatetime.cpp6
-rw-r--r--src/corelib/time/qdatetimeparser.cpp24
-rw-r--r--src/corelib/time/qdatetimeparser_p.h4
-rw-r--r--src/corelib/tools/qduplicatetracker_p.h94
-rw-r--r--src/corelib/tools/qmap.cpp7
-rw-r--r--src/corelib/tools/tools.pri1
-rw-r--r--src/dbus/Qt5DBusConfigExtras.cmake.in11
-rw-r--r--src/dbus/Qt5DBusMacros.cmake43
-rw-r--r--src/dbus/qdbusabstractinterface.cpp2
-rw-r--r--src/dbus/qdbusargument.h4
-rw-r--r--src/dbus/qdbusintegrator.cpp4
-rw-r--r--src/dbus/qdbusinterface.cpp18
-rw-r--r--src/dbus/qdbusmarshaller.cpp10
-rw-r--r--src/dbus/qdbusmessage.cpp2
-rw-r--r--src/dbus/qdbusmetaobject.cpp20
-rw-r--r--src/dbus/qdbusmetatype.cpp38
-rw-r--r--src/dbus/qdbusutil.cpp8
-rw-r--r--src/dbus/qdbusxmlgenerator.cpp6
-rw-r--r--src/gui/accessible/qaccessible.cpp2
-rw-r--r--src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp2
-rw-r--r--src/gui/doc/src/qtgui.qdoc2
-rw-r--r--src/gui/image/qbitmap.cpp2
-rw-r--r--src/gui/image/qicon.cpp2
-rw-r--r--src/gui/image/qimage.cpp6
-rw-r--r--src/gui/image/qpixmap.cpp6
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp2
-rw-r--r--src/gui/kernel/qcursor.cpp78
-rw-r--r--src/gui/kernel/qcursor.h15
-rw-r--r--src/gui/kernel/qevent.cpp4
-rw-r--r--src/gui/kernel/qguiapplication.cpp15
-rw-r--r--src/gui/kernel/qguivariant.cpp65
-rw-r--r--src/gui/kernel/qinternalmimedata.cpp13
-rw-r--r--src/gui/kernel/qkeysequence.cpp2
-rw-r--r--src/gui/kernel/qopenglcontext.cpp2
-rw-r--r--src/gui/kernel/qpalette.cpp2
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp2
-rw-r--r--src/gui/math3d/qquaternion.cpp2
-rw-r--r--src/gui/math3d/qvector2d.cpp2
-rw-r--r--src/gui/math3d/qvector3d.cpp2
-rw-r--r--src/gui/math3d/qvector4d.cpp2
-rw-r--r--src/gui/painting/qbrush.cpp2
-rw-r--r--src/gui/painting/qcolor.cpp2
-rw-r--r--src/gui/painting/qcolorspace.cpp9
-rw-r--r--src/gui/painting/qcolorspace.h2
-rw-r--r--src/gui/painting/qmatrix.cpp2
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp2
-rw-r--r--src/gui/painting/qpen.cpp2
-rw-r--r--src/gui/painting/qpolygon.cpp2
-rw-r--r--src/gui/painting/qregion.cpp2
-rw-r--r--src/gui/painting/qtransform.cpp2
-rw-r--r--src/gui/rhi/qrhi.cpp4
-rw-r--r--src/gui/rhi/qrhivulkan.cpp17
-rw-r--r--src/gui/text/qcssparser.cpp20
-rw-r--r--src/gui/text/qfont.cpp10
-rw-r--r--src/gui/text/qfont.h6
-rw-r--r--src/gui/text/qfontmetrics.cpp4
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp2
-rw-r--r--src/gui/text/qtextdocument.cpp6
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp2
-rw-r--r--src/gui/text/qtextformat.cpp52
-rw-r--r--src/gui/text/qtexthtmlparser.cpp12
-rw-r--r--src/gui/text/qtextimagehandler.cpp8
-rw-r--r--src/gui/text/qtextlayout.cpp2
-rw-r--r--src/gui/text/qtextodfwriter.cpp4
-rw-r--r--src/network/access/qftp.cpp2
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp2
-rw-r--r--src/network/doc/snippets/code/src_network_ssl_qsslcertificate.cpp8
-rw-r--r--src/network/socket/qudpsocket.cpp2
-rw-r--r--src/network/ssl/qsslcertificate.cpp107
-rw-r--r--src/network/ssl/qsslcertificate.h20
-rw-r--r--src/platformsupport/accessibility/qaccessiblebridgeutils.cpp2
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp9
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp2
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp2
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp40
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview_menus.mm3
-rw-r--r--src/plugins/platforms/eglfs/api/api.pri9
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp16
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h4
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration.cpp19
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration_p.h3
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow_p.h4
-rw-r--r--src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance.cpp280
-rw-r--r--src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h88
-rw-r--r--src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow.cpp75
-rw-r--r--src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow_p.h74
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp21
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h6
-rw-r--r--src/plugins/platforms/eglfs/eglfsdeviceintegration.pro3
-rw-r--r--src/plugins/platforms/wasm/qwasmeventdispatcher.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsclipboard.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp56
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h3
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp14
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h8
-rw-r--r--src/plugins/platforms/windows/qwindowssystemtrayicon.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp131
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h4
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp44
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp3
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.cpp8
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.h4
-rw-r--r--src/plugins/sqldrivers/ibase/qsql_ibase.cpp4
-rw-r--r--src/plugins/sqldrivers/mysql/qsql_mysql.cpp116
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp6
-rw-r--r--src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp2
-rw-r--r--src/plugins/styles/windowsvista/qwindowsxpstyle.cpp8
-rw-r--r--src/sql/kernel/qsqldriver.cpp22
-rw-r--r--src/sql/kernel/qsqlfield.cpp11
-rw-r--r--src/sql/kernel/qsqlfield.h2
-rw-r--r--src/sql/kernel/qsqlresult.cpp4
-rw-r--r--src/testlib/qtest.h2
-rw-r--r--src/testlib/qtestlog.cpp4
-rw-r--r--src/tools/moc/generator.cpp2
-rw-r--r--src/tools/moc/moc.cpp4
-rw-r--r--src/tools/moc/moc.h1
-rw-r--r--src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp6
-rw-r--r--src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp2
-rw-r--r--src/widgets/Qt5WidgetsConfigExtras.cmake.in11
-rw-r--r--src/widgets/Qt5WidgetsMacros.cmake12
-rw-r--r--src/widgets/accessible/simplewidgets.cpp15
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp6
-rw-r--r--src/widgets/dialogs/qsidebar.cpp2
-rw-r--r--src/widgets/dialogs/qwizard.cpp6
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp14
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp10
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp18
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp2
-rw-r--r--src/widgets/itemviews/qheaderview.cpp2
-rw-r--r--src/widgets/itemviews/qitemdelegate.cpp22
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp34
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp10
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp7
-rw-r--r--src/widgets/kernel/qapplication.cpp5
-rw-r--r--src/widgets/kernel/qapplication.h4
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp7
-rw-r--r--src/widgets/kernel/qsizepolicy.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp4
-rw-r--r--src/widgets/kernel/qwidgetsvariant.cpp12
-rw-r--r--src/widgets/styles/qdrawutil.cpp20
-rw-r--r--src/widgets/styles/qproxystyle.cpp4
-rw-r--r--src/widgets/styles/qstyle.cpp6
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp31
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp17
-rw-r--r--src/widgets/styles/qwindowsstyle_p_p.h1
-rw-r--r--src/widgets/util/qundoview.cpp10
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp6
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp70
-rw-r--r--src/widgets/widgets/qabstractspinbox_p.h2
-rw-r--r--src/widgets/widgets/qcombobox.cpp10
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp32
-rw-r--r--src/widgets/widgets/qdatetimeedit.h3
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp2
-rw-r--r--src/widgets/widgets/qdockwidget.cpp4
-rw-r--r--src/widgets/widgets/qlabel.cpp78
-rw-r--r--src/widgets/widgets/qlabel.h20
-rw-r--r--src/widgets/widgets/qmdiarea.cpp4
-rw-r--r--src/widgets/widgets/qmenu.cpp188
-rw-r--r--src/widgets/widgets/qmenu_p.h6
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp20
-rw-r--r--src/widgets/widgets/qspinbox.cpp4
-rw-r--r--src/widgets/widgets/qtabbar.cpp2
-rw-r--r--src/widgets/widgets/qtabwidget.cpp2
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp41
-rw-r--r--src/widgets/widgets/qtextbrowser.h3
-rw-r--r--src/widgets/widgets/qtextedit.cpp24
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp67
-rw-r--r--src/xml/dom/qdom.cpp8
-rw-r--r--tests/auto/gui/rhi/qrhi/data/buildshaders.bat (renamed from tests/auto/gui/rhi/qrhi/data/compile.bat)0
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simple.frag.qsbbin908 -> 730 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simple.vert.qsbbin958 -> 791 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletextured.frag.qsbbin1479 -> 1208 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletextured.vert.qsbbin1195 -> 964 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/textured.frag.qsbbin1997 -> 1574 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/textured.vert.qsbbin1708 -> 1342 bytes
-rw-r--r--tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp140
-rw-r--r--tests/auto/tools/moc/allmocs_baseline_in.json16
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp26
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp56
-rw-r--r--tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp36
-rw-r--r--tests/benchmarks/corelib/text/qstringlist/main.cpp39
-rw-r--r--tests/benchmarks/corelib/text/qstringlist/qstringlist.pro1
-rw-r--r--tests/manual/rhi/computebuffer/buffer.comp.qsbbin2160 -> 1868 bytes
-rw-r--r--tests/manual/rhi/computebuffer/main.frag.qsbbin672 -> 584 bytes
-rw-r--r--tests/manual/rhi/computebuffer/main.vert.qsbbin852 -> 762 bytes
-rw-r--r--tests/manual/rhi/computeimage/image.comp.qsbbin1811 -> 1594 bytes
-rw-r--r--tests/manual/rhi/cubemap/cubemap.frag.qsbbin1311 -> 1089 bytes
-rw-r--r--tests/manual/rhi/cubemap/cubemap.vert.qsbbin1499 -> 1200 bytes
-rw-r--r--tests/manual/rhi/instancing/inst.frag.qsbbin936 -> 735 bytes
-rw-r--r--tests/manual/rhi/instancing/inst.vert.qsbbin1792 -> 1456 bytes
-rw-r--r--tests/manual/rhi/mrt/mrt.frag.qsbbin1934 -> 1594 bytes
-rw-r--r--tests/manual/rhi/mrt/mrt.vert.qsbbin1633 -> 1299 bytes
-rwxr-xr-xtests/manual/rhi/shadowmap/buildshaders.sh5
-rw-r--r--tests/manual/rhi/shadowmap/main.frag.qsbbin2489 -> 2307 bytes
-rw-r--r--tests/manual/rhi/shadowmap/main.vert.qsbbin1595 -> 1587 bytes
-rw-r--r--tests/manual/rhi/shadowmap/shadowmap.frag.qsbbin408 -> 466 bytes
-rw-r--r--tests/manual/rhi/shadowmap/shadowmap.vert.qsbbin1215 -> 1083 bytes
-rw-r--r--tests/manual/rhi/shared/color.frag.qsbbin1483 -> 1179 bytes
-rw-r--r--tests/manual/rhi/shared/color.vert.qsbbin1648 -> 1318 bytes
-rw-r--r--tests/manual/rhi/shared/texture.frag.qsbbin1710 -> 1345 bytes
-rw-r--r--tests/manual/rhi/shared/texture.vert.qsbbin1897 -> 1574 bytes
-rw-r--r--tests/manual/rhi/shared/texture_ms4.frag.qsbbin1847 -> 1555 bytes
277 files changed, 3205 insertions, 1415 deletions
diff --git a/examples/corelib/serialization/convert/cborconverter.cpp b/examples/corelib/serialization/convert/cborconverter.cpp
index 60410ed26a5..77df367e50c 100644
--- a/examples/corelib/serialization/convert/cborconverter.cpp
+++ b/examples/corelib/serialization/convert/cborconverter.cpp
@@ -134,7 +134,7 @@ static QVariant convertCborValue(const QCborValue &value)
enum TrimFloatingPoint { Double, Float, Float16 };
static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrimming)
{
- if (v.userType() == QVariant::List) {
+ if (v.userType() == QMetaType::QVariantList) {
const QVariantList list = v.toList();
QCborArray array;
for (const QVariant &v : list)
@@ -152,7 +152,7 @@ static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrim
return map;
}
- if (v.userType() == QVariant::Double && fpTrimming != Double) {
+ if (v.userType() == QMetaType::Double && fpTrimming != Double) {
float f = float(v.toDouble());
if (fpTrimming == Float16)
return float(qfloat16(f));
diff --git a/examples/corelib/serialization/convert/datastreamconverter.cpp b/examples/corelib/serialization/convert/datastreamconverter.cpp
index 7e9f5e1bdcb..6f0ca41ff57 100644
--- a/examples/corelib/serialization/convert/datastreamconverter.cpp
+++ b/examples/corelib/serialization/convert/datastreamconverter.cpp
@@ -96,8 +96,8 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
QString indented = indent + QLatin1String(" ");
int type = v.userType();
- if (type == qMetaTypeId<VariantOrderedMap>() || type == QVariant::Map) {
- const auto map = (type == QVariant::Map) ?
+ if (type == qMetaTypeId<VariantOrderedMap>() || type == QMetaType::QVariantMap) {
+ const auto map = (type == QMetaType::QVariantMap) ?
VariantOrderedMap(v.toMap()) : qvariant_cast<VariantOrderedMap>(v);
result = QLatin1String("Map {");
@@ -109,7 +109,7 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
}
result.chop(1); // remove comma
result += indent + QLatin1String("},");
- } else if (type == QVariant::List) {
+ } else if (type == QMetaType::QVariantList) {
const QVariantList list = v.toList();
result = QLatin1String("List [");
diff --git a/examples/corelib/serialization/convert/textconverter.cpp b/examples/corelib/serialization/convert/textconverter.cpp
index 7aed08f96c3..ae03b9a334b 100644
--- a/examples/corelib/serialization/convert/textconverter.cpp
+++ b/examples/corelib/serialization/convert/textconverter.cpp
@@ -56,21 +56,21 @@
static void dumpVariant(QTextStream &out, const QVariant &v)
{
switch (v.userType()) {
- case QVariant::List: {
+ case QMetaType::QVariantList: {
const QVariantList list = v.toList();
for (const QVariant &item : list)
dumpVariant(out, item);
break;
}
- case QVariant::String: {
+ case QMetaType::QString: {
const QStringList list = v.toStringList();
for (const QString &s : list)
out << s << Qt::endl;
break;
}
- case QVariant::Map: {
+ case QMetaType::QVariantMap: {
const QVariantMap map = v.toMap();
for (auto it = map.begin(); it != map.end(); ++it) {
out << it.key() << " => ";
diff --git a/examples/corelib/serialization/convert/xmlconverter.cpp b/examples/corelib/serialization/convert/xmlconverter.cpp
index d9e724dfe13..42cb10100ad 100644
--- a/examples/corelib/serialization/convert/xmlconverter.cpp
+++ b/examples/corelib/serialization/convert/xmlconverter.cpp
@@ -284,18 +284,18 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
ba.resize(n);
result = ba;
} else {
- int id = QVariant::Invalid;
+ int id = QMetaType::UnknownType;
if (type == QLatin1String("datetime"))
- id = QVariant::DateTime;
+ id = QMetaType::QDateTime;
else if (type == QLatin1String("url"))
- id = QVariant::Url;
+ id = QMetaType::QUrl;
else if (type == QLatin1String("uuid"))
- id = QVariant::Uuid;
+ id = QMetaType::QUuid;
else if (type == QLatin1String("regex"))
- id = QVariant::RegularExpression;
+ id = QMetaType::QRegularExpression;
else
id = QMetaType::type(type.toLatin1());
- if (id == QVariant::Invalid) {
+ if (id == QMetaType::UnknownType) {
fprintf(stderr, "%lld:%lld: Invalid XML: unknown type '%s'.\n",
xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString()));
exit(EXIT_FAILURE);
@@ -327,14 +327,14 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
{
int type = v.userType();
- if (type == QVariant::List) {
+ if (type == QMetaType::QVariantList) {
QVariantList list = v.toList();
xml.writeStartElement("list");
for (const QVariant &v : list)
variantToXml(xml, v);
xml.writeEndElement();
- } else if (type == QVariant::Map || type == qMetaTypeId<VariantOrderedMap>()) {
- const VariantOrderedMap map = (type == QVariant::Map) ?
+ } else if (type == QMetaType::QVariantMap || type == qMetaTypeId<VariantOrderedMap>()) {
+ const VariantOrderedMap map = (type == QMetaType::QVariantMap) ?
VariantOrderedMap(v.toMap()) :
qvariant_cast<VariantOrderedMap>(v);
@@ -433,7 +433,7 @@ static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
// does this convert to string?
const char *typeName = v.typeName();
QVariant copy = v;
- if (copy.convert(QVariant::String)) {
+ if (copy.convert(QMetaType::QString)) {
xml.writeAttribute(typeString, QString::fromLatin1(typeName));
xml.writeCharacters(copy.toString());
} else {
diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp
index 540ab315577..a50a49fd64d 100644
--- a/examples/network/torrent/trackerclient.cpp
+++ b/examples/network/torrent/trackerclient.cpp
@@ -209,7 +209,7 @@ void TrackerClient::httpRequestDone(QNetworkReply *reply)
// store it
peers.clear();
QVariant peerEntry = dict.value("peers");
- if (peerEntry.type() == QVariant::List) {
+ if (peerEntry.userType() == QMetaType::QVariantList) {
QList<QVariant> peerTmp = peerEntry.toList();
for (int i = 0; i < peerTmp.size(); ++i) {
TorrentPeer tmp;
diff --git a/examples/sql/doc/src/drilldown.qdoc b/examples/sql/doc/src/drilldown.qdoc
index 7a8aa2037a4..8beb515a839 100644
--- a/examples/sql/doc/src/drilldown.qdoc
+++ b/examples/sql/doc/src/drilldown.qdoc
@@ -425,7 +425,7 @@
The \c findWindow() function simply searches through the list of
existing windows, returning a pointer to the window that matches
- the given item ID, or 0 if the window doesn't exists.
+ the given item ID, or \nullptr if the window doesn't exists.
Finally, let's take a quick look at our custom \c ImageItem class:
diff --git a/examples/widgets/doc/src/gallery.qdoc b/examples/widgets/doc/src/gallery.qdoc
index a262374ce63..455099ddce7 100644
--- a/examples/widgets/doc/src/gallery.qdoc
+++ b/examples/widgets/doc/src/gallery.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \example widgets/gallery
+ \example gallery
\title Widgets Gallery Example
\ingroup examples-widgets
\brief The Widgets Gallery example shows widgets relevant for designing UIs.
diff --git a/examples/widgets/itemviews/coloreditorfactory/window.cpp b/examples/widgets/itemviews/coloreditorfactory/window.cpp
index e4a9379d8fe..25e196a80c8 100644
--- a/examples/widgets/itemviews/coloreditorfactory/window.cpp
+++ b/examples/widgets/itemviews/coloreditorfactory/window.cpp
@@ -61,7 +61,7 @@ Window::Window()
QItemEditorCreatorBase *colorListCreator =
new QStandardItemEditorCreator<ColorListEditor>();
- factory->registerEditor(QVariant::Color, colorListCreator);
+ factory->registerEditor(QMetaType::QColor, colorListCreator);
QItemEditorFactory::setDefaultFactory(factory);
diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
index 4753d04d9b4..b0b4017e62a 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
+++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
@@ -98,7 +98,7 @@ bool MySortFilterProxyModel::lessThan(const QModelIndex &left,
//! [4]
//! [6]
- if (leftData.type() == QVariant::DateTime) {
+ if (leftData.userType() == QMetaType::QDateTime) {
return leftData.toDateTime() < rightData.toDateTime();
} else {
static const QRegularExpression emailPattern("[\\w\\.]*@[\\w\\.]*");
diff --git a/examples/widgets/tools/settingseditor/settingstree.cpp b/examples/widgets/tools/settingseditor/settingstree.cpp
index 49d299bf72d..9132368e4a5 100644
--- a/examples/widgets/tools/settingseditor/settingstree.cpp
+++ b/examples/widgets/tools/settingseditor/settingstree.cpp
@@ -208,7 +208,7 @@ void SettingsTree::updateChildItems(QTreeWidgetItem *parent)
}
QVariant value = settings->value(key);
- if (value.type() == QVariant::Invalid) {
+ if (value.userType() == QMetaType::UnknownType) {
child->setText(1, "Invalid");
} else {
child->setText(1, value.typeName());
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.cpp b/examples/widgets/tools/settingseditor/variantdelegate.cpp
index 9772fe8a41d..eb822f0dc26 100644
--- a/examples/widgets/tools/settingseditor/variantdelegate.cpp
+++ b/examples/widgets/tools/settingseditor/variantdelegate.cpp
@@ -81,7 +81,7 @@ void VariantDelegate::paint(QPainter *painter,
{
if (index.column() == 2) {
QVariant value = index.model()->data(index, Qt::UserRole);
- if (!isSupportedType(value.type())) {
+ if (!isSupportedType(value.userType())) {
QStyleOptionViewItem myOption = option;
myOption.state &= ~QStyle::State_Enabled;
QStyledItemDelegate::paint(painter, myOption, index);
@@ -100,7 +100,7 @@ QWidget *VariantDelegate::createEditor(QWidget *parent,
return nullptr;
QVariant originalValue = index.model()->data(index, Qt::UserRole);
- if (!isSupportedType(originalValue.type()))
+ if (!isSupportedType(originalValue.userType()))
return nullptr;
QLineEdit *lineEdit = new QLineEdit(parent);
@@ -108,46 +108,46 @@ QWidget *VariantDelegate::createEditor(QWidget *parent,
QRegularExpression regExp;
- switch (originalValue.type()) {
- case QVariant::Bool:
+ switch (originalValue.userType()) {
+ case QMetaType::Bool:
regExp = boolExp;
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
regExp = byteArrayExp;
break;
- case QVariant::Char:
+ case QMetaType::QChar:
regExp = charExp;
break;
- case QVariant::Color:
+ case QMetaType::QColor:
regExp = colorExp;
break;
- case QVariant::Date:
+ case QMetaType::QDate:
regExp = dateExp;
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
regExp = dateTimeExp;
break;
- case QVariant::Double:
+ case QMetaType::Double:
regExp = doubleExp;
break;
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
regExp = signedIntegerExp;
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
regExp = pointExp;
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
regExp = rectExp;
break;
- case QVariant::Size:
+ case QMetaType::QSize:
regExp = sizeExp;
break;
- case QVariant::Time:
+ case QMetaType::QTime:
regExp = timeExp;
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
regExp = unsignedIntegerExp;
break;
default:
@@ -189,18 +189,18 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
QVariant value;
QRegularExpressionMatch match;
- switch (originalValue.type()) {
- case QVariant::Char:
+ switch (originalValue.userType()) {
+ case QMetaType::QChar:
value = text.at(0);
break;
- case QVariant::Color:
+ case QMetaType::QColor:
match = colorExp.match(text);
value = QColor(qMin(match.captured(1).toInt(), 255),
qMin(match.captured(2).toInt(), 255),
qMin(match.captured(3).toInt(), 255),
qMin(match.captured(4).toInt(), 255));
break;
- case QVariant::Date:
+ case QMetaType::QDate:
{
QDate date = QDate::fromString(text, Qt::ISODate);
if (!date.isValid())
@@ -208,7 +208,7 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
value = date;
}
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
{
QDateTime dateTime = QDateTime::fromString(text, Qt::ISODate);
if (!dateTime.isValid())
@@ -216,23 +216,23 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
value = dateTime;
}
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
match = pointExp.match(text);
value = QPoint(match.captured(1).toInt(), match.captured(2).toInt());
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
match = rectExp.match(text);
value = QRect(match.captured(1).toInt(), match.captured(2).toInt(),
match.captured(3).toInt(), match.captured(4).toInt());
break;
- case QVariant::Size:
+ case QMetaType::QSize:
match = sizeExp.match(text);
value = QSize(match.captured(1).toInt(), match.captured(2).toInt());
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
value = text.split(',');
break;
- case QVariant::Time:
+ case QMetaType::QTime:
{
QTime time = QTime::fromString(text, Qt::ISODate);
if (!time.isValid())
@@ -242,33 +242,33 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
break;
default:
value = text;
- value.convert(originalValue.type());
+ value.convert(originalValue.userType());
}
model->setData(index, displayText(value), Qt::DisplayRole);
model->setData(index, value, Qt::UserRole);
}
-bool VariantDelegate::isSupportedType(QVariant::Type type)
+bool VariantDelegate::isSupportedType(int type)
{
switch (type) {
- case QVariant::Bool:
- case QVariant::ByteArray:
- case QVariant::Char:
- case QVariant::Color:
- case QVariant::Date:
- case QVariant::DateTime:
- case QVariant::Double:
- case QVariant::Int:
- case QVariant::LongLong:
- case QVariant::Point:
- case QVariant::Rect:
- case QVariant::Size:
- case QVariant::String:
- case QVariant::StringList:
- case QVariant::Time:
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::Bool:
+ case QMetaType::QByteArray:
+ case QMetaType::QChar:
+ case QMetaType::QColor:
+ case QMetaType::QDate:
+ case QMetaType::QDateTime:
+ case QMetaType::Double:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
+ case QMetaType::QPoint:
+ case QMetaType::QRect:
+ case QMetaType::QSize:
+ case QMetaType::QString:
+ case QMetaType::QStringList:
+ case QMetaType::QTime:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
return true;
default:
return false;
@@ -277,50 +277,50 @@ bool VariantDelegate::isSupportedType(QVariant::Type type)
QString VariantDelegate::displayText(const QVariant &value)
{
- switch (value.type()) {
- case QVariant::Bool:
- case QVariant::ByteArray:
- case QVariant::Char:
- case QVariant::Double:
- case QVariant::Int:
- case QVariant::LongLong:
- case QVariant::String:
- case QVariant::UInt:
- case QVariant::ULongLong:
+ switch (value.userType()) {
+ case QMetaType::Bool:
+ case QMetaType::QByteArray:
+ case QMetaType::QChar:
+ case QMetaType::Double:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
+ case QMetaType::QString:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
return value.toString();
- case QVariant::Color:
+ case QMetaType::QColor:
{
QColor color = qvariant_cast<QColor>(value);
return QString("(%1,%2,%3,%4)")
.arg(color.red()).arg(color.green())
.arg(color.blue()).arg(color.alpha());
}
- case QVariant::Date:
+ case QMetaType::QDate:
return value.toDate().toString(Qt::ISODate);
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return value.toDateTime().toString(Qt::ISODate);
- case QVariant::Invalid:
+ case QMetaType::UnknownType:
return "<Invalid>";
- case QVariant::Point:
+ case QMetaType::QPoint:
{
QPoint point = value.toPoint();
return QString("(%1,%2)").arg(point.x()).arg(point.y());
}
- case QVariant::Rect:
+ case QMetaType::QRect:
{
QRect rect = value.toRect();
return QString("(%1,%2,%3,%4)")
.arg(rect.x()).arg(rect.y())
.arg(rect.width()).arg(rect.height());
}
- case QVariant::Size:
+ case QMetaType::QSize:
{
QSize size = value.toSize();
return QString("(%1,%2)").arg(size.width()).arg(size.height());
}
- case QVariant::StringList:
+ case QMetaType::QStringList:
return value.toStringList().join(',');
- case QVariant::Time:
+ case QMetaType::QTime:
return value.toTime().toString(Qt::ISODate);
default:
break;
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.h b/examples/widgets/tools/settingseditor/variantdelegate.h
index 68f21fa3f6c..96e44fd181d 100644
--- a/examples/widgets/tools/settingseditor/variantdelegate.h
+++ b/examples/widgets/tools/settingseditor/variantdelegate.h
@@ -69,7 +69,7 @@ public:
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const override;
- static bool isSupportedType(QVariant::Type type);
+ static bool isSupportedType(int type);
static QString displayText(const QVariant &value);
private:
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 346fbf2467c..63b4a73660e 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -176,7 +176,7 @@ contains(CONFIG, plugin) {
list_plugin_extends =
for (p, PLUGIN_EXTENDS) {
m = $$cmakeModuleName($$p)
- list_plugin_extends += Qt5::$$m
+ list_plugin_extends += Qt::$$m
}
CMAKE_PLUGIN_EXTENDS = $$join(list_plugin_extends, ";")
}
@@ -291,6 +291,10 @@ CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
CMAKE_MODULE_PLUGIN_TYPES = $$join(QT.$${MODULE}.plugin_types, ";")
+# Interface libraries have to have all properties starting with "INTERFACE_".
+CMAKE_FEATURE_PROPERTY_PREFIX = ""
+equals(TEMPLATE, aux): CMAKE_FEATURE_PROPERTY_PREFIX = "INTERFACE_"
+
mac {
!isEmpty(CMAKE_STATIC_TYPE) {
CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a
diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
index 26d4c17e6cb..01dda9b0c35 100644
--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
@@ -406,6 +406,15 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
!!ENDIF
!!ENDIF
+
+ # Add a versionless target, for compatibility with Qt6.
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME})
+ add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
+ set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES
+ INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\"
+ )
+ endif()
+
!!IF !equals(TEMPLATE, aux)
!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
@@ -420,6 +429,20 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_ENABLED_FEATURES $$join(QT.$${MODULE}.enabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_DISABLED_FEATURES $$join(QT.$${MODULE}.disabled_features, ";"))
+ # Qt 6 forward compatible properties.
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
+ PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_ENABLED_PUBLIC_FEATURES
+ $$join(QT.$${MODULE}.enabled_features, ";"))
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
+ PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_DISABLED_PUBLIC_FEATURES
+ $$join(QT.$${MODULE}.disabled_features, ";"))
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
+ PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_ENABLED_PRIVATE_FEATURES
+ $$join(QT.$${MODULE}_private.enabled_features, ";"))
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
+ PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_DISABLED_PRIVATE_FEATURES
+ $$join(QT.$${MODULE}_private.disabled_features, ";"))
+
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_PLUGIN_TYPES \"$${CMAKE_MODULE_PLUGIN_TYPES}\")
set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST TRUE)
@@ -443,6 +466,14 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY
INTERFACE_LINK_LIBRARIES Qt5::$${CMAKE_MODULE_NAME} ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATEDEPS}
)
+
+ # Add a versionless target, for compatibility with Qt6.
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME}Private)
+ add_library(Qt::$${CMAKE_MODULE_NAME}Private INTERFACE IMPORTED)
+ set_target_properties(Qt::$${CMAKE_MODULE_NAME}Private PROPERTIES
+ INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}Private\"
+ )
+ endif()
endif()
!!IF !equals(TEMPLATE, aux)
diff --git a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
index 7b70cfed096..b550a52c608 100644
--- a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+++ b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
@@ -75,19 +75,30 @@ endif()
set(_user_specified_genex
\"$<IN_LIST:Qt5::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\"
)
+set(_user_specified_genex_versionless
+ \"$<IN_LIST:Qt::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\"
+)
string(CONCAT _plugin_genex
\"$<$<OR:\"
- # Add this plugin if it\'s in the list of manual plugins or plugins for the type
+ # Add this plugin if it\'s in the list of manually specified plugins or in the list of
+ # explicitly included plugin types.
\"${_user_specified_genex},\"
- # Add this plugin if the list of plugins for the type is empty, the PLUGIN_EXTENDS
- # is either empty or equal to the module name, and the user hasn\'t blacklisted it
+ \"${_user_specified_genex_versionless},\"
+ # Add this plugin if all of the following are true:
+ # 1) the list of explicitly included plugin types is empty
+ # 2) the QT_PLUGIN_EXTENDS property for the plugin is empty or equal to the current
+ # module name
+ # 3) the user hasn\'t explicitly excluded the plugin.
\"$<AND:\"
\"$<STREQUAL:${_plugin_type_genex},>,\"
\"$<OR:\"
- \"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,Qt5::$${CMAKE_MODULE_NAME}>,\"
+ # FIXME: The value of CMAKE_MODULE_NAME seems to be wrong (e.g for Svg plugin
+ # it should be Qt::Svg instead of Qt::Gui).
+ \"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,Qt::$${CMAKE_MODULE_NAME}>,\"
\"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,>\"
\">,\"
- \"$<NOT:$<IN_LIST:Qt5::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>\"
+ \"$<NOT:$<IN_LIST:Qt5::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>,\"
+ \"$<NOT:$<IN_LIST:Qt::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>\"
\">\"
\">:Qt5::$$CMAKE_PLUGIN_NAME>\"
)
@@ -100,3 +111,4 @@ set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} APPEND PROPERTY INTERFACE_LINK_LI
!!ENDIF
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_TYPE \"$$CMAKE_PLUGIN_TYPE\")
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_EXTENDS \"$$CMAKE_PLUGIN_EXTENDS\")
+set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_CLASS_NAME \"$$CMAKE_PLUGIN_NAME\")
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 7e471f126cb..8e46da521f6 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -1851,7 +1851,6 @@ QString MakefileGenerator::resolveDependency(const QDir &outDir, const QString &
}
void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCompiler,
- const QString &dep_cd_cmd,
const QString &tmp_dep_cmd,
const QString &inpf,
const QString &tmp_out,
@@ -1864,7 +1863,10 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell);
if (checkCommandAvailability && !canExecute(dep_cmd))
return;
- dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
+ dep_cmd = QLatin1String("cd ")
+ + IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ + QLatin1String(" && ")
+ + fixEnvVariables(dep_cmd);
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
QByteArray depData;
while (int read_in = feof(proc) ? 0 : (int)fread(buff, 1, 255, proc))
@@ -1916,12 +1918,6 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
FileFixifyFromOutdir);
const QString tmp_cmd = project->values(ProKey(*it + ".commands")).join(' ');
const QString tmp_dep_cmd = project->values(ProKey(*it + ".depend_command")).join(' ');
- QString dep_cd_cmd;
- if (!tmp_dep_cmd.isEmpty()) {
- dep_cd_cmd = QLatin1String("cd ")
- + IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
- + QLatin1String(" && ");
- }
const bool dep_lines = (config.indexOf("dep_lines") != -1);
const ProStringList &vars = project->values(ProKey(*it + ".variables"));
if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
@@ -2035,7 +2031,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
deps += findDependencies(inpf);
inputs += Option::fixPathToTargetOS(inpf, false);
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
- callExtraCompilerDependCommand(*it, dep_cd_cmd, tmp_dep_cmd, inpf,
+ callExtraCompilerDependCommand(*it, tmp_dep_cmd, inpf,
tmp_out, dep_lines, &deps, existingDepsOnly);
}
}
@@ -2084,7 +2080,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
for (ProStringList::ConstIterator it3 = vars.constBegin(); it3 != vars.constEnd(); ++it3)
cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
- callExtraCompilerDependCommand(*it, dep_cd_cmd, tmp_dep_cmd, inpf,
+ callExtraCompilerDependCommand(*it, tmp_dep_cmd, inpf,
tmp_out, dep_lines, &deps, existingDepsOnly);
//use the depend system to find includes of these included files
QStringList inc_deps;
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index ab970c966fd..a96b9c54da5 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -84,7 +84,7 @@ protected:
void writeExtraVariables(QTextStream &t);
void writeExtraTargets(QTextStream &t);
QString resolveDependency(const QDir &outDir, const QString &file);
- void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd,
+ void callExtraCompilerDependCommand(const ProString &extraCompiler,
const QString &tmp_dep_cmd, const QString &inpf,
const QString &tmp_out, bool dep_lines, QStringList *deps,
bool existingDepsOnly,
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
index 2b39a4baaaa..3002ce889c9 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -2351,10 +2351,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
if (!tmp_dep.isEmpty())
deps = tmp_dep;
if (!tmp_dep_cmd.isEmpty()) {
- const QString dep_cd_cmd = QLatin1String("cd ")
- + IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
- + QLatin1String(" && ");
- Project->callExtraCompilerDependCommand(extraCompilerName, dep_cd_cmd, tmp_dep_cmd,
+ Project->callExtraCompilerDependCommand(extraCompilerName, tmp_dep_cmd,
inFile, out,
true, // dep_lines
&deps,
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 867b14faea9..e117f472e09 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1481,36 +1481,20 @@ void VcprojGenerator::initResourceFiles()
// Bad hack, please look away -------------------------------------
QString rcc_dep_cmd = project->values("rcc.depend_command").join(' ');
if(!rcc_dep_cmd.isEmpty()) {
- ProStringList qrc_files = project->values("RESOURCES");
+ const QStringList qrc_files = project->values("RESOURCES").toQStringList();
QStringList deps;
- if(!qrc_files.isEmpty()) {
- for (int i = 0; i < qrc_files.count(); ++i) {
- char buff[256];
- QString dep_cmd = replaceExtraCompilerVariables(
- rcc_dep_cmd, qrc_files.at(i).toQString(), QString(), LocalShell);
-
- dep_cmd = Option::fixPathToLocalOS(dep_cmd, true, false);
- if(canExecute(dep_cmd)) {
- dep_cmd.prepend(QLatin1String("cd ")
- + IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
- + QLatin1String(" && "));
- if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
- QString indeps;
- while(!feof(proc)) {
- int read_in = (int)fread(buff, 1, 255, proc);
- if(!read_in)
- break;
- indeps += QByteArray(buff, read_in);
- }
- QT_PCLOSE(proc);
- if(!indeps.isEmpty())
- deps += fileFixify(indeps.replace('\n', ' ').simplified().split(' '),
- FileFixifyFromOutdir);
- }
- }
- }
- vcProject.ResourceFiles.addFiles(deps);
+ for (const QString &qrc_file : qrc_files) {
+ callExtraCompilerDependCommand("rcc",
+ rcc_dep_cmd,
+ qrc_file,
+ QString(),
+ true, // dep_lines
+ &deps,
+ false, // existingDepsOnly
+ true // checkCommandavailability
+ );
}
+ vcProject.ResourceFiles.addFiles(deps);
}
// You may look again --------------------------------------------
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 9b672327eff..4c1c3a612ba 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -1,3 +1,6 @@
+if(NOT DEFINED QT_DEFAULT_MAJOR_VERSION)
+ set(QT_DEFAULT_MAJOR_VERSION 5)
+endif()
if (NOT TARGET Qt5::qmake)
add_executable(Qt5::qmake IMPORTED)
@@ -177,3 +180,24 @@ if (ANDROID_PLATFORM)
endif()
_qt5_Core_check_file_exists(${_Qt5CTestMacros})
+
+# Create versionless tool targets.
+foreach(__qt_tool qmake moc rcc)
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::${__qt_tool}
+ AND TARGET Qt5::${__qt_tool})
+ add_executable(Qt::${__qt_tool} IMPORTED)
+ get_target_property(__qt_imported_location Qt5::${__qt_tool} IMPORTED_LOCATION)
+ set_target_properties(Qt::${__qt_tool}
+ PROPERTIES IMPORTED_LOCATION \"${__qt_imported_location}\")
+ endif()
+endforeach()
+
+!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
+# Add a versionless target for WinMain.
+if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::WinMain)
+ add_library(Qt::WinMain INTERFACE IMPORTED)
+ set_target_properties(Qt::WinMain PROPERTIES
+ INTERFACE_LINK_LIBRARIES \"Qt5::WinMain\"
+ )
+endif()
+!!ENDIF
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index e298cf7de76..6c214701642 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -157,6 +157,16 @@ function(qt5_generate_moc infile outfile )
qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_generate_moc)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_generate_moc(${ARGV})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_generate_moc(${ARGV})
+ endif()
+ endfunction()
+endif()
+
# qt5_wrap_cpp(outfiles inputfile ... )
@@ -184,6 +194,17 @@ function(qt5_wrap_cpp outfiles )
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
+# This will override the CMake upstream command, because that one is for Qt 3.
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_wrap_cpp outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_wrap_cpp("${outfiles}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_wrap_cpp("${outfiles}" ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
# _qt5_parse_qrc_file(infile _out_depends _rc_depends)
@@ -255,6 +276,16 @@ function(qt5_add_binary_resources target )
add_custom_target(${target} ALL DEPENDS ${rcc_destination})
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_binary_resources)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_binary_resources(${ARGV})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_binary_resources(${ARGV})
+ endif()
+ endfunction()
+endif()
+
# qt5_add_resources(outfiles inputfile ... )
@@ -293,6 +324,18 @@ function(qt5_add_resources outfiles )
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_resources outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_resources("${outfiles}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_resources("${outfiles}" ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
+
+
# qt5_add_big_resources(outfiles inputfile ... )
function(qt5_add_big_resources outfiles )
@@ -341,6 +384,18 @@ function(qt5_add_big_resources outfiles )
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_big_resources outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_big_resources(${outfiles} ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_big_resources(${outfiles} ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
+
+
set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
macro(qt5_use_modules _target _link_type)
@@ -413,10 +468,19 @@ function(qt5_import_plugins TARGET_NAME)
elseif(_doing STREQUAL "EXCLUDE_BY_TYPE")
string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}")
set_property(TARGET ${TARGET_NAME} PROPERTY "QT_PLUGINS_${_plugin_type}" -)
- set(_doing "")
else()
message(FATAL_ERROR "Unexpected extra argument: \"${_arg}\"")
endif()
endif()
endforeach()
endfunction()
+
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_import_plugins)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_import_plugins(${ARGV})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_import_plugins(${ARGV})
+ endif()
+ endfunction()
+endif()
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index c71a77e0732..d014b5c4413 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE
void QPropertyAnimationPrivate::updateMetaProperty()
{
if (!target || propertyName.isEmpty()) {
- propertyType = QVariant::Invalid;
+ propertyType = QMetaType::UnknownType;
propertyIndex = -1;
return;
}
@@ -102,11 +102,11 @@ void QPropertyAnimationPrivate::updateMetaProperty()
propertyType = targetValue->property(propertyName).userType();
propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName);
- if (propertyType != QVariant::Invalid)
+ if (propertyType != QMetaType::UnknownType)
convertValues(propertyType);
if (propertyIndex == -1) {
//there is no Q_PROPERTY on the object
- propertyType = QVariant::Invalid;
+ propertyType = QMetaType::UnknownType;
if (!targetValue->dynamicPropertyNames().contains(propertyName))
qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData());
} else if (!targetValue->metaObject()->property(propertyIndex).isWritable()) {
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp
index b72c9d13e1e..a67945bbcf2 100644
--- a/src/corelib/doc/snippets/code/doc_src_properties.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp
@@ -61,6 +61,7 @@ Q_PROPERTY(type name
[USER bool]
[CONSTANT]
[FINAL])
+ [REQUIRED]
//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
index aae2456bf15..36b47e6f6eb 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
@@ -56,7 +56,7 @@ QApplication::sendEvent(mainWindow, &event);
//! [1]
QPushButton *quitButton = new QPushButton("Quit");
-connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()), Qt::QueuedConnection);
+connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection);
//! [1]
@@ -79,12 +79,12 @@ Q_COREAPP_STARTUP_FUNCTION(preRoutineMyDebugTool)
//! [4]
-static int *global_ptr = 0;
+static int *global_ptr = nullptr;
static void cleanup_ptr()
{
delete [] global_ptr;
- global_ptr = 0;
+ global_ptr = nullptr;
}
void init_ptr()
@@ -125,9 +125,9 @@ private:
//! [6]
static inline QString tr(const char *sourceText,
- const char *comment = 0);
+ const char *comment = nullptr);
static inline QString trUtf8(const char *sourceText,
- const char *comment = 0);
+ const char *comment = nullptr);
//! [6]
diff --git a/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp
index a606da1a0ce..c756116de4d 100644
--- a/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp
@@ -56,7 +56,7 @@ QState *s1 = new QState();
s1->assignProperty(&button, "text", "Click me");
QFinalState *s2 = new QFinalState();
-s1->addTransition(&button, SIGNAL(clicked()), s2);
+s1->addTransition(&button, &QPushButton::clicked, s2);
machine.addState(s1);
machine.addState(s2);
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp
index 043974b25b0..336c1e9c791 100644
--- a/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp
@@ -52,7 +52,7 @@
// Instantiate the objects and connect to the finished signal.
MyClass myObject;
QFutureWatcher<int> watcher;
-connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished()));
+connect(&watcher, QFutureWatcher<int>::finished, &myObject, &MyClass::handleFinished);
// Start the computation.
QFuture<int> future = QtConcurrent::run(...);
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp
index 004a810fcef..80859d5ba59 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp
@@ -56,10 +56,10 @@ progressBar->setRange(0, 100);
// Construct a 1-second timeline with a frame range of 0 - 100
QTimeLine *timeLine = new QTimeLine(1000, this);
timeLine->setFrameRange(0, 100);
-connect(timeLine, SIGNAL(frameChanged(int)), progressBar, SLOT(setValue(int)));
+connect(timeLine, &QTimeLine::frameChanged, progressBar, &QProgressBar::setValue);
// Clicking the push button will start the progress bar animation
pushButton = new QPushButton(tr("Start animation"), this);
-connect(pushButton, SIGNAL(clicked()), timeLine, SLOT(start()));
+connect(pushButton, &QPushButton::clicked, timeLine, &QTimeLine::start);
...
//! [0]
diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
index e91c41b3054..84a156bb6db 100644
--- a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
+++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
@@ -48,11 +48,10 @@
**
****************************************************************************/
-#include <QtGui>
-#include <QtWidgets>
-
#include "buttonwidget.h"
+#include <QtWidgets>
+
//! [0]
ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
: QWidget(parent)
@@ -62,15 +61,16 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
QGridLayout *gridLayout = new QGridLayout;
for (int i = 0; i < texts.size(); ++i) {
QPushButton *button = new QPushButton(texts[i]);
- connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
+ connect(button, &QPushButton::clicked,
+ signalMapper, &QSignalMapper::map);
//! [0] //! [1]
signalMapper->setMapping(button, texts[i]);
gridLayout->addWidget(button, i / 3, i % 3);
}
- connect(signalMapper, SIGNAL(mapped(QString)),
+ connect(signalMapper, QOverload<const QString &>::of(&QSignalMapper::mapped),
//! [1] //! [2]
- this, SIGNAL(clicked(QString)));
+ this, &ButtonWidget::clicked);
setLayout(gridLayout);
}
@@ -84,7 +84,7 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
for (int i = 0; i < texts.size(); ++i) {
QString text = texts[i];
QPushButton *button = new QPushButton(text);
- connect(button, &QPushButton::clicked, [=] { clicked(text); });
+ connect(button, &QPushButton::clicked, [this, text] { clicked(text); });
gridLayout->addWidget(button, i / 3, i % 3);
}
setLayout(gridLayout);
diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h
index f55683c2d5c..b9d59f8dd84 100644
--- a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h
+++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h
@@ -51,7 +51,7 @@
#ifndef BUTTONWIDGET_H
#define BUTTONWIDGET_H
-#include <qwidget.h>
+#include <QWidget>
class QSignalMapper;
class QString;
@@ -63,7 +63,7 @@ class ButtonWidget : public QWidget
Q_OBJECT
public:
- ButtonWidget(const QStringList &texts, QWidget *parent = 0);
+ ButtonWidget(const QStringList &texts, QWidget *parent = nullptr);
signals:
void clicked(const QString &text);
diff --git a/src/corelib/doc/snippets/resource-system/mainwindow.cpp b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
index 86e93aaa624..6dc525304c5 100644
--- a/src/corelib/doc/snippets/resource-system/mainwindow.cpp
+++ b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
@@ -68,10 +68,10 @@ MainWindow::MainWindow()
readSettings();
- connect(textEdit->document(), SIGNAL(contentsChanged()),
- this, SLOT(documentWasModified()));
+ connect(textEdit->document(), &QTextEdit::contentsChanged,
+ this, &QAction::documentWasModified);
- setCurrentFile("");
+ setCurrentFile(QString());
setUnifiedTitleAndToolBarOnMac(true);
}
//! [2]
@@ -95,7 +95,7 @@ void MainWindow::newFile()
{
if (maybeSave()) {
textEdit->clear();
- setCurrentFile("");
+ setCurrentFile(QString());
}
}
//! [6]
@@ -162,31 +162,31 @@ void MainWindow::createActions()
newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
+ connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
//! [19]
openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+ connect(openAct, &QAction::triggered, this, &MainWindow::open);
//! [18] //! [19]
saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
+ connect(saveAct, &QAction::triggered, this, &MainWindow::save);
saveAsAct = new QAction(tr("Save &As..."), this);
saveAsAct->setShortcuts(QKeySequence::SaveAs);
saveAsAct->setStatusTip(tr("Save the document under a new name"));
- connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
+ connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs);
//! [20]
exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
//! [20]
exitAct->setStatusTip(tr("Exit the application"));
- connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+ connect(exitAct, &QAction::triggered, this, &MainWindow::close);
//! [21]
cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
@@ -194,38 +194,38 @@ void MainWindow::createActions()
cutAct->setShortcuts(QKeySequence::Cut);
cutAct->setStatusTip(tr("Cut the current selection's contents to the "
"clipboard"));
- connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut()));
+ connect(cutAct, &QAction::triggered, textEdit, &QTextEdit::cut);
copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
copyAct->setShortcuts(QKeySequence::Copy);
copyAct->setStatusTip(tr("Copy the current selection's contents to the "
"clipboard"));
- connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy()));
+ connect(copyAct, &QAction::triggered, textEdit, &QTextEdit::copy);
pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
pasteAct->setShortcuts(QKeySequence::Paste);
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
"selection"));
- connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));
+ connect(pasteAct, &QAction::triggered, textEdit, &QTextEdit::paste);
aboutAct = new QAction(tr("&About"), this);
aboutAct->setStatusTip(tr("Show the application's About box"));
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+ connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
//! [22]
aboutQtAct = new QAction(tr("About &Qt"), this);
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+ connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
//! [22]
//! [23]
cutAct->setEnabled(false);
//! [23] //! [24]
copyAct->setEnabled(false);
- connect(textEdit, SIGNAL(copyAvailable(bool)),
- cutAct, SLOT(setEnabled(bool)));
- connect(textEdit, SIGNAL(copyAvailable(bool)),
- copyAct, SLOT(setEnabled(bool)));
+ connect(textEdit, &QTextEdit::copyAvailable,
+ cutAct, &QAction::setEnabled);
+ connect(textEdit, &QTextEdit::copyAvailable,
+ copyAct, &QAction::setEnabled);
}
//! [24]
diff --git a/src/corelib/doc/snippets/statemachine/main.cpp b/src/corelib/doc/snippets/statemachine/main.cpp
index 8cd8b69e128..c399f4f1992 100644
--- a/src/corelib/doc/snippets/statemachine/main.cpp
+++ b/src/corelib/doc/snippets/statemachine/main.cpp
@@ -48,13 +48,14 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
int main(int argv, char **args)
{
QApplication app(argv, args);
QLabel *label = new QLabel;
+ QPushButton *button = new QPushButton;
//![0]
QStateMachine machine;
@@ -70,14 +71,14 @@ int main(int argv, char **args)
//![4]
//![5]
- QObject::connect(s3, SIGNAL(entered()), button, SLOT(showMaximized()));
- QObject::connect(s3, SIGNAL(exited()), button, SLOT(showMinimized()));
+ QObject::connect(s3, &QState::entered, button, &QPushButton:showMaximized);
+ QObject::connect(s3, &QState::exited, button, &QPushButton::showMinimized);
//![5]
//![1]
- s1->addTransition(button, SIGNAL(clicked()), s2);
- s2->addTransition(button, SIGNAL(clicked()), s3);
- s3->addTransition(button, SIGNAL(clicked()), s1);
+ s1->addTransition(button, &QPushButton::clicked, s2);
+ s2->addTransition(button, &QPushButton::clicked, s3);
+ s3->addTransition(button, &QPushButton::clicked, s1);
//![1]
//![2]
diff --git a/src/corelib/doc/snippets/statemachine/main2.cpp b/src/corelib/doc/snippets/statemachine/main2.cpp
index 96eb912b143..dedd2d29bf4 100644
--- a/src/corelib/doc/snippets/statemachine/main2.cpp
+++ b/src/corelib/doc/snippets/statemachine/main2.cpp
@@ -48,11 +48,11 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
int main(int argv, char **args)
{
- QApplication app(argv, args);
+ QApplication app(argv, args);
QStateMachine machine;
@@ -66,16 +66,17 @@ int main(int argv, char **args)
//![0]
//![2]
- s12->addTransition(quitButton, SIGNAL(clicked()), s12);
+ s12->addTransition(quitButton, &QPushButton::clicked, s12);
//![2]
//![1]
QFinalState *s2 = new QFinalState();
- s1->addTransition(quitButton, SIGNAL(clicked()), s2);
+ s1->addTransition(quitButton, &QPushButton::clicked, s2);
machine.addState(s2);
machine.setInitialState(s1);
- QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
+ QObject::connect(&machine, &QStateMachine::finished,
+ QCoreApplication::instance(), &QCoreApplication::quit);
//![1]
QButton *interruptButton = new QPushButton("Interrupt Button");
@@ -90,11 +91,11 @@ int main(int argv, char **args)
mbox->addButton(QMessageBox::Ok);
mbox->setText("Interrupted!");
mbox->setIcon(QMessageBox::Information);
- QObject::connect(s3, SIGNAL(entered()), mbox, SLOT(exec()));
+ QObject::connect(s3, &QState::entered, mbox, &QMessageBox::exec);
s3->addTransition(s1h);
machine.addState(s3);
- s1->addTransition(interruptButton, SIGNAL(clicked()), s3);
+ s1->addTransition(interruptButton, &QPushButton::clicked, s3);
//![3]
return app.exec();
diff --git a/src/corelib/doc/snippets/statemachine/main3.cpp b/src/corelib/doc/snippets/statemachine/main3.cpp
index bc9a0e29c4b..b665565aef3 100644
--- a/src/corelib/doc/snippets/statemachine/main3.cpp
+++ b/src/corelib/doc/snippets/statemachine/main3.cpp
@@ -62,7 +62,7 @@ int main(int argv, char **args)
//![0]
//![1]
- s1->addTransition(s1, SIGNAL(finished()), s2);
+ s1->addTransition(s1, &QState::finished, s2);
//![1]
return app.exec();
diff --git a/src/corelib/doc/snippets/statemachine/main5.cpp b/src/corelib/doc/snippets/statemachine/main5.cpp
index 38bb2cb475f..d701f51e2b6 100644
--- a/src/corelib/doc/snippets/statemachine/main5.cpp
+++ b/src/corelib/doc/snippets/statemachine/main5.cpp
@@ -98,7 +98,7 @@ int main(int argv, char **args)
s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));
- s1->addTransition(button, SIGNAL(clicked()), s2);
+ s1->addTransition(button, &QPushButton::clicked, s2);
//![3]
}
@@ -111,7 +111,7 @@ int main(int argv, char **args)
s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));
- QSignalTransition *transition = s1->addTransition(button, SIGNAL(clicked()), s2);
+ QSignalTransition *transition = s1->addTransition(button, &QPushButton::clicked, s2);
transition->addAnimation(new QPropertyAnimation(button, "geometry"));
//![4]
@@ -130,9 +130,9 @@ int main(int argv, char **args)
QState *s2 = new QState();
s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
- connect(s2, SIGNAL(entered()), messageBox, SLOT(exec()));
+ connect(s2, &QState::entered, messageBox, SLOT(exec()));
- s1->addTransition(button, SIGNAL(clicked()), s2);
+ s1->addTransition(button, &QPushButton::clicked, s2);
//![5]
}
@@ -151,10 +151,10 @@ int main(int argv, char **args)
s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
QState *s3 = new QState();
- connect(s3, SIGNAL(entered()), messageBox, SLOT(exec()));
+ connect(s3, &QState::entered, messageBox, SLOT(exec()));
- s1->addTransition(button, SIGNAL(clicked()), s2);
- s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
+ s1->addTransition(button, &QPushButton::clicked, s2);
+ s2->addTransition(s2, &QState::propertiesAssigned, s3);
//![6]
}
diff --git a/src/corelib/doc/snippets/timers/analogclock.cpp b/src/corelib/doc/snippets/timers/analogclock.cpp
index 4e1957a450a..3edfce32357 100644
--- a/src/corelib/doc/snippets/timers/analogclock.cpp
+++ b/src/corelib/doc/snippets/timers/analogclock.cpp
@@ -61,7 +61,7 @@ AnalogClock::AnalogClock(QWidget *parent)
//! [3] //! [4]
QTimer *timer = new QTimer(this);
//! [4] //! [5]
- connect(timer, SIGNAL(timeout()), this, SLOT(update()));
+ connect(timer, &QTimer::timeout, this, QOverload<>::of(&AnalogClock::update));
//! [5] //! [6]
timer->start(1000);
//! [6]
diff --git a/src/corelib/doc/snippets/timers/timers.cpp b/src/corelib/doc/snippets/timers/timers.cpp
index 5f95899af21..eb0c82c625d 100644
--- a/src/corelib/doc/snippets/timers/timers.cpp
+++ b/src/corelib/doc/snippets/timers/timers.cpp
@@ -61,13 +61,13 @@ Foo::Foo()
//! [0]
QTimer *timer = new QTimer(this);
//! [0] //! [1]
- connect(timer, SIGNAL(timeout()), this, SLOT(updateCaption()));
+ connect(timer, &QTimer::timeout, this, &Foo::updateCaption);
//! [1] //! [2]
timer->start(1000);
//! [2]
//! [3]
- QTimer::singleShot(200, this, SLOT(updateCaption()));
+ QTimer::singleShot(200, this, &Foo::updateCaption);
//! [3]
{
@@ -75,7 +75,7 @@ Foo::Foo()
//! [4]
QTimer *timer = new QTimer(this);
//! [4] //! [5]
- connect(timer, SIGNAL(timeout()), this, SLOT(processOneThing()));
+ connect(timer, &QTimer::timeout, this, &Foo::processOneThing);
//! [5] //! [6]
timer->start();
//! [6]
diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc
index 0c1b2aed171..9cbe50d4a98 100644
--- a/src/corelib/doc/src/animation.qdoc
+++ b/src/corelib/doc/src/animation.qdoc
@@ -356,11 +356,11 @@
state2->assignProperty(button, "geometry", QRect(250, 250, 100, 30));
QSignalTransition *transition1 = state1->addTransition(button,
- SIGNAL(clicked()), state2);
+ &QPushButton::clicked, state2);
transition1->addAnimation(new QPropertyAnimation(button, "geometry"));
QSignalTransition *transition2 = state2->addTransition(button,
- SIGNAL(clicked()), state1);
+ &QPushButton::clicked, state1);
transition2->addAnimation(new QPropertyAnimation(button, "geometry"));
machine->start();
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
index 9ef08cce073..680e5598f09 100644
--- a/src/corelib/doc/src/objectmodel/properties.qdoc
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -144,6 +144,12 @@
optimizations in some cases, but is not enforced by moc. Care must be taken
never to override a \c FINAL property.
+ \li The presence of the \c REQUIRED attribute indicates that the property
+ should be set by a user of the class. This is not enforced by moc, and is
+ mostly useful for classes exposed to QML. In QML, classes with REQUIRED
+ properties cannot be instantiated unless all REQUIRED properties have
+ been set.
+
\endlist
The \c READ, \c WRITE, and \c RESET functions can be inherited.
diff --git a/src/corelib/doc/src/statemachine.qdoc b/src/corelib/doc/src/statemachine.qdoc
index 43c8497ef2b..881a0785c6c 100644
--- a/src/corelib/doc/src/statemachine.qdoc
+++ b/src/corelib/doc/src/statemachine.qdoc
@@ -323,12 +323,12 @@
QState *s1 = new QState(&machine);
QPushButton button;
- QSignalTransition *trans = new QSignalTransition(&button, SIGNAL(clicked()));
+ QSignalTransition *trans = new QSignalTransition(&button, &QPushButton::clicked);
s1->addTransition(trans);
QMessageBox msgBox;
msgBox.setText("The button was clicked; carry on.");
- QObject::connect(trans, SIGNAL(triggered()), &msgBox, SLOT(exec()));
+ QObject::connect(trans, QSignalTransition::triggered, &msgBox, &QMessageBox::exec);
machine.setInitialState(s1);
\endcode
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index ea91dee471c..c9e155555c9 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -702,7 +702,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
64-bit integer literals in a platform-independent way. The
Q_CHECK_PTR() macro prints a warning containing the source code's
file name and line number, saying that the program ran out of
- memory, if the pointer is 0. The qPrintable() and qUtf8Printable()
+ memory, if the pointer is \nullptr. The qPrintable() and qUtf8Printable()
macros represent an easy way of printing text.
The QT_POINTER_SIZE macro expands to the size of a pointer in bytes.
@@ -3279,7 +3279,7 @@ QByteArray QSysInfo::bootUniqueId()
\macro void Q_CHECK_PTR(void *pointer)
\relates <QtGlobal>
- If \a pointer is 0, prints a message containing the source
+ If \a pointer is \nullptr, prints a message containing the source
code's file name and line number, saying that the program ran out
of memory and aborts program execution. It throws \c std::bad_alloc instead
if exceptions are enabled.
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index b9e981b4a60..f278850ccf4 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1749,6 +1749,9 @@ namespace Qt {
PassThrough
};
+ // QTBUG-48701
+ enum ReturnByValue_t { ReturnByValue }; // ### Qt 7: Remove me
+
#ifndef Q_QDOC
// NOTE: Generally, do not add Q_ENUM_NS if a corresponding Q_FLAG_NS exists.
Q_ENUM_NS(ScrollBarPolicy)
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 6149281904b..29b58783d5e 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -3319,3 +3319,15 @@
\value RoundPreferFloor Round up for .75 and above.
\value PassThrough Don't round.
*/
+
+/*!
+ \enum Qt::ReturnByValue_t
+ \since 5.15
+
+ This is a dummy type, designed to help users transition from certain deprecated APIs to their replacement APIs.
+
+ \sa QCursor::bitmap()
+ \sa QCursor::mask()
+ \sa QLabel::picture()
+ \sa QLabel::pixmap()
+*/
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp
index 8e980733de1..595fcd27248 100644
--- a/src/corelib/io/qbuffer.cpp
+++ b/src/corelib/io/qbuffer.cpp
@@ -227,7 +227,7 @@ QBuffer::~QBuffer()
\snippet buffer/buffer.cpp 4
- If \a byteArray is 0, the buffer creates its own internal
+ If \a byteArray is \nullptr, the buffer creates its own internal
QByteArray to work on. This byte array is initially empty.
\sa buffer(), setData(), open()
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index b89cab5e3cb..f7a86c25cd2 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1829,7 +1829,7 @@ QByteArray QIODevicePrivate::peek(qint64 maxSize)
/*! \fn bool QIODevice::getChar(char *c)
Reads one character from the device and stores it in \a c. If \a c
- is 0, the character is discarded. Returns \c true on success;
+ is \nullptr, the character is discarded. Returns \c true on success;
otherwise returns \c false.
\sa read(), putChar(), ungetChar()
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 779b6f72def..6c66d1097d7 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -396,12 +396,12 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
{
QString result;
- switch (v.type()) {
- case QVariant::Invalid:
+ switch (v.userType()) {
+ case QMetaType::UnknownType:
result = QLatin1String("@Invalid()");
break;
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
QByteArray a = v.toByteArray();
result = QLatin1String("@ByteArray(")
+ QLatin1String(a.constData(), a.size())
@@ -409,17 +409,16 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
break;
}
- case QVariant::String:
- case QVariant::LongLong:
- case QVariant::ULongLong:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::Bool:
- case QVariant::Double:
#if QT_CONFIG(shortcut)
- case QVariant::KeySequence:
+ case QMetaType::QKeySequence:
#endif
- {
+ case QMetaType::QString:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ case QMetaType::Bool:
+ case QMetaType::Double: {
result = v.toString();
if (result.contains(QChar::Null))
result = QLatin1String("@String(") + result + QLatin1Char(')');
@@ -428,17 +427,17 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
break;
}
#ifndef QT_NO_GEOM_VARIANT
- case QVariant::Rect: {
+ case QMetaType::QRect: {
QRect r = qvariant_cast<QRect>(v);
result = QString::asprintf("@Rect(%d %d %d %d)", r.x(), r.y(), r.width(), r.height());
break;
}
- case QVariant::Size: {
+ case QMetaType::QSize: {
QSize s = qvariant_cast<QSize>(v);
result = QString::asprintf("@Size(%d %d)", s.width(), s.height());
break;
}
- case QVariant::Point: {
+ case QMetaType::QPoint: {
QPoint p = qvariant_cast<QPoint>(v);
result = QString::asprintf("@Point(%d %d)", p.x(), p.y());
break;
@@ -449,7 +448,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
#ifndef QT_NO_DATASTREAM
QDataStream::Version version;
const char *typeSpec;
- if (v.type() == QVariant::DateTime) {
+ if (v.userType() == QMetaType::QDateTime) {
version = QDataStream::Qt_5_6;
typeSpec = "@DateTime(";
} else {
@@ -1891,8 +1890,8 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti
QVariant(QString("foo")).toList() returns an empty
list, not a list containing "foo".
*/
- if (value.type() == QVariant::StringList
- || (value.type() == QVariant::List && value.toList().size() != 1)) {
+ if (value.userType() == QMetaType::QStringList
+ || (value.userType() == QMetaType::QVariantList && value.toList().size() != 1)) {
iniEscapedStringList(variantListToStringList(value.toList()), block, iniCodec);
} else {
iniEscapedString(variantToString(value), block, iniCodec);
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 3bcd81bcdfb..f0eb8e5c8b5 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -552,32 +552,32 @@ const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
bool QAbstractItemModelPrivate::isVariantLessThan(const QVariant &left, const QVariant &right,
Qt::CaseSensitivity cs, bool isLocaleAware)
{
- if (left.userType() == QVariant::Invalid)
+ if (left.userType() == QMetaType::UnknownType)
return false;
- if (right.userType() == QVariant::Invalid)
+ if (right.userType() == QMetaType::UnknownType)
return true;
switch (left.userType()) {
- case QVariant::Int:
+ case QMetaType::Int:
return left.toInt() < right.toInt();
- case QVariant::UInt:
+ case QMetaType::UInt:
return left.toUInt() < right.toUInt();
- case QVariant::LongLong:
+ case QMetaType::LongLong:
return left.toLongLong() < right.toLongLong();
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return left.toULongLong() < right.toULongLong();
case QMetaType::Float:
return left.toFloat() < right.toFloat();
- case QVariant::Double:
+ case QMetaType::Double:
return left.toDouble() < right.toDouble();
- case QVariant::Char:
+ case QMetaType::QChar:
return left.toChar() < right.toChar();
- case QVariant::Date:
+ case QMetaType::QDate:
return left.toDate() < right.toDate();
- case QVariant::Time:
+ case QMetaType::QTime:
return left.toTime() < right.toTime();
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return left.toDateTime() < right.toDateTime();
- case QVariant::String:
+ case QMetaType::QString:
default:
if (isLocaleAware)
return left.toString().localeAwareCompare(right.toString()) < 0;
@@ -591,19 +591,19 @@ static uint typeOfVariant(const QVariant &value)
{
//return 0 for integer, 1 for floating point and 2 for other
switch (value.userType()) {
- case QVariant::Bool:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::LongLong:
- case QVariant::ULongLong:
- case QVariant::Char:
+ case QMetaType::Bool:
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
+ case QMetaType::QChar:
case QMetaType::Short:
case QMetaType::UShort:
case QMetaType::UChar:
case QMetaType::ULong:
case QMetaType::Long:
return 0;
- case QVariant::Double:
+ case QMetaType::Double:
case QMetaType::Float:
return 1;
default:
@@ -2374,7 +2374,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role,
} else { // QString or regular expression based matching
if (matchType == Qt::MatchRegularExpression) {
if (rx.pattern().isEmpty()) {
- if (value.type() == QVariant::RegularExpression) {
+ if (value.userType() == QMetaType::QRegularExpression) {
rx = value.toRegularExpression();
} else {
rx.setPattern(value.toString());
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index 7215b3f2bd1..685a0c595ae 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -160,7 +160,7 @@ QAbstractEventDispatcher::~QAbstractEventDispatcher()
/*!
Returns a pointer to the event dispatcher object for the specified
- \a thread. If \a thread is zero, the current thread is used. If no
+ \a thread. If \a thread is \nullptr, the current thread is used. If no
event dispatcher exists for the specified thread, this function
returns \nullptr.
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 3883613d49d..f4d0a88529d 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -603,7 +603,7 @@ static bool methodMatch(const QMetaObject *m, int handle,
* \internal
* helper function for indexOf{Method,Slot,Signal}, returns the relative index of the method within
* the baseObject
-* \a MethodType might be MethodSignal or MethodSlot, or 0 to match everything.
+* \a MethodType might be MethodSignal or MethodSlot, or \nullptr to match everything.
*/
template<int MethodType>
static inline int indexOfMethodRelative(const QMetaObject **baseObject,
@@ -737,7 +737,7 @@ int QMetaObject::indexOfSignal(const char *signal) const
\internal
Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object.
- \a baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found
+ \a baseObject will be adjusted to the enclosing QMetaObject, or \nullptr if the signal is not found
*/
int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject,
const QByteArray &name, int argc,
@@ -2988,7 +2988,7 @@ int QMetaProperty::userType() const
if (type == QMetaType::UnknownType) {
type = registerPropertyType();
if (type == QMetaType::UnknownType)
- return QVariant::Int; // Match behavior of QMetaType::type()
+ return QMetaType::Int; // Match behavior of QMetaType::type()
}
return type;
}
@@ -3106,7 +3106,7 @@ QVariant QMetaProperty::read(const QObject *object) const
if (!object || !mobj)
return QVariant();
- uint t = QVariant::Int;
+ uint t = QMetaType::Int;
if (isEnumType()) {
/*
try to create a QVariant that can be converted to this enum
@@ -3183,9 +3183,9 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const
return false;
QVariant v = value;
- uint t = QVariant::Invalid;
+ uint t = QMetaType::UnknownType;
if (isEnumType()) {
- if (v.type() == QVariant::String) {
+ if (v.userType() == QMetaType::QString) {
bool ok;
if (isFlagType())
v = QVariant(menum.keysToValue(value.toByteArray(), &ok));
@@ -3193,13 +3193,13 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const
v = QVariant(menum.keyToValue(value.toByteArray(), &ok));
if (!ok)
return false;
- } else if (v.type() != QVariant::Int && v.type() != QVariant::UInt) {
+ } else if (v.userType() != QMetaType::Int && v.userType() != QMetaType::UInt) {
int enumMetaTypeId = QMetaType::type(qualifiedName(menum));
if ((enumMetaTypeId == QMetaType::UnknownType) || (v.userType() != enumMetaTypeId) || !v.constData())
return false;
v = QVariant(*reinterpret_cast<const int *>(v.constData()));
}
- v.convert(QVariant::Int);
+ v.convert(QMetaType::Int);
} else {
int handle = priv(mobj->d.data)->propertyData + 3*idx;
const char *typeName = nullptr;
@@ -3579,6 +3579,21 @@ bool QMetaProperty::isFinal() const
}
/*!
+ \since 5.15
+ Returns \c true if the property is required; otherwise returns \c false.
+
+ A property is final if the \c{Q_PROPERTY()}'s \c REQUIRED attribute
+ is set.
+*/
+bool QMetaProperty::isRequired() const
+{
+ if (!mobj)
+ return false;
+ int flags = mobj->d.data[handle + 2];
+ return flags & Required;
+}
+
+/*!
\obsolete
Returns \c true if the property is editable for the given \a object;
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 31fecd0b07f..d0c4b489a67 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -263,6 +263,7 @@ public:
bool isUser(const QObject *obj = nullptr) const;
bool isConstant() const;
bool isFinal() const;
+ bool isRequired() const;
bool isFlagType() const;
bool isEnumType() const;
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 56e3d6cb446..277109dac46 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -85,7 +85,8 @@ enum PropertyFlags {
User = 0x00100000,
ResolveUser = 0x00200000,
Notify = 0x00400000,
- Revisioned = 0x00800000
+ Revisioned = 0x00800000,
+ Required = 0x01000000,
};
enum MethodFlags {
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 79d6d0aa93d..e498772e320 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -254,6 +254,7 @@ struct DefinedTypesFilter {
\value QPolygon QPolygon
\value QPolygonF QPolygonF
\value QColor QColor
+ \value QColorSpace QColorSpace
\value QSizeF QSizeF
\value QRectF QRectF
\value QLine QLine
@@ -458,7 +459,7 @@ struct DefinedTypesFilter {
\deprecated
Constructs a value of the given type which is a copy of \a copy.
- The default value for \a copy is 0.
+ The default value for \a copy is \nullptr.
Deprecated, use the static function QMetaType::create(int type,
const void *copy) instead.
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 7628f5f6b32..927bfb76674 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -182,6 +182,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(QVector4D, 84, QVector4D) \
F(QQuaternion, 85, QQuaternion) \
F(QPolygonF, 86, QPolygonF) \
+ F(QColorSpace, 87, QColorSpace) \
#define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\
@@ -440,7 +441,7 @@ public:
FirstCoreType = Bool,
LastCoreType = QCborMap,
FirstGuiType = QFont,
- LastGuiType = QPolygonF,
+ LastGuiType = QColorSpace,
FirstWidgetsType = QSizePolicy,
LastWidgetsType = QSizePolicy,
HighestInternalId = LastWidgetsType,
@@ -475,12 +476,12 @@ public:
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
QCursor = 74, QKeySequence = 75, QPen = 76, QTextLength = 77, QTextFormat = 78,
QMatrix = 79, QTransform = 80, QMatrix4x4 = 81, QVector2D = 82,
- QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86,
+ QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86, QColorSpace = 87,
// Widget types
QSizePolicy = 121,
LastCoreType = QCborMap,
- LastGuiType = QPolygonF,
+ LastGuiType = QColorSpace,
User = 1024
};
#endif
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index 00e5183eb16..fca258c9e3d 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -70,7 +70,7 @@ public:
void setData(const QString &format, const QVariant &data);
QVariant getData(const QString &format) const;
- QVariant retrieveTypedData(const QString &format, QVariant::Type type) const;
+ QVariant retrieveTypedData(const QString &format, QMetaType::Type type) const;
QVector<QMimeDataStruct> dataList;
};
@@ -108,23 +108,23 @@ QVariant QMimeDataPrivate::getData(const QString &format) const
return data;
}
-QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Type type) const
+QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType::Type type) const
{
Q_Q(const QMimeData);
- QVariant data = q->retrieveData(format, type);
+ QVariant data = q->retrieveData(format, QVariant::Type(type));
// Text data requested: fallback to URL data if available
if (format == QLatin1String("text/plain") && !data.isValid()) {
- data = retrieveTypedData(textUriListLiteral(), QVariant::List);
- if (data.type() == QVariant::Url) {
+ data = retrieveTypedData(textUriListLiteral(), QMetaType::QVariantList);
+ if (data.userType() == QMetaType::QUrl) {
data = QVariant(data.toUrl().toDisplayString());
- } else if (data.type() == QVariant::List) {
+ } else if (data.userType() == QMetaType::QVariantList) {
QString text;
int numUrls = 0;
const QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) {
- if (list.at(i).type() == QVariant::Url) {
+ if (list.at(i).userType() == QMetaType::QUrl) {
text += list.at(i).toUrl().toDisplayString() + QLatin1Char('\n');
++numUrls;
}
@@ -135,26 +135,26 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
}
}
- if (data.type() == type || !data.isValid())
+ if (data.userType() == type || !data.isValid())
return data;
// provide more conversion possiblities than just what QVariant provides
// URLs can be lists as well...
- if ((type == QVariant::Url && data.type() == QVariant::List)
- || (type == QVariant::List && data.type() == QVariant::Url))
+ if ((type == QMetaType::QUrl && data.userType() == QMetaType::QVariantList)
+ || (type == QMetaType::QVariantList && data.userType() == QMetaType::QUrl))
return data;
// images and pixmaps are interchangeable
- if ((type == QVariant::Pixmap && data.type() == QVariant::Image)
- || (type == QVariant::Image && data.type() == QVariant::Pixmap))
+ if ((type == QMetaType::QPixmap && data.userType() == QMetaType::QImage)
+ || (type == QMetaType::QImage && data.userType() == QMetaType::QPixmap))
return data;
- if (data.type() == QVariant::ByteArray) {
+ if (data.userType() == QMetaType::QByteArray) {
// see if we can convert to the requested type
switch(type) {
#if QT_CONFIG(textcodec)
- case QVariant::String: {
+ case QMetaType::QString: {
const QByteArray ba = data.toByteArray();
QTextCodec *codec = QTextCodec::codecForName("utf-8");
if (format == QLatin1String("text/html"))
@@ -162,17 +162,17 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
return codec->toUnicode(ba);
}
#endif // textcodec
- case QVariant::Color: {
+ case QMetaType::QColor: {
QVariant newData = data;
- newData.convert(QVariant::Color);
+ newData.convert(QMetaType::QColor);
return newData;
}
- case QVariant::List: {
+ case QMetaType::QVariantList: {
if (format != QLatin1String("text/uri-list"))
break;
Q_FALLTHROUGH();
}
- case QVariant::Url: {
+ case QMetaType::QUrl: {
QByteArray ba = data.toByteArray();
// Qt 3.x will send text/uri-list with a trailing
// null-terminator (that is *not* sent for any other
@@ -193,23 +193,23 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
break;
}
- } else if (type == QVariant::ByteArray) {
+ } else if (type == QMetaType::QByteArray) {
// try to convert to bytearray
- switch(data.type()) {
- case QVariant::ByteArray:
- case QVariant::Color:
+ switch (data.userType()) {
+ case QMetaType::QByteArray:
+ case QMetaType::QColor:
return data.toByteArray();
- case QVariant::String:
+ case QMetaType::QString:
return data.toString().toUtf8();
- case QVariant::Url:
+ case QMetaType::QUrl:
return data.toUrl().toEncoded();
- case QVariant::List: {
+ case QMetaType::QVariantList: {
// has to be list of URLs
QByteArray result;
QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) {
- if (list.at(i).type() == QVariant::Url) {
+ if (list.at(i).userType() == QMetaType::QUrl) {
result += list.at(i).toUrl().toEncoded();
result += "\r\n";
}
@@ -340,14 +340,14 @@ QMimeData::~QMimeData()
QList<QUrl> QMimeData::urls() const
{
Q_D(const QMimeData);
- QVariant data = d->retrieveTypedData(textUriListLiteral(), QVariant::List);
+ QVariant data = d->retrieveTypedData(textUriListLiteral(), QMetaType::QVariantList);
QList<QUrl> urls;
- if (data.type() == QVariant::Url)
+ if (data.userType() == QMetaType::QUrl)
urls.append(data.toUrl());
- else if (data.type() == QVariant::List) {
+ else if (data.userType() == QMetaType::QVariantList) {
QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) {
- if (list.at(i).type() == QVariant::Url)
+ if (list.at(i).userType() == QMetaType::QUrl)
urls.append(list.at(i).toUrl());
}
}
@@ -400,11 +400,11 @@ bool QMimeData::hasUrls() const
QString QMimeData::text() const
{
Q_D(const QMimeData);
- QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QVariant::String);
+ QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QMetaType::QString);
if (!utf8Text.isNull())
return utf8Text.toString();
- QVariant data = d->retrieveTypedData(textPlainLiteral(), QVariant::String);
+ QVariant data = d->retrieveTypedData(textPlainLiteral(), QMetaType::QString);
return data.toString();
}
@@ -440,7 +440,7 @@ bool QMimeData::hasText() const
QString QMimeData::html() const
{
Q_D(const QMimeData);
- QVariant data = d->retrieveTypedData(textHtmlLiteral(), QVariant::String);
+ QVariant data = d->retrieveTypedData(textHtmlLiteral(), QMetaType::QString);
return data.toString();
}
@@ -482,7 +482,7 @@ bool QMimeData::hasHtml() const
QVariant QMimeData::imageData() const
{
Q_D(const QMimeData);
- return d->retrieveTypedData(applicationXQtImageLiteral(), QVariant::Image);
+ return d->retrieveTypedData(applicationXQtImageLiteral(), QMetaType::QImage);
}
/*!
@@ -529,7 +529,7 @@ bool QMimeData::hasImage() const
QVariant QMimeData::colorData() const
{
Q_D(const QMimeData);
- return d->retrieveTypedData(applicationXColorLiteral(), QVariant::Color);
+ return d->retrieveTypedData(applicationXColorLiteral(), QMetaType::QColor);
}
/*!
@@ -564,7 +564,7 @@ bool QMimeData::hasColor() const
QByteArray QMimeData::data(const QString &mimeType) const
{
Q_D(const QMimeData);
- QVariant data = d->retrieveTypedData(mimeType, QVariant::ByteArray);
+ QVariant data = d->retrieveTypedData(mimeType, QMetaType::QByteArray);
return data.toByteArray();
}
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 888da17a98b..815eefc6173 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2018 Intel Corporation.
** Copyright (C) 2015 Olivier Goffart <[email protected]>
** Contact: https://www.qt.io/licensing/
@@ -168,7 +168,7 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d)
return qlonglong(d->data.l);
case QMetaType::Float:
return qRound64(d->data.f);
- case QVariant::Double:
+ case QMetaType::Double:
return qRound64(d->data.d);
#ifndef QT_BOOTSTRAPPED
case QMetaType::QJsonValue:
@@ -184,9 +184,9 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d)
static qulonglong qMetaTypeUNumber(const QVariant::Private *d)
{
switch (d->type) {
- case QVariant::UInt:
+ case QMetaType::UInt:
return d->data.u;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return d->data.ull;
case QMetaType::UChar:
return d->data.uc;
@@ -204,13 +204,13 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
*ok = true;
switch (uint(d->type)) {
- case QVariant::String:
+ case QMetaType::QString:
return v_cast<QString>(d)->toLongLong(ok);
- case QVariant::Char:
+ case QMetaType::QChar:
return v_cast<QChar>(d)->unicode();
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
return v_cast<QByteArray>(d)->toLongLong(ok);
- case QVariant::Bool:
+ case QMetaType::Bool:
return qlonglong(d->data.b);
#ifndef QT_BOOTSTRAPPED
case QMetaType::QCborValue:
@@ -222,8 +222,8 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
break;
Q_FALLTHROUGH();
#endif
- case QVariant::Double:
- case QVariant::Int:
+ case QMetaType::Double:
+ case QMetaType::Int:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
@@ -231,8 +231,8 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
case QMetaType::Float:
case QMetaType::LongLong:
return qMetaTypeNumber(d);
- case QVariant::ULongLong:
- case QVariant::UInt:
+ case QMetaType::ULongLong:
+ case QMetaType::UInt:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -262,12 +262,12 @@ static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok)
{
*ok = true;
switch (uint(d->type)) {
- case QVariant::Double:
+ case QMetaType::Double:
return qreal(d->data.d);
case QMetaType::Float:
return qreal(d->data.f);
- case QVariant::ULongLong:
- case QVariant::UInt:
+ case QMetaType::ULongLong:
+ case QMetaType::UInt:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -289,13 +289,13 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
*ok = true;
switch (uint(d->type)) {
- case QVariant::String:
+ case QMetaType::QString:
return v_cast<QString>(d)->toULongLong(ok);
- case QVariant::Char:
+ case QMetaType::QChar:
return v_cast<QChar>(d)->unicode();
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
return v_cast<QByteArray>(d)->toULongLong(ok);
- case QVariant::Bool:
+ case QMetaType::Bool:
return qulonglong(d->data.b);
#ifndef QT_BOOTSTRAPPED
case QMetaType::QCborValue:
@@ -309,8 +309,8 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
break;
Q_FALLTHROUGH();
#endif
- case QVariant::Double:
- case QVariant::Int:
+ case QMetaType::Double:
+ case QMetaType::Int:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
@@ -318,8 +318,8 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
case QMetaType::Float:
case QMetaType::LongLong:
return qulonglong(qMetaTypeNumber(d));
- case QVariant::ULongLong:
- case QVariant::UInt:
+ case QMetaType::ULongLong:
+ case QMetaType::UInt:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -406,9 +406,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
switch (uint(t)) {
#ifndef QT_BOOTSTRAPPED
- case QVariant::Url:
+ case QMetaType::QUrl:
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d));
break;
case QMetaType::QCborValue:
@@ -423,18 +423,18 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
#endif // QT_BOOTSTRAPPED
#if QT_CONFIG(itemmodel)
- case QVariant::ModelIndex:
+ case QMetaType::QModelIndex:
switch (d->type) {
- case QVariant::PersistentModelIndex:
+ case QMetaType::QPersistentModelIndex:
*static_cast<QModelIndex *>(result) = QModelIndex(*v_cast<QPersistentModelIndex>(d));
break;
default:
return false;
}
break;
- case QVariant::PersistentModelIndex:
+ case QMetaType::QPersistentModelIndex:
switch (d->type) {
- case QVariant::ModelIndex:
+ case QMetaType::QModelIndex:
*static_cast<QPersistentModelIndex *>(result) = QPersistentModelIndex(*v_cast<QModelIndex>(d));
break;
default:
@@ -442,10 +442,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
#endif // QT_CONFIG(itemmodel)
- case QVariant::String: {
+ case QMetaType::QString: {
QString *str = static_cast<QString *>(result);
switch (d->type) {
- case QVariant::Char:
+ case QMetaType::QChar:
*str = *v_cast<QChar>(d);
break;
case QMetaType::Char:
@@ -455,12 +455,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::Short:
case QMetaType::Long:
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
*str = QString::number(qMetaTypeNumber(d));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UShort:
case QMetaType::ULong:
*str = QString::number(qMetaTypeUNumber(d));
@@ -468,32 +468,32 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Float:
*str = QString::number(d->data.f, 'g', QLocale::FloatingPointShortest);
break;
- case QVariant::Double:
+ case QMetaType::Double:
*str = QString::number(d->data.d, 'g', QLocale::FloatingPointShortest);
break;
#if QT_CONFIG(datestring)
- case QVariant::Date:
+ case QMetaType::QDate:
*str = v_cast<QDate>(d)->toString(Qt::ISODate);
break;
- case QVariant::Time:
+ case QMetaType::QTime:
*str = v_cast<QTime>(d)->toString(Qt::ISODateWithMs);
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
*str = v_cast<QDateTime>(d)->toString(Qt::ISODateWithMs);
break;
#endif
- case QVariant::Bool:
+ case QMetaType::Bool:
*str = d->data.b ? QStringLiteral("true") : QStringLiteral("false");
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*str = QString::fromUtf8(v_cast<QByteArray>(d)->constData());
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
if (v_cast<QStringList>(d)->count() == 1)
*str = v_cast<QStringList>(d)->at(0);
break;
#ifndef QT_BOOTSTRAPPED
- case QVariant::Url:
+ case QMetaType::QUrl:
*str = v_cast<QUrl>(d)->toString();
break;
case QMetaType::QJsonValue:
@@ -508,7 +508,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*str = v_cast<QCborValue>(d)->toVariant().toString();
break;
#endif
- case QVariant::Uuid:
+ case QMetaType::QUuid:
*str = v_cast<QUuid>(d)->toString();
break;
case QMetaType::Nullptr:
@@ -528,11 +528,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
}
- case QVariant::Char: {
+ case QMetaType::QChar: {
QChar *c = static_cast<QChar *>(result);
switch (d->type) {
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
@@ -540,8 +540,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Float:
*c = QChar(ushort(qMetaTypeNumber(d)));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -553,10 +553,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
#ifndef QT_NO_GEOM_VARIANT
- case QVariant::Size: {
+ case QMetaType::QSize: {
QSize *s = static_cast<QSize *>(result);
switch (d->type) {
- case QVariant::SizeF:
+ case QMetaType::QSizeF:
*s = v_cast<QSizeF>(d)->toSize();
break;
default:
@@ -565,10 +565,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
- case QVariant::SizeF: {
+ case QMetaType::QSizeF: {
QSizeF *s = static_cast<QSizeF *>(result);
switch (d->type) {
- case QVariant::Size:
+ case QMetaType::QSize:
*s = QSizeF(*(v_cast<QSize>(d)));
break;
default:
@@ -577,10 +577,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
- case QVariant::Line: {
+ case QMetaType::QLine: {
QLine *s = static_cast<QLine *>(result);
switch (d->type) {
- case QVariant::LineF:
+ case QMetaType::QLineF:
*s = v_cast<QLineF>(d)->toLine();
break;
default:
@@ -589,10 +589,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
- case QVariant::LineF: {
+ case QMetaType::QLineF: {
QLineF *s = static_cast<QLineF *>(result);
switch (d->type) {
- case QVariant::Line:
+ case QMetaType::QLine:
*s = QLineF(*(v_cast<QLine>(d)));
break;
default:
@@ -601,27 +601,27 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
#endif
- case QVariant::StringList:
- if (d->type == QVariant::List) {
+ case QMetaType::QStringList:
+ if (d->type == QMetaType::QVariantList) {
QStringList *slst = static_cast<QStringList *>(result);
const QVariantList *list = v_cast<QVariantList >(d);
const int size = list->size();
slst->reserve(size);
for (int i = 0; i < size; ++i)
slst->append(list->at(i).toString());
- } else if (d->type == QVariant::String) {
+ } else if (d->type == QMetaType::QString) {
QStringList *slst = static_cast<QStringList *>(result);
*slst = QStringList(*v_cast<QString>(d));
} else {
return false;
}
break;
- case QVariant::Date: {
+ case QMetaType::QDate: {
QDate *dt = static_cast<QDate *>(result);
- if (d->type == QVariant::DateTime)
+ if (d->type == QMetaType::QDateTime)
*dt = v_cast<QDateTime>(d)->date();
#if QT_CONFIG(datestring)
- else if (d->type == QVariant::String)
+ else if (d->type == QMetaType::QString)
*dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);
#endif
else
@@ -629,14 +629,14 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return dt->isValid();
}
- case QVariant::Time: {
+ case QMetaType::QTime: {
QTime *t = static_cast<QTime *>(result);
switch (d->type) {
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
*t = v_cast<QDateTime>(d)->time();
break;
#if QT_CONFIG(datestring)
- case QVariant::String:
+ case QMetaType::QString:
*t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate);
break;
#endif
@@ -645,11 +645,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
return t->isValid();
}
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QDateTime *dt = static_cast<QDateTime *>(result);
switch (d->type) {
#if QT_CONFIG(datestring)
- case QVariant::String:
+ case QMetaType::QString:
*dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate);
break;
# ifndef QT_BOOTSTRAPPED
@@ -661,7 +661,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
# endif
#endif
- case QVariant::Date:
+ case QMetaType::QDate:
*dt = QDateTime(*v_cast<QDate>(d));
break;
default:
@@ -669,13 +669,13 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
return dt->isValid();
}
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
QByteArray *ba = static_cast<QByteArray *>(result);
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*ba = v_cast<QString>(d)->toUtf8();
break;
- case QVariant::Double:
+ case QMetaType::Double:
*ba = QByteArray::number(d->data.d, 'g', QLocale::FloatingPointShortest);
break;
case QMetaType::Float:
@@ -686,22 +686,22 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::UChar:
*ba = QByteArray(1, d->data.c);
break;
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
case QMetaType::Short:
case QMetaType::Long:
*ba = QByteArray::number(qMetaTypeNumber(d));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UShort:
case QMetaType::ULong:
*ba = QByteArray::number(qMetaTypeUNumber(d));
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*ba = QByteArray(d->data.b ? "true" : "false");
break;
- case QVariant::Uuid:
+ case QMetaType::QUuid:
*ba = v_cast<QUuid>(d)->toByteArray();
break;
case QMetaType::Nullptr:
@@ -741,16 +741,16 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::ULong:
*static_cast<ulong *>(result) = ulong(qConvertToUnsignedNumber(d, ok));
return *ok;
- case QVariant::Int:
+ case QMetaType::Int:
*static_cast<int *>(result) = int(qConvertToNumber(d, ok));
return *ok;
- case QVariant::UInt:
+ case QMetaType::UInt:
*static_cast<uint *>(result) = uint(qConvertToUnsignedNumber(d, ok));
return *ok;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
*static_cast<qlonglong *>(result) = qConvertToNumber(d, ok);
return *ok;
- case QVariant::ULongLong: {
+ case QMetaType::ULongLong: {
*static_cast<qulonglong *>(result) = qConvertToUnsignedNumber(d, ok);
return *ok;
}
@@ -763,21 +763,21 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*static_cast<uchar *>(result) = qConvertToUnsignedNumber(d, ok);
return *ok;
}
- case QVariant::Bool: {
+ case QMetaType::Bool: {
bool *b = static_cast<bool *>(result);
switch(d->type) {
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*b = qt_convertToBool<QByteArray, const char*>(d);
break;
- case QVariant::String:
+ case QMetaType::QString:
*b = qt_convertToBool<QString, QLatin1String>(d);
break;
- case QVariant::Char:
+ case QMetaType::QChar:
*b = !v_cast<QChar>(d)->isNull();
break;
- case QVariant::Double:
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Double:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
@@ -785,8 +785,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Float:
*b = qMetaTypeNumber(d) != Q_INT64_C(0);
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -810,31 +810,31 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
}
- case QVariant::Double: {
+ case QMetaType::Double: {
double *f = static_cast<double *>(result);
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*f = v_cast<QString>(d)->toDouble(ok);
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*f = v_cast<QByteArray>(d)->toDouble(ok);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*f = double(d->data.b);
break;
case QMetaType::Float:
*f = double(d->data.f);
break;
- case QVariant::LongLong:
- case QVariant::Int:
+ case QMetaType::LongLong:
+ case QMetaType::Int:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
case QMetaType::Long:
*f = double(qMetaTypeNumber(d));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -861,28 +861,28 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Float: {
float *f = static_cast<float *>(result);
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*f = v_cast<QString>(d)->toFloat(ok);
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*f = v_cast<QByteArray>(d)->toFloat(ok);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*f = float(d->data.b);
break;
- case QVariant::Double:
+ case QMetaType::Double:
*f = float(d->data.d);
break;
- case QVariant::LongLong:
- case QVariant::Int:
+ case QMetaType::LongLong:
+ case QMetaType::Int:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
case QMetaType::Long:
*f = float(qMetaTypeNumber(d));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -906,8 +906,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
}
- case QVariant::List:
- if (d->type == QVariant::StringList) {
+ case QMetaType::QVariantList:
+ if (d->type == QMetaType::QStringList) {
QVariantList *lst = static_cast<QVariantList *>(result);
const QStringList *slist = v_cast<QStringList>(d);
const int size = slist->size();
@@ -935,11 +935,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return false;
}
break;
- case QVariant::Map:
+ case QMetaType::QVariantMap:
if (qstrcmp(QMetaType::typeName(d->type), "QMap<QString, QVariant>") == 0) {
*static_cast<QVariantMap *>(result) =
*static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr);
- } else if (d->type == QVariant::Hash) {
+ } else if (d->type == QMetaType::QVariantHash) {
QVariantMap *map = static_cast<QVariantMap *>(result);
const QVariantHash *hash = v_cast<QVariantHash>(d);
const auto end = hash->end();
@@ -963,11 +963,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return false;
}
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
if (qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0) {
*static_cast<QVariantHash *>(result) =
*static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr);
- } else if (d->type == QVariant::Map) {
+ } else if (d->type == QMetaType::QVariantMap) {
QVariantHash *hash = static_cast<QVariantHash *>(result);
const QVariantMap *map = v_cast<QVariantMap>(d);
const auto end = map->end();
@@ -992,26 +992,26 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
#ifndef QT_NO_GEOM_VARIANT
- case QVariant::Rect:
- if (d->type == QVariant::RectF)
+ case QMetaType::QRect:
+ if (d->type == QMetaType::QRectF)
*static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect();
else
return false;
break;
- case QVariant::RectF:
- if (d->type == QVariant::Rect)
+ case QMetaType::QRectF:
+ if (d->type == QMetaType::QRect)
*static_cast<QRectF *>(result) = *v_cast<QRect>(d);
else
return false;
break;
- case QVariant::PointF:
- if (d->type == QVariant::Point)
+ case QMetaType::QPointF:
+ if (d->type == QMetaType::QPoint)
*static_cast<QPointF *>(result) = *v_cast<QPoint>(d);
else
return false;
break;
- case QVariant::Point:
- if (d->type == QVariant::PointF)
+ case QMetaType::QPoint:
+ if (d->type == QMetaType::QPointF)
*static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint();
else
return false;
@@ -1022,12 +1022,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return *ok;
}
#endif
- case QVariant::Uuid:
+ case QMetaType::QUuid:
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d));
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*static_cast<QUuid *>(result) = QUuid(*v_cast<QByteArray>(d));
break;
#ifndef QT_BOOTSTRAPPED
@@ -1067,7 +1067,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Nullptr:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonValue::Null);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*static_cast<QJsonValue *>(result) = QJsonValue(d->data.b);
break;
case QMetaType::Int:
@@ -1086,19 +1086,19 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*static_cast<QJsonValue *>(result) = QJsonValue(qConvertToRealNumber(d, ok));
Q_ASSERT(ok);
break;
- case QVariant::String:
+ case QMetaType::QString:
*static_cast<QJsonValue *>(result) = QJsonValue(*v_cast<QString>(d));
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonArray::fromStringList(*v_cast<QStringList>(d)));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonArray::fromVariantList(*v_cast<QVariantList>(d)));
break;
- case QVariant::Map:
+ case QMetaType::QVariantMap:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonObject::fromVariantMap(*v_cast<QVariantMap>(d)));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonObject::fromVariantHash(*v_cast<QVariantHash>(d)));
break;
case QMetaType::QJsonObject:
@@ -1128,10 +1128,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::QJsonArray:
switch (d->type) {
- case QVariant::StringList:
+ case QMetaType::QStringList:
*static_cast<QJsonArray *>(result) = QJsonArray::fromStringList(*v_cast<QStringList>(d));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
*static_cast<QJsonArray *>(result) = QJsonArray::fromVariantList(*v_cast<QVariantList>(d));
break;
case QMetaType::QJsonValue:
@@ -1158,10 +1158,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::QJsonObject:
switch (d->type) {
- case QVariant::Map:
+ case QMetaType::QVariantMap:
*static_cast<QJsonObject *>(result) = QJsonObject::fromVariantMap(*v_cast<QVariantMap>(d));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
*static_cast<QJsonObject *>(result) = QJsonObject::fromVariantHash(*v_cast<QVariantHash>(d));
break;
case QMetaType::QJsonValue:
@@ -1197,7 +1197,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Nullptr:
*static_cast<QCborValue *>(result) = QCborValue(QCborValue::Null);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*static_cast<QCborValue *>(result) = QCborValue(d->data.b);
break;
case QMetaType::Int:
@@ -1219,39 +1219,39 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*static_cast<QCborValue *>(result) = QCborValue(qConvertToRealNumber(d, ok));
Q_ASSERT(ok);
break;
- case QVariant::String:
+ case QMetaType::QString:
*static_cast<QCborValue *>(result) = *v_cast<QString>(d);
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
*static_cast<QCborValue *>(result) = QCborArray::fromStringList(*v_cast<QStringList>(d));
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*static_cast<QCborValue *>(result) = *v_cast<QByteArray>(d);
break;
- case QVariant::Date:
+ case QMetaType::QDate:
*static_cast<QCborValue *>(result) = QCborValue(QDateTime(*v_cast<QDate>(d)));
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
*static_cast<QCborValue *>(result) = QCborValue(*v_cast<QDateTime>(d));
break;
- case QVariant::Url:
+ case QMetaType::QUrl:
*static_cast<QCborValue *>(result) = QCborValue(*v_cast<QUrl>(d));
break;
#if QT_CONFIG(regularexpression)
- case QVariant::RegularExpression:
+ case QMetaType::QRegularExpression:
*static_cast<QCborValue *>(result) = QCborValue(*v_cast<QRegularExpression>(d));
break;
#endif
- case QVariant::Uuid:
+ case QMetaType::QUuid:
*static_cast<QCborValue *>(result) = QCborValue(*v_cast<QUuid>(d));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
*static_cast<QCborValue *>(result) = QCborArray::fromVariantList(*v_cast<QVariantList>(d));
break;
- case QVariant::Map:
+ case QMetaType::QVariantMap:
*static_cast<QCborValue *>(result) = QCborMap::fromVariantMap(*v_cast<QVariantMap>(d));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
*static_cast<QCborValue *>(result) = QCborMap::fromVariantHash(*v_cast<QVariantHash>(d));
break;
case QMetaType::QJsonValue:
@@ -1287,10 +1287,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::QCborArray:
switch (d->type) {
- case QVariant::StringList:
+ case QMetaType::QStringList:
*static_cast<QCborArray *>(result) = QCborArray::fromStringList(*v_cast<QStringList>(d));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
*static_cast<QCborArray *>(result) = QCborArray::fromVariantList(*v_cast<QVariantList>(d));
break;
case QMetaType::QCborValue:
@@ -1317,10 +1317,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::QCborMap:
switch (d->type) {
- case QVariant::Map:
+ case QMetaType::QVariantMap:
*static_cast<QCborMap *>(result) = QCborMap::fromVariantMap(*v_cast<QVariantMap>(d));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
*static_cast<QCborMap *>(result) = QCborMap::fromVariantHash(*v_cast<QVariantHash>(d));
break;
case QMetaType::QCborValue:
@@ -1349,10 +1349,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
default:
#ifndef QT_NO_QOBJECT
- if (d->type == QVariant::String || d->type == QVariant::ByteArray) {
+ if (d->type == QMetaType::QString || d->type == QMetaType::QByteArray) {
QMetaEnum en = metaEnumFromType(t);
if (en.isValid()) {
- QByteArray keys = (d->type == QVariant::String) ? v_cast<QString>(d)->toUtf8() : *v_cast<QByteArray>(d);
+ QByteArray keys = (d->type == QMetaType::QString) ? v_cast<QString>(d)->toUtf8() : *v_cast<QByteArray>(d);
int value = en.keysToValue(keys.constData(), ok);
if (*ok) {
switch (QMetaType::sizeOf(t)) {
@@ -1457,7 +1457,7 @@ static void customConstruct(QVariant::Private *d, const void *copy)
const uint size = type.sizeOf();
if (!size) {
qWarning("Trying to construct an instance of an invalid type, type id: %i", d->type);
- d->type = QVariant::Invalid;
+ d->type = QMetaType::UnknownType;
return;
}
@@ -2438,45 +2438,45 @@ QVariant::Type QVariant::nameToType(const char *name)
enum { MapFromThreeCount = 36 };
static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] =
{
- QVariant::Invalid,
- QVariant::Map,
- QVariant::List,
- QVariant::String,
- QVariant::StringList,
- QVariant::Font,
- QVariant::Pixmap,
- QVariant::Brush,
- QVariant::Rect,
- QVariant::Size,
- QVariant::Color,
- QVariant::Palette,
+ QMetaType::UnknownType,
+ QMetaType::QVariantMap,
+ QMetaType::QVariantList,
+ QMetaType::QString,
+ QMetaType::QStringList,
+ QMetaType::QFont,
+ QMetaType::QPixmap,
+ QMetaType::QBrush,
+ QMetaType::QRect,
+ QMetaType::QSize,
+ QMetaType::QColor,
+ QMetaType::QPalette,
0, // ColorGroup
- QVariant::Icon,
- QVariant::Point,
- QVariant::Image,
- QVariant::Int,
- QVariant::UInt,
- QVariant::Bool,
- QVariant::Double,
+ QMetaType::QIcon,
+ QMetaType::QPoint,
+ QMetaType::QImage,
+ QMetaType::Int,
+ QMetaType::UInt,
+ QMetaType::Bool,
+ QMetaType::Double,
0, // Buggy ByteArray, QByteArray never had id == 20
- QVariant::Polygon,
- QVariant::Region,
- QVariant::Bitmap,
- QVariant::Cursor,
- QVariant::SizePolicy,
- QVariant::Date,
- QVariant::Time,
- QVariant::DateTime,
- QVariant::ByteArray,
- QVariant::BitArray,
+ QMetaType::QPolygon,
+ QMetaType::QRegion,
+ QMetaType::QBitmap,
+ QMetaType::QCursor,
+ QMetaType::QSizePolicy,
+ QMetaType::QDate,
+ QMetaType::QTime,
+ QMetaType::QDateTime,
+ QMetaType::QByteArray,
+ QMetaType::QBitArray,
#if QT_CONFIG(shortcut)
- QVariant::KeySequence,
+ QMetaType::QKeySequence,
#endif
- QVariant::Pen,
- QVariant::LongLong,
- QVariant::ULongLong,
+ QMetaType::QPen,
+ QMetaType::LongLong,
+ QMetaType::ULongLong,
#if QT_CONFIG(easingcurve)
- QVariant::EasingCurve
+ QMetaType::QEasingCurve
#endif
};
@@ -2553,7 +2553,7 @@ void QVariant::load(QDataStream &s)
*/
void QVariant::save(QDataStream &s) const
{
- quint32 typeId = type();
+ quint32 typeId = d.type >= QMetaType::User ? QMetaType::User : userType();
bool fakeUserType = false;
if (s.version() < QDataStream::Qt_4_0) {
int i;
@@ -3300,80 +3300,80 @@ QVariantList QVariant::toList() const
}
-static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
+static const quint32 qCanConvertMatrix[QMetaType::LastCoreType + 1] =
{
/*Invalid*/ 0,
-/*Bool*/ 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt
- | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray
- | 1 << QVariant::String | 1 << QVariant::Char,
+/*Bool*/ 1 << QMetaType::Double | 1 << QMetaType::Int | 1 << QMetaType::UInt
+ | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong | 1 << QMetaType::QByteArray
+ | 1 << QMetaType::QString | 1 << QMetaType::QChar,
-/*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double
- | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong
- | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int,
+/*Int*/ 1 << QMetaType::UInt | 1 << QMetaType::QString | 1 << QMetaType::Double
+ | 1 << QMetaType::Bool | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray | 1 << QMetaType::Int,
-/*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double
- | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong
- | 1 << QVariant::Char | 1 << QVariant::ByteArray,
+/*UInt*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double
+ | 1 << QMetaType::Bool | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray,
-/*LLong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double
- | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong
- | 1 << QVariant::Char | 1 << QVariant::ByteArray,
+/*LLong*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double
+ | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray,
-/*ULlong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double
- | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong
- | 1 << QVariant::Char | 1 << QVariant::ByteArray,
+/*ULlong*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double
+ | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::LongLong
+ | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray,
-/*double*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong
- | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong
- | 1 << QVariant::ByteArray,
+/*double*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::LongLong
+ | 1 << QMetaType::QByteArray,
-/*QChar*/ 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong
- | 1 << QVariant::ULongLong,
+/*QChar*/ 1 << QMetaType::Int | 1 << QMetaType::UInt | 1 << QMetaType::LongLong
+ | 1 << QMetaType::ULongLong,
/*QMap*/ 0,
-/*QList*/ 1 << QVariant::StringList,
+/*QList*/ 1 << QMetaType::QStringList,
-/*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int
- | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double
- | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime
- | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char
- | 1 << QVariant::Url | 1 << QVariant::Uuid,
+/*QString*/ 1 << QMetaType::QStringList | 1 << QMetaType::QByteArray | 1 << QMetaType::Int
+ | 1 << QMetaType::UInt | 1 << QMetaType::Bool | 1 << QMetaType::Double
+ | 1 << QMetaType::QDate | 1 << QMetaType::QTime | 1 << QMetaType::QDateTime
+ | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong | 1 << QMetaType::QChar
+ | 1 << QMetaType::QUrl | 1 << QMetaType::QUuid,
-/*QStringList*/ 1 << QVariant::List | 1 << QVariant::String,
+/*QStringList*/ 1 << QMetaType::QVariantList | 1 << QMetaType::QString,
-/*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool
- | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong
- | 1 << QVariant::Uuid,
+/*QByteArray*/ 1 << QMetaType::QString | 1 << QMetaType::Int | 1 << QMetaType::UInt | 1 << QMetaType::Bool
+ | 1 << QMetaType::Double | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::QUuid,
/*QBitArray*/ 0,
-/*QDate*/ 1 << QVariant::String | 1 << QVariant::DateTime,
+/*QDate*/ 1 << QMetaType::QString | 1 << QMetaType::QDateTime,
-/*QTime*/ 1 << QVariant::String | 1 << QVariant::DateTime,
+/*QTime*/ 1 << QMetaType::QString | 1 << QMetaType::QDateTime,
-/*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date,
+/*QDateTime*/ 1 << QMetaType::QString | 1 << QMetaType::QDate,
-/*QUrl*/ 1 << QVariant::String,
+/*QUrl*/ 1 << QMetaType::QString,
/*QLocale*/ 0,
-/*QRect*/ 1 << QVariant::RectF,
+/*QRect*/ 1 << QMetaType::QRectF,
-/*QRectF*/ 1 << QVariant::Rect,
+/*QRectF*/ 1 << QMetaType::QRect,
-/*QSize*/ 1 << QVariant::SizeF,
+/*QSize*/ 1 << QMetaType::QSizeF,
-/*QSizeF*/ 1 << QVariant::Size,
+/*QSizeF*/ 1 << QMetaType::QSize,
-/*QLine*/ 1 << QVariant::LineF,
+/*QLine*/ 1 << QMetaType::QLineF,
-/*QLineF*/ 1 << QVariant::Line,
+/*QLineF*/ 1 << QMetaType::QLine,
-/*QPoint*/ 1 << QVariant::PointF,
+/*QPoint*/ 1 << QMetaType::QPointF,
-/*QPointF*/ 1 << QVariant::Point,
+/*QPointF*/ 1 << QMetaType::QPoint,
/*QRegExp*/ 0,
@@ -3381,7 +3381,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*QEasingCurve*/ 0,
-/*QUuid*/ 1 << QVariant::String | 1 << QVariant::ByteArray,
+/*QUuid*/ 1 << QMetaType::QString | 1 << QMetaType::QByteArray,
};
static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix);
@@ -3862,7 +3862,7 @@ static bool qIsNumericType(uint tp)
static bool qIsFloatingPoint(uint tp)
{
- return tp == QVariant::Double || tp == QMetaType::Float;
+ return tp == QMetaType::Double || tp == QMetaType::Float;
}
static int normalizeLowerRanks(uint tp)
@@ -3874,13 +3874,13 @@ static int normalizeLowerRanks(uint tp)
Q_UINT64_C(1) << QMetaType::UChar |
Q_UINT64_C(1) << QMetaType::Short |
Q_UINT64_C(1) << QMetaType::UShort;
- return numericTypeBits & (Q_UINT64_C(1) << tp) ? QVariant::Int : tp;
+ return numericTypeBits & (Q_UINT64_C(1) << tp) ? uint(QMetaType::Int) : tp;
}
static int normalizeLong(uint tp)
{
- const uint IntType = sizeof(long) == sizeof(int) ? QVariant::Int : QVariant::LongLong;
- const uint UIntType = sizeof(ulong) == sizeof(uint) ? QVariant::UInt : QVariant::ULongLong;
+ const uint IntType = sizeof(long) == sizeof(int) ? QMetaType::Int : QMetaType::LongLong;
+ const uint UIntType = sizeof(ulong) == sizeof(uint) ? QMetaType::UInt : QMetaType::ULongLong;
return tp == QMetaType::Long ? IntType :
tp == QMetaType::ULong ? UIntType : tp;
}
@@ -3922,13 +3922,13 @@ static int numericTypePromotion(uint t1, uint t2)
// if any of the two is ULongLong, then it wins (highest rank, unsigned)
// otherwise, if one of the two is LongLong, then the other is either LongLong too or lower-ranked
// otherwise, if one of the two is UInt, then the other is either UInt too or Int
- if (t1 == QVariant::ULongLong || t2 == QVariant::ULongLong)
- return QVariant::ULongLong;
- if (t1 == QVariant::LongLong || t2 == QVariant::LongLong)
- return QVariant::LongLong;
- if (t1 == QVariant::UInt || t2 == QVariant::UInt)
- return QVariant::UInt;
- return QVariant::Int;
+ if (t1 == QMetaType::ULongLong || t2 == QMetaType::ULongLong)
+ return QMetaType::ULongLong;
+ if (t1 == QMetaType::LongLong || t2 == QMetaType::LongLong)
+ return QMetaType::LongLong;
+ if (t1 == QMetaType::UInt || t2 == QMetaType::UInt)
+ return QMetaType::UInt;
+ return QMetaType::Int;
}
static int integralCompare(uint promotedType, const QVariant::Private *d1, const QVariant::Private *d2)
@@ -3941,13 +3941,13 @@ static int integralCompare(uint promotedType, const QVariant::Private *d1, const
qlonglong l2 = qConvertToNumber(d2, &ok);
Q_ASSERT(ok);
- if (promotedType == QVariant::Int)
+ if (promotedType == QMetaType::Int)
return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1;
- if (promotedType == QVariant::UInt)
+ if (promotedType == QMetaType::UInt)
return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1;
- if (promotedType == QVariant::LongLong)
+ if (promotedType == QMetaType::LongLong)
return l1 < l2 ? -1 : l1 == l2 ? 0 : 1;
- if (promotedType == QVariant::ULongLong)
+ if (promotedType == QMetaType::ULongLong)
return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1;
Q_UNREACHABLE();
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index b8b63b5e6fd..94781a9957e 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -362,7 +362,7 @@ class QVariantConstructor
FilteredConstructor(const QVariantConstructor &tc)
{
// ignore types that lives outside of the current library
- tc.m_x->type = QVariant::Invalid;
+ tc.m_x->type = QMetaType::UnknownType;
}
};
public:
@@ -430,7 +430,7 @@ public:
{}
~QVariantDestructor()
{
- m_d->type = QVariant::Invalid;
+ m_d->type = QMetaType::UnknownType;
m_d->is_null = true;
m_d->is_shared = false;
}
diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp
index fbea84fe735..000008db50a 100644
--- a/src/corelib/serialization/qjsoncbor.cpp
+++ b/src/corelib/serialization/qjsoncbor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Intel Corporation.
+** Copyright (C) 2020 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -637,9 +637,9 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant)
// Handle strings and byte arrays directly, to avoid creating a temporary
// dummy container to hold their data.
int type = variant.userType();
- if (type == QVariant::String) {
+ if (type == QMetaType::QString) {
d->append(variant.toString());
- } else if (type == QVariant::ByteArray) {
+ } else if (type == QMetaType::QByteArray) {
QByteArray ba = variant.toByteArray();
d->appendByteData(ba.constData(), ba.size(), QCborValue::ByteArray);
} else {
@@ -698,48 +698,48 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant)
QCborValue QCborValue::fromVariant(const QVariant &variant)
{
switch (variant.userType()) {
- case QVariant::Invalid:
+ case QMetaType::UnknownType:
return {};
case QMetaType::Nullptr:
return nullptr;
- case QVariant::Bool:
+ case QMetaType::Bool:
return variant.toBool();
case QMetaType::Short:
case QMetaType::UShort:
- case QVariant::Int:
- case QVariant::LongLong:
- case QVariant::UInt:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
+ case QMetaType::UInt:
return variant.toLongLong();
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
if (variant.toULongLong() <= static_cast<uint64_t>(std::numeric_limits<qint64>::max()))
return variant.toLongLong();
Q_FALLTHROUGH();
case QMetaType::Float:
- case QVariant::Double:
+ case QMetaType::Double:
return variant.toDouble();
- case QVariant::String:
+ case QMetaType::QString:
return variant.toString();
- case QVariant::StringList:
+ case QMetaType::QStringList:
return QCborArray::fromStringList(variant.toStringList());
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
return variant.toByteArray();
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return QCborValue(variant.toDateTime());
#ifndef QT_BOOTSTRAPPED
- case QVariant::Url:
+ case QMetaType::QUrl:
return QCborValue(variant.toUrl());
#endif
- case QVariant::Uuid:
+ case QMetaType::QUuid:
return QCborValue(variant.toUuid());
- case QVariant::List:
+ case QMetaType::QVariantList:
return QCborArray::fromVariantList(variant.toList());
- case QVariant::Map:
+ case QMetaType::QVariantMap:
return QCborMap::fromVariantMap(variant.toMap());
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
return QCborMap::fromVariantHash(variant.toHash());
#ifndef QT_BOOTSTRAPPED
#if QT_CONFIG(regularexpression)
- case QVariant::RegularExpression:
+ case QMetaType::QRegularExpression:
return QCborValue(variant.toRegularExpression());
#endif
case QMetaType::QJsonValue:
diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp
index fe0500bdef1..0be0fc020d3 100644
--- a/src/corelib/serialization/qjsondocument.cpp
+++ b/src/corelib/serialization/qjsondocument.cpp
@@ -405,17 +405,17 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
{
QJsonDocument doc;
- switch (variant.type()) {
- case QVariant::Map:
+ switch (variant.userType()) {
+ case QMetaType::QVariantMap:
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
doc.d = qt_make_unique<QJsonDocumentPrivate>();
doc.d->value = QCborArray::fromStringList(variant.toStringList());
break;
diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp
index 4a7fab21d77..e9ba176d7f9 100644
--- a/src/corelib/serialization/qjsonvalue.cpp
+++ b/src/corelib/serialization/qjsonvalue.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -449,35 +449,35 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant)
switch (variant.userType()) {
case QMetaType::Nullptr:
return QJsonValue(Null);
- case QVariant::Bool:
+ case QMetaType::Bool:
return QJsonValue(variant.toBool());
case QMetaType::Short:
case QMetaType::UShort:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ case QMetaType::LongLong:
return QJsonValue(variant.toLongLong());
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
if (variant.toULongLong() <= static_cast<uint64_t>(std::numeric_limits<qint64>::max()))
return QJsonValue(variant.toLongLong());
Q_FALLTHROUGH();
case QMetaType::Float:
- case QVariant::Double:
+ case QMetaType::Double:
return QJsonValue(variant.toDouble());
- case QVariant::String:
+ case QMetaType::QString:
return QJsonValue(variant.toString());
- case QVariant::StringList:
+ case QMetaType::QStringList:
return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));
- case QVariant::List:
+ case QMetaType::QVariantList:
return QJsonValue(QJsonArray::fromVariantList(variant.toList()));
- case QVariant::Map:
+ case QMetaType::QVariantMap:
return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
return QJsonValue(QJsonObject::fromVariantHash(variant.toHash()));
#ifndef QT_BOOTSTRAPPED
- case QVariant::Url:
+ case QMetaType::QUrl:
return QJsonValue(variant.toUrl().toString(QUrl::FullyEncoded));
- case QVariant::Uuid:
+ case QMetaType::QUuid:
return variant.toUuid().toString(QUuid::WithoutBraces);
case QMetaType::QJsonValue:
return variant.toJsonValue();
diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp
index 4d92b1e0dad..b8137e0abd4 100644
--- a/src/corelib/serialization/qtextstream.cpp
+++ b/src/corelib/serialization/qtextstream.cpp
@@ -1681,7 +1681,7 @@ QString QTextStream::readLine(qint64 maxlen)
\since 5.5
Reads one line of text from the stream into \a line.
- If \a line is 0, the read line is not stored.
+ If \a line is \nullptr, the read line is not stored.
The maximum allowed line length is set to \a maxlen. If
the stream contains lines longer than this, then the lines will be
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 93a8abb1ce4..fb45b829677 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -2430,7 +2430,7 @@ QTime QLocale::toTime(const QString &string, const QString &format, QCalendar ca
{
QTime time;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this);
if (dt.parseFormat(format))
dt.fromString(string, nullptr, &time);
@@ -2469,7 +2469,7 @@ QDate QLocale::toDate(const QString &string, const QString &format, QCalendar ca
{
QDate date;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this);
if (dt.parseFormat(format))
dt.fromString(string, &date, nullptr);
@@ -2510,7 +2510,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCal
QTime time;
QDate date;
- QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this);
if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time);
diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp
index 5e1e47eae76..207331b8ac5 100644
--- a/src/corelib/text/qlocale_unix.cpp
+++ b/src/corelib/text/qlocale_unix.cpp
@@ -234,16 +234,16 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
case CurrencySymbol:
return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
case CurrencyToString: {
- switch (in.type()) {
- case QVariant::Int:
+ switch (in.userType()) {
+ case QMetaType::Int:
return lc_monetary.toCurrencyString(in.toInt());
- case QVariant::UInt:
+ case QMetaType::UInt:
return lc_monetary.toCurrencyString(in.toUInt());
- case QVariant::Double:
+ case QMetaType::Double:
return lc_monetary.toCurrencyString(in.toDouble());
- case QVariant::LongLong:
+ case QMetaType::LongLong:
return lc_monetary.toCurrencyString(in.toLongLong());
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return lc_monetary.toCurrencyString(in.toULongLong());
default:
break;
diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp
index 4bbe424ed23..4b9dcee169f 100644
--- a/src/corelib/text/qstringlist.cpp
+++ b/src/corelib/text/qstringlist.cpp
@@ -43,9 +43,9 @@
#if QT_CONFIG(regularexpression)
# include <qregularexpression.h>
#endif
+#include <private/qduplicatetracker_p.h>
#include <algorithm>
-
QT_BEGIN_NAMESPACE
/*! \typedef QStringListIterator
@@ -885,15 +885,13 @@ int QtPrivate::QStringList_removeDuplicates(QStringList *that)
{
int n = that->size();
int j = 0;
- QSet<QString> seen;
+
+ QDuplicateTracker<QString> seen;
seen.reserve(n);
- int setSize = 0;
for (int i = 0; i < n; ++i) {
const QString &s = that->at(i);
- seen.insert(s);
- if (setSize == seen.size()) // unchanged size => was already seen
+ if (seen.hasSeen(s))
continue;
- ++setSize;
if (j != i)
that->swapItemsAt(i, j);
++j;
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index f3883278e37..0508932d68c 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -487,7 +487,7 @@ QRecursiveMutex::~QRecursiveMutex()
\fn QMutexLocker::QMutexLocker(QMutex *mutex)
Constructs a QMutexLocker and locks \a mutex. The mutex will be
- unlocked when the QMutexLocker is destroyed. If \a mutex is zero,
+ unlocked when the QMutexLocker is destroyed. If \a mutex is \nullptr,
QMutexLocker does nothing.
\sa QMutex::lock()
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 1437768f1ca..155bff1758d 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -614,7 +614,7 @@ void QThread::run()
priority.
The \a priority argument can be any value in the \c
- QThread::Priority enum except for \c InheritPriorty.
+ QThread::Priority enum except for \c InheritPriority.
The effect of the \a priority parameter is dependent on the
operating system's scheduling policy. In particular, the \a priority
@@ -626,6 +626,10 @@ void QThread::run()
*/
void QThread::setPriority(Priority priority)
{
+ if (priority == QThread::InheritPriority) {
+ qWarning("QThread::setPriority: Argument cannot be InheritPriority");
+ return;
+ }
Q_D(QThread);
QMutexLocker locker(&d->mutex);
if (!d->running) {
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 44cb5653bf9..00d67b3a00b 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -715,9 +715,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
prio = THREAD_PRIORITY_TIME_CRITICAL;
break;
- case QThread::InheritPriority:
default:
- qWarning("QThread::setPriority: Argument cannot be InheritPriority");
return;
}
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 67d37f19d8e..80751e60a01 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -1791,7 +1791,7 @@ QDate QDate::fromString(const QString &string, const QString &format, QCalendar
{
QDate date;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format))
dt.fromString(string, &date, nullptr);
@@ -2537,7 +2537,7 @@ QTime QTime::fromString(const QString &string, const QString &format)
{
QTime time;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, QCalendar());
+ QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, QCalendar());
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format))
dt.fromString(string, nullptr, &time);
@@ -5482,7 +5482,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format, QC
QTime time;
QDate date;
- QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time);
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp
index 31d8e6cc200..70460ae6322 100644
--- a/src/corelib/time/qdatetimeparser.cpp
+++ b/src/corelib/time/qdatetimeparser.cpp
@@ -425,7 +425,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
switch (sect) {
case 'H':
case 'h':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const Section hour = (sect == 'h') ? Hour12Section : Hour24Section;
const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
@@ -436,7 +436,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'm':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -446,7 +446,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 's':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -457,7 +457,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
break;
case 'z':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -468,7 +468,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
break;
case 'A':
case 'a':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const bool cap = (sect == 'A');
const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 };
newSectionNodes.append(sn);
@@ -482,7 +482,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'y':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const int repeat = countRepeat(newFormat, i, 4);
if (repeat >= 2) {
const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
@@ -496,7 +496,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'M':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn);
newSeparators.append(unquote(newFormat.midRef(index, i - index)));
@@ -506,7 +506,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'd':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const int repeat = countRepeat(newFormat, i, 4);
const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong
: (repeat == 3 ? DayOfWeekSectionShort : DaySection));
@@ -519,7 +519,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 't':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -1252,7 +1252,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
return StateNode();
}
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
if (year % 100 != year2digits && (isSet & YearSection2Digits)) {
if (!(isSet & YearSection)) {
year = (year / 100) * 100;
@@ -1322,7 +1322,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
}
}
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
if (isSet & Hour12Section) {
const bool hasHour = isSet & Hour24Section;
if (ampm == -1) {
@@ -1360,7 +1360,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
// If hour wasn't specified, check the default we're using exists on the
// given date (which might be a spring-forward, skipping an hour).
- if (parserType == QVariant::DateTime && !(isSet & HourSectionMask) && !when.isValid()) {
+ if (parserType == QMetaType::QDateTime && !(isSet & HourSectionMask) && !when.isValid()) {
qint64 msecs = when.toMSecsSinceEpoch();
// Fortunately, that gets a useful answer, even though when is invalid ...
const QDateTime replace =
diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h
index ff8da956f06..bc390db2232 100644
--- a/src/corelib/time/qdatetimeparser_p.h
+++ b/src/corelib/time/qdatetimeparser_p.h
@@ -82,7 +82,7 @@ public:
FromString,
DateTimeEdit
};
- QDateTimeParser(QVariant::Type t, Context ctx, const QCalendar &cal = QCalendar())
+ QDateTimeParser(QMetaType::Type t, Context ctx, const QCalendar &cal = QCalendar())
: currentSectionIndex(-1), cachedDay(-1), parserType(t),
fixday(false), spec(Qt::LocalTime), context(ctx), calendar(cal)
{
@@ -295,7 +295,7 @@ protected: // for the benefit of QDateTimeEditPrivate
QStringList separators;
QString displayFormat;
QLocale defaultLocale;
- QVariant::Type parserType;
+ QMetaType::Type parserType;
bool fixday;
Qt::TimeSpec spec; // spec if used by QDateTimeEdit
Context context;
diff --git a/src/corelib/tools/qduplicatetracker_p.h b/src/corelib/tools/qduplicatetracker_p.h
new file mode 100644
index 00000000000..99068c01a33
--- /dev/null
+++ b/src/corelib/tools/qduplicatetracker_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected], author Marc Mutz <[email protected]>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QDUPLICATETRACKER_P_H
+#define QDUPLICATETRACKER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qglobal.h>
+
+#if QT_HAS_INCLUDE(<memory_resource>) && __cplusplus > 201402L
+# include <unordered_set>
+# include <memory_resource>
+#else
+# include <qset.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+template <typename T, size_t Prealloc = 32>
+class QDuplicateTracker {
+#ifdef __cpp_lib_memory_resource
+ char buffer[Prealloc * sizeof(T)];
+ std::pmr::monotonic_buffer_resource res{buffer, sizeof buffer};
+ std::pmr::unordered_set<T> set{&res};
+#else
+ QSet<T> set;
+ int setSize = 0;
+#endif
+ Q_DISABLE_COPY_MOVE(QDuplicateTracker);
+public:
+ QDuplicateTracker() = default;
+ void reserve(int n) { set.reserve(n); }
+ Q_REQUIRED_RESULT bool hasSeen(const T &s)
+ {
+ bool inserted;
+#ifdef __cpp_lib_memory_resource
+ inserted = set.insert(s).second;
+#else
+ set.insert(s);
+ const int n = set.size();
+ inserted = qExchange(setSize, n) != n;
+#endif
+ return !inserted;
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif /* QDUPLICATETRACKER_P_H */
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index d747a8cda40..e2b7705b557 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -2128,4 +2128,11 @@ void QMapDataBase::freeData(QMapDataBase *d)
once in the returned list.
*/
+/*! \fn template <class Key, class T> QMultiMap<Key, T> &QMultiMap<Key, T>::unite(const QMultiMap<Key, T> &other)
+
+ Inserts all the items in the \a other map into this map. If a
+ key is common to both maps, the resulting map will contain the
+ key multiple times.
+*/
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 230456bef96..ff300bcf7b7 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -12,6 +12,7 @@ HEADERS += \
tools/qcontainerfwd.h \
tools/qcontainertools_impl.h \
tools/qcryptographichash.h \
+ tools/qduplicatetracker_p.h \
tools/qflatmap_p.h \
tools/qfreelist_p.h \
tools/qhash.h \
diff --git a/src/dbus/Qt5DBusConfigExtras.cmake.in b/src/dbus/Qt5DBusConfigExtras.cmake.in
index 1d947159e2e..a814678f7b5 100644
--- a/src/dbus/Qt5DBusConfigExtras.cmake.in
+++ b/src/dbus/Qt5DBusConfigExtras.cmake.in
@@ -31,3 +31,14 @@ endif()
set(Qt5DBus_QDBUSCPP2XML_EXECUTABLE Qt5::qdbuscpp2xml)
set(Qt5DBus_QDBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp)
+
+# Create versionless tool targets.
+foreach(__qt_tool qdbuscpp2xml qdbusxml2cpp)
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::${__qt_tool}
+ AND TARGET Qt5::${__qt_tool})
+ add_executable(Qt::${__qt_tool} IMPORTED)
+ get_target_property(__qt_imported_location Qt5::${__qt_tool} IMPORTED_LOCATION)
+ set_target_properties(Qt::${__qt_tool}
+ PROPERTIES IMPORTED_LOCATION \"${__qt_imported_location}\")
+ endif()
+endforeach()
diff --git a/src/dbus/Qt5DBusMacros.cmake b/src/dbus/Qt5DBusMacros.cmake
index 9b69e77dc75..1cacccdddd3 100644
--- a/src/dbus/Qt5DBusMacros.cmake
+++ b/src/dbus/Qt5DBusMacros.cmake
@@ -70,6 +70,17 @@ function(qt5_add_dbus_interface _sources _interface _basename)
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_dbus_interface sources)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_dbus_interface("${sources}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_dbus_interface("${sources}" ${ARGN})
+ endif()
+ set("${sources}" "${${sources}}" PARENT_SCOPE)
+ endfunction()
+endif()
+
function(qt5_add_dbus_interfaces _sources)
foreach(_current_FILE ${ARGN})
@@ -83,6 +94,17 @@ function(qt5_add_dbus_interfaces _sources)
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_dbus_interfaces sources)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_dbus_interfaces("${sources}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_dbus_interfaces("${sources}" ${ARGN})
+ endif()
+ set("${sources}" "${${sources}}" PARENT_SCOPE)
+ endfunction()
+endif()
+
function(qt5_generate_dbus_interface _header) # _customName OPTIONS -some -options )
set(options)
@@ -116,6 +138,16 @@ function(qt5_generate_dbus_interface _header) # _customName OPTIONS -some -optio
)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_generate_dbus_interface)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_generate_dbus_interface(${ARGV})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_generate_dbus_interface(${ARGV})
+ endif()
+ endfunction()
+endif()
+
function(qt5_add_dbus_adaptor _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
get_filename_component(_infile ${_xml_file} ABSOLUTE)
@@ -152,3 +184,14 @@ function(qt5_add_dbus_adaptor _sources _xml_file _include _parentClass) # _optio
list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()
+
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_dbus_adaptor sources)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_dbus_adaptor("${sources}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_dbus_adaptor("${sources}" ${ARGN})
+ endif()
+ set("${sources}" "${${sources}}" PARENT_SCOPE)
+ endfunction()
+endif()
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp
index 8a11767140c..d603264a1e2 100644
--- a/src/dbus/qdbusabstractinterface.cpp
+++ b/src/dbus/qdbusabstractinterface.cpp
@@ -157,7 +157,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
const int type = mp.userType();
// is this metatype registered?
const char *expectedSignature = "";
- if (int(mp.type()) != QMetaType::QVariant) {
+ if (int(mp.userType()) != QMetaType::QVariant) {
expectedSignature = QDBusMetaType::typeToSignature(type);
if (expectedSignature == nullptr) {
qWarning("QDBusAbstractInterface: type %s must be registered with Qt D-Bus before it can be "
diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h
index 477bd1e8fd2..339f8c5dc8e 100644
--- a/src/dbus/qdbusargument.h
+++ b/src/dbus/qdbusargument.h
@@ -330,7 +330,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, QMap<Key, T> &m
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
{
- arg.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>());
+ arg.beginMap(QMetaType::QString, qMetaTypeId<QDBusVariant>());
QVariantMap::ConstIterator it = map.constBegin();
QVariantMap::ConstIterator end = map.constEnd();
for ( ; it != end; ++it) {
@@ -379,7 +379,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, QHash<Key, T> &
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
{
- arg.beginMap(QVariant::String, qMetaTypeId<QDBusVariant>());
+ arg.beginMap(QMetaType::QString, qMetaTypeId<QDBusVariant>());
QVariantHash::ConstIterator it = map.constBegin();
QVariantHash::ConstIterator end = map.constEnd();
for ( ; it != end; ++it) {
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index bca02be59e1..669b330f1db 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -1822,7 +1822,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
hook.service = QDBusUtil::dbusService();
hook.path.clear(); // no matching
hook.obj = this;
- hook.params << QMetaType::Void << QVariant::String; // both functions take a QString as parameter and return void
+ hook.params << QMetaType::Void << QMetaType::QString; // both functions take a QString as parameter and return void
hook.midx = staticMetaObject.indexOfSlot("registerServiceNoLock(QString)");
Q_ASSERT(hook.midx != -1);
@@ -1836,7 +1836,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
// we don't use connectSignal here because the rules are added by connectSignal on a per-need basis
hook.params.clear();
hook.params.reserve(4);
- hook.params << QMetaType::Void << QVariant::String << QVariant::String << QVariant::String;
+ hook.params << QMetaType::Void << QMetaType::QString << QMetaType::QString << QMetaType::QString;
hook.midx = staticMetaObject.indexOfSlot("serviceOwnerChangedNoLock(QString,QString,QString)");
Q_ASSERT(hook.midx != -1);
signalHooks.insert(QLatin1String("NameOwnerChanged:" DBUS_INTERFACE_DBUS), hook);
diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp
index fb958a89544..c1b0feea378 100644
--- a/src/dbus/qdbusinterface.cpp
+++ b/src/dbus/qdbusinterface.cpp
@@ -55,7 +55,7 @@ static void copyArgument(void *to, int id, const QVariant &arg)
{
if (id == arg.userType()) {
switch (id) {
- case QVariant::Bool:
+ case QMetaType::Bool:
*reinterpret_cast<bool *>(to) = arg.toBool();
return;
@@ -71,35 +71,35 @@ static void copyArgument(void *to, int id, const QVariant &arg)
*reinterpret_cast<ushort *>(to) = qvariant_cast<ushort>(arg);
return;
- case QVariant::Int:
+ case QMetaType::Int:
*reinterpret_cast<int *>(to) = arg.toInt();
return;
- case QVariant::UInt:
+ case QMetaType::UInt:
*reinterpret_cast<uint *>(to) = arg.toUInt();
return;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
*reinterpret_cast<qlonglong *>(to) = arg.toLongLong();
return;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
*reinterpret_cast<qulonglong *>(to) = arg.toULongLong();
return;
- case QVariant::Double:
+ case QMetaType::Double:
*reinterpret_cast<double *>(to) = arg.toDouble();
return;
- case QVariant::String:
+ case QMetaType::QString:
*reinterpret_cast<QString *>(to) = arg.toString();
return;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*reinterpret_cast<QByteArray *>(to) = arg.toByteArray();
return;
- case QVariant::StringList:
+ case QMetaType::QStringList:
*reinterpret_cast<QStringList *>(to) = arg.toStringList();
return;
}
diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp
index 46b41d1c07f..c80131f41df 100644
--- a/src/dbus/qdbusmarshaller.cpp
+++ b/src/dbus/qdbusmarshaller.cpp
@@ -190,7 +190,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
const QVariant &value = arg.variant();
int id = value.userType();
- if (id == QVariant::Invalid) {
+ if (id == QMetaType::UnknownType) {
qWarning("QDBusMarshaller: cannot add a null QDBusVariant");
error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
return false;
@@ -384,7 +384,7 @@ void QDBusMarshaller::error(const QString &msg)
bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
{
int id = arg.userType();
- if (id == QVariant::Invalid) {
+ if (id == QMetaType::UnknownType) {
qWarning("QDBusMarshaller: cannot add an invalid QVariant");
error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
return false;
@@ -485,12 +485,12 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
case DBUS_TYPE_ARRAY:
// could be many things
// find out what kind of array it is
- switch (arg.type()) {
- case QVariant::StringList:
+ switch (arg.userType()) {
+ case QMetaType::QStringList:
append( arg.toStringList() );
return true;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
append( arg.toByteArray() );
return true;
diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp
index 71cdec93caa..10d2f07d4d2 100644
--- a/src/dbus/qdbusmessage.cpp
+++ b/src/dbus/qdbusmessage.cpp
@@ -276,7 +276,7 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn,
for ( ; it != end; ++it) {
int id = it->userType();
const char *signature = QDBusMetaType::typeToSignature(id);
- if ((id != QVariant::StringList && id != QVariant::ByteArray &&
+ if ((id != QMetaType::QStringList && id != QMetaType::QByteArray &&
qstrlen(signature) != 1) || id == qMetaTypeId<QDBusVariant>()) {
// yes, we are
// we must marshall and demarshall again so as to create QDBusArgument
diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp
index b549e240660..dabd417a321 100644
--- a/src/dbus/qdbusmetaobject.cpp
+++ b/src/dbus/qdbusmetaobject.cpp
@@ -158,10 +158,10 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
const char *direction, int id)
{
Type result;
- result.id = QVariant::Invalid;
+ result.id = QMetaType::UnknownType;
int type = QDBusMetaType::signatureToType(signature);
- if (type == QVariant::Invalid && !qt_dbus_metaobject_skip_annotations) {
+ if (type == QMetaType::UnknownType && !qt_dbus_metaobject_skip_annotations) {
// it's not a type normally handled by our meta type system
// it must contain an annotation
QString annotationName = QString::fromLatin1("org.qtproject.QtDBus.QtTypeName");
@@ -189,7 +189,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
type = QMetaType::type(typeName);
}
- if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type)) {
+ if (type == QMetaType::UnknownType || signature != QDBusMetaType::typeToSignature(type)) {
// type is still unknown or doesn't match back to the signature that it
// was expected to, so synthesize a fake type
typeName = "QDBusRawType<0x" + signature.toHex() + ">*";
@@ -197,16 +197,16 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
}
result.name = typeName;
- } else if (type == QVariant::Invalid) {
+ } else if (type == QMetaType::UnknownType) {
// this case is used only by the qdbus command-line tool
// invalid, let's create an impossible type that contains the signature
if (signature == "av") {
result.name = "QVariantList";
- type = QVariant::List;
+ type = QMetaType::QVariantList;
} else if (signature == "a{sv}") {
result.name = "QVariantMap";
- type = QVariant::Map;
+ type = QMetaType::QVariantMap;
} else if (signature == "a{ss}") {
result.name = "QMap<QString,QString>";
type = qMetaTypeId<QMap<QString, QString> >();
@@ -246,7 +246,7 @@ void QDBusMetaObjectGenerator::parseMethods()
const QDBusIntrospection::Argument &arg = m.inputArgs.at(i);
Type type = findType(arg.type.toLatin1(), m.annotations, "In", i);
- if (type.id == QVariant::Invalid) {
+ if (type.id == QMetaType::UnknownType) {
ok = false;
break;
}
@@ -265,7 +265,7 @@ void QDBusMetaObjectGenerator::parseMethods()
const QDBusIntrospection::Argument &arg = m.outputArgs.at(i);
Type type = findType(arg.type.toLatin1(), m.annotations, "Out", i);
- if (type.id == QVariant::Invalid) {
+ if (type.id == QMetaType::UnknownType) {
ok = false;
break;
}
@@ -322,7 +322,7 @@ void QDBusMetaObjectGenerator::parseSignals()
const QDBusIntrospection::Argument &arg = s.outputArgs.at(i);
Type type = findType(arg.type.toLatin1(), s.annotations, "Out", i);
- if (type.id == QVariant::Invalid) {
+ if (type.id == QMetaType::UnknownType) {
ok = false;
break;
}
@@ -358,7 +358,7 @@ void QDBusMetaObjectGenerator::parseProperties()
const QDBusIntrospection::Property &p = *prop_it;
Property mp;
Type type = findType(p.type.toLatin1(), p.annotations);
- if (type.id == QVariant::Invalid)
+ if (type.id == QMetaType::UnknownType)
continue;
QByteArray name = p.name.toLatin1();
diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp
index e3804f74f83..bcbb22fba65 100644
--- a/src/dbus/qdbusmetatype.cpp
+++ b/src/dbus/qdbusmetatype.cpp
@@ -325,7 +325,7 @@ int QDBusMetaType::signatureToType(const char *signature)
switch (signature[0])
{
case DBUS_TYPE_BOOLEAN:
- return QVariant::Bool;
+ return QMetaType::Bool;
case DBUS_TYPE_BYTE:
return QMetaType::UChar;
@@ -337,22 +337,22 @@ int QDBusMetaType::signatureToType(const char *signature)
return QMetaType::UShort;
case DBUS_TYPE_INT32:
- return QVariant::Int;
+ return QMetaType::Int;
case DBUS_TYPE_UINT32:
- return QVariant::UInt;
+ return QMetaType::UInt;
case DBUS_TYPE_INT64:
- return QVariant::LongLong;
+ return QMetaType::LongLong;
case DBUS_TYPE_UINT64:
- return QVariant::ULongLong;
+ return QMetaType::ULongLong;
case DBUS_TYPE_DOUBLE:
- return QVariant::Double;
+ return QMetaType::Double;
case DBUS_TYPE_STRING:
- return QVariant::String;
+ return QMetaType::QString;
case DBUS_TYPE_OBJECT_PATH:
return QDBusMetaTypeId::objectpath();
@@ -369,13 +369,13 @@ int QDBusMetaType::signatureToType(const char *signature)
case DBUS_TYPE_ARRAY: // special case
switch (signature[1]) {
case DBUS_TYPE_BYTE:
- return QVariant::ByteArray;
+ return QMetaType::QByteArray;
case DBUS_TYPE_STRING:
- return QVariant::StringList;
+ return QMetaType::QStringList;
case DBUS_TYPE_VARIANT:
- return QVariant::List;
+ return QMetaType::QVariantList;
case DBUS_TYPE_OBJECT_PATH:
return qMetaTypeId<QList<QDBusObjectPath> >();
@@ -409,7 +409,7 @@ const char *QDBusMetaType::typeToSignature(int type)
case QMetaType::UChar:
return DBUS_TYPE_BYTE_AS_STRING;
- case QVariant::Bool:
+ case QMetaType::Bool:
return DBUS_TYPE_BOOLEAN_AS_STRING;
case QMetaType::Short:
@@ -418,29 +418,29 @@ const char *QDBusMetaType::typeToSignature(int type)
case QMetaType::UShort:
return DBUS_TYPE_UINT16_AS_STRING;
- case QVariant::Int:
+ case QMetaType::Int:
return DBUS_TYPE_INT32_AS_STRING;
- case QVariant::UInt:
+ case QMetaType::UInt:
return DBUS_TYPE_UINT32_AS_STRING;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
return DBUS_TYPE_INT64_AS_STRING;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return DBUS_TYPE_UINT64_AS_STRING;
- case QVariant::Double:
+ case QMetaType::Double:
return DBUS_TYPE_DOUBLE_AS_STRING;
- case QVariant::String:
+ case QMetaType::QString:
return DBUS_TYPE_STRING_AS_STRING;
- case QVariant::StringList:
+ case QMetaType::QStringList:
return DBUS_TYPE_ARRAY_AS_STRING
DBUS_TYPE_STRING_AS_STRING; // as
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
return DBUS_TYPE_ARRAY_AS_STRING
DBUS_TYPE_BYTE_AS_STRING; // ay
}
diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp
index 09311d1ad4f..b4ee6811ac5 100644
--- a/src/dbus/qdbusutil.cpp
+++ b/src/dbus/qdbusutil.cpp
@@ -82,7 +82,7 @@ static bool variantToString(const QVariant &arg, QString &out)
{
int argType = arg.userType();
- if (argType == QVariant::StringList) {
+ if (argType == QMetaType::QStringList) {
out += QLatin1Char('{');
const QStringList list = arg.toStringList();
for (const QString &item : list)
@@ -90,7 +90,7 @@ static bool variantToString(const QVariant &arg, QString &out)
if (!list.isEmpty())
out.chop(2);
out += QLatin1Char('}');
- } else if (argType == QVariant::ByteArray) {
+ } else if (argType == QMetaType::QByteArray) {
out += QLatin1Char('{');
QByteArray list = arg.toByteArray();
for (int i = 0; i < list.count(); ++i) {
@@ -100,7 +100,7 @@ static bool variantToString(const QVariant &arg, QString &out)
if (!list.isEmpty())
out.chop(2);
out += QLatin1Char('}');
- } else if (argType == QVariant::List) {
+ } else if (argType == QMetaType::QVariantList) {
out += QLatin1Char('{');
const QList<QVariant> list = arg.toList();
for (const QVariant &item : list) {
@@ -148,7 +148,7 @@ static bool variantToString(const QVariant &arg, QString &out)
if (!variantToString(v, out))
return false;
out += QLatin1Char(']');
- } else if (arg.canConvert(QVariant::String)) {
+ } else if (arg.canConvert(QMetaType::QString)) {
out += QLatin1Char('\"') + arg.toString() + QLatin1Char('\"');
} else {
out += QLatin1Char('[');
diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp
index c6b3b90508b..7370ce0de36 100644
--- a/src/dbus/qdbusxmlgenerator.cpp
+++ b/src/dbus/qdbusxmlgenerator.cpp
@@ -113,7 +113,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
QLatin1String(signature),
accessAsString(mp.isReadable(), mp.isWritable()));
- if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
+ if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) {
const char *typeName = QMetaType::typeName(typeId);
retval += QLatin1String(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
.arg(typeNameToXml(typeName));
@@ -161,7 +161,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
.arg(typeNameToXml(typeName));
// do we need to describe this argument?
- if (QDBusMetaType::signatureToType(typeName) == QVariant::Invalid)
+ if (QDBusMetaType::signatureToType(typeName) == QMetaType::UnknownType)
xml += QLatin1String(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
.arg(typeNameToXml(QMetaType::typeName(typeId)));
} else {
@@ -208,7 +208,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
qUtf16Printable(name), signature, isOutput ? "out" : "in");
// do we need to describe this argument?
- if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
+ if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) {
const char *typeName = QMetaType::typeName(types.at(j));
xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
.arg(isOutput ? QLatin1String("Out") : QLatin1String("In"))
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 7922d6fb06c..a789e65284d 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -2029,7 +2029,7 @@ QAccessibleTextInterface::~QAccessibleTextInterface()
\fn void QAccessibleTextInterface::selection(int selectionIndex, int *startOffset, int *endOffset) const
Returns a selection. The size of the selection is returned in \a startOffset and \a endOffset.
- If there is no selection both \a startOffset and \a endOffset are 0.
+ If there is no selection both \a startOffset and \a endOffset are \nullptr.
The accessibility APIs support multiple selections. For most widgets though, only one selection
is supported with \a selectionIndex equal to 0.
diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp
index f1f51c0582a..138d0dfa1b9 100644
--- a/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp
+++ b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
//! [3]
QSize MyWidget::sizeHint() const
{
- return QSize(80, 25).expandedTo(QApplication::globalStrut());
+ return QSize(80, 25);
}
//! [3]
diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index 392b6040cb1..f8a3ce84aab 100644
--- a/src/gui/doc/src/qtgui.qdoc
+++ b/src/gui/doc/src/qtgui.qdoc
@@ -62,7 +62,7 @@
\include module-use.qdocinc using qt module
\quotefile overview/using-qt-gui.cmake
- See also the \l[QtDoc]{Build with CMake} overview.
+ See also the \l{Build with CMake} overview.
\section2 Building with qmake
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index 455045eb571..a44f7151b15 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -218,7 +218,7 @@ QBitmap::~QBitmap()
*/
QBitmap::operator QVariant() const
{
- return QVariant(QVariant::Bitmap, this);
+ return QVariant(QMetaType::QBitmap, this);
}
static QBitmap makeBitmap(QImage &&image, Qt::ImageConversionFlags flags)
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 19be066d234..38285dd827c 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -782,7 +782,7 @@ QIcon &QIcon::operator=(const QIcon &other)
*/
QIcon::operator QVariant() const
{
- return QVariant(QVariant::Icon, this);
+ return QVariant(QMetaType::QIcon, this);
}
/*! \fn int QIcon::serialNumber() const
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 08b1373f96b..74dc81e3652 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1067,7 +1067,7 @@ int QImage::devType() const
*/
QImage::operator QVariant() const
{
- return QVariant(QVariant::Image, this);
+ return QVariant(QMetaType::QImage, this);
}
/*!
@@ -3649,8 +3649,8 @@ QImage QImage::fromData(const uchar *data, int size, const char *format)
/*!
Saves the image to the file with the given \a fileName, using the
given image file \a format and \a quality factor. If \a format is
- 0, QImage will attempt to guess the format by looking at \a fileName's
- suffix.
+ \nullptr, QImage will attempt to guess the format by looking at
+ \a fileName's suffix.
The \a quality factor must be in the range 0 to 100 or -1. Specify
0 to obtain small compressed files, 100 for large uncompressed
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 3fce64cb206..adadba20571 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -402,7 +402,7 @@ QPixmap &QPixmap::operator=(const QPixmap &pixmap)
*/
QPixmap::operator QVariant() const
{
- return QVariant(QVariant::Pixmap, this);
+ return QVariant(QMetaType::QPixmap, this);
}
/*!
@@ -813,8 +813,8 @@ bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::I
0 to obtain small compressed files, 100 for large uncompressed
files, and -1 to use the default settings.
- If \a format is 0, an image format will be chosen from \a fileName's
- suffix.
+ If \a format is \nullptr, an image format will be chosen from
+ \a fileName's suffix.
\sa {QPixmap#Reading and Writing Image Files}{Reading and Writing
Image Files}
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index 9bdc22b49eb..fc9424763ef 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -926,7 +926,7 @@ void QStandardItem::setData(const QVariant &value, int role)
for (it = d->values.begin(); it != d->values.end(); ++it) {
if ((*it).role == role) {
if (value.isValid()) {
- if ((*it).value.type() == value.type() && (*it).value == value)
+ if ((*it).value.userType() == value.userType() && (*it).value == value)
return;
(*it).value = value;
} else {
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
index f5a794b642d..7f6fdafbd0e 100644
--- a/src/gui/kernel/qcursor.cpp
+++ b/src/gui/kernel/qcursor.cpp
@@ -325,7 +325,7 @@ QDataStream &operator<<(QDataStream &s, const QCursor &c)
if (isPixmap)
s << c.pixmap();
else
- s << *c.bitmap() << *c.mask();
+ s << c.bitmap(Qt::ReturnByValue) << c.mask(Qt::ReturnByValue);
s << c.hotSpot();
}
return s;
@@ -565,7 +565,12 @@ void QCursor::setShape(Qt::CursorShape shape)
}
}
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
+ \deprecated
+
+ New code should use the other overload which returns QBitmap by-value.
+
Returns the cursor bitmap, or \nullptr if it is one of the
standard cursors.
*/
@@ -577,6 +582,10 @@ const QBitmap *QCursor::bitmap() const
}
/*!
+ \deprecated
+
+ New code should use the other overload which returns QBitmap by-value.
+
Returns the cursor bitmap mask, or \nullptr if it is one of the
standard cursors.
*/
@@ -587,6 +596,71 @@ const QBitmap *QCursor::mask() const
QCursorData::initialize();
return d->bmm;
}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+/*!
+ \since 5.15
+
+ Returns the cursor bitmap, or a null bitmap if it is one of the
+ standard cursors.
+
+ Previously, Qt provided a version of \c bitmap() which returned the bitmap
+ by-pointer. That version is now deprecated. To maintain compatibility
+ with old code, you can explicitly differentiate between the by-pointer
+ function and the by-value function:
+
+ \code
+ const QBitmap *bmpPtr = cursor->bitmap();
+ QBitmap bmpVal = cursor->bitmap(Qt::ReturnByValue);
+ \endcode
+
+ If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE
+ macro, then you can omit \c Qt::ReturnByValue as shown below:
+
+ \code
+ QBitmap bmpVal = cursor->bitmap();
+ \endcode
+*/
+QBitmap QCursor::bitmap(Qt::ReturnByValue_t) const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ if (d->bm)
+ return *(d->bm);
+ return QBitmap();
+}
+
+/*!
+ \since 5.15
+
+ Returns the cursor bitmap mask, or a null bitmap if it is one of the
+ standard cursors.
+
+ Previously, Qt provided a version of \c mask() which returned the bitmap
+ by-pointer. That version is now deprecated. To maintain compatibility
+ with old code, you can explicitly differentiate between the by-pointer
+ function and the by-value function:
+
+ \code
+ const QBitmap *bmpPtr = cursor->mask();
+ QBitmap bmpVal = cursor->mask(Qt::ReturnByValue);
+ \endcode
+
+ If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE
+ macro, then you can omit \c Qt::ReturnByValue as shown below:
+
+ \code
+ QBitmap bmpVal = cursor->mask();
+ \endcode
+*/
+QBitmap QCursor::mask(Qt::ReturnByValue_t) const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ if (d->bmm)
+ return *(d->bmm);
+ return QBitmap();
+}
/*!
Returns the cursor pixmap. This is only valid if the cursor is a
@@ -657,7 +731,7 @@ QCursor &QCursor::operator=(const QCursor &c)
*/
QCursor::operator QVariant() const
{
- return QVariant(QVariant::Cursor, this);
+ return QVariant(QMetaType::QCursor, this);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index 7966e358408..7a11fe59eec 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -97,8 +97,19 @@ public:
Qt::CursorShape shape() const;
void setShape(Qt::CursorShape newShape);
- const QBitmap *bitmap() const;
- const QBitmap *mask() const;
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QBitmap by-value")
+ const QBitmap *bitmap() const; // ### Qt 7: Remove function
+
+ QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QBitmap by-value")
+ const QBitmap *mask() const; // ### Qt 7: Remove function
+
+ QBitmap bitmap(Qt::ReturnByValue_t) const;
+ QBitmap mask(Qt::ReturnByValue_t) const;
+#else
+ QBitmap bitmap(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg
+ QBitmap mask(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg
+#endif // QT_DEPRECATED_SINCE(5, 15)
QPixmap pixmap() const;
QPoint hotSpot() const;
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index e36080eee2d..5a71475dc94 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -946,7 +946,7 @@ QWheelEvent::~QWheelEvent()
\li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
\endlist
- \see pixelDelta()
+ \sa pixelDelta()
*/
/*!
@@ -3355,7 +3355,7 @@ QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
\a action is the action that is changed, added, or removed. If \a
type is ActionAdded, the action is to be inserted before the
- action \a before. If \a before is 0, the action is appended.
+ action \a before. If \a before is \nullptr, the action is appended.
*/
QActionEvent::QActionEvent(int type, QGuiAction *action, QGuiAction *before)
: QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index d72cc2df79b..a723ca6e7f2 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -592,6 +592,21 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME
\list
\li \c {altgr}, detect the key \c {AltGr} found on some keyboards as
Qt::GroupSwitchModifier (since Qt 5.12).
+ \li \c {darkmode=[1|2]} controls how Qt responds to the activation
+ of the \e{Dark Mode for applications} introduced in Windows 10
+ 1903 (since Qt 5.15).
+
+ A value of 1 causes Qt to switch the window borders to black
+ when \e{Dark Mode for applications} is activated and no High
+ Contrast Theme is in use. This is intended for applications
+ that implement their own theming.
+
+ A value of 2 will in addition cause the Windows Vista style to
+ be deactivated and switch to the Windows style using a
+ simplified palette in dark mode. This is currently
+ experimental pending the introduction of new style that
+ properly adapts to dark mode.
+
\li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and
\c none disables them.
diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp
index 0f296332227..94296dd6fc4 100644
--- a/src/gui/kernel/qguivariant.cpp
+++ b/src/gui/kernel/qguivariant.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -41,6 +41,7 @@
#include "qbitmap.h"
#include "qbrush.h"
#include "qcolor.h"
+#include "qcolorspace.h"
#include "qcursor.h"
#include "qfont.h"
#include "qimage.h"
@@ -180,25 +181,25 @@ static bool convert(const QVariant::Private *d, int t,
void *result, bool *ok)
{
switch (t) {
- case QVariant::ByteArray:
- if (d->type == QVariant::Color) {
+ case QMetaType::QByteArray:
+ if (d->type == QMetaType::QColor) {
const QColor *c = v_cast<QColor>(d);
*static_cast<QByteArray *>(result) = c->name(c->alpha() != 255 ? QColor::HexArgb : QColor::HexRgb).toLatin1();
return true;
}
break;
- case QVariant::String: {
+ case QMetaType::QString: {
QString *str = static_cast<QString *>(result);
switch (d->type) {
#if QT_CONFIG(shortcut)
- case QVariant::KeySequence:
+ case QMetaType::QKeySequence:
*str = (*v_cast<QKeySequence>(d)).toString(QKeySequence::NativeText);
return true;
#endif
- case QVariant::Font:
+ case QMetaType::QFont:
*str = v_cast<QFont>(d)->toString();
return true;
- case QVariant::Color: {
+ case QMetaType::QColor: {
const QColor *c = v_cast<QColor>(d);
*str = c->name(c->alpha() != 255 ? QColor::HexArgb : QColor::HexRgb);
return true;
@@ -208,85 +209,85 @@ static bool convert(const QVariant::Private *d, int t,
}
break;
}
- case QVariant::Pixmap:
- if (d->type == QVariant::Image) {
+ case QMetaType::QPixmap:
+ if (d->type == QMetaType::QImage) {
*static_cast<QPixmap *>(result) = QPixmap::fromImage(*v_cast<QImage>(d));
return true;
- } else if (d->type == QVariant::Bitmap) {
+ } else if (d->type == QMetaType::QBitmap) {
*static_cast<QPixmap *>(result) = *v_cast<QBitmap>(d);
return true;
- } else if (d->type == QVariant::Brush) {
+ } else if (d->type == QMetaType::QBrush) {
if (v_cast<QBrush>(d)->style() == Qt::TexturePattern) {
*static_cast<QPixmap *>(result) = v_cast<QBrush>(d)->texture();
return true;
}
}
break;
- case QVariant::Image:
- if (d->type == QVariant::Pixmap) {
+ case QMetaType::QImage:
+ if (d->type == QMetaType::QPixmap) {
*static_cast<QImage *>(result) = v_cast<QPixmap>(d)->toImage();
return true;
- } else if (d->type == QVariant::Bitmap) {
+ } else if (d->type == QMetaType::QBitmap) {
*static_cast<QImage *>(result) = v_cast<QBitmap>(d)->toImage();
return true;
}
break;
- case QVariant::Bitmap:
- if (d->type == QVariant::Pixmap) {
+ case QMetaType::QBitmap:
+ if (d->type == QMetaType::QPixmap) {
*static_cast<QBitmap *>(result) = *v_cast<QPixmap>(d);
return true;
- } else if (d->type == QVariant::Image) {
+ } else if (d->type == QMetaType::QImage) {
*static_cast<QBitmap *>(result) = QBitmap::fromImage(*v_cast<QImage>(d));
return true;
}
break;
#if QT_CONFIG(shortcut)
- case QVariant::Int:
- if (d->type == QVariant::KeySequence) {
+ case QMetaType::Int:
+ if (d->type == QMetaType::QKeySequence) {
const QKeySequence &seq = *v_cast<QKeySequence>(d);
*static_cast<int *>(result) = seq.isEmpty() ? 0 : seq[0];
return true;
}
break;
#endif
- case QVariant::Font:
- if (d->type == QVariant::String) {
+ case QMetaType::QFont:
+ if (d->type == QMetaType::QString) {
QFont *f = static_cast<QFont *>(result);
f->fromString(*v_cast<QString>(d));
return true;
}
break;
- case QVariant::Color:
- if (d->type == QVariant::String) {
+ case QMetaType::QColor:
+ if (d->type == QMetaType::QString) {
static_cast<QColor *>(result)->setNamedColor(*v_cast<QString>(d));
return static_cast<QColor *>(result)->isValid();
- } else if (d->type == QVariant::ByteArray) {
+ } else if (d->type == QMetaType::QByteArray) {
static_cast<QColor *>(result)->setNamedColor(QLatin1String(*v_cast<QByteArray>(d)));
return true;
- } else if (d->type == QVariant::Brush) {
+ } else if (d->type == QMetaType::QBrush) {
if (v_cast<QBrush>(d)->style() == Qt::SolidPattern) {
*static_cast<QColor *>(result) = v_cast<QBrush>(d)->color();
return true;
}
}
break;
- case QVariant::Brush:
- if (d->type == QVariant::Color) {
+ case QMetaType::QBrush:
+ if (d->type == QMetaType::QColor) {
*static_cast<QBrush *>(result) = QBrush(*v_cast<QColor>(d));
return true;
- } else if (d->type == QVariant::Pixmap) {
+ } else if (d->type == QMetaType::QPixmap) {
*static_cast<QBrush *>(result) = QBrush(*v_cast<QPixmap>(d));
return true;
}
break;
#if QT_CONFIG(shortcut)
- case QVariant::KeySequence: {
+ case QMetaType::QKeySequence: {
QKeySequence *seq = static_cast<QKeySequence *>(result);
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*seq = QKeySequence(*v_cast<QString>(d));
return true;
- case QVariant::Int:
+ case QMetaType::Int:
*seq = QKeySequence(d->data.i);
return true;
default:
@@ -296,7 +297,7 @@ static bool convert(const QVariant::Private *d, int t,
}
#endif
#ifndef QT_NO_ICON
- case QVariant::Icon: {
+ case QMetaType::QIcon: {
if (ok)
*ok = false;
return false;
diff --git a/src/gui/kernel/qinternalmimedata.cpp b/src/gui/kernel/qinternalmimedata.cpp
index 8f4da1afb56..d5cdc743ee9 100644
--- a/src/gui/kernel/qinternalmimedata.cpp
+++ b/src/gui/kernel/qinternalmimedata.cpp
@@ -112,22 +112,23 @@ QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type
{
QVariant data = retrieveData_sys(mimeType, type);
if (mimeType == QLatin1String("application/x-qt-image")) {
- if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) {
+ if (data.isNull() || (data.userType() == QMetaType::QByteArray && data.toByteArray().isEmpty())) {
// try to find an image
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
data = retrieveData_sys(imageFormats.at(i), type);
- if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty()))
+ if (data.isNull() || (data.userType() == QMetaType::QByteArray && data.toByteArray().isEmpty()))
continue;
break;
}
}
+ int typeId = type;
// we wanted some image type, but all we got was a byte array. Convert it to an image.
- if (data.type() == QVariant::ByteArray
- && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap))
+ if (data.userType() == QMetaType::QByteArray
+ && (typeId == QMetaType::QImage || typeId == QMetaType::QPixmap || typeId == QMetaType::QBitmap))
data = QImage::fromData(data.toByteArray());
- } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) {
+ } else if (mimeType == QLatin1String("application/x-color") && data.userType() == QMetaType::QByteArray) {
QColor c;
QByteArray ba = data.toByteArray();
if (ba.size() == 8) {
@@ -140,7 +141,7 @@ QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type
} else {
qWarning("Qt: Invalid color format");
}
- } else if (data.type() != type && data.type() == QVariant::ByteArray) {
+ } else if (data.userType() != int(type) && data.userType() == QMetaType::QByteArray) {
// try to use mime data's internal conversion stuf.
QInternalMimeData *that = const_cast<QInternalMimeData *>(this);
that->setData(mimeType, data.toByteArray());
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index d5bdf1f15bc..57a89bb8c2d 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1402,7 +1402,7 @@ QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const
*/
QKeySequence::operator QVariant() const
{
- return QVariant(QVariant::KeySequence, this);
+ return QVariant(QMetaType::QKeySequence, this);
}
/*! \fn QKeySequence::operator int () const
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index ab71434c134..fbaff74561c 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -942,7 +942,7 @@ GLuint QOpenGLContext::defaultFramebufferObject() const
The latter may happen if the surface is not exposed, or the graphics
hardware is not available due to e.g. the application being suspended.
- If \a surface is 0 this is equivalent to calling doneCurrent().
+ If \a surface is \nullptr this is equivalent to calling doneCurrent().
Avoid calling this function from a different thread than the one the
QOpenGLContext instance lives in. If you wish to use QOpenGLContext from a
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index e31ce00e146..f6180be8a8e 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -725,7 +725,7 @@ QPalette &QPalette::operator=(const QPalette &p)
*/
QPalette::operator QVariant() const
{
- return QVariant(QVariant::Palette, this);
+ return QVariant(QMetaType::QPalette, this);
}
/*!
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index ad4cdfdbf4a..6666eb037f3 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -2007,7 +2007,7 @@ void QMatrix4x4::optimize()
*/
QMatrix4x4::operator QVariant() const
{
- return QVariant(QVariant::Matrix4x4, this);
+ return QVariant(QMetaType::QMatrix4x4, this);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index 899ec12eb34..5f15949c5b8 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -983,7 +983,7 @@ QQuaternion QQuaternion::nlerp
*/
QQuaternion::operator QVariant() const
{
- return QVariant(QVariant::Quaternion, this);
+ return QVariant(QMetaType::QQuaternion, this);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp
index c04f8b1cbfe..5f651cf3761 100644
--- a/src/gui/math3d/qvector2d.cpp
+++ b/src/gui/math3d/qvector2d.cpp
@@ -531,7 +531,7 @@ QVector4D QVector2D::toVector4D() const
*/
QVector2D::operator QVariant() const
{
- return QVariant(QVariant::Vector2D, this);
+ return QVariant(QMetaType::QVector2D, this);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index 4f72c1da660..08c3de99d2a 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -706,7 +706,7 @@ QVector4D QVector3D::toVector4D() const
*/
QVector3D::operator QVariant() const
{
- return QVariant(QVariant::Vector3D, this);
+ return QVariant(QMetaType::QVector3D, this);
}
/*!
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp
index 3a68bd6cb78..070ea7454ea 100644
--- a/src/gui/math3d/qvector4d.cpp
+++ b/src/gui/math3d/qvector4d.cpp
@@ -608,7 +608,7 @@ QVector3D QVector4D::toVector3DAffine() const
*/
QVector4D::operator QVariant() const
{
- return QVariant(QVariant::Vector4D, this);
+ return QVariant(QMetaType::QVector4D, this);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 83032bdc4fe..e84916e063a 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -672,7 +672,7 @@ QBrush &QBrush::operator=(const QBrush &b)
*/
QBrush::operator QVariant() const
{
- return QVariant(QVariant::Brush, this);
+ return QVariant(QMetaType::QBrush, this);
}
/*!
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index c567b254687..e544fce70eb 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2940,7 +2940,7 @@ bool QColor::operator!=(const QColor &color) const noexcept
*/
QColor::operator QVariant() const
{
- return QVariant(QVariant::Color, this);
+ return QVariant(QMetaType::QColor, this);
}
/*! \internal
diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp
index 0fb0e9ee336..7ebd5f1bf48 100644
--- a/src/gui/painting/qcolorspace.cpp
+++ b/src/gui/painting/qcolorspace.cpp
@@ -744,6 +744,15 @@ QColorTransform QColorSpace::transformationToColorSpace(const QColorSpace &color
return d_ptr->transformationToColorSpace(colorspace.d_ptr);
}
+/*!
+ Returns the color space as a QVariant.
+ \since 5.15
+*/
+QColorSpace::operator QVariant() const
+{
+ return QVariant(QMetaType::QColorSpace, this);
+}
+
/*****************************************************************************
QColorSpace stream functions
*****************************************************************************/
diff --git a/src/gui/painting/qcolorspace.h b/src/gui/painting/qcolorspace.h
index e6bc62d58a6..08c9944301a 100644
--- a/src/gui/painting/qcolorspace.h
+++ b/src/gui/painting/qcolorspace.h
@@ -44,6 +44,7 @@
#include <QtGui/qcolortransform.h>
#include <QtCore/qobjectdefs.h>
#include <QtCore/qshareddata.h>
+#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
@@ -125,6 +126,7 @@ public:
QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const;
+ operator QVariant() const;
private:
Q_DECLARE_PRIVATE(QColorSpace)
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index b1f01332b6d..890b0079de0 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -1087,7 +1087,7 @@ QMatrix &QMatrix::operator=(const QMatrix &matrix) noexcept
*/
QMatrix::operator QVariant() const
{
- return QVariant(QVariant::Matrix, this);
+ return QVariant(QMetaType::QMatrix, this);
}
Q_GUI_EXPORT QPainterPath operator *(const QPainterPath &p, const QMatrix &m)
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index bc65ed56e33..10920c38fe1 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -342,7 +342,7 @@ QRasterPaintEnginePrivate::QRasterPaintEnginePrivate() :
*/
/*!
- \fn Type QRasterPaintEngine::type() const
+ \fn QPaintEngine::Type QRasterPaintEngine::type() const
\reimp
*/
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index 1a940443d19..01e581d2ed9 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -408,7 +408,7 @@ QPen &QPen::operator=(const QPen &p) noexcept
*/
QPen::operator QVariant() const
{
- return QVariant(QVariant::Pen, this);
+ return QVariant(QMetaType::QPen, this);
}
/*!
diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp
index 3bf6004fcce..20337477b73 100644
--- a/src/gui/painting/qpolygon.cpp
+++ b/src/gui/painting/qpolygon.cpp
@@ -716,7 +716,7 @@ QPolygon QPolygonF::toPolygon() const
*/
QPolygon::operator QVariant() const
{
- return QVariant(QVariant::Polygon, this);
+ return QVariant(QMetaType::QPolygon, this);
}
/*****************************************************************************
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index 783b02fb931..44ee038194b 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -599,7 +599,7 @@ QRegion& QRegion::operator^=(const QRegion &r)
*/
QRegion::operator QVariant() const
{
- return QVariant(QVariant::Region, this);
+ return QVariant(QMetaType::QRegion, this);
}
/*!
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index d75b66c50b5..279a817ff1e 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -2155,7 +2155,7 @@ QTransform::TransformationType QTransform::type() const
*/
QTransform::operator QVariant() const
{
- return QVariant(QVariant::Transform, this);
+ return QVariant(QMetaType::QTransform, this);
}
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index d2c8ae104e0..a9c6835687c 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -2361,7 +2361,7 @@ QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const
/*!
\return a pointer to a backend-specific QRhiNativeHandles subclass, such as
- QRhiVulkanRenderPassNativeHandles. The returned value is null when exposing
+ QRhiVulkanRenderPassNativeHandles. The returned value is \nullptr when exposing
the underlying native resources is not supported by the backend.
\sa QRhiVulkanRenderPassNativeHandles
@@ -4933,7 +4933,7 @@ void QRhiCommandBuffer::dispatch(int x, int y, int z)
/*!
\return a pointer to a backend-specific QRhiNativeHandles subclass, such as
- QRhiVulkanCommandBufferNativeHandles. The returned value is null when
+ QRhiVulkanCommandBufferNativeHandles. The returned value is \nullptr when
exposing the underlying native resources is not supported by, or not
applicable to, the backend.
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp
index f4c72d2ccac..e7faa0cadd4 100644
--- a/src/gui/rhi/qrhivulkan.cpp
+++ b/src/gui/rhi/qrhivulkan.cpp
@@ -1351,8 +1351,8 @@ bool QRhiVulkan::recreateSwapChain(QRhiSwapChain *swapChain)
quint32 actualSwapChainBufferCount = 0;
err = vkGetSwapchainImagesKHR(dev, swapChainD->sc, &actualSwapChainBufferCount, nullptr);
- if (err != VK_SUCCESS || actualSwapChainBufferCount < 2) {
- qWarning("Failed to get swapchain images: %d (count=%u)", err, actualSwapChainBufferCount);
+ if (err != VK_SUCCESS || actualSwapChainBufferCount == 0) {
+ qWarning("Failed to get swapchain images: %d", err);
return false;
}
@@ -1528,7 +1528,8 @@ void QRhiVulkan::releaseSwapChainResources(QRhiSwapChain *swapChain)
QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags)
{
QVkSwapChain *swapChainD = QRHI_RES(QVkSwapChain, swapChain);
- QVkSwapChain::FrameResources &frame(swapChainD->frameRes[swapChainD->currentFrameSlot]);
+ const int frameResIndex = swapChainD->bufferCount > 1 ? swapChainD->currentFrameSlot : 0;
+ QVkSwapChain::FrameResources &frame(swapChainD->frameRes[frameResIndex]);
QRhiProfilerPrivate *rhiP = profilerPrivateOrNull();
if (!frame.imageAcquired) {
@@ -1571,7 +1572,7 @@ QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::Begin
// will make B wait for A's frame 0 commands, so if a resource is written
// in B's frame or when B checks for pending resource releases, that won't
// mess up A's in-flight commands (as they are not in flight anymore).
- waitCommandCompletion(int(swapChainD->currentFrameSlot));
+ waitCommandCompletion(frameResIndex);
// Now is the time to read the timestamps for the previous frame for this slot.
if (frame.timestampQueryIndex >= 0) {
@@ -1606,7 +1607,7 @@ QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::Begin
// when profiling is enabled, pick a free query (pair) from the pool
int timestampQueryIdx = -1;
- if (profilerPrivateOrNull()) {
+ if (profilerPrivateOrNull() && swapChainD->bufferCount > 1) { // no timestamps if not having at least 2 frames in flight
for (int i = 0; i < timestampQueryPoolMap.count(); ++i) {
if (!timestampQueryPoolMap.testBit(i)) {
timestampQueryPoolMap.setBit(i);
@@ -1648,7 +1649,8 @@ QRhi::FrameOpResult QRhiVulkan::endFrame(QRhiSwapChain *swapChain, QRhi::EndFram
recordPrimaryCommandBuffer(&swapChainD->cbWrapper);
- QVkSwapChain::FrameResources &frame(swapChainD->frameRes[swapChainD->currentFrameSlot]);
+ int frameResIndex = swapChainD->bufferCount > 1 ? swapChainD->currentFrameSlot : 0;
+ QVkSwapChain::FrameResources &frame(swapChainD->frameRes[frameResIndex]);
QVkSwapChain::ImageResources &image(swapChainD->imageRes[swapChainD->currentImageIndex]);
if (image.lastUse != QVkSwapChain::ImageResources::ScImageUseRender) {
@@ -1860,7 +1862,8 @@ QRhi::FrameOpResult QRhiVulkan::endAndSubmitPrimaryCommandBuffer(VkCommandBuffer
void QRhiVulkan::waitCommandCompletion(int frameSlot)
{
for (QVkSwapChain *sc : qAsConst(swapchains)) {
- QVkSwapChain::FrameResources &frame(sc->frameRes[frameSlot]);
+ const int frameResIndex = sc->bufferCount > 1 ? frameSlot : 0;
+ QVkSwapChain::FrameResources &frame(sc->frameRes[frameResIndex]);
if (frame.cmdFenceWaitable) {
df->vkWaitForFences(dev, 1, &frame.cmdFence, VK_TRUE, UINT64_MAX);
df->vkResetFences(dev, 1, &frame.cmdFence);
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index c0b0071e4df..a12eb985282 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -707,7 +707,7 @@ static Qt::Alignment parseAlignment(const QCss::Value *values, int count)
static ColorData parseColorValue(QCss::Value v)
{
if (v.type == Value::Identifier || v.type == Value::String) {
- v.variant.convert(QVariant::Color);
+ v.variant.convert(QMetaType::QColor);
v.type = Value::Color;
}
@@ -1143,7 +1143,7 @@ static bool setFontSizeFromValue(QCss::Value value, QFont *font, int *fontSizeAd
} else if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)) {
s.chop(2);
value.variant = s;
- if (value.variant.convert(QVariant::Int)) {
+ if (value.variant.convert(QMetaType::Int)) {
font->setPixelSize(value.variant.toInt());
valid = true;
}
@@ -1420,9 +1420,9 @@ QColor Declaration::colorValue(const QPalette &pal) const
return QColor();
if (d->parsed.isValid()) {
- if (d->parsed.type() == QVariant::Color)
+ if (d->parsed.userType() == QMetaType::QColor)
return qvariant_cast<QColor>(d->parsed);
- if (d->parsed.type() == QVariant::Int)
+ if (d->parsed.userType() == QMetaType::Int)
return pal.color((QPalette::ColorRole)(d->parsed.toInt()));
}
@@ -1442,9 +1442,9 @@ QBrush Declaration::brushValue(const QPalette &pal) const
return QBrush();
if (d->parsed.isValid()) {
- if (d->parsed.type() == QVariant::Brush)
+ if (d->parsed.userType() == QMetaType::QBrush)
return qvariant_cast<QBrush>(d->parsed);
- if (d->parsed.type() == QVariant::Int)
+ if (d->parsed.userType() == QMetaType::Int)
return pal.color((QPalette::ColorRole)(d->parsed.toInt()));
}
@@ -1469,9 +1469,9 @@ void Declaration::brushValues(QBrush *c, const QPalette &pal) const
needParse = 0;
QList<QVariant> v = d->parsed.toList();
for (i = 0; i < qMin(v.count(), 4); i++) {
- if (v.at(i).type() == QVariant::Brush) {
+ if (v.at(i).userType() == QMetaType::QBrush) {
c[i] = qvariant_cast<QBrush>(v.at(i));
- } else if (v.at(i).type() == QVariant::Int) {
+ } else if (v.at(i).userType() == QMetaType::Int) {
c[i] = pal.color((QPalette::ColorRole)(v.at(i).toInt()));
} else {
needParse |= (1<<i);
@@ -1598,7 +1598,7 @@ void Declaration::colorValues(QColor *c, const QPalette &pal) const
if (d->parsed.isValid()) {
QList<QVariant> v = d->parsed.toList();
for (i = 0; i < qMin(d->values.count(), 4); i++) {
- if (v.at(i).type() == QVariant::Color) {
+ if (v.at(i).userType() == QMetaType::QColor) {
c[i] = qvariant_cast<QColor>(v.at(i));
} else {
c[i] = pal.color((QPalette::ColorRole)(v.at(i).toInt()));
@@ -2723,7 +2723,7 @@ bool Parser::parseTerm(Value *value)
switch (lookup()) {
case NUMBER:
value->type = Value::Number;
- value->variant.convert(QVariant::Double);
+ value->variant.convert(QMetaType::Double);
break;
case PERCENTAGE:
value->type = Value::Percentage;
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 9ede90d8de9..8f0d7d9d382 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1353,8 +1353,8 @@ QFont::StyleHint QFont::styleHint() const
\value NoAntialias don't antialias the fonts.
\value NoSubpixelAntialias avoid subpixel antialiasing on the fonts if possible.
\value PreferAntialias antialias if possible.
- \value OpenGLCompatible forces the use of OpenGL compatible
- fonts.
+ \value OpenGLCompatible This style strategy has been deprecated. All fonts are
+ OpenGL-compatible by default.
\value NoFontMerging If the font selected for a certain writing system
does not contain a character requested to draw, then Qt automatically chooses a similar
looking font that contains the character. The NoFontMerging flag disables this feature.
@@ -1373,8 +1373,8 @@ QFont::StyleHint QFont::styleHint() const
\value PreferQuality prefer the best quality font. The font matcher
will use the nearest standard point size that the font
supports.
- \value ForceIntegerMetrics forces the use of integer values in font engines that support fractional
- font metrics.
+ \value ForceIntegerMetrics This style strategy has been deprecated. Use \l QFontMetrics to
+ retrieve rounded font metrics.
*/
/*!
@@ -1753,7 +1753,7 @@ bool QFont::operator!=(const QFont &f) const
*/
QFont::operator QVariant() const
{
- return QVariant(QVariant::Font, this);
+ return QVariant(QMetaType::QFont, this);
}
/*!
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 683aa3bf652..e5734679ed4 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -80,8 +80,10 @@ public:
PreferQuality = 0x0040,
PreferAntialias = 0x0080,
NoAntialias = 0x0100,
- OpenGLCompatible = 0x0200,
- ForceIntegerMetrics = 0x0400,
+#if QT_DEPRECATED_SINCE(5, 15)
+ OpenGLCompatible Q_DECL_ENUMERATOR_DEPRECATED = 0x0200,
+ ForceIntegerMetrics Q_DECL_ENUMERATOR_DEPRECATED = 0x0400,
+#endif
NoSubpixelAntialias = 0x0800,
PreferNoShaping = 0x1000,
NoFontMerging = 0x8000
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index de9cae0c917..73fcc4bc788 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -161,7 +161,7 @@ QFontMetrics::QFontMetrics(const QFont &font)
Constructs a font metrics object for \a font and \a paintdevice.
The font metrics will be compatible with the paintdevice passed.
- If the \a paintdevice is 0, the metrics will be screen-compatible,
+ If the \a paintdevice is \nullptr, the metrics will be screen-compatible,
ie. the metrics you get if you use the font for drawing text on a
\l{QWidget}{widgets} or \l{QPixmap}{pixmaps},
not on a QPicture or QPrinter.
@@ -1154,7 +1154,7 @@ QFontMetricsF::QFontMetricsF(const QFont &font)
Constructs a font metrics object for \a font and \a paintdevice.
The font metrics will be compatible with the paintdevice passed.
- If the \a paintdevice is 0, the metrics will be screen-compatible,
+ If the \a paintdevice is \nullptr, the metrics will be screen-compatible,
ie. the metrics you get if you use the font for drawing text on a
\l{QWidget}{widgets} or \l{QPixmap}{pixmaps},
not on a QPicture or QPrinter.
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 02e25bb6afc..48ba8987f3d 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -82,7 +82,7 @@ void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *
if (!fontName.isEmpty() && pixelSize) {
QFont::Weight fontWeight = QFont::Normal;
- if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt)
+ if (weight.userType() == QMetaType::Int || weight.userType() == QMetaType::UInt)
fontWeight = QFont::Weight(weight.toInt());
QFont::Style fontStyle = static_cast<QFont::Style>(style.toInt());
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 2d7f2bb844a..46cfc79643c 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2234,7 +2234,7 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name)
}
if (!r.isNull()) {
- if (type == ImageResource && r.type() == QVariant::ByteArray) {
+ if (type == ImageResource && r.userType() == QMetaType::QByteArray) {
if (qApp->thread() != QThread::currentThread()) {
// must use images in non-GUI threads
QImage image;
@@ -3049,12 +3049,12 @@ QString QTextHtmlExporter::findUrlForImage(const QTextDocument *doc, qint64 cach
for (; it != priv->cachedResources.constEnd(); ++it) {
const QVariant &v = it.value();
- if (v.type() == QVariant::Image && !isPixmap) {
+ if (v.userType() == QMetaType::QImage && !isPixmap) {
if (qvariant_cast<QImage>(v).cacheKey() == cacheKey)
break;
}
- if (v.type() == QVariant::Pixmap && isPixmap) {
+ if (v.userType() == QMetaType::QPixmap && isPixmap) {
if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey)
break;
}
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index e21a8d8d527..9d708735903 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -248,7 +248,7 @@ public:
if (v.isNull()) {
return cellPadding;
} else {
- Q_ASSERT(v.userType() == QVariant::Double || v.userType() == QMetaType::Float);
+ Q_ASSERT(v.userType() == QMetaType::Double || v.userType() == QMetaType::Float);
return QFixed::fromReal(v.toReal() * deviceScale);
}
}
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index e3bd49a15ef..10b8ade1178 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -144,7 +144,7 @@ QT_BEGIN_NAMESPACE
*/
QTextLength::operator QVariant() const
{
- return QVariant(QVariant::TextLength, this);
+ return QVariant(QMetaType::QTextLength, this);
}
#ifndef QT_NO_DATASTREAM
@@ -288,20 +288,20 @@ static inline uint variantHash(const QVariant &variant)
{
// simple and fast hash functions to differentiate between type and value
switch (variant.userType()) { // sorted by occurrence frequency
- case QVariant::String: return qHash(variant.toString());
- case QVariant::Double: return qHash(variant.toDouble());
- case QVariant::Int: return 0x811890 + variant.toInt();
- case QVariant::Brush:
+ case QMetaType::QString: return qHash(variant.toString());
+ case QMetaType::Double: return qHash(variant.toDouble());
+ case QMetaType::Int: return 0x811890 + variant.toInt();
+ case QMetaType::QBrush:
return 0x01010101 + hash(qvariant_cast<QBrush>(variant));
- case QVariant::Bool: return 0x371818 + variant.toBool();
- case QVariant::Pen: return 0x02020202 + hash(qvariant_cast<QPen>(variant));
- case QVariant::List:
+ case QMetaType::Bool: return 0x371818 + variant.toBool();
+ case QMetaType::QPen: return 0x02020202 + hash(qvariant_cast<QPen>(variant));
+ case QMetaType::QVariantList:
return 0x8377 + qvariant_cast<QVariantList>(variant).count();
- case QVariant::Color: return hash(qvariant_cast<QColor>(variant));
- case QVariant::TextLength:
+ case QMetaType::QColor: return hash(qvariant_cast<QColor>(variant));
+ case QMetaType::QTextLength:
return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue());
case QMetaType::Float: return qHash(variant.toFloat());
- case QVariant::Invalid: return 0;
+ case QMetaType::UnknownType: return 0;
default: break;
}
return qHash(variant.typeName());
@@ -874,7 +874,7 @@ QTextFormat::~QTextFormat()
*/
QTextFormat::operator QVariant() const
{
- return QVariant(QVariant::TextFormat, this);
+ return QVariant(QMetaType::QTextFormat, this);
}
/*!
@@ -984,7 +984,7 @@ bool QTextFormat::boolProperty(int propertyId) const
if (!d)
return false;
const QVariant prop = d->property(propertyId);
- if (prop.userType() != QVariant::Bool)
+ if (prop.userType() != QMetaType::Bool)
return false;
return prop.toBool();
}
@@ -1004,7 +1004,7 @@ int QTextFormat::intProperty(int propertyId) const
if (!d)
return def;
const QVariant prop = d->property(propertyId);
- if (prop.userType() != QVariant::Int)
+ if (prop.userType() != QMetaType::Int)
return def;
return prop.toInt();
}
@@ -1022,7 +1022,7 @@ qreal QTextFormat::doubleProperty(int propertyId) const
if (!d)
return 0.;
const QVariant prop = d->property(propertyId);
- if (prop.userType() != QVariant::Double && prop.userType() != QMetaType::Float)
+ if (prop.userType() != QMetaType::Double && prop.userType() != QMetaType::Float)
return 0.;
return qvariant_cast<qreal>(prop);
}
@@ -1040,7 +1040,7 @@ QString QTextFormat::stringProperty(int propertyId) const
if (!d)
return QString();
const QVariant prop = d->property(propertyId);
- if (prop.userType() != QVariant::String)
+ if (prop.userType() != QMetaType::QString)
return QString();
return prop.toString();
}
@@ -1058,7 +1058,7 @@ QColor QTextFormat::colorProperty(int propertyId) const
if (!d)
return QColor();
const QVariant prop = d->property(propertyId);
- if (prop.userType() != QVariant::Color)
+ if (prop.userType() != QMetaType::QColor)
return QColor();
return qvariant_cast<QColor>(prop);
}
@@ -1076,7 +1076,7 @@ QPen QTextFormat::penProperty(int propertyId) const
if (!d)
return QPen(Qt::NoPen);
const QVariant prop = d->property(propertyId);
- if (prop.userType() != QVariant::Pen)
+ if (prop.userType() != QMetaType::QPen)
return QPen(Qt::NoPen);
return qvariant_cast<QPen>(prop);
}
@@ -1094,7 +1094,7 @@ QBrush QTextFormat::brushProperty(int propertyId) const
if (!d)
return QBrush(Qt::NoBrush);
const QVariant prop = d->property(propertyId);
- if (prop.userType() != QVariant::Brush)
+ if (prop.userType() != QMetaType::QBrush)
return QBrush(Qt::NoBrush);
return qvariant_cast<QBrush>(prop);
}
@@ -1126,13 +1126,13 @@ QVector<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const
if (!d)
return vector;
const QVariant prop = d->property(propertyId);
- if (prop.userType() != QVariant::List)
+ if (prop.userType() != QMetaType::QVariantList)
return vector;
QList<QVariant> propertyList = prop.toList();
for (int i=0; i<propertyList.size(); ++i) {
QVariant var = propertyList.at(i);
- if (var.userType() == QVariant::TextLength)
+ if (var.userType() == QMetaType::QTextLength)
vector.append(qvariant_cast<QTextLength>(var));
}
@@ -1222,7 +1222,7 @@ int QTextFormat::objectIndex() const
if (!d)
return -1;
const QVariant prop = d->property(ObjectIndex);
- if (prop.userType() != QVariant::Int) // ####
+ if (prop.userType() != QMetaType::Int) // ####
return -1;
return prop.toInt();
}
@@ -1859,9 +1859,9 @@ void QTextCharFormat::setUnderlineStyle(UnderlineStyle style)
QString QTextCharFormat::anchorName() const
{
QVariant prop = property(AnchorName);
- if (prop.userType() == QVariant::StringList)
+ if (prop.userType() == QMetaType::QStringList)
return prop.toStringList().value(0);
- else if (prop.userType() != QVariant::String)
+ else if (prop.userType() != QMetaType::QString)
return QString();
return prop.toString();
}
@@ -1878,9 +1878,9 @@ QString QTextCharFormat::anchorName() const
QStringList QTextCharFormat::anchorNames() const
{
QVariant prop = property(AnchorName);
- if (prop.userType() == QVariant::StringList)
+ if (prop.userType() == QMetaType::QStringList)
return prop.toStringList();
- else if (prop.userType() != QVariant::String)
+ else if (prop.userType() != QMetaType::QString)
return QStringList();
return QStringList(prop.toString());
}
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 3b9f2d253e5..f0035443913 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1451,19 +1451,19 @@ void QTextHtmlParserNode::applyBackgroundImage(const QString &url, const QTextDo
if (QCoreApplication::instance()->thread() != QThread::currentThread()) {
// must use images in non-GUI threads
- if (val.type() == QVariant::Image) {
+ if (val.userType() == QMetaType::QImage) {
QImage image = qvariant_cast<QImage>(val);
charFormat.setBackground(image);
- } else if (val.type() == QVariant::ByteArray) {
+ } else if (val.userType() == QMetaType::QByteArray) {
QImage image;
if (image.loadFromData(val.toByteArray())) {
charFormat.setBackground(image);
}
}
} else {
- if (val.type() == QVariant::Image || val.type() == QVariant::Pixmap) {
+ if (val.userType() == QMetaType::QImage || val.userType() == QMetaType::QPixmap) {
charFormat.setBackground(qvariant_cast<QPixmap>(val));
- } else if (val.type() == QVariant::ByteArray) {
+ } else if (val.userType() == QMetaType::QByteArray) {
QPixmap pm;
if (pm.loadFromData(val.toByteArray())) {
charFormat.setBackground(pm);
@@ -1907,9 +1907,9 @@ void QTextHtmlParser::importStyleSheet(const QString &href)
QVariant res = resourceProvider->resource(QTextDocument::StyleSheetResource, href);
QString css;
- if (res.type() == QVariant::String) {
+ if (res.userType() == QMetaType::QString) {
css = res.toString();
- } else if (res.type() == QVariant::ByteArray) {
+ } else if (res.userType() == QMetaType::QByteArray) {
// #### detect @charset
css = QString::fromUtf8(res.toByteArray());
}
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index 14018f34da7..0d87a2135d9 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -88,9 +88,9 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con
qreal sourcePixelRatio = 1.0;
name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio);
const QVariant data = doc->resource(QTextDocument::ImageResource, url);
- if (data.type() == QVariant::Pixmap || data.type() == QVariant::Image) {
+ if (data.userType() == QMetaType::QPixmap || data.userType() == QMetaType::QImage) {
pm = qvariant_cast<QPixmap>(data);
- } else if (data.type() == QVariant::ByteArray) {
+ } else if (data.userType() == QMetaType::QByteArray) {
pm.loadFromData(data.toByteArray());
}
@@ -170,9 +170,9 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format, const
qreal sourcePixelRatio = 1.0;
name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio);
const QVariant data = doc->resource(QTextDocument::ImageResource, url);
- if (data.type() == QVariant::Image) {
+ if (data.userType() == QMetaType::QImage) {
image = qvariant_cast<QImage>(data);
- } else if (data.type() == QVariant::ByteArray) {
+ } else if (data.userType() == QMetaType::QByteArray) {
image.loadFromData(data.toByteArray());
}
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index fc256d72f37..02c42eaf03b 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -350,7 +350,7 @@ QTextLayout::QTextLayout(const QString& text)
\a font.
All the metric and layout calculations will be done in terms of
- the paint device, \a paintdevice. If \a paintdevice is 0 the
+ the paint device, \a paintdevice. If \a paintdevice is \nullptr the
calculations will be done in screen metrics.
*/
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 408e3ec167e..155ec43c50a 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -455,9 +455,9 @@ void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextF
name.prepend(QLatin1String("qrc"));
QUrl url = QUrl(name);
const QVariant variant = m_document->resource(QTextDocument::ImageResource, url);
- if (variant.type() == QVariant::Image) {
+ if (variant.userType() == QMetaType::QImage) {
image = qvariant_cast<QImage>(variant);
- } else if (variant.type() == QVariant::ByteArray) {
+ } else if (variant.userType() == QMetaType::QByteArray) {
data = variant.toByteArray();
QBuffer buffer(&data);
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index 62ae1adbd91..66dd3f9371f 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -1820,7 +1820,7 @@ int QFtp::cd(const QString &dir)
\internal
Downloads the file \a file from the server.
- If \a dev is 0, then the readyRead() signal is emitted when there
+ If \a dev is \nullptr, then the readyRead() signal is emitted when there
is data available to read. You can then read the data with the
read() or readAll() functions.
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 3dea2e026a4..c80600d1b79 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -1774,6 +1774,8 @@ void QNetworkAccessManagerPrivate::_q_replyEncrypted(QNetworkReply *reply)
#ifndef QT_NO_SSL
Q_Q(QNetworkAccessManager);
emit q->encrypted(reply);
+#else
+ Q_UNUSED(reply);
#endif
}
diff --git a/src/network/doc/snippets/code/src_network_ssl_qsslcertificate.cpp b/src/network/doc/snippets/code/src_network_ssl_qsslcertificate.cpp
index 12691da7a25..b381ae7b6e9 100644
--- a/src/network/doc/snippets/code/src_network_ssl_qsslcertificate.cpp
+++ b/src/network/doc/snippets/code/src_network_ssl_qsslcertificate.cpp
@@ -55,3 +55,11 @@ for (const QSslCertificate &cert : certs) {
qDebug() << cert.issuerInfo(QSslCertificate::Organization);
}
//! [0]
+
+//! [1]
+const auto certs = QSslCertificate::fromPath("C:/ssl/certificate.*.pem",
+ QSsl::Pem, QSslCertificate::Wildcard);
+for (const QSslCertificate &cert : certs) {
+ qDebug() << cert.issuerInfo(QSslCertificate::Organization);
+}
+//! [1]
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp
index 0e3d5165353..9694dfa5078 100644
--- a/src/network/socket/qudpsocket.cpp
+++ b/src/network/socket/qudpsocket.cpp
@@ -479,7 +479,7 @@ QNetworkDatagram QUdpSocket::receiveDatagram(qint64 maxSize)
/*!
Receives a datagram no larger than \a maxSize bytes and stores
it in \a data. The sender's host address and port is stored in
- *\a address and *\a port (unless the pointers are 0).
+ *\a address and *\a port (unless the pointers are \nullptr).
Returns the size of the datagram on success; otherwise returns
-1.
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index 4820953468d..c179cf9c4a8 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -124,7 +124,9 @@
#if QT_CONFIG(schannel)
#include "qsslsocket_schannel_p.h"
#endif
-
+#if QT_CONFIG(regularexpression)
+#include "qregularexpression.h"
+#endif
#include "qssl_p.h"
#include "qsslcertificate.h"
#include "qsslcertificate_p.h"
@@ -462,7 +464,10 @@ QByteArray QSslCertificate::digest(QCryptographicHash::Algorithm algorithm) cons
\since 5.0
*/
+#if QT_DEPRECATED_SINCE(5,15)
/*!
+ \obsolete
+
Searches all files in the \a path for certificates encoded in the
specified \a format and returns them in a list. \a path must be a file
or a pattern matching one or more files, as specified by \a syntax.
@@ -537,6 +542,106 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
}
return certs;
}
+#endif // QT_DEPRECATED_SINCE(5,15)
+
+/*!
+ \since 5.15
+
+ Searches all files in the \a path for certificates encoded in the
+ specified \a format and returns them in a list. \a path must be a file
+ or a pattern matching one or more files, as specified by \a syntax.
+
+ Example:
+
+ \snippet code/src_network_ssl_qsslcertificate.cpp 1
+
+ \sa fromData()
+*/
+QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
+ QSsl::EncodingFormat format,
+ PatternSyntax syntax)
+{
+ // $, (,), *, +, ., ?, [, ,], ^, {, | and }.
+
+ // make sure to use the same path separators on Windows and Unix like systems.
+ QString sourcePath = QDir::fromNativeSeparators(path);
+
+ // Find the path without the filename
+ QString pathPrefix = sourcePath.left(sourcePath.lastIndexOf(QLatin1Char('/')));
+
+ // Check if the path contains any special chars
+ int pos = -1;
+
+#if QT_CONFIG(regularexpression)
+ if (syntax == Wildcard)
+ pos = pathPrefix.indexOf(QRegularExpression(QLatin1String("[*?[]")));
+ else if (syntax == RegExp)
+ pos = sourcePath.indexOf(QRegularExpression(QLatin1String("[\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]")));
+#else
+ if (syntax == Wildcard || syntax == RegExp)
+ qWarning("Regular expression support is disabled in this build. Only fixed string can be searched");
+ return QList<QSslCertificate>();
+#endif
+
+ if (pos != -1) {
+ // there was a special char in the path so cut of the part containing that char.
+ pathPrefix = pathPrefix.left(pos);
+ const int lastIndexOfSlash = pathPrefix.lastIndexOf(QLatin1Char('/'));
+ if (lastIndexOfSlash != -1)
+ pathPrefix = pathPrefix.left(lastIndexOfSlash);
+ else
+ pathPrefix.clear();
+ } else {
+ // Check if the path is a file.
+ if (QFileInfo(sourcePath).isFile()) {
+ QFile file(sourcePath);
+ QIODevice::OpenMode openMode = QIODevice::ReadOnly;
+ if (format == QSsl::Pem)
+ openMode |= QIODevice::Text;
+ if (file.open(openMode))
+ return QSslCertificate::fromData(file.readAll(), format);
+ return QList<QSslCertificate>();
+ }
+ }
+
+ // Special case - if the prefix ends up being nothing, use "." instead.
+ int startIndex = 0;
+ if (pathPrefix.isEmpty()) {
+ pathPrefix = QLatin1String(".");
+ startIndex = 2;
+ }
+
+ // The path can be a file or directory.
+ QList<QSslCertificate> certs;
+
+#if QT_CONFIG(regularexpression)
+ if (syntax == Wildcard)
+ sourcePath = QRegularExpression::wildcardToRegularExpression(sourcePath);
+
+ QRegularExpression pattern(QRegularExpression::anchoredPattern(sourcePath));
+#endif
+
+ QDirIterator it(pathPrefix, QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ QString filePath = startIndex == 0 ? it.next() : it.next().mid(startIndex);
+
+#if QT_CONFIG(regularexpression)
+ if (!pattern.match(filePath).hasMatch())
+ continue;
+#else
+ if (sourcePath != filePath)
+ continue;
+#endif
+
+ QFile file(filePath);
+ QIODevice::OpenMode openMode = QIODevice::ReadOnly;
+ if (format == QSsl::Pem)
+ openMode |= QIODevice::Text;
+ if (file.open(openMode))
+ certs += QSslCertificate::fromData(file.readAll(), format);
+ }
+ return certs;
+}
/*!
Searches for and parses all certificates in \a device that are
diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h
index 69901b526c6..99937698881 100644
--- a/src/network/ssl/qsslcertificate.h
+++ b/src/network/ssl/qsslcertificate.h
@@ -84,6 +84,13 @@ public:
EmailAddress
};
+ enum PatternSyntax {
+ RegExp,
+ Wildcard,
+ FixedString
+ };
+
+
explicit QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
explicit QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem);
QSslCertificate(const QSslCertificate &other);
@@ -139,9 +146,20 @@ public:
QByteArray toDer() const;
QString toText() const;
- static QList<QSslCertificate> fromPath(
+#if QT_DEPRECATED_SINCE(5,15)
+ QT_DEPRECATED_X("Use the overload not using QRegExp") static QList<QSslCertificate> fromPath(
const QString &path, QSsl::EncodingFormat format = QSsl::Pem,
QRegExp::PatternSyntax syntax = QRegExp::FixedString);
+
+ static QList<QSslCertificate> fromPath(
+ const QString &path, QSsl::EncodingFormat format,
+ PatternSyntax syntax);
+#else
+ static QList<QSslCertificate> fromPath(
+ const QString &path, QSsl::EncodingFormat format = QSsl::Pem,
+ PatternSyntax syntax = FixedString);
+#endif
+
static QList<QSslCertificate> fromDevice(
QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
static QList<QSslCertificate> fromData(
diff --git a/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp b/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp
index f280e65c297..a15b93e31ee 100644
--- a/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp
+++ b/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp
@@ -93,7 +93,7 @@ bool performEffectiveAction(QAccessibleInterface *iface, const QString &actionNa
if (!success)
return false;
stepSize = (max - min) / 10; // this is pretty arbitrary, we just need to provide something
- const int typ = currentVariant.type();
+ const int typ = currentVariant.userType();
if (typ != QMetaType::Float && typ != QMetaType::Double) {
// currentValue is an integer. Round it up to ensure stepping in case it was below 1
stepSize = qCeil(stepSize);
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 7af5490963b..af49ad6407b 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -56,6 +56,8 @@
#include <QtGui/qguiapplication.h>
+#include <QtCore/private/qduplicatetracker_p.h>
+
#include <fontconfig/fontconfig.h>
#if FC_VERSION >= 20402
#include <fontconfig/fcfreetype.h>
@@ -778,9 +780,9 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont
FcPatternDestroy(pattern);
if (fontSet) {
- QSet<QString> duplicates;
+ QDuplicateTracker<QString> duplicates;
duplicates.reserve(fontSet->nfont + 1);
- duplicates.insert(family.toCaseFolded());
+ (void)duplicates.hasSeen(family.toCaseFolded());
for (int i = 0; i < fontSet->nfont; i++) {
FcChar8 *value = nullptr;
if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
@@ -788,9 +790,8 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont
// capitalize(value);
const QString familyName = QString::fromUtf8((const char *)value);
const QString familyNameCF = familyName.toCaseFolded();
- if (!duplicates.contains(familyNameCF)) {
+ if (!duplicates.hasSeen(familyNameCF)) {
fallbackFamilies << familyName;
- duplicates.insert(familyNameCF);
}
}
FcFontSetDestroy(fontSet);
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
index 0f34e1a4ca0..012edc82e44 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
@@ -2250,7 +2250,7 @@ bool AtSpiAdaptor::valueInterface(QAccessibleInterface *interface, const QString
qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::valueInterface does not implement " << function << message.path();
return false;
}
- if (!value.canConvert(QVariant::Double)) {
+ if (!value.canConvert(QMetaType::Double)) {
qCDebug(lcAccessibilityAtspi) << "AtSpiAdaptor::valueInterface: Could not convert to double: " << function;
}
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index 70d56160750..36d9e4e0659 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -517,7 +517,7 @@ QFont *QKdeThemePrivate::kdeFont(const QVariant &fontValue)
// causing recursion.
QString fontDescription;
QString fontFamily;
- if (fontValue.type() == QVariant::StringList) {
+ if (fontValue.userType() == QMetaType::QStringList) {
const QStringList list = fontValue.toStringList();
if (!list.isEmpty()) {
fontFamily = list.first();
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index cb82672acd3..6ad4597b19e 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -226,7 +226,7 @@ void QTuioHandler::process2DCurSource(const QOscMessage &message)
return;
}
- if (QMetaType::Type(arguments.at(1).type()) != QMetaType::QByteArray) {
+ if (QMetaType::Type(arguments.at(1).userType()) != QMetaType::QByteArray) {
qCWarning(lcTuioSource, "Ignoring malformed TUIO source message (bad argument type)");
return;
}
@@ -248,7 +248,7 @@ void QTuioHandler::process2DCurAlive(const QOscMessage &message)
QMap<int, QTuioCursor> newActiveCursors;
for (int i = 1; i < arguments.count(); ++i) {
- if (QMetaType::Type(arguments.at(i).type()) != QMetaType::Int) {
+ if (QMetaType::Type(arguments.at(i).userType()) != QMetaType::Int) {
qCWarning(lcTuioHandler) << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')';
return;
}
@@ -293,12 +293,12 @@ void QTuioHandler::process2DCurSet(const QOscMessage &message)
return;
}
- if (QMetaType::Type(arguments.at(1).type()) != QMetaType::Int ||
- QMetaType::Type(arguments.at(2).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(3).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(4).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(5).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(6).type()) != QMetaType::Float
+ if (QMetaType::Type(arguments.at(1).userType()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(2).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(3).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(4).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(5).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(6).userType()) != QMetaType::Float
) {
qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with bad types: " << arguments;
return;
@@ -391,7 +391,7 @@ void QTuioHandler::process2DObjSource(const QOscMessage &message)
return;
}
- if (QMetaType::Type(arguments.at(1).type()) != QMetaType::QByteArray) {
+ if (QMetaType::Type(arguments.at(1).userType()) != QMetaType::QByteArray) {
qCWarning(lcTuioSource, "Ignoring malformed TUIO source message (bad argument type)");
return;
}
@@ -413,7 +413,7 @@ void QTuioHandler::process2DObjAlive(const QOscMessage &message)
QMap<int, QTuioToken> newActiveTokens;
for (int i = 1; i < arguments.count(); ++i) {
- if (QMetaType::Type(arguments.at(i).type()) != QMetaType::Int) {
+ if (QMetaType::Type(arguments.at(i).userType()) != QMetaType::Int) {
qCWarning(lcTuioHandler) << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')';
return;
}
@@ -458,16 +458,16 @@ void QTuioHandler::process2DObjSet(const QOscMessage &message)
return;
}
- if (QMetaType::Type(arguments.at(1).type()) != QMetaType::Int ||
- QMetaType::Type(arguments.at(2).type()) != QMetaType::Int ||
- QMetaType::Type(arguments.at(3).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(4).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(5).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(6).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(7).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(8).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(9).type()) != QMetaType::Float ||
- QMetaType::Type(arguments.at(10).type()) != QMetaType::Float) {
+ if (QMetaType::Type(arguments.at(1).userType()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(2).userType()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(3).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(4).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(5).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(6).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(7).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(8).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(9).userType()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(10).userType()) != QMetaType::Float) {
qCWarning(lcTuioSet) << "Ignoring malformed TUIO set message with bad types: " << arguments;
return;
}
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 8c4fca0d297..90d5180fed5 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -334,7 +334,7 @@ void QCocoaMenu::setEnabled(bool enabled)
bool QCocoaMenu::isEnabled() const
{
- return m_attachedItem ? m_attachedItem.enabled : m_enabled && m_parentEnabled;
+ return m_enabled && m_parentEnabled;
}
void QCocoaMenu::setVisible(bool visible)
diff --git a/src/plugins/platforms/cocoa/qnsview_menus.mm b/src/plugins/platforms/cocoa/qnsview_menus.mm
index a55fd97eb71..b6cd8322823 100644
--- a/src/plugins/platforms/cocoa/qnsview_menus.mm
+++ b/src/plugins/platforms/cocoa/qnsview_menus.mm
@@ -84,7 +84,8 @@ static bool selectorIsCutCopyPaste(SEL selector)
menuParent = menuObject->menuParent();
}
- if (menubar && menubar->cocoaWindow() != self.platformWindow)
+ // we have no menubar parent for the application menu items, e.g About and Preferences
+ if (!menubar || menubar->cocoaWindow() != self.platformWindow)
return NO;
}
diff --git a/src/plugins/platforms/eglfs/api/api.pri b/src/plugins/platforms/eglfs/api/api.pri
index a6d81016b6f..68965b58d89 100644
--- a/src/plugins/platforms/eglfs/api/api.pri
+++ b/src/plugins/platforms/eglfs/api/api.pri
@@ -23,4 +23,13 @@ qtConfig(opengl) {
$$PWD/qeglfscontext_p.h
}
+qtConfig(vulkan) {
+ SOURCES += \
+ $$PWD/vulkan/qeglfsvulkaninstance.cpp \
+ $$PWD/vulkan/qeglfsvulkanwindow.cpp
+ HEADERS += \
+ $$PWD/vulkan/qeglfsvulkaninstance_p.h \
+ $$PWD/vulkan/qeglfsvulkanwindow_p.h
+}
+
INCLUDEPATH += $$PWD
diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
index 81bad45cd2f..e3145aa0b0b 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
@@ -52,6 +52,7 @@
#include <QScreen>
#include <QDir>
#if QT_CONFIG(regularexpression)
+# include <QFileInfo>
# include <QRegularExpression>
#endif
#include <QLoggingCategory>
@@ -144,7 +145,12 @@ int QEglFSDeviceIntegration::framebufferIndex() const
int fbIndex = 0;
#if QT_CONFIG(regularexpression)
QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
- QRegularExpressionMatch match = fbIndexRx.match(QString::fromLocal8Bit(fbDeviceName()));
+ QFileInfo fbinfo(QString::fromLocal8Bit(fbDeviceName()));
+ QRegularExpressionMatch match;
+ if (fbinfo.isSymLink())
+ match = fbIndexRx.match(fbinfo.symLinkTarget());
+ else
+ match = fbIndexRx.match(fbinfo.fileName());
if (match.hasMatch())
fbIndex = match.captured(1).toInt();
#endif
@@ -375,6 +381,14 @@ void *QEglFSDeviceIntegration::wlDisplay() const
return nullptr;
}
+#if QT_CONFIG(vulkan)
+QPlatformVulkanInstance *QEglFSDeviceIntegration::createPlatformVulkanInstance(QVulkanInstance *instance)
+{
+ Q_UNUSED(instance);
+ return nullptr;
+}
+#endif
+
EGLConfig QEglFSDeviceIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
{
class Chooser : public QEglConfigChooser {
diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
index 71ffb4c69a4..08447a40ea9 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
@@ -108,6 +108,10 @@ public:
virtual void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen);
virtual void *wlDisplay() const;
+#if QT_CONFIG(vulkan)
+ virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance);
+#endif
+
static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
};
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
index d9a3545a956..e26d984cc1f 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
@@ -247,6 +247,13 @@ QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOf
}
#endif // QT_NO_OPENGL
+#if QT_CONFIG(vulkan)
+QPlatformVulkanInstance *QEglFSIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const
+{
+ return qt_egl_device_integration()->createPlatformVulkanInstance(instance);
+}
+#endif
+
bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
// We assume that devices will have more and not less capabilities
@@ -283,7 +290,8 @@ enum ResourceType {
NativeDisplay,
XlibDisplay,
WaylandDisplay,
- EglSurface
+ EglSurface,
+ VkSurface
};
static int resourceType(const QByteArray &key)
@@ -296,7 +304,8 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("nativedisplay"),
QByteArrayLiteral("display"),
QByteArrayLiteral("server_wl_display"),
- QByteArrayLiteral("eglsurface")
+ QByteArrayLiteral("eglsurface"),
+ QByteArrayLiteral("vksurface")
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
@@ -364,6 +373,12 @@ void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWi
if (window && window->handle())
result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->surface());
break;
+#if QT_CONFIG(vulkan)
+ case VkSurface:
+ if (window && window->handle() && window->surfaceType() == QSurface::VulkanSurface)
+ result = static_cast<QEglFSWindow *>(window->handle())->vulkanSurfacePtr();
+ break;
+#endif
default:
break;
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
index 898b3228348..b293651ce71 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
@@ -86,6 +86,9 @@ public:
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
#endif
+#if QT_CONFIG(vulkan)
+ QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;
+#endif
bool hasCapability(QPlatformIntegration::Capability cap) const override;
QPlatformNativeInterface *nativeInterface() const override;
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
index be2a0630d3c..7bf74c25ee4 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
@@ -64,6 +64,7 @@ QT_BEGIN_NAMESPACE
class QOpenGLCompositorBackingStore;
class QPlatformTextureList;
+
#ifndef QT_NO_OPENGL
class Q_EGLFS_EXPORT QEglFSWindow : public QPlatformWindow, public QOpenGLCompositorWindow
#else
@@ -96,6 +97,9 @@ public:
EGLNativeWindowType eglWindow() const;
EGLSurface surface() const;
QEglFSScreen *screen() const override;
+#if QT_CONFIG(vulkan)
+ virtual void *vulkanSurfacePtr() { return nullptr; }
+#endif
bool hasNativeWindow() const { return m_flags.testFlag(HasNativeWindow); }
diff --git a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance.cpp b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance.cpp
new file mode 100644
index 00000000000..a75251ca5f3
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance.cpp
@@ -0,0 +1,280 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsvulkaninstance_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfshooks_p.h"
+#include <QLoggingCategory>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcEglDevDebug)
+
+QEglFSVulkanInstance::QEglFSVulkanInstance(QVulkanInstance *instance)
+ : m_instance(instance)
+{
+ loadVulkanLibrary(QStringLiteral("vulkan"));
+}
+
+void QEglFSVulkanInstance::createOrAdoptInstance()
+{
+ qCDebug(qLcEglDevDebug, "Creating Vulkan instance for VK_KHR_display");
+
+ const QByteArray extName = QByteArrayLiteral("VK_KHR_display");
+ initInstance(m_instance, { extName });
+ if (!m_vkInst)
+ return;
+ if (!enabledExtensions().contains(extName)) {
+ qWarning("Failed to enable VK_KHR_display extension");
+ return;
+ }
+
+#if VK_KHR_display
+ m_getPhysicalDeviceDisplayPropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetPhysicalDeviceDisplayPropertiesKHR");
+ m_getDisplayModePropertiesKHR = (PFN_vkGetDisplayModePropertiesKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetDisplayModePropertiesKHR");
+ m_getPhysicalDeviceDisplayPlanePropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
+
+ m_getDisplayPlaneSupportedDisplaysKHR = (PFN_vkGetDisplayPlaneSupportedDisplaysKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetDisplayPlaneSupportedDisplaysKHR");
+ m_getDisplayPlaneCapabilitiesKHR = (PFN_vkGetDisplayPlaneCapabilitiesKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetDisplayPlaneCapabilitiesKHR");
+
+ m_createDisplayPlaneSurfaceKHR = (PFN_vkCreateDisplayPlaneSurfaceKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkCreateDisplayPlaneSurfaceKHR");
+#endif
+
+ m_enumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkEnumeratePhysicalDevices");
+
+ // Use for first physical device, unless overridden by QT_VK_PHYSICAL_DEVICE_INDEX.
+ // This behavior matches what the Vulkan backend of QRhi would do.
+
+ uint32_t physDevCount = 0;
+ m_enumeratePhysicalDevices(m_vkInst, &physDevCount, nullptr);
+ if (!physDevCount) {
+ qWarning("No physical devices");
+ return;
+ }
+ QVarLengthArray<VkPhysicalDevice, 4> physDevs(physDevCount);
+ VkResult err = m_enumeratePhysicalDevices(m_vkInst, &physDevCount, physDevs.data());
+ if (err != VK_SUCCESS || !physDevCount) {
+ qWarning("Failed to enumerate physical devices: %d", err);
+ return;
+ }
+
+ if (qEnvironmentVariableIsSet("QT_VK_PHYSICAL_DEVICE_INDEX")) {
+ int requestedPhysDevIndex = qEnvironmentVariableIntValue("QT_VK_PHYSICAL_DEVICE_INDEX");
+ if (requestedPhysDevIndex >= 0 && uint32_t(requestedPhysDevIndex) < physDevCount)
+ m_physDev = physDevs[requestedPhysDevIndex];
+ }
+
+ if (m_physDev == VK_NULL_HANDLE)
+ m_physDev = physDevs[0];
+}
+
+bool QEglFSVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ QWindow *window)
+{
+ Q_UNUSED(physicalDevice);
+ Q_UNUSED(queueFamilyIndex);
+ Q_UNUSED(window);
+ return true;
+}
+
+VkSurfaceKHR QEglFSVulkanInstance::createSurface(QEglFSWindow *window)
+{
+#if VK_KHR_display
+ qCDebug(qLcEglDevDebug, "Creating VkSurfaceKHR via VK_KHR_display for window %p", (void *) window);
+
+ if (!m_physDev) {
+ qWarning("No physical device, cannot create surface");
+ return VK_NULL_HANDLE;
+ }
+
+ uint32_t displayCount = 0;
+ VkResult err = m_getPhysicalDeviceDisplayPropertiesKHR(m_physDev, &displayCount, nullptr);
+ if (err != VK_SUCCESS) {
+ qWarning("Failed to get display properties: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, "Display count: %u", displayCount);
+
+ QVarLengthArray<VkDisplayPropertiesKHR, 4> displayProps(displayCount);
+ m_getPhysicalDeviceDisplayPropertiesKHR(m_physDev, &displayCount, displayProps.data());
+
+ VkDisplayKHR display = VK_NULL_HANDLE;
+ VkDisplayModeKHR displayMode = VK_NULL_HANDLE;
+ uint32_t width = 0;
+ uint32_t height = 0;
+
+ for (uint32_t i = 0; i < displayCount; ++i) {
+ const VkDisplayPropertiesKHR &disp(displayProps[i]);
+ qCDebug(qLcEglDevDebug, "Display #%u:\n display: %p\n name: %s\n dimensions: %ux%u\n resolution: %ux%u",
+ i, (void *) disp.display, disp.displayName,
+ disp.physicalDimensions.width, disp.physicalDimensions.height,
+ disp.physicalResolution.width, disp.physicalResolution.height);
+
+ // Just pick the first display and the first mode.
+ if (i == 0)
+ display = disp.display;
+
+ uint32_t modeCount = 0;
+ if (m_getDisplayModePropertiesKHR(m_physDev, disp.display, &modeCount, nullptr) != VK_SUCCESS) {
+ qWarning("Failed to get modes for display");
+ continue;
+ }
+ QVarLengthArray<VkDisplayModePropertiesKHR, 16> modeProps(modeCount);
+ m_getDisplayModePropertiesKHR(m_physDev, disp.display, &modeCount, modeProps.data());
+ for (uint32_t j = 0; j < modeCount; ++j) {
+ const VkDisplayModePropertiesKHR &mode(modeProps[j]);
+ qCDebug(qLcEglDevDebug, " Mode #%u:\n mode: %p\n visibleRegion: %ux%u\n refreshRate: %u",
+ j, (void *) mode.displayMode,
+ mode.parameters.visibleRegion.width, mode.parameters.visibleRegion.height,
+ mode.parameters.refreshRate);
+ if (j == 0) {
+ displayMode = mode.displayMode;
+ width = mode.parameters.visibleRegion.width;
+ height = mode.parameters.visibleRegion.height;
+ }
+ }
+ }
+
+ if (display == VK_NULL_HANDLE || displayMode == VK_NULL_HANDLE) {
+ qWarning("Failed to choose display and mode");
+ return VK_NULL_HANDLE;
+ }
+ uint32_t planeCount = 0;
+ err = m_getPhysicalDeviceDisplayPlanePropertiesKHR(m_physDev, &planeCount, nullptr);
+ if (err != VK_SUCCESS) {
+ qWarning("Failed to get plane properties: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, "Plane count: %u", planeCount);
+
+ QVarLengthArray<VkDisplayPlanePropertiesKHR, 4> planeProps(planeCount);
+ m_getPhysicalDeviceDisplayPlanePropertiesKHR(m_physDev, &planeCount, planeProps.data());
+
+ uint32_t planeIndex = UINT_MAX;
+ for (uint32_t i = 0; i < planeCount; ++i) {
+ uint32_t supportedDisplayCount = 0;
+ err = m_getDisplayPlaneSupportedDisplaysKHR(m_physDev, i, &supportedDisplayCount, nullptr);
+ if (err != VK_SUCCESS) {
+ qWarning("Failed to query supported displays for plane: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ QVarLengthArray<VkDisplayKHR, 4> supportedDisplays(supportedDisplayCount);
+ m_getDisplayPlaneSupportedDisplaysKHR(m_physDev, i, &supportedDisplayCount, supportedDisplays.data());
+ qCDebug(qLcEglDevDebug, "Plane #%u supports %u displays, currently bound to display %p",
+ i, supportedDisplayCount, (void *) planeProps[i].currentDisplay);
+
+ VkDisplayPlaneCapabilitiesKHR caps;
+ err = m_getDisplayPlaneCapabilitiesKHR(m_physDev, displayMode, i, &caps);
+ if (err != VK_SUCCESS) {
+ qWarning("Failed to query plane capabilities: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, " supportedAlpha: %d (1=no, 2=global, 4=per pixel, 8=per pixel premul)\n"
+ " minSrc=%d, %d %ux%u\n"
+ " maxSrc=%d, %d %ux%u\n"
+ " minDst=%d, %d %ux%u\n"
+ " maxDst=%d, %d %ux%u",
+ int(caps.supportedAlpha),
+ caps.minSrcPosition.x, caps.minSrcPosition.y, caps.minSrcExtent.width, caps.minSrcExtent.height,
+ caps.maxSrcPosition.x, caps.maxSrcPosition.y, caps.maxSrcExtent.width, caps.maxSrcExtent.height,
+ caps.minDstPosition.x, caps.minDstPosition.y, caps.minDstExtent.width, caps.minDstExtent.height,
+ caps.maxDstPosition.x, caps.maxDstPosition.y, caps.maxDstExtent.width, caps.maxDstExtent.height);
+
+ // if the plane is not in use and supports our chosen display, use that plane
+ if (supportedDisplays.contains(display)
+ && (planeProps[i].currentDisplay == VK_NULL_HANDLE || planeProps[i].currentDisplay == display))
+ {
+ planeIndex = i;
+ }
+ }
+
+ if (planeIndex == UINT_MAX) {
+ qWarning("Failed to find a suitable plane");
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, "Using plane #%u", planeIndex);
+
+ VkDisplaySurfaceCreateInfoKHR surfaceCreateInfo = {};
+ surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR;
+ surfaceCreateInfo.displayMode = displayMode;
+ surfaceCreateInfo.planeIndex = planeIndex;
+ surfaceCreateInfo.planeStackIndex = planeProps[planeIndex].currentStackIndex;
+ surfaceCreateInfo.transform = VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR;
+ surfaceCreateInfo.globalAlpha = 1.0f;
+ surfaceCreateInfo.alphaMode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR;
+ surfaceCreateInfo.imageExtent = { width, height };
+
+ VkSurfaceKHR surface = VK_NULL_HANDLE;
+ err = m_createDisplayPlaneSurfaceKHR(m_vkInst, &surfaceCreateInfo, nullptr, &surface);
+ if (err != VK_SUCCESS || surface == VK_NULL_HANDLE) {
+ qWarning("Failed to create surface: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, "Created surface %p", (void *) surface);
+
+ return surface;
+
+#else
+ Q_UNUSED(window);
+ qWarning("VK_KHR_display support was not compiled in, cannot create surface");
+ return VK_NULL_HANDLE;
+#endif
+}
+
+void QEglFSVulkanInstance::presentAboutToBeQueued(QWindow *window)
+{
+ // support QT_QPA_EGLFS_FORCEVSYNC (i.MX8 with eglfs_viv)
+ qt_egl_device_integration()->waitForVSync(window->handle());
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h
new file mode 100644
index 00000000000..9d6d47f4392
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSVULKANINSTANCE_H
+#define QEGLFSVULKANINSTANCE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
+#include <QtVulkanSupport/private/qbasicvulkanplatforminstance_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSWindow;
+
+class Q_EGLFS_EXPORT QEglFSVulkanInstance : public QBasicPlatformVulkanInstance
+{
+public:
+ QEglFSVulkanInstance(QVulkanInstance *instance);
+
+ void createOrAdoptInstance() override;
+ bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override;
+ void presentAboutToBeQueued(QWindow *window) override;
+
+ VkSurfaceKHR createSurface(QEglFSWindow *window);
+
+private:
+ QVulkanInstance *m_instance;
+ VkPhysicalDevice m_physDev = VK_NULL_HANDLE;
+ PFN_vkEnumeratePhysicalDevices m_enumeratePhysicalDevices = nullptr;
+#if VK_KHR_display
+ PFN_vkGetPhysicalDeviceDisplayPropertiesKHR m_getPhysicalDeviceDisplayPropertiesKHR = nullptr;
+ PFN_vkGetDisplayModePropertiesKHR m_getDisplayModePropertiesKHR = nullptr;
+ PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR m_getPhysicalDeviceDisplayPlanePropertiesKHR = nullptr;
+ PFN_vkGetDisplayPlaneSupportedDisplaysKHR m_getDisplayPlaneSupportedDisplaysKHR = nullptr;
+ PFN_vkGetDisplayPlaneCapabilitiesKHR m_getDisplayPlaneCapabilitiesKHR = nullptr;
+ PFN_vkCreateDisplayPlaneSurfaceKHR m_createDisplayPlaneSurfaceKHR = nullptr;
+#endif
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow.cpp b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow.cpp
new file mode 100644
index 00000000000..ae41ca00b6d
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsvulkanwindow_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QEglFSVulkanWindow::QEglFSVulkanWindow(QWindow *window)
+ : QEglFSWindow(window),
+ m_surface(VK_NULL_HANDLE)
+{
+}
+
+QEglFSVulkanWindow::~QEglFSVulkanWindow()
+{
+ if (m_surface) {
+ QVulkanInstance *inst = window()->vulkanInstance();
+ if (inst)
+ static_cast<QEglFSVulkanInstance *>(inst->handle())->destroySurface(m_surface);
+ }
+}
+
+void *QEglFSVulkanWindow::vulkanSurfacePtr()
+{
+ if (m_surface)
+ return &m_surface;
+
+ QVulkanInstance *inst = window()->vulkanInstance();
+ if (!inst) {
+ qWarning("Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?");
+ return nullptr;
+ }
+ QEglFSVulkanInstance *eglfsInst = static_cast<QEglFSVulkanInstance *>(inst->handle());
+ m_surface = eglfsInst->createSurface(this);
+
+ return &m_surface;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow_p.h b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow_p.h
new file mode 100644
index 00000000000..492fb41ca4d
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSVULKANWINDOW_H
+#define QEGLFSVULKANWINDOW_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfsvulkaninstance_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q_EGLFS_EXPORT QEglFSVulkanWindow : public QEglFSWindow
+{
+public:
+ QEglFSVulkanWindow(QWindow *window);
+ ~QEglFSVulkanWindow();
+
+ void *vulkanSurfacePtr() override;
+
+private:
+ VkSurfaceKHR m_surface;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
index 2fc076ad0c1..5e1d28a3539 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
@@ -41,6 +41,11 @@
#include <EGL/eglvivante.h>
#include <QDebug>
+#if QT_CONFIG(vulkan)
+#include "private/qeglfsvulkaninstance_p.h"
+#include "private/qeglfsvulkanwindow_p.h"
+#endif
+
#ifdef Q_OS_INTEGRITY
extern "C" void VivanteInit(void);
#endif
@@ -97,4 +102,20 @@ void QEglFSVivIntegration::destroyNativeWindow(EGLNativeWindowType window)
fbDestroyWindow(window);
}
+#if QT_CONFIG(vulkan)
+
+QEglFSWindow *QEglFSVivIntegration::createWindow(QWindow *window) const
+{
+ if (window->surfaceType() == QSurface::VulkanSurface)
+ return new QEglFSVulkanWindow(window);
+ return QEglFSDeviceIntegration::createWindow(window);
+}
+
+QPlatformVulkanInstance *QEglFSVivIntegration::createPlatformVulkanInstance(QVulkanInstance *instance)
+{
+ return new QEglFSVulkanInstance(instance);
+}
+
+#endif // vulkan
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
index 4d1718afcf1..02b59c16b58 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
@@ -53,6 +53,12 @@ public:
void destroyNativeWindow(EGLNativeWindowType window) override;
EGLNativeDisplayType platformDisplay() const override;
+ // Vulkan support with VK_KHR_display
+#if QT_CONFIG(vulkan)
+ QEglFSWindow *createWindow(QWindow *window) const override;
+ QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) override;
+#endif
+
private:
QSize mScreenSize;
EGLNativeDisplayType mNativeDisplay;
diff --git a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
index 8bb7b614f10..bd02aea4d30 100644
--- a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
+++ b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
@@ -20,6 +20,9 @@ qtHaveModule(input_support-private): \
qtHaveModule(platformcompositor_support-private): \
QT += platformcompositor_support-private
+qtConfig(vulkan): \
+ QT += vulkan_support-private
+
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp
index d89cd78b285..ca8db9b2154 100644
--- a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp
+++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp
@@ -33,9 +33,11 @@
#include <emscripten.h>
+#if QT_CONFIG(thread)
#if (__EMSCRIPTEN_major__ > 1 || __EMSCRIPTEN_minor__ > 38 || __EMSCRIPTEN_minor__ == 38 && __EMSCRIPTEN_tiny__ >= 22)
# define EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD
#endif
+#endif
#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD
#include <emscripten/threading.h>
diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp
index ccd4e50a8b3..efcb0b6e6ed 100644
--- a/src/plugins/platforms/windows/qwindowsclipboard.cpp
+++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp
@@ -190,7 +190,7 @@ void QWindowsClipboard::releaseIData()
void QWindowsClipboard::registerViewer()
{
m_clipboardViewer = QWindowsContext::instance()->
- createDummyWindow(QStringLiteral("Qt5ClipboardView"), L"Qt5ClipboardView",
+ createDummyWindow(QStringLiteral("ClipboardView"), L"QtClipboardView",
qClipboardViewerWndProc, WS_OVERLAPPED);
// Try format listener API (Vista onwards) first.
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index d31352b8546..2591966d54a 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -42,6 +42,7 @@
#include "qwindowsintegration.h"
#include "qwindowswindow.h"
#include "qwindowskeymapper.h"
+#include "qwindowsnativeinterface.h"
#include "qwindowsmousehandler.h"
#include "qwindowspointerhandler.h"
#include "qtwindowsglobal.h"
@@ -72,6 +73,7 @@
#include <QtCore/qset.h>
#include <QtCore/qhash.h>
+#include <QtCore/qlibraryinfo.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qdebug.h>
#include <QtCore/qoperatingsystemversion.h>
@@ -276,8 +278,11 @@ struct QWindowsContextPrivate {
bool m_asyncExpose = false;
HPOWERNOTIFY m_powerNotification = nullptr;
HWND m_powerDummyWindow = nullptr;
+ static bool m_darkMode;
};
+bool QWindowsContextPrivate::m_darkMode = false;
+
QWindowsContextPrivate::QWindowsContextPrivate()
: m_oleInitializeResult(OleInitialize(nullptr))
{
@@ -292,6 +297,7 @@ QWindowsContextPrivate::QWindowsContextPrivate()
m_systemInfo |= QWindowsContext::SI_RTL_Extensions;
m_keyMapper.setUseRTLExtensions(true);
}
+ m_darkMode = QWindowsTheme::queryDarkMode();
if (FAILED(m_oleInitializeResult)) {
qWarning() << "QWindowsContext: OleInitialize() failed: "
<< QWindowsContext::comErrorString(m_oleInitializeResult);
@@ -426,7 +432,7 @@ bool QWindowsContext::initPowerNotificationHandler()
if (d->m_powerNotification)
return false;
- d->m_powerDummyWindow = createDummyWindow(QStringLiteral("QtPowerDummyWindow"), L"QtPowerDummyWindow", qWindowsPowerWindowProc);
+ d->m_powerDummyWindow = createDummyWindow(QStringLiteral("PowerDummyWindow"), L"QtPowerDummyWindow", qWindowsPowerWindowProc);
if (!d->m_powerDummyWindow)
return false;
@@ -484,6 +490,11 @@ void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiA
}
}
+bool QWindowsContext::isDarkMode()
+{
+ return QWindowsContextPrivate::m_darkMode;
+}
+
QWindowsContext *QWindowsContext::instance()
{
return m_instance;
@@ -536,6 +547,23 @@ void QWindowsContext::setKeyGrabber(QWindow *w)
d->m_keyMapper.setKeyGrabber(w);
}
+QString QWindowsContext::classNamePrefix()
+{
+ static QString result;
+ if (result.isEmpty()) {
+ QTextStream str(&result);
+ str << "Qt" << QT_VERSION_MAJOR << QT_VERSION_MINOR << QT_VERSION_PATCH;
+ if (QLibraryInfo::isDebugBuild())
+ str << 'd';
+#ifdef QT_NAMESPACE
+# define xstr(s) str(s)
+# define str(s) #s
+ str << xstr(QT_NAMESPACE);
+#endif
+ }
+ return result;
+}
+
// Window class registering code (from qapplication_win.cpp)
QString QWindowsContext::registerWindowClass(const QWindow *w)
@@ -567,8 +595,8 @@ QString QWindowsContext::registerWindowClass(const QWindow *w)
break;
}
// Create a unique name for the flag combination
- QString cname;
- cname += QLatin1String("Qt5QWindow");
+ QString cname = classNamePrefix();
+ cname += QLatin1String("QWindow");
switch (type) {
case Qt::Tool:
cname += QLatin1String("Tool");
@@ -878,7 +906,7 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
{
if (!wndProc)
wndProc = DefWindowProc;
- QString className = registerWindowClass(classNameIn, wndProc);
+ QString className = registerWindowClass(classNamePrefix() + classNameIn, wndProc);
return CreateWindowEx(0, reinterpret_cast<LPCWSTR>(className.utf16()),
windowName, style,
CW_USEDEFAULT, CW_USEDEFAULT,
@@ -1185,9 +1213,27 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
t->displayChanged();
QWindowsWindow::displayChanged();
return d->m_screenManager.handleDisplayChange(wParam, lParam);
- case QtWindows::SettingChangedEvent:
+ case QtWindows::SettingChangedEvent: {
QWindowsWindow::settingsChanged();
+ const bool darkMode = QWindowsTheme::queryDarkMode();
+ if (darkMode != QWindowsContextPrivate::m_darkMode) {
+ QWindowsContextPrivate::m_darkMode = darkMode;
+ auto nativeInterface =
+ static_cast<QWindowsNativeInterface *>(QWindowsIntegration::instance()->nativeInterface());
+ emit nativeInterface->darkModeChanged(darkMode);
+ const auto options = QWindowsIntegration::instance()->options();
+ if ((options & QWindowsIntegration::DarkModeWindowFrames) != 0) {
+ for (QWindowsWindow *w : d->m_windows)
+ w->setDarkBorder(QWindowsContextPrivate::m_darkMode);
+ }
+ if ((options & QWindowsIntegration::DarkModeStyle) != 0) {
+ QWindowsTheme::instance()->refresh();
+ for (QWindowsWindow *w : d->m_windows)
+ QWindowSystemInterface::handleThemeChange(w->window());
+ }
+ }
return d->m_screenManager.handleScreenChanges();
+ }
default:
break;
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index 8027f093897..1831ac6ec01 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -180,6 +180,7 @@ public:
int defaultDPI() const;
+ static QString classNamePrefix();
QString registerWindowClass(const QWindow *w);
QString registerWindowClass(QString cname, WNDPROC proc,
unsigned style = 0, HBRUSH brush = nullptr,
@@ -225,6 +226,8 @@ public:
void setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness);
static int processDpiAwareness();
+ static bool isDarkMode();
+
void setDetectAltGrModifier(bool a);
// Returns a combination of SystemInfoFlags
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index 59457f1720f..19de3d59393 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -80,10 +80,10 @@ QWindowsPixmapCursorCacheKey::QWindowsPixmapCursorCacheKey(const QCursor &c)
: bitmapCacheKey(c.pixmap().cacheKey()), maskCacheKey(0)
{
if (!bitmapCacheKey) {
- Q_ASSERT(c.bitmap());
- Q_ASSERT(c.mask());
- bitmapCacheKey = c.bitmap()->cacheKey();
- maskCacheKey = c.mask()->cacheKey();
+ Q_ASSERT(!c.bitmap(Qt::ReturnByValue).isNull());
+ Q_ASSERT(!c.mask(Qt::ReturnByValue).isNull());
+ bitmapCacheKey = c.bitmap(Qt::ReturnByValue).cacheKey();
+ maskCacheKey = c.mask(Qt::ReturnByValue).cacheKey();
}
}
@@ -169,9 +169,9 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
// Create a cursor from image and mask of the format QImage::Format_Mono.
static HCURSOR createBitmapCursor(const QCursor &cursor, qreal scaleFactor = 1)
{
- Q_ASSERT(cursor.shape() == Qt::BitmapCursor && cursor.bitmap());
- QImage bbits = cursor.bitmap()->toImage();
- QImage mbits = cursor.mask()->toImage();
+ Q_ASSERT(cursor.shape() == Qt::BitmapCursor && !cursor.bitmap(Qt::ReturnByValue).isNull());
+ QImage bbits = cursor.bitmap(Qt::ReturnByValue).toImage();
+ QImage mbits = cursor.mask(Qt::ReturnByValue).toImage();
scaleFactor /= bbits.devicePixelRatioF();
if (!qFuzzyCompare(scaleFactor, 1)) {
const QSize scaledSize = (QSizeF(bbits.size()) * scaleFactor).toSize();
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index d9521e7e086..7431f52e8ac 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -802,7 +802,7 @@ static HGLRC createContext(const QOpenGLStaticContext &staticContext,
static inline HWND createDummyGLWindow()
{
return QWindowsContext::instance()->
- createDummyWindow(QStringLiteral("QtOpenGLDummyWindow"),
+ createDummyWindow(QStringLiteral("OpenGLDummyWindow"),
L"OpenGLDummyWindow", nullptr, WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
}
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 32bd29a8429..4b4047ac0cd 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -219,6 +219,10 @@ static inline unsigned parseOptions(const QStringList &paramList,
options |= QWindowsIntegration::DontUseWMPointer;
} else if (param == u"reverse") {
options |= QWindowsIntegration::RtlEnabled;
+ } else if (param == u"darkmode=1") {
+ options |= QWindowsIntegration::DarkModeWindowFrames;
+ } else if (param == u"darkmode=2") {
+ options |= QWindowsIntegration::DarkModeWindowFrames | QWindowsIntegration::DarkModeStyle;
} else {
qWarning() << "Unknown option" << param;
}
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index b49d21022b7..1f16d137698 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -70,7 +70,9 @@ public:
NoNativeMenus = 0x200,
DontUseWMPointer = 0x400,
DetectAltGrModifier = 0x800,
- RtlEnabled = 0x1000
+ RtlEnabled = 0x1000,
+ DarkModeWindowFrames = 0x2000,
+ DarkModeStyle = 0x4000
};
explicit QWindowsIntegration(const QStringList &paramList);
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index d1d181d66e7..1195f15a597 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -47,6 +47,7 @@
#include "qwindowsopengltester.h"
#include "qwindowsintegration.h"
#include "qwindowsmime.h"
+#include "qwindowstheme.h"
#include "qwin10helpers.h"
#include <QtGui/qwindow.h>
@@ -316,4 +317,15 @@ QVariant QWindowsNativeInterface::gpuList() const
return result;
}
+bool QWindowsNativeInterface::isDarkMode() const
+{
+ return QWindowsContext::isDarkMode();
+}
+
+// Dark mode support level 2 (style)
+bool QWindowsNativeInterface::isDarkModeStyle() const
+{
+ return (QWindowsIntegration::instance()->options() & QWindowsIntegration::DarkModeStyle) != 0;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index ce395dc5a42..90ba7a44c97 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -65,6 +65,8 @@ class QWindowsNativeInterface : public QPlatformNativeInterface
{
Q_OBJECT
Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose)
+ Q_PROPERTY(bool darkMode READ isDarkMode STORED false NOTIFY darkModeChanged)
+ Q_PROPERTY(bool darkModeStyle READ isDarkModeStyle STORED false)
Q_PROPERTY(QVariant gpu READ gpu STORED false)
Q_PROPERTY(QVariant gpuList READ gpuList STORED false)
@@ -92,6 +94,9 @@ public:
bool asyncExpose() const;
void setAsyncExpose(bool value);
+ bool isDarkMode() const;
+ bool isDarkModeStyle() const;
+
QVariant gpu() const;
QVariant gpuList() const;
@@ -109,6 +114,9 @@ public:
QFunctionPointer platformFunction(const QByteArray &function) const override;
+Q_SIGNALS:
+ void darkModeChanged(bool);
+
private:
static QWindowsWindowFunctions::WindowActivationBehavior m_windowActivationBehavior;
};
diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
index 66c558df1ea..53562c87dd9 100644
--- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
+++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
@@ -168,7 +168,7 @@ static inline HWND createTrayIconMessageWindow()
return nullptr;
// Register window class in the platform plugin.
const QString className =
- ctx->registerWindowClass(QStringLiteral("QTrayIconMessageWindowClass"),
+ ctx->registerWindowClass(QWindowsContext::classNamePrefix() + QStringLiteral("TrayIconMessageWindowClass"),
qWindowsTrayIconWndProc);
const wchar_t windowName[] = L"QTrayIconMessageWindow";
return CreateWindowEx(0, reinterpret_cast<const wchar_t *>(className.utf16()),
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 010aea20682..325956b7ba7 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -63,6 +63,7 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
#include <QtCore/qtextstream.h>
+#include <QtCore/qoperatingsystemversion.h>
#include <QtCore/qsysinfo.h>
#include <QtCore/qcache.h>
#include <QtCore/qthread.h>
@@ -78,6 +79,7 @@
#include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h>
#include <private/qhighdpiscaling_p.h>
#include <private/qsystemlibrary_p.h>
+#include <private/qwinregistry_p.h>
#include <algorithm>
@@ -241,6 +243,15 @@ static bool shGetFileInfoBackground(const QString &fileName, DWORD attributes,
return result;
}
+// Dark Mode constants
+enum DarkModeColors : QRgb {
+ darkModeBtnHighlightRgb = 0xc0c0c0,
+ darkModeBtnShadowRgb = 0x808080,
+ darkModeHighlightRgb = 0x0055ff, // deviating from 0x800080
+ darkModeMenuHighlightRgb = darkModeHighlightRgb,
+ darkModeGrayTextRgb = 0x00ff00
+};
+
// from QStyle::standardPalette
static inline QPalette standardPalette()
{
@@ -258,23 +269,55 @@ static inline QPalette standardPalette()
return palette;
}
-static inline QPalette systemPalette()
+static void populateLightSystemBasePalette(QPalette &result)
{
- QPalette result = standardPalette();
result.setColor(QPalette::WindowText, getSysColor(COLOR_WINDOWTEXT));
- result.setColor(QPalette::Button, getSysColor(COLOR_BTNFACE));
- result.setColor(QPalette::Light, getSysColor(COLOR_BTNHIGHLIGHT));
+ const QColor btnFace = getSysColor(COLOR_BTNFACE);
+ result.setColor(QPalette::Button, btnFace);
+ const QColor btnHighlight = getSysColor(COLOR_BTNHIGHLIGHT);
+ result.setColor(QPalette::Light, btnHighlight);
result.setColor(QPalette::Dark, getSysColor(COLOR_BTNSHADOW));
result.setColor(QPalette::Mid, result.button().color().darker(150));
result.setColor(QPalette::Text, getSysColor(COLOR_WINDOWTEXT));
- result.setColor(QPalette::BrightText, getSysColor(COLOR_BTNHIGHLIGHT));
+ result.setColor(QPalette::BrightText, btnHighlight);
result.setColor(QPalette::Base, getSysColor(COLOR_WINDOW));
- result.setColor(QPalette::Window, getSysColor(COLOR_BTNFACE));
+ result.setColor(QPalette::Window, btnFace);
result.setColor(QPalette::ButtonText, getSysColor(COLOR_BTNTEXT));
result.setColor(QPalette::Midlight, getSysColor(COLOR_3DLIGHT));
result.setColor(QPalette::Shadow, getSysColor(COLOR_3DDKSHADOW));
result.setColor(QPalette::Highlight, getSysColor(COLOR_HIGHLIGHT));
result.setColor(QPalette::HighlightedText, getSysColor(COLOR_HIGHLIGHTTEXT));
+}
+
+static void populateDarkSystemBasePalette(QPalette &result)
+{
+ const QColor darkModeWindowText = Qt::white;
+ result.setColor(QPalette::WindowText, darkModeWindowText);
+ const QColor darkModebtnFace = Qt::black;
+ result.setColor(QPalette::Button, darkModebtnFace);
+ const QColor btnHighlight = QColor(darkModeBtnHighlightRgb);
+ result.setColor(QPalette::Light, btnHighlight);
+ result.setColor(QPalette::Dark, QColor(darkModeBtnShadowRgb));
+ result.setColor(QPalette::Mid, result.button().color().darker(150));
+ result.setColor(QPalette::Text, darkModeWindowText);
+ result.setColor(QPalette::BrightText, btnHighlight);
+ result.setColor(QPalette::Base, darkModebtnFace);
+ result.setColor(QPalette::Window, darkModebtnFace);
+ result.setColor(QPalette::ButtonText, darkModeWindowText);
+ result.setColor(QPalette::Midlight, darkModeWindowText);
+ result.setColor(QPalette::Shadow, darkModeWindowText);
+ result.setColor(QPalette::Highlight, QColor(darkModeHighlightRgb));
+ result.setColor(QPalette::HighlightedText, darkModeWindowText);
+}
+
+static QPalette systemPalette(bool light)
+{
+ QPalette result = standardPalette();
+ if (light)
+ populateLightSystemBasePalette(result);
+ else
+ populateDarkSystemBasePalette(result);
+
result.setColor(QPalette::Link, Qt::blue);
result.setColor(QPalette::LinkVisited, Qt::magenta);
result.setColor(QPalette::Inactive, QPalette::Button, result.button().color());
@@ -300,19 +343,19 @@ static inline QPalette systemPalette()
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
result.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
result.setColor(QPalette::Disabled, QPalette::Highlight,
- getSysColor(COLOR_HIGHLIGHT));
+ light ? getSysColor(COLOR_HIGHLIGHT) : QColor(darkModeHighlightRgb));
result.setColor(QPalette::Disabled, QPalette::HighlightedText,
- getSysColor(COLOR_HIGHLIGHTTEXT));
+ light ? getSysColor(COLOR_HIGHLIGHTTEXT) : QColor(Qt::white));
result.setColor(QPalette::Disabled, QPalette::Base,
result.window().color());
return result;
}
-static inline QPalette toolTipPalette(const QPalette &systemPalette)
+static inline QPalette toolTipPalette(const QPalette &systemPalette, bool light)
{
QPalette result(systemPalette);
- const QColor tipBgColor(getSysColor(COLOR_INFOBK));
- const QColor tipTextColor(getSysColor(COLOR_INFOTEXT));
+ const QColor tipBgColor = light ? getSysColor(COLOR_INFOBK) : QColor(Qt::black);
+ const QColor tipTextColor = light ? getSysColor(COLOR_INFOTEXT) : QColor(Qt::white);
result.setColor(QPalette::All, QPalette::Button, tipBgColor);
result.setColor(QPalette::All, QPalette::Window, tipBgColor);
@@ -337,12 +380,13 @@ static inline QPalette toolTipPalette(const QPalette &systemPalette)
return result;
}
-static inline QPalette menuPalette(const QPalette &systemPalette)
+static inline QPalette menuPalette(const QPalette &systemPalette, bool light)
{
QPalette result(systemPalette);
- const QColor menuColor(getSysColor(COLOR_MENU));
- const QColor menuTextColor(getSysColor(COLOR_MENUTEXT));
- const QColor disabled(getSysColor(COLOR_GRAYTEXT));
+ const QColor menuColor = light ? getSysColor(COLOR_MENU) : QColor(Qt::black);
+ const QColor menuTextColor = light ? getSysColor(COLOR_MENUTEXT) : QColor(Qt::white);
+ const QColor disabled = light
+ ? getSysColor(COLOR_GRAYTEXT) : QColor(darkModeGrayTextRgb);
// we might need a special color group for the result.
result.setColor(QPalette::Active, QPalette::Button, menuColor);
result.setColor(QPalette::Active, QPalette::Text, menuTextColor);
@@ -351,8 +395,10 @@ static inline QPalette menuPalette(const QPalette &systemPalette)
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false);
- result.setColor(QPalette::Disabled, QPalette::Highlight,
- getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT));
+ const QColor highlightColor = light
+ ? (getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT))
+ : QColor(darkModeMenuHighlightRgb);
+ result.setColor(QPalette::Disabled, QPalette::Highlight, highlightColor);
result.setColor(QPalette::Disabled, QPalette::HighlightedText, disabled);
result.setColor(QPalette::Disabled, QPalette::Button,
result.color(QPalette::Active, QPalette::Button));
@@ -373,12 +419,12 @@ static inline QPalette menuPalette(const QPalette &systemPalette)
return result;
}
-static inline QPalette *menuBarPalette(const QPalette &menuPalette)
+static inline QPalette *menuBarPalette(const QPalette &menuPalette, bool light)
{
QPalette *result = nullptr;
if (booleanSystemParametersInfo(SPI_GETFLATMENU, false)) {
result = new QPalette(menuPalette);
- const QColor menubar(getSysColor(COLOR_MENUBAR));
+ const QColor menubar(light ? getSysColor(COLOR_MENUBAR) : QColor(Qt::black));
result->setColor(QPalette::Active, QPalette::Button, menubar);
result->setColor(QPalette::Disabled, QPalette::Button, menubar);
result->setColor(QPalette::Inactive, QPalette::Button, menubar);
@@ -485,10 +531,26 @@ void QWindowsTheme::refreshPalettes()
if (!QGuiApplication::desktopSettingsAware())
return;
- m_palettes[SystemPalette] = new QPalette(systemPalette());
- m_palettes[ToolTipPalette] = new QPalette(toolTipPalette(*m_palettes[SystemPalette]));
- m_palettes[MenuPalette] = new QPalette(menuPalette(*m_palettes[SystemPalette]));
- m_palettes[MenuBarPalette] = menuBarPalette(*m_palettes[MenuPalette]);
+ const bool light =
+ !QWindowsContext::isDarkMode()
+ || (QWindowsIntegration::instance()->options() & QWindowsIntegration::DarkModeStyle) == 0;
+ m_palettes[SystemPalette] = new QPalette(systemPalette(light));
+ m_palettes[ToolTipPalette] = new QPalette(toolTipPalette(*m_palettes[SystemPalette], light));
+ m_palettes[MenuPalette] = new QPalette(menuPalette(*m_palettes[SystemPalette], light));
+ m_palettes[MenuBarPalette] = menuBarPalette(*m_palettes[MenuPalette], light);
+ if (!light) {
+ m_palettes[ButtonPalette] = new QPalette(*m_palettes[SystemPalette]);
+ m_palettes[ButtonPalette]->setColor(QPalette::Button, QColor(0x666666u));
+ const QColor checkBoxBlue(0x0078d7u);
+ const QColor white(Qt::white);
+ m_palettes[CheckBoxPalette] = new QPalette(*m_palettes[SystemPalette]);
+ m_palettes[CheckBoxPalette]->setColor(QPalette::Window, checkBoxBlue);
+ m_palettes[CheckBoxPalette]->setColor(QPalette::Base, checkBoxBlue);
+ m_palettes[CheckBoxPalette]->setColor(QPalette::Button, checkBoxBlue);
+ m_palettes[CheckBoxPalette]->setColor(QPalette::ButtonText, white);
+ m_palettes[RadioButtonPalette] = new QPalette(*m_palettes[CheckBoxPalette]);
+
+ }
}
void QWindowsTheme::clearFonts()
@@ -497,6 +559,12 @@ void QWindowsTheme::clearFonts()
std::fill(m_fonts, m_fonts + NFonts, nullptr);
}
+void QWindowsTheme::refresh()
+{
+ refreshPalettes();
+ refreshFonts();
+}
+
void QWindowsTheme::refreshFonts()
{
clearFonts();
@@ -946,6 +1014,23 @@ bool QWindowsTheme::useNativeMenus()
return result;
}
+bool QWindowsTheme::queryDarkMode()
+{
+ if (QOperatingSystemVersion::current()
+ < QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 17763)
+ || queryHighContrast()) {
+ return false;
+ }
+ const auto setting = QWinRegistryKey(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)")
+ .dwordValue(L"AppsUseLightTheme");
+ return setting.second && setting.first == 0;
+}
+
+bool QWindowsTheme::queryHighContrast()
+{
+ return booleanSystemParametersInfo(SPI_GETHIGHCONTRAST, false);
+}
+
QPlatformMenuItem *QWindowsTheme::createPlatformMenuItem() const
{
qCDebug(lcQpaMenus) << __FUNCTION__;
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
index 7a8c321da4d..af28f2878c6 100644
--- a/src/plugins/platforms/windows/qwindowstheme.h
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -84,13 +84,15 @@ public:
void showPlatformMenuBar() override;
static bool useNativeMenus();
+ static bool queryDarkMode();
+ static bool queryHighContrast();
void refreshFonts();
+ void refresh();
static const char *name;
private:
- void refresh() { refreshPalettes(); refreshFonts(); }
void clearPalettes();
void refreshPalettes();
void clearFonts();
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 04596b2d4dd..d22cc75647c 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -749,6 +749,11 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
}
}
+static inline bool shouldApplyDarkFrame(const QWindow *w)
+{
+ return w->isTopLevel() && !w->flags().testFlag(Qt::FramelessWindowHint);
+}
+
QWindowsWindowData
WindowCreationData::create(const QWindow *w, const WindowData &data, QString title) const
{
@@ -816,6 +821,12 @@ QWindowsWindowData
return result;
}
+ if (QWindowsContext::isDarkMode()
+ && (QWindowsIntegration::instance()->options() & QWindowsIntegration::DarkModeWindowFrames) != 0
+ && shouldApplyDarkFrame(w)) {
+ QWindowsWindow::setDarkBorderToWindow(result.hwnd, true);
+ }
+
if (mirrorParentWidth != 0) {
context->obtainedPos.setX(mirrorParentWidth - context->obtainedSize.width()
- context->obtainedPos.x());
@@ -2892,6 +2903,39 @@ bool QWindowsWindow::isTopLevel() const
return window()->isTopLevel() && !m_data.embedded;
}
+enum : WORD {
+ DwmwaUseImmersiveDarkMode = 20,
+ DwmwaUseImmersiveDarkModeBefore20h1 = 19
+};
+
+static bool queryDarkBorder(HWND hwnd)
+{
+ BOOL result = FALSE;
+ const bool ok =
+ SUCCEEDED(DwmGetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &result, sizeof(result)))
+ || SUCCEEDED(DwmGetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &result, sizeof(result)));
+ if (!ok)
+ qWarning("%s: Unable to retrieve dark window border setting.", __FUNCTION__);
+ return result == TRUE;
+}
+
+bool QWindowsWindow::setDarkBorderToWindow(HWND hwnd, bool d)
+{
+ const BOOL darkBorder = d ? TRUE : FALSE;
+ const bool ok =
+ SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &darkBorder, sizeof(darkBorder)))
+ || SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &darkBorder, sizeof(darkBorder)));
+ if (!ok)
+ qWarning("%s: Unable to set dark window border.", __FUNCTION__);
+ return ok;
+}
+
+void QWindowsWindow::setDarkBorder(bool d)
+{
+ if (shouldApplyDarkFrame(window()) && queryDarkBorder(m_data.hwnd) != d)
+ setDarkBorderToWindow(m_data.hwnd, d);
+}
+
QWindowsMenuBar *QWindowsWindow::menuBar() const
{
return m_menuBar.data();
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 1f8800272b7..7c37c6b1159 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -287,6 +287,9 @@ public:
HWND handle() const override { return m_data.hwnd; }
bool isTopLevel() const override;
+ static bool setDarkBorderToWindow(HWND hwnd, bool d);
+ void setDarkBorder(bool d);
+
QWindowsMenuBar *menuBar() const;
void setMenuBar(QWindowsMenuBar *mb);
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index c2d9d060fb4..fe9ddfece7d 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -123,8 +123,9 @@ protected:
return list.contains(format);
}
- QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const override
+ QVariant retrieveData_sys(const QString &fmt, QVariant::Type type) const override
{
+ auto requestedType = QMetaType::Type(type);
if (fmt.isEmpty() || isEmpty())
return QByteArray();
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 47d58fa8807..e76fc8bd401 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -114,7 +114,7 @@ protected:
QStringList formats_sys() const override;
QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const override;
- QVariant xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const;
+ QVariant xdndObtainData(const QByteArray &format, QMetaType::Type requestedType) const;
QXcbDrag *drag;
};
@@ -1248,11 +1248,11 @@ QXcbDropData::~QXcbDropData()
QVariant QXcbDropData::retrieveData_sys(const QString &mimetype, QVariant::Type requestedType) const
{
QByteArray mime = mimetype.toLatin1();
- QVariant data = xdndObtainData(mime, requestedType);
+ QVariant data = xdndObtainData(mime, QMetaType::Type(requestedType));
return data;
}
-QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const
+QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QMetaType::Type requestedType) const
{
QByteArray result;
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp
index d611f86a9ce..0b3219f792d 100644
--- a/src/plugins/platforms/xcb/qxcbmime.cpp
+++ b/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -159,7 +159,7 @@ QVector<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, con
}
QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &d, const QString &format,
- QVariant::Type requestedType, const QByteArray &encoding)
+ QMetaType::Type requestedType, const QByteArray &encoding)
{
QByteArray data = d;
QString atomName = mimeAtomToString(connection, a);
@@ -169,7 +169,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
&& atomName == format + QLatin1String(";charset=") + QLatin1String(encoding)) {
#if QT_CONFIG(textcodec)
- if (requestedType == QVariant::String) {
+ if (requestedType == QMetaType::QString) {
QTextCodec *codec = QTextCodec::codecForName(encoding);
if (codec)
return codec->toUnicode(data);
@@ -264,7 +264,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
return QVariant();
}
-xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,
+xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QMetaType::Type requestedType,
const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding)
{
requestedEncoding->clear();
@@ -297,7 +297,7 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString
// for string/text requests try to use a format with a well-defined charset
// first to avoid encoding problems
- if (requestedType == QVariant::String
+ if (requestedType == QMetaType::QString
&& format.startsWith(QLatin1String("text/"))
&& !format.contains(QLatin1String("charset="))) {
diff --git a/src/plugins/platforms/xcb/qxcbmime.h b/src/plugins/platforms/xcb/qxcbmime.h
index f2136ec9f44..dcb4f6b6c6a 100644
--- a/src/plugins/platforms/xcb/qxcbmime.h
+++ b/src/plugins/platforms/xcb/qxcbmime.h
@@ -60,8 +60,8 @@ public:
static bool mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeData *mimeData, QByteArray *data,
xcb_atom_t *atomFormat, int *dataFormat);
static QVariant mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &data, const QString &format,
- QVariant::Type requestedType, const QByteArray &encoding);
- static xcb_atom_t mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,
+ QMetaType::Type requestedType, const QByteArray &encoding);
+ static xcb_atom_t mimeAtomForFormat(QXcbConnection *connection, const QString &format, QMetaType::Type requestedType,
const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding);
};
diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
index d0928fe6ab7..7bacb59994e 100644
--- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
@@ -730,7 +730,7 @@ static char* createArrayBuffer(char *buffer, const QList<QVariant> &list,
if (curDim != dim) {
for(i = 0; i < list.size(); ++i) {
- if (list.at(i).type() != QVariant::List) { // dimensions mismatch
+ if (list.at(i).userType() != QVariant::List) { // dimensions mismatch
error = QLatin1String("Array dimensons mismatch. Fieldname: %1");
return 0;
}
@@ -1162,7 +1162,7 @@ bool QIBaseResult::gotoNext(QSqlCachedResult::ValueCache& row, int rowIdx)
// null value
QVariant v;
v.convert(qIBaseTypeName2(d->sqlda->sqlvar[i].sqltype, d->sqlda->sqlvar[i].sqlscale < 0));
- if(v.type() == QVariant::Double) {
+ if (v.userType() == QVariant::Double) {
switch(numericalPrecisionPolicy()) {
case QSql::LowPrecisionInt32:
v.convert(QVariant::Int);
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
index 0e195cfdb41..90a810d5163 100644
--- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
@@ -223,13 +223,13 @@ public:
{
QMyField()
: outField(0), nullIndicator(false), bufLength(0ul),
- myField(0), type(QVariant::Invalid)
+ myField(0), type(QMetaType::UnknownType)
{}
char *outField;
my_bool nullIndicator;
ulong bufLength;
MYSQL_FIELD *myField;
- QVariant::Type type;
+ QMetaType::Type type;
};
QVector<QMyField> fields;
@@ -263,25 +263,25 @@ static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type,
}
-static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
+static QMetaType::Type qDecodeMYSQLType(int mysqltype, uint flags)
{
- QVariant::Type type;
+ QMetaType::Type type;
switch (mysqltype) {
case FIELD_TYPE_TINY :
- type = static_cast<QVariant::Type>((flags & UNSIGNED_FLAG) ? QMetaType::UChar : QMetaType::Char);
+ type = (flags & UNSIGNED_FLAG) ? QMetaType::UChar : QMetaType::Char;
break;
case FIELD_TYPE_SHORT :
- type = static_cast<QVariant::Type>((flags & UNSIGNED_FLAG) ? QMetaType::UShort : QMetaType::Short);
+ type = (flags & UNSIGNED_FLAG) ? QMetaType::UShort : QMetaType::Short;
break;
case FIELD_TYPE_LONG :
case FIELD_TYPE_INT24 :
- type = (flags & UNSIGNED_FLAG) ? QVariant::UInt : QVariant::Int;
+ type = (flags & UNSIGNED_FLAG) ? QMetaType::UInt : QMetaType::Int;
break;
case FIELD_TYPE_YEAR :
- type = QVariant::Int;
+ type = QMetaType::Int;
break;
case FIELD_TYPE_LONGLONG :
- type = (flags & UNSIGNED_FLAG) ? QVariant::ULongLong : QVariant::LongLong;
+ type = (flags & UNSIGNED_FLAG) ? QMetaType::ULongLong : QMetaType::LongLong;
break;
case FIELD_TYPE_FLOAT :
case FIELD_TYPE_DOUBLE :
@@ -289,19 +289,19 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
#if defined(FIELD_TYPE_NEWDECIMAL)
case FIELD_TYPE_NEWDECIMAL:
#endif
- type = QVariant::Double;
+ type = QMetaType::Double;
break;
case FIELD_TYPE_DATE :
- type = QVariant::Date;
+ type = QMetaType::QDate;
break;
case FIELD_TYPE_TIME :
// A time field can be within the range '-838:59:59' to '838:59:59' so
// use QString instead of QTime since QTime is limited to 24 hour clock
- type = QVariant::String;
+ type = QMetaType::QString;
break;
case FIELD_TYPE_DATETIME :
case FIELD_TYPE_TIMESTAMP :
- type = QVariant::DateTime;
+ type = QMetaType::QDateTime;
break;
case FIELD_TYPE_STRING :
case FIELD_TYPE_VAR_STRING :
@@ -309,12 +309,12 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
case FIELD_TYPE_TINY_BLOB :
case FIELD_TYPE_MEDIUM_BLOB :
case FIELD_TYPE_LONG_BLOB :
- type = (flags & BINARY_FLAG) ? QVariant::ByteArray : QVariant::String;
+ type = (flags & BINARY_FLAG) ? QMetaType::QByteArray : QMetaType::QString;
break;
default:
case FIELD_TYPE_ENUM :
case FIELD_TYPE_SET :
- type = QVariant::String;
+ type = QMetaType::QString;
break;
}
return type;
@@ -323,7 +323,7 @@ static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags)
static QSqlField qToField(MYSQL_FIELD *field, QTextCodec *tc)
{
QSqlField f(toUnicode(tc, field->name),
- qDecodeMYSQLType(int(field->type), field->flags),
+ QVariant::Type(qDecodeMYSQLType(int(field->type), field->flags)),
toUnicode(tc, field->table));
f.setRequired(IS_NOT_NULL(field->flags));
f.setLength(field->length);
@@ -610,7 +610,7 @@ QVariant QMYSQLResult::data(int field)
QString val;
if (d->preparedQuery) {
if (f.nullIndicator)
- return QVariant(f.type);
+ return QVariant(QVariant::Type(f.type));
if (qIsInteger(f.type)) {
QVariant variant(f.type, f.outField);
@@ -622,34 +622,34 @@ QVariant QMYSQLResult::data(int field)
return variant;
}
- if (f.type != QVariant::ByteArray)
+ if (f.type != QMetaType::QByteArray)
val = toUnicode(d->drv_d_func()->tc, f.outField, f.bufLength);
} else {
if (d->row[field] == NULL) {
// NULL value
- return QVariant(f.type);
+ return QVariant(QVariant::Type(f.type));
}
fieldLength = mysql_fetch_lengths(d->result)[field];
- if (f.type != QVariant::ByteArray)
+ if (f.type != QMetaType::QByteArray)
val = toUnicode(d->drv_d_func()->tc, d->row[field], fieldLength);
}
switch (static_cast<int>(f.type)) {
- case QVariant::LongLong:
+ case QMetaType::LongLong:
return QVariant(val.toLongLong());
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return QVariant(val.toULongLong());
case QMetaType::Char:
case QMetaType::Short:
- case QVariant::Int:
+ case QMetaType::Int:
return QVariant(val.toInt());
case QMetaType::UChar:
case QMetaType::UShort:
- case QVariant::UInt:
+ case QMetaType::UInt:
return QVariant(val.toUInt());
- case QVariant::Double: {
+ case QMetaType::Double: {
QVariant v;
bool ok=false;
double dbl = val.toDouble(&ok);
@@ -673,13 +673,13 @@ QVariant QMYSQLResult::data(int field)
return v;
return QVariant();
}
- case QVariant::Date:
+ case QMetaType::QDate:
return qDateFromString(val);
- case QVariant::Time:
+ case QMetaType::QTime:
return qTimeFromString(val);
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return qDateTimeFromString(val);
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
QByteArray ba;
if (d->preparedQuery) {
@@ -689,7 +689,7 @@ QVariant QMYSQLResult::data(int field)
}
return QVariant(ba);
}
- case QVariant::String:
+ case QMetaType::QString:
default:
return QVariant(val);
}
@@ -867,21 +867,21 @@ void QMYSQLResult::virtual_hook(int id, void *data)
QSqlResult::virtual_hook(id, data);
}
-static MYSQL_TIME *toMySqlDate(QDate date, QTime time, QVariant::Type type)
+static MYSQL_TIME *toMySqlDate(QDate date, QTime time, int type)
{
- Q_ASSERT(type == QVariant::Time || type == QVariant::Date
- || type == QVariant::DateTime);
+ Q_ASSERT(type == QMetaType::QTime || type == QMetaType::QDate
+ || type == QMetaType::QDateTime);
MYSQL_TIME *myTime = new MYSQL_TIME;
memset(myTime, 0, sizeof(MYSQL_TIME));
- if (type == QVariant::Time || type == QVariant::DateTime) {
+ if (type == QMetaType::QTime || type == QMetaType::QDateTime) {
myTime->hour = time.hour();
myTime->minute = time.minute();
myTime->second = time.second();
myTime->second_part = time.msec() * 1000;
}
- if (type == QVariant::Date || type == QVariant::DateTime) {
+ if (type == QMetaType::QDate || type == QMetaType::QDateTime) {
myTime->year = date.year();
myTime->month = date.month();
myTime->day = date.day();
@@ -971,30 +971,30 @@ bool QMYSQLResult::exec()
currBind->length = 0;
currBind->is_unsigned = 0;
- switch (val.type()) {
- case QVariant::ByteArray:
+ switch (val.userType()) {
+ case QMetaType::QByteArray:
currBind->buffer_type = MYSQL_TYPE_BLOB;
currBind->buffer = const_cast<char *>(val.toByteArray().constData());
currBind->buffer_length = val.toByteArray().size();
break;
- case QVariant::Time:
- case QVariant::Date:
- case QVariant::DateTime: {
- MYSQL_TIME *myTime = toMySqlDate(val.toDate(), val.toTime(), val.type());
+ case QMetaType::QTime:
+ case QMetaType::QDate:
+ case QMetaType::QDateTime: {
+ MYSQL_TIME *myTime = toMySqlDate(val.toDate(), val.toTime(), val.userType());
timeVector.append(myTime);
currBind->buffer = myTime;
- switch(val.type()) {
- case QVariant::Time:
+ switch (val.userType()) {
+ case QMetaType::QTime:
currBind->buffer_type = MYSQL_TYPE_TIME;
myTime->time_type = MYSQL_TIMESTAMP_TIME;
break;
- case QVariant::Date:
+ case QMetaType::QDate:
currBind->buffer_type = MYSQL_TYPE_DATE;
myTime->time_type = MYSQL_TIMESTAMP_DATE;
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
currBind->buffer_type = MYSQL_TYPE_DATETIME;
myTime->time_type = MYSQL_TIMESTAMP_DATETIME;
break;
@@ -1004,32 +1004,32 @@ bool QMYSQLResult::exec()
currBind->buffer_length = sizeof(MYSQL_TIME);
currBind->length = 0;
break; }
- case QVariant::UInt:
- case QVariant::Int:
+ case QMetaType::UInt:
+ case QMetaType::Int:
currBind->buffer_type = MYSQL_TYPE_LONG;
currBind->buffer = data;
currBind->buffer_length = sizeof(int);
- currBind->is_unsigned = (val.type() != QVariant::Int);
+ currBind->is_unsigned = (val.userType() != QMetaType::Int);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
currBind->buffer_type = MYSQL_TYPE_TINY;
currBind->buffer = data;
currBind->buffer_length = sizeof(bool);
currBind->is_unsigned = false;
break;
- case QVariant::Double:
+ case QMetaType::Double:
currBind->buffer_type = MYSQL_TYPE_DOUBLE;
currBind->buffer = data;
currBind->buffer_length = sizeof(double);
break;
- case QVariant::LongLong:
- case QVariant::ULongLong:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
currBind->buffer_type = MYSQL_TYPE_LONGLONG;
currBind->buffer = data;
currBind->buffer_length = sizeof(qint64);
- currBind->is_unsigned = (val.type() == QVariant::ULongLong);
+ currBind->is_unsigned = (val.userType() == QMetaType::ULongLong);
break;
- case QVariant::String:
+ case QMetaType::QString:
default: {
QByteArray ba = fromUnicode(d->drv_d_func()->tc, val.toString());
stringVector.append(ba);
@@ -1548,16 +1548,16 @@ QString QMYSQLDriver::formatValue(const QSqlField &field, bool trimStrings) cons
if (field.isNull()) {
r = QStringLiteral("NULL");
} else {
- switch(field.type()) {
- case QVariant::Double:
+ switch (+field.type()) {
+ case QMetaType::Double:
r = QString::number(field.value().toDouble(), 'g', field.precision());
break;
- case QVariant::String:
+ case QMetaType::QString:
// Escape '\' characters
r = QSqlDriver::formatValue(field, trimStrings);
r.replace(QLatin1String("\\"), QLatin1String("\\\\"));
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
if (isOpen()) {
const QByteArray ba = field.value().toByteArray();
// buffer has to be at least length*2+1 bytes
diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index 7709b13cd15..33bad23e3b3 100644
--- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
@@ -1422,7 +1422,7 @@ bool QODBCResult::exec()
SQLLEN *ind = &indicators[i];
if (val.isNull())
*ind = SQL_NULL_DATA;
- switch (val.type()) {
+ switch (val.userType()) {
case QVariant::Date: {
QByteArray &ba = tmpStorage[i];
ba.resize(sizeof(DATE_STRUCT));
@@ -1694,7 +1694,7 @@ bool QODBCResult::exec()
return true;
for (i = 0; i < values.count(); ++i) {
- switch (values.at(i).type()) {
+ switch (values.at(i).userType()) {
case QVariant::Date: {
DATE_STRUCT ds = *((DATE_STRUCT *)const_cast<char *>(tmpStorage.at(i).constData()));
values[i] = QVariant(QDate(ds.year, ds.month, ds.day));
@@ -1735,7 +1735,7 @@ bool QODBCResult::exec()
break; }
}
if (indicators[i] == SQL_NULL_DATA)
- values[i] = QVariant(values[i].type());
+ values[i] = QVariant(QVariant::Type(values[i].userType()));
}
return true;
}
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index 5ef76eec212..009e8a39eff 100644
--- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -505,7 +505,7 @@ bool QSQLiteResult::exec()
if (value.isNull()) {
res = sqlite3_bind_null(d->stmt, i + 1);
} else {
- switch (value.type()) {
+ switch (value.userType()) {
case QVariant::ByteArray: {
const QByteArray *ba = static_cast<const QByteArray*>(value.constData());
res = sqlite3_bind_blob(d->stmt, i + 1, ba->constData(),
diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
index 5d2e8efd682..899e7f7c177 100644
--- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
@@ -225,9 +225,11 @@ static HRGN qt_hrgn_from_qregion(const QRegion &region)
*/
bool QWindowsXPStylePrivate::useXP(bool update)
{
- if (!update)
- return use_xp;
- return use_xp = IsThemeActive() && (IsAppThemed() || !QCoreApplication::instance());
+ if (update) {
+ use_xp = IsThemeActive() && (IsAppThemed() || !QCoreApplication::instance())
+ && !QWindowsStylePrivate::isDarkMode();
+ }
+ return use_xp;
}
/* \internal
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index adf4421c895..638476c2c13 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -611,30 +611,30 @@ QString QSqlDriver::formatValue(const QSqlField &field, bool trimStrings) const
if (field.isNull())
r = nullTxt;
else {
- switch (field.type()) {
- case QVariant::Int:
- case QVariant::UInt:
- if (field.value().type() == QVariant::Bool)
+ switch (+field.type()) {
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ if (field.value().userType() == QMetaType::Bool)
r = field.value().toBool() ? QLatin1String("1") : QLatin1String("0");
else
r = field.value().toString();
break;
#if QT_CONFIG(datestring)
- case QVariant::Date:
+ case QMetaType::QDate:
if (field.value().toDate().isValid())
r = QLatin1Char('\'') + field.value().toDate().toString(Qt::ISODate)
+ QLatin1Char('\'');
else
r = nullTxt;
break;
- case QVariant::Time:
+ case QMetaType::QTime:
if (field.value().toTime().isValid())
r = QLatin1Char('\'') + field.value().toTime().toString(Qt::ISODate)
+ QLatin1Char('\'');
else
r = nullTxt;
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
if (field.value().toDateTime().isValid())
r = QLatin1Char('\'') +
field.value().toDateTime().toString(Qt::ISODate) + QLatin1Char('\'');
@@ -642,8 +642,8 @@ QString QSqlDriver::formatValue(const QSqlField &field, bool trimStrings) const
r = nullTxt;
break;
#endif
- case QVariant::String:
- case QVariant::Char:
+ case QMetaType::QString:
+ case QMetaType::QChar:
{
QString result = field.value().toString();
if (trimStrings) {
@@ -657,10 +657,10 @@ QString QSqlDriver::formatValue(const QSqlField &field, bool trimStrings) const
r = QLatin1Char('\'') + result + QLatin1Char('\'');
break;
}
- case QVariant::Bool:
+ case QMetaType::Bool:
r = QString::number(field.value().toBool());
break;
- case QVariant::ByteArray : {
+ case QMetaType::QByteArray : {
if (hasFeature(BLOB)) {
QByteArray ba = field.value().toByteArray();
QString res;
diff --git a/src/sql/kernel/qsqlfield.cpp b/src/sql/kernel/qsqlfield.cpp
index 5a6d173b3bd..86a22bae106 100644
--- a/src/sql/kernel/qsqlfield.cpp
+++ b/src/sql/kernel/qsqlfield.cpp
@@ -48,7 +48,7 @@ class QSqlFieldPrivate
public:
QSqlFieldPrivate(const QString &name,
QVariant::Type type, const QString &tableName) :
- ref(1), nm(name), table(tableName), def(QVariant()), type(type),
+ ref(1), nm(name), table(tableName), def(QVariant()), type(QMetaType::Type(type)),
req(QSqlField::Unknown), len(-1), prec(-1), tp(-1),
ro(false), gen(true), autoval(false)
{}
@@ -86,7 +86,7 @@ public:
QString nm;
QString table;
QVariant def;
- QVariant::Type type;
+ QMetaType::Type type;
QSqlField::RequiredStatus req;
int len;
int prec;
@@ -399,7 +399,7 @@ QString QSqlField::name() const
*/
QVariant::Type QSqlField::type() const
{
- return d->type;
+ return QVariant::Type(d->type);
}
/*!
@@ -411,12 +411,11 @@ QVariant::Type QSqlField::type() const
void QSqlField::setType(QVariant::Type type)
{
detach();
- d->type = type;
+ d->type = QMetaType::Type(type);
if (!val.isValid())
val = QVariant(type);
}
-
/*!
Returns \c true if the field's value is read-only; otherwise returns
false.
@@ -526,7 +525,7 @@ bool QSqlField::isGenerated() const
*/
bool QSqlField::isValid() const
{
- return d->type != QVariant::Invalid;
+ return d->type != QMetaType::UnknownType;
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/sql/kernel/qsqlfield.h b/src/sql/kernel/qsqlfield.h
index 8650ba8715f..892420d26ef 100644
--- a/src/sql/kernel/qsqlfield.h
+++ b/src/sql/kernel/qsqlfield.h
@@ -55,7 +55,7 @@ public:
enum RequiredStatus { Unknown = -1, Optional = 0, Required = 1 };
explicit QSqlField(const QString& fieldName = QString(),
- QVariant::Type type = QVariant::Invalid);
+ QVariant::Type type = {});
QSqlField(const QString &fieldName, QVariant::Type type,
const QString &tableName);
diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp
index cc91c6d0ed7..a41b3d8424c 100644
--- a/src/sql/kernel/qsqlresult.cpp
+++ b/src/sql/kernel/qsqlresult.cpp
@@ -645,7 +645,7 @@ bool QSqlResult::exec()
for (i = d->holders.count() - 1; i >= 0; --i) {
holder = d->holders.at(i).holderName;
val = d->values.value(d->indexes.value(holder).value(0,-1));
- QSqlField f(QLatin1String(""), val.type());
+ QSqlField f(QLatin1String(""), QVariant::Type(val.userType()));
f.setValue(val);
query = query.replace(d->holders.at(i).holderPos,
holder.length(), driver()->formatValue(f));
@@ -659,7 +659,7 @@ bool QSqlResult::exec()
if (i == -1)
continue;
QVariant var = d->values.value(idx);
- QSqlField f(QLatin1String(""), var.type());
+ QSqlField f(QLatin1String(""), QVariant::Type(var.userType()));
if (var.isNull())
f.clear();
else
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 3b1ffb389e4..0298ff96e3f 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -218,7 +218,7 @@ template<> inline char *toString(const QVariant &v)
vstring.append(type);
if (!v.isNull()) {
vstring.append(',');
- if (v.canConvert(QVariant::String)) {
+ if (v.canConvert(QMetaType::QString)) {
vstring.append(v.toString().toLocal8Bit());
}
else {
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index f3ebf343c51..27767407847 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -152,7 +152,7 @@ namespace QTest {
inline bool matches(QtMsgType tp, const QString &message) const
{
return tp == type
- && (pattern.type() == QVariant::String ?
+ && (pattern.userType() == QMetaType::QString ?
stringsMatch(pattern.toString(), message) :
#if QT_CONFIG(regularexpression)
pattern.toRegularExpression().match(message).hasMatch());
@@ -292,7 +292,7 @@ void QTestLog::printUnhandledIgnoreMessages()
QString message;
QTest::IgnoreResultList *list = QTest::ignoreResultList;
while (list) {
- if (list->pattern.type() == QVariant::String) {
+ if (list->pattern.userType() == QMetaType::QString) {
message = QStringLiteral("Did not receive message: \"") + list->pattern.toString() + QLatin1Char('"');
} else {
#if QT_CONFIG(regularexpression)
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 43bbe5ad02f..f41b0e8ba48 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -854,6 +854,8 @@ void Generator::generateProperties()
flags |= Constant;
if (p.final)
flags |= Final;
+ if (p.required)
+ flags |= Required;
fprintf(out, " %4d, ", stridx(p.name));
generateTypeInfo(p.type);
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 2fb8c8dee32..625725e5a1d 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -1254,6 +1254,9 @@ void Moc::createPropertyDef(PropertyDef &propDef)
} else if(l[0] == 'F' && l == "FINAL") {
propDef.final = true;
continue;
+ } else if (l[0] == 'R' && l == "REQUIRED") {
+ propDef.required = true;
+ continue;
}
QByteArray v, v2;
@@ -1986,6 +1989,7 @@ QJsonObject PropertyDef::toJson() const
prop[QLatin1String("constant")] = constant;
prop[QLatin1String("final")] = final;
+ prop[QLatin1String("required")] = required;
if (revision > 0)
prop[QLatin1String("revision")] = revision;
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index 91a03a767f7..4d3d32a6ac7 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -138,6 +138,7 @@ struct PropertyDef
int revision = 0;
bool constant = false;
bool final = false;
+ bool required = false;
QJsonObject toJson() const;
};
diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
index 81ebafad790..768594efb46 100644
--- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
+++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
@@ -115,7 +115,7 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
.arg(typeNameToXml(typeName));
// do we need to describe this argument?
- if (QDBusMetaType::signatureToType(typeName) == QVariant::Invalid)
+ if (QDBusMetaType::signatureToType(typeName) == QMetaType::UnknownType)
xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
.arg(typeNameToXml(mm.normalizedType.constData()));
} else {
@@ -159,7 +159,7 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) {
isOutput ? QLatin1String("out") : QLatin1String("in"));
// do we need to describe this argument?
- if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
+ if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) {
const char *typeName = QMetaType::typeName(types.at(j));
xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
.arg(isOutput ? QLatin1String("Out") : QLatin1String("In"))
@@ -225,7 +225,7 @@ static QString generateInterfaceXml(const ClassDef *mo)
QLatin1String(signature),
QLatin1String(accessvalues[access]));
- if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) {
+ if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) {
retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
.arg(typeNameToXml(mp.type.constData()));
} else {
diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
index 69d46632d2e..04932651645 100644
--- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
+++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
@@ -210,7 +210,7 @@ static QString classNameForInterface(const QString &interface, ClassType classTy
static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection::Annotations &annotations, int paramId = -1, const char *direction = "Out", bool isSignal = false)
{
int type = QDBusMetaType::signatureToType(signature.toLatin1());
- if (type == QVariant::Invalid) {
+ if (type == QMetaType::UnknownType) {
QString annotationName = QString::fromLatin1("org.qtproject.QtDBus.QtTypeName");
if (paramId >= 0)
annotationName += QString::fromLatin1(".%1%2").arg(QLatin1String(direction)).arg(paramId);
diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
index 99d87e2e46f..236d1d4159c 100644
--- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
@@ -17,3 +17,14 @@ endif()
include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5Widgets_AccessibleFactory.cmake\" OPTIONAL)
set(Qt5Widgets_UIC_EXECUTABLE Qt5::uic)
+
+# Create versionless tool targets.
+foreach(__qt_tool uic)
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::${__qt_tool}
+ AND TARGET Qt5::${__qt_tool})
+ add_executable(Qt::${__qt_tool} IMPORTED)
+ get_target_property(__qt_imported_location Qt5::${__qt_tool} IMPORTED_LOCATION)
+ set_target_properties(Qt::${__qt_tool}
+ PROPERTIES IMPORTED_LOCATION \"${__qt_imported_location}\")
+ endif()
+endforeach()
diff --git a/src/widgets/Qt5WidgetsMacros.cmake b/src/widgets/Qt5WidgetsMacros.cmake
index 21e73d4f0cc..35d2a2dc546 100644
--- a/src/widgets/Qt5WidgetsMacros.cmake
+++ b/src/widgets/Qt5WidgetsMacros.cmake
@@ -66,3 +66,15 @@ function(qt5_wrap_ui outfiles )
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
+
+# This will override the CMake upstream command, because that one is for Qt 3.
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_wrap_ui outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_wrap_ui("${outfiles}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_wrap_ui("${outfiles}" ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index 9dbbe9c6086..107fd729fe7 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -76,6 +76,9 @@
#include <qlineedit.h>
#include <private/qlineedit_p.h>
#endif
+#ifndef QT_NO_PICTURE
+#include <QtGui/qpicture.h>
+#endif
#include <qstyle.h>
#include <qstyleoption.h>
#include <qtextdocument.h>
@@ -431,10 +434,10 @@ QAccessible::Role QAccessibleDisplay::role() const
#if QT_CONFIG(label)
QLabel *l = qobject_cast<QLabel*>(object());
if (l) {
- if (l->pixmap())
+ if (!l->pixmap(Qt::ReturnByValue).isNull())
return QAccessible::Graphic;
#ifndef QT_NO_PICTURE
- if (l->picture())
+ if (!l->picture(Qt::ReturnByValue).isNull())
return QAccessible::Graphic;
#endif
#if QT_CONFIG(movie)
@@ -558,10 +561,7 @@ QSize QAccessibleDisplay::imageSize() const
#endif
return QSize();
#if QT_CONFIG(label)
- const QPixmap *pixmap = label->pixmap();
- if (!pixmap)
- return QSize();
- return pixmap->size();
+ return label->pixmap(Qt::ReturnByValue).size();
#endif
}
@@ -574,8 +574,7 @@ QPoint QAccessibleDisplay::imagePosition() const
#endif
return QPoint();
#if QT_CONFIG(label)
- const QPixmap *pixmap = label->pixmap();
- if (!pixmap)
+ if (label->pixmap(Qt::ReturnByValue).isNull())
return QPoint();
return QPoint(label->mapToGlobal(label->pos()));
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 854fee6e33a..4e7a4a65e39 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -305,7 +305,7 @@ void QMessageBoxPrivate::setupLayout()
Q_Q(QMessageBox);
delete q->layout();
QGridLayout *grid = new QGridLayout;
- bool hasIcon = iconLabel->pixmap() && !iconLabel->pixmap()->isNull();
+ bool hasIcon = !iconLabel->pixmap(Qt::ReturnByValue).isNull();
if (hasIcon)
grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
@@ -1323,9 +1323,7 @@ void QMessageBox::setIcon(Icon icon)
QPixmap QMessageBox::iconPixmap() const
{
Q_D(const QMessageBox);
- if (d->iconLabel && d->iconLabel->pixmap())
- return *d->iconLabel->pixmap();
- return QPixmap();
+ return d->iconLabel->pixmap(Qt::ReturnByValue);
}
void QMessageBox::setIconPixmap(const QPixmap &pixmap)
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index dfb707eda05..4272b612ec1 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -163,7 +163,7 @@ bool QUrlModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
*/
bool QUrlModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
- if (value.type() == QVariant::Url) {
+ if (value.userType() == QMetaType::QUrl) {
QUrl url = value.toUrl();
QModelIndex dirIndex = fileSystemModel->index(url.toLocalFile());
//On windows the popup display the "C:\", convert to nativeSeparators
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index a4789f40b15..87f6875c8c6 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -452,8 +452,8 @@ public:
}
QSize minimumSizeHint() const override {
- if (pixmap() && !pixmap()->isNull())
- return pixmap()->size() / pixmap()->devicePixelRatio();
+ if (!pixmap(Qt::ReturnByValue).isNull())
+ return pixmap(Qt::ReturnByValue).size() / pixmap(Qt::ReturnByValue).devicePixelRatio();
return QFrame::minimumSizeHint();
}
@@ -2924,7 +2924,7 @@ void QWizard::setDefaultProperty(const char *className, const char *property,
or when the watermark is not provided the side widget is displayed
on the left side of the wizard.
- Passing 0 shows no side widget.
+ Passing \nullptr shows no side widget.
When the \a widget is not \nullptr the wizard reparents it.
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
index 5e1f0883e74..a7bce6d378b 100644
--- a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
//! [3]
QSize MyWidget::sizeHint() const
{
- return QSize(80, 25).expandedTo(QApplication::globalStrut());
+ return QSize(80, 25);
}
//! [3]
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index b410ba82c27..26f5a3baf25 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -10506,13 +10506,13 @@ QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const
v = int(inputMethodHints());
else if (dd->control)
v = dd->control->inputMethodQuery(query, QVariant());
- if (v.type() == QVariant::RectF)
+ if (v.userType() == QMetaType::QRectF)
v = v.toRectF().translated(-dd->controlOffset());
- else if (v.type() == QVariant::PointF)
+ else if (v.userType() == QMetaType::QPointF)
v = v.toPointF() - dd->controlOffset();
- else if (v.type() == QVariant::Rect)
+ else if (v.userType() == QMetaType::QRect)
v = v.toRect().translated(-dd->controlOffset().toPoint());
- else if (v.type() == QVariant::Point)
+ else if (v.userType() == QMetaType::QPoint)
v = v.toPoint() - dd->controlOffset().toPoint();
return v;
}
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 4d4958c674c..a9a57c57fac 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -570,8 +570,8 @@ QGraphicsProxyWidget::~QGraphicsProxyWidget()
After this function returns, QGraphicsProxyWidget will keep its state
synchronized with that of \a widget whenever possible.
- If a widget is already embedded by this proxy when this function is
- called, that widget will first be automatically unembedded. Passing 0 for
+ If a widget is already embedded by this proxy when this function is called,
+ that widget will first be automatically unembedded. Passing \nullptr for
the \a widget argument will only unembed the widget, and the ownership of
the currently embedded widget will be passed on to the caller.
Every child widget that are embedded will also be embedded and their proxy
@@ -1441,17 +1441,17 @@ QVariant QGraphicsProxyWidget::inputMethodQuery(Qt::InputMethodQuery query) cons
focusWidget = d->widget;
QVariant v = focusWidget->inputMethodQuery(query);
QPointF focusWidgetPos = subWidgetRect(focusWidget).topLeft();
- switch (v.type()) {
- case QVariant::RectF:
+ switch (v.userType()) {
+ case QMetaType::QRectF:
v = v.toRectF().translated(focusWidgetPos);
break;
- case QVariant::PointF:
+ case QMetaType::QPointF:
v = v.toPointF() + focusWidgetPos;
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
v = v.toRect().translated(focusWidgetPos.toPoint());
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
v = v.toPoint() + focusWidgetPos.toPoint();
break;
default:
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 1c6e68def14..1cb24f74b6c 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -3190,13 +3190,13 @@ QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const
return QVariant();
const QTransform matrix = d->focusItem->sceneTransform();
QVariant value = d->focusItem->inputMethodQuery(query);
- if (value.type() == QVariant::RectF)
+ if (value.userType() == QMetaType::QRectF)
value = matrix.mapRect(value.toRectF());
- else if (value.type() == QVariant::PointF)
+ else if (value.userType() == QMetaType::QPointF)
value = matrix.map(value.toPointF());
- else if (value.type() == QVariant::Rect)
+ else if (value.userType() == QMetaType::QRect)
value = matrix.mapRect(value.toRect());
- else if (value.type() == QVariant::Point)
+ else if (value.userType() == QMetaType::QPoint)
value = matrix.map(value.toPoint());
return value;
}
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 7589a1ebbd5..102f3e894fa 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -963,7 +963,7 @@ static inline void QRect_unite(QRect *rect, const QRect &other)
/*
Calling this function results in update rects being clipped to the item's
bounding rect. Note that updates prior to this function call is not clipped.
- The clip is removed by passing 0.
+ The clip is removed by passing \nullptr.
*/
void QGraphicsViewPrivate::setUpdateClip(QGraphicsItem *item)
{
@@ -2589,13 +2589,13 @@ QVariant QGraphicsView::inputMethodQuery(Qt::InputMethodQuery query) const
return QVariant();
QVariant value = d->scene->inputMethodQuery(query);
- if (value.type() == QVariant::RectF)
+ if (value.userType() == QMetaType::QRectF)
value = d->mapRectFromScene(value.toRectF());
- else if (value.type() == QVariant::PointF)
+ else if (value.userType() == QMetaType::QPointF)
value = mapFromScene(value.toPointF());
- else if (value.type() == QVariant::Rect)
+ else if (value.userType() == QMetaType::QRect)
value = d->mapRectFromScene(value.toRect()).toRect();
- else if (value.type() == QVariant::Point)
+ else if (value.userType() == QMetaType::QPoint)
value = mapFromScene(value.toPoint());
return value;
}
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index bb47881c030..c5b22b56679 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -585,27 +585,27 @@ QString QAbstractItemDelegatePrivate::textForRole(Qt::ItemDataRole role, const Q
case QMetaType::Float:
text = locale.toString(value.toFloat());
break;
- case QVariant::Double:
+ case QMetaType::Double:
text = locale.toString(value.toDouble(), 'g', precision);
break;
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
text = locale.toString(value.toLongLong());
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
text = locale.toString(value.toULongLong());
break;
- case QVariant::Date:
+ case QMetaType::QDate:
text = locale.toString(value.toDate(), formatType);
break;
- case QVariant::Time:
+ case QMetaType::QTime:
text = locale.toString(value.toTime(), formatType);
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
text = locale.toString(value.toDateTime(), formatType);
break;
- case QVariant::Type(QMetaType::QJsonValue): {
+ case QMetaType::QJsonValue: {
const QJsonValue val = value.toJsonValue();
if (val.isBool()) {
text = QVariant(val.toBool()).toString();
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 0e54cf235fa..2524d4acfa8 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -2339,7 +2339,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
QVariant variant;
if (d->model)
variant = d->model->data(currentIndex(), Qt::DisplayRole);
- if (variant.type() == QVariant::String)
+ if (variant.userType() == QMetaType::QString)
QGuiApplication::clipboard()->setText(variant.toString());
event->accept();
}
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 790f3054634..84e2fd72a96 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -3660,7 +3660,7 @@ void QHeaderViewPrivate::flipSortIndicator(int section)
sortOrder = (sortIndicatorOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder;
} else {
const QVariant value = model->headerData(section, orientation, Qt::InitialSortOrderRole);
- if (value.canConvert(QVariant::Int))
+ if (value.canConvert(QMetaType::Int))
sortOrder = static_cast<Qt::SortOrder>(value.toInt());
else
sortOrder = Qt::AscendingOrder;
diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp
index daea907963c..4420d39b8e0 100644
--- a/src/widgets/itemviews/qitemdelegate.cpp
+++ b/src/widgets/itemviews/qitemdelegate.cpp
@@ -414,7 +414,7 @@ void QItemDelegate::paint(QPainter *painter,
if (value.isValid()) {
// ### we need the pixmap to call the virtual function
pixmap = decoration(opt, value);
- if (value.type() == QVariant::Icon) {
+ if (value.userType() == QMetaType::QIcon) {
d->tmp.icon = qvariant_cast<QIcon>(value);
d->tmp.mode = d->iconMode(option.state);
d->tmp.state = d->iconState(option.state);
@@ -969,12 +969,12 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option,
QPixmap QItemDelegate::decoration(const QStyleOptionViewItem &option, const QVariant &variant) const
{
Q_D(const QItemDelegate);
- switch (variant.type()) {
- case QVariant::Icon: {
+ switch (variant.userType()) {
+ case QMetaType::QIcon: {
QIcon::Mode mode = d->iconMode(option.state);
QIcon::State state = d->iconState(option.state);
return qvariant_cast<QIcon>(variant).pixmap(option.decorationSize, mode, state); }
- case QVariant::Color: {
+ case QMetaType::QColor: {
static QPixmap pixmap(option.decorationSize);
pixmap.fill(qvariant_cast<QColor>(variant));
return pixmap; }
@@ -1060,24 +1060,24 @@ QRect QItemDelegate::rect(const QStyleOptionViewItem &option,
if (role == Qt::CheckStateRole)
return doCheck(option, option.rect, value);
if (value.isValid() && !value.isNull()) {
- switch (value.type()) {
- case QVariant::Invalid:
+ switch (value.userType()) {
+ case QMetaType::UnknownType:
break;
- case QVariant::Pixmap: {
+ case QMetaType::QPixmap: {
const QPixmap &pixmap = qvariant_cast<QPixmap>(value);
return QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() ); }
- case QVariant::Image: {
+ case QMetaType::QImage: {
const QImage &image = qvariant_cast<QImage>(value);
return QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() ); }
- case QVariant::Icon: {
+ case QMetaType::QIcon: {
QIcon::Mode mode = d->iconMode(option.state);
QIcon::State state = d->iconState(option.state);
QIcon icon = qvariant_cast<QIcon>(value);
QSize size = icon.actualSize(option.decorationSize, mode, state);
return QRect(QPoint(0, 0), size); }
- case QVariant::Color:
+ case QMetaType::QColor:
return QRect(QPoint(0, 0), option.decorationSize);
- case QVariant::String:
+ case QMetaType::QString:
default: {
const QString text = d->valueToText(value, option);
value = index.data(Qt::FontRole);
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index f874597d59e..fe9b482122f 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -241,21 +241,21 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
{
switch (userType) {
#if QT_CONFIG(combobox)
- case QVariant::Bool: {
+ case QMetaType::Bool: {
QBooleanComboBox *cb = new QBooleanComboBox(parent);
cb->setFrame(false);
cb->setSizePolicy(QSizePolicy::Ignored, cb->sizePolicy().verticalPolicy());
return cb; }
#endif
#if QT_CONFIG(spinbox)
- case QVariant::UInt: {
+ case QMetaType::UInt: {
QSpinBox *sb = new QUIntSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(0);
sb->setMaximum(INT_MAX);
sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
- case QVariant::Int: {
+ case QMetaType::Int: {
QSpinBox *sb = new QSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(INT_MIN);
@@ -264,25 +264,25 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
return sb; }
#endif
#if QT_CONFIG(datetimeedit)
- case QVariant::Date: {
+ case QMetaType::QDate: {
QDateTimeEdit *ed = new QDateEdit(parent);
ed->setFrame(false);
return ed; }
- case QVariant::Time: {
+ case QMetaType::QTime: {
QDateTimeEdit *ed = new QTimeEdit(parent);
ed->setFrame(false);
return ed; }
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QDateTimeEdit *ed = new QDateTimeEdit(parent);
ed->setFrame(false);
return ed; }
#endif
#if QT_CONFIG(label)
- case QVariant::Pixmap:
+ case QMetaType::QPixmap:
return new QLabel(parent);
#endif
#if QT_CONFIG(spinbox)
- case QVariant::Double: {
+ case QMetaType::Double: {
QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(-DBL_MAX);
@@ -291,7 +291,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
return sb; }
#endif
#if QT_CONFIG(lineedit)
- case QVariant::String:
+ case QMetaType::QString:
default: {
// the default editor is a lineedit
QExpandingLineEdit *le = new QExpandingLineEdit(parent);
@@ -311,24 +311,24 @@ QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const
{
switch (userType) {
#if QT_CONFIG(combobox)
- case QVariant::Bool:
+ case QMetaType::Bool:
return "currentIndex";
#endif
#if QT_CONFIG(spinbox)
- case QVariant::UInt:
- case QVariant::Int:
- case QVariant::Double:
+ case QMetaType::UInt:
+ case QMetaType::Int:
+ case QMetaType::Double:
return "value";
#endif
#if QT_CONFIG(datetimeedit)
- case QVariant::Date:
+ case QMetaType::QDate:
return "date";
- case QVariant::Time:
+ case QMetaType::QTime:
return "time";
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return "dateTime";
#endif
- case QVariant::String:
+ case QMetaType::QString:
default:
// the default editor is a lineedit
return "text";
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index f42af2ea004..c685cc7f052 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -302,8 +302,8 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
value = index.data(Qt::DecorationRole);
if (value.isValid() && !value.isNull()) {
option->features |= QStyleOptionViewItem::HasDecoration;
- switch (value.type()) {
- case QVariant::Icon: {
+ switch (value.userType()) {
+ case QMetaType::QIcon: {
option->icon = qvariant_cast<QIcon>(value);
QIcon::Mode mode;
if (!(option->state & QStyle::State_Enabled))
@@ -319,19 +319,19 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
qMin(option->decorationSize.height(), actualSize.height()));
break;
}
- case QVariant::Color: {
+ case QMetaType::QColor: {
QPixmap pixmap(option->decorationSize);
pixmap.fill(qvariant_cast<QColor>(value));
option->icon = QIcon(pixmap);
break;
}
- case QVariant::Image: {
+ case QMetaType::QImage: {
QImage image = qvariant_cast<QImage>(value);
option->icon = QIcon(QPixmap::fromImage(image));
option->decorationSize = image.size() / image.devicePixelRatio();
break;
}
- case QVariant::Pixmap: {
+ case QMetaType::QPixmap: {
QPixmap pixmap = qvariant_cast<QPixmap>(value);
option->icon = QIcon(pixmap);
option->decorationSize = pixmap.size() / pixmap.devicePixelRatio();
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 4908ad6ad21..3bd77b340bd 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -48,6 +48,8 @@
#include <private/qwidgetitemdata_p.h>
#include <private/qtreewidgetitemiterator_p.h>
+#include <QtCore/private/qduplicatetracker_p.h>
+
#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -3175,13 +3177,12 @@ QList<QTreeWidgetItem*> QTreeWidget::selectedItems() const
const QModelIndexList indexes = selectionModel()->selectedIndexes();
QList<QTreeWidgetItem*> items;
items.reserve(indexes.count());
- QSet<QTreeWidgetItem *> seen;
+ QDuplicateTracker<QTreeWidgetItem *> seen;
seen.reserve(indexes.count());
for (const auto &index : indexes) {
QTreeWidgetItem *item = d->item(index);
- if (item->isHidden() || seen.contains(item))
+ if (item->isHidden() || seen.hasSeen(item))
continue;
- seen.insert(item);
items.append(item);
}
return items;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index eea97b2c0bc..68f6b72d20e 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1224,6 +1224,7 @@ void QApplication::setColorSpec(int spec)
\property QApplication::globalStrut
\brief the minimum size that any GUI element that the user can interact
with should have
+ \deprecated
For example, no button should be resized to be smaller than the global
strut size. The strut size should be considered when reimplementing GUI
@@ -3761,7 +3762,9 @@ void QApplicationPrivate::closePopup(QWidget *popup)
if (QWidget *fw = aw->focusWidget())
fw->setFocus(Qt::PopupFocusReason);
- if (QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard
+ // can become nullptr due to setFocus() above
+ if (QApplicationPrivate::popupWidgets &&
+ QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard
grabForPopup(aw);
}
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index d7cc4489c4f..4ecfe64b605 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -78,7 +78,9 @@ class Q_WIDGETS_EXPORT QApplication : public QGuiApplication
#if QT_CONFIG(wheelevent)
Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
#endif
+#if QT_DEPRECATED_SINCE(5, 15)
Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)
+#endif
Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
#ifndef QT_NO_STYLE_STYLESHEET
@@ -157,8 +159,10 @@ public:
static void setWheelScrollLines(int);
static int wheelScrollLines();
#endif
+#if QT_DEPRECATED_SINCE(5, 15)
static void setGlobalStrut(const QSize &);
static QSize globalStrut();
+#endif
static void setStartDragTime(int ms);
static int startDragTime();
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 56043910590..541519245e2 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -105,11 +105,10 @@ QGestureManager::QGestureManager(QObject *parent)
QGestureManager::~QGestureManager()
{
qDeleteAll(m_recognizers);
- foreach (QGestureRecognizer *recognizer, m_obsoleteGestures.keys()) {
- qDeleteAll(m_obsoleteGestures.value(recognizer));
- delete recognizer;
+ for (auto it = m_obsoleteGestures.cbegin(), end = m_obsoleteGestures.cend(); it != end; ++it) {
+ qDeleteAll(it.value());
+ delete it.key();
}
- m_obsoleteGestures.clear();
}
Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer)
diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp
index 54bf8fe0dc8..c4372a9fbc7 100644
--- a/src/widgets/kernel/qsizepolicy.cpp
+++ b/src/widgets/kernel/qsizepolicy.cpp
@@ -439,7 +439,7 @@ void QSizePolicy::setControlType(ControlType type) noexcept
*/
QSizePolicy::operator QVariant() const
{
- return QVariant(QVariant::SizePolicy, this);
+ return QVariant(QMetaType::QSizePolicy, this);
}
#ifndef QT_NO_DATASTREAM
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index db3c2699495..25ca732c9e2 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -5954,9 +5954,9 @@ void QWidget::setWindowTitle(const QString &title)
\note On \macos, window icons represent the active document,
and will not be displayed unless a file path has also been
- set using setFilePath.
+ set using setWindowFilePath.
- \sa windowTitle, setFilePath
+ \sa windowTitle, setWindowFilePath
*/
QIcon QWidget::windowIcon() const
{
diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp
index 41600d21438..edb166e8d5a 100644
--- a/src/widgets/kernel/qwidgetsvariant.cpp
+++ b/src/widgets/kernel/qwidgetsvariant.cpp
@@ -51,12 +51,12 @@ namespace {
static void construct(QVariant::Private *x, const void *copy)
{
switch (x->type) {
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
v_construct<QSizePolicy>(x, copy);
break;
default:
qWarning("Trying to construct an instance of an invalid type, type id: %i", x->type);
- x->type = QVariant::Invalid;
+ x->type = QMetaType::UnknownType;
return;
}
x->is_null = !copy;
@@ -65,7 +65,7 @@ static void construct(QVariant::Private *x, const void *copy)
static void clear(QVariant::Private *d)
{
switch (d->type) {
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
v_clear<QSizePolicy>(d);
break;
default:
@@ -73,7 +73,7 @@ static void clear(QVariant::Private *d)
return;
}
- d->type = QVariant::Invalid;
+ d->type = QMetaType::UnknownType;
d->is_null = true;
d->is_shared = false;
}
@@ -88,7 +88,7 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
{
Q_ASSERT(a->type == b->type);
switch(a->type) {
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
default:
Q_ASSERT(false);
@@ -111,7 +111,7 @@ static void streamDebug(QDebug dbg, const QVariant &v)
{
QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
switch (d->type) {
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
dbg.nospace() << *v_cast<QSizePolicy>(d);
break;
default:
diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp
index d30b43a679c..66729e4dc78 100644
--- a/src/widgets/styles/qdrawutil.cpp
+++ b/src/widgets/styles/qdrawutil.cpp
@@ -214,7 +214,7 @@ void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
specifies the line width for each of the lines; it is not the
total line width. The \a midLineWidth specifies the width of a
middle line drawn in the QPalette::mid() color. The rectangle's
- interior is filled with the \a fill brush unless \a fill is 0.
+ interior is filled with the \a fill brush unless \a fill is \nullptr.
The rectangle appears sunken if \a sunken is true, otherwise
raised.
@@ -331,7 +331,7 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
The given \a palette specifies the shading colors (\l
{QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
{QPalette::mid()}{middle} colors). The panel's interior is filled
- with the \a fill brush unless \a fill is 0.
+ with the \a fill brush unless \a fill is \nullptr.
The panel appears sunken if \a sunken is true, otherwise raised.
@@ -490,7 +490,7 @@ static void qDrawWinShades(QPainter *p,
Draws the Windows-style button specified by the given point (\a x,
\a y}, \a width and \a height using the provided \a painter with a
line width of 2 pixels. The button's interior is filled with the
- \a{fill} brush unless \a fill is 0.
+ \a{fill} brush unless \a fill is \nullptr.
The given \a palette specifies the shading colors (\l
{QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
@@ -528,7 +528,7 @@ void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
Draws the Windows-style panel specified by the given point(\a x,
\a y), \a width and \a height using the provided \a painter with a
line width of 2 pixels. The button's interior is filled with the
- \a fill brush unless \a fill is 0.
+ \a fill brush unless \a fill is \nullptr.
The given \a palette specifies the shading colors. The panel
appears sunken if \a sunken is true, otherwise raised.
@@ -567,7 +567,7 @@ void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
Draws the plain rectangle beginning at (\a x, \a y) with the given
\a width and \a height, using the specified \a painter, \a lineColor
and \a lineWidth. The rectangle's interior is filled with the \a
- fill brush unless \a fill is 0.
+ fill brush unless \a fill is \nullptr.
\warning This function does not look at QWidget::style() or
QApplication::style(). Use the drawing functions in QStyle to make
@@ -676,7 +676,7 @@ void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
specifies the line width for each of the lines; it is not the
total line width. The \a midLineWidth specifies the width of a
middle line drawn in the QPalette::mid() color. The rectangle's
- interior is filled with the \a fill brush unless \a fill is 0.
+ interior is filled with the \a fill brush unless \a fill is \nullptr.
The rectangle appears sunken if \a sunken is true, otherwise
raised.
@@ -714,7 +714,7 @@ void qDrawShadeRect(QPainter *p, const QRect &r,
The given \a palette specifies the shading colors (\l
{QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
{QPalette::mid()}{middle} colors). The panel's interior is filled
- with the \a fill brush unless \a fill is 0.
+ with the \a fill brush unless \a fill is \nullptr.
The panel appears sunken if \a sunken is true, otherwise raised.
@@ -746,7 +746,7 @@ void qDrawShadePanel(QPainter *p, const QRect &r,
Draws the Windows-style button at the rectangle specified by \a rect using
the given \a painter with a line width of 2 pixels. The button's interior
- is filled with the \a{fill} brush unless \a fill is 0.
+ is filled with the \a{fill} brush unless \a fill is \nullptr.
The given \a palette specifies the shading colors (\l
{QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
@@ -774,7 +774,7 @@ void qDrawWinButton(QPainter *p, const QRect &r,
Draws the Windows-style panel at the rectangle specified by \a rect using
the given \a painter with a line width of 2 pixels. The button's interior
- is filled with the \a fill brush unless \a fill is 0.
+ is filled with the \a fill brush unless \a fill is \nullptr.
The given \a palette specifies the shading colors. The panel
appears sunken if \a sunken is true, otherwise raised.
@@ -804,7 +804,7 @@ void qDrawWinPanel(QPainter *p, const QRect &r,
Draws the plain rectangle specified by \a rect using the given \a painter,
\a lineColor and \a lineWidth. The rectangle's interior is filled with the
- \a fill brush unless \a fill is 0.
+ \a fill brush unless \a fill is \nullptr.
\warning This function does not look at QWidget::style() or
QApplication::style(). Use the drawing functions in QStyle to make
diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp
index cfaa5a2011b..ecad637957c 100644
--- a/src/widgets/styles/qproxystyle.cpp
+++ b/src/widgets/styles/qproxystyle.cpp
@@ -162,7 +162,7 @@ QStyle *QProxyStyle::baseStyle() const
Ownership of \a style is transferred to QProxyStyle.
- If style is zero, a desktop-dependant style will be
+ If style is \nullptr, a desktop-dependent style will be
assigned automatically.
*/
void QProxyStyle::setBaseStyle(QStyle *style)
@@ -403,7 +403,7 @@ QIcon QProxyStyle::standardIcon(StandardPixmap standardIcon,
orientation specifies whether the controls are laid out side by side
or stacked vertically. The \a option parameter can be used to pass
extra information about the parent widget. The \a widget parameter
- is optional and can also be used if \a option is 0.
+ is optional and can also be used if \a option is \nullptr.
The default implementation returns -1.
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index e462d0696b2..1110cc33230 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -2361,14 +2361,14 @@ QPalette QStyle::standardPalette() const
\fn int QStyle::layoutSpacing(QSizePolicy::ControlType control1,
QSizePolicy::ControlType control2, Qt::Orientation orientation,
- const QStyleOption *option = 0, const QWidget *widget = 0) const
+ const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const
Returns the spacing that should be used between \a control1 and
\a control2 in a layout. \a orientation specifies whether the
controls are laid out side by side or stacked vertically. The \a
option parameter can be used to pass extra information about the
parent widget. The \a widget parameter is optional and can also
- be used if \a option is 0.
+ be used if \a option is \nullptr.
This function is called by the layout system. It is used only if
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
@@ -2385,7 +2385,7 @@ QPalette QStyle::standardPalette() const
controls are laid out side by side or stacked vertically. The \a
option parameter can be used to pass extra information about the
parent widget. The \a widget parameter is optional and can also
- be used if \a option is 0.
+ be used if \a option is \nullptr.
\a controls1 and \a controls2 are OR-combination of zero or more
\l{QSizePolicy::ControlTypes}{control types}.
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 2eccb244319..1e032b237a9 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -1547,11 +1547,10 @@ public:
}
}
}
- QString valueStr;
- if(value.type() == QVariant::StringList || value.type() == QVariant::List)
- valueStr = value.toStringList().join(QLatin1Char(' '));
- else
- valueStr = value.toString();
+ QString valueStr = (value.userType() == QMetaType::QStringList
+ || value.userType() == QMetaType::QVariantList)
+ ? value.toStringList().join(QLatin1Char(' '))
+ : value.toString();
cache[name] = valueStr;
return valueStr;
}
@@ -2611,16 +2610,16 @@ void QStyleSheetStyle::setProperties(QWidget *w)
QVariant v;
const QVariant value = w->property(property.toLatin1());
- switch (value.type()) {
- case QVariant::Icon: v = decl.iconValue(); break;
- case QVariant::Image: v = QImage(decl.uriValue()); break;
- case QVariant::Pixmap: v = QPixmap(decl.uriValue()); break;
- case QVariant::Rect: v = decl.rectValue(); break;
- case QVariant::Size: v = decl.sizeValue(); break;
- case QVariant::Color: v = decl.colorValue(); break;
- case QVariant::Brush: v = decl.brushValue(); break;
+ switch (value.userType()) {
+ case QMetaType::QIcon: v = decl.iconValue(); break;
+ case QMetaType::QImage: v = QImage(decl.uriValue()); break;
+ case QMetaType::QPixmap: v = QPixmap(decl.uriValue()); break;
+ case QMetaType::QRect: v = decl.rectValue(); break;
+ case QMetaType::QSize: v = decl.sizeValue(); break;
+ case QMetaType::QColor: v = decl.colorValue(); break;
+ case QMetaType::QBrush: v = decl.brushValue(); break;
#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break;
+ case QMetaType::QKeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break;
#endif
default: v = decl.d->values.at(0).variant; break;
}
@@ -4648,7 +4647,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
}
if (baseStyle()->property("_q_styleSheetRealCloseButton").toBool())
- baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant(QVariant::Invalid));
+ baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant());
}
QPixmap QStyleSheetStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap,
@@ -6128,7 +6127,7 @@ void QStyleSheetStyle::saveWidgetFont(QWidget* w, const QFont& font) const
void QStyleSheetStyle::clearWidgetFont(QWidget* w) const
{
- w->setProperty("_q_styleSheetWidgetFont", QVariant(QVariant::Invalid));
+ w->setProperty("_q_styleSheetWidgetFont", QVariant());
}
// Polish palette that should be used for a particular widget, with particular states
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 8496a2c2236..497afd17e1a 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -84,6 +84,7 @@
#include <qpa/qplatformscreen.h>
#include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
+#include <qpa/qplatformnativeinterface.h>
#include <private/qwidget_p.h>
#include <private/qstylehelper_p.h>
@@ -127,6 +128,22 @@ qreal QWindowsStylePrivate::appDevicePixelRatio()
return qApp->devicePixelRatio();
}
+bool QWindowsStylePrivate::isDarkMode()
+{
+ bool result = false;
+#ifdef Q_OS_WIN
+ // Windows only: Return whether dark mode style support is desired and
+ // dark mode is in effect.
+ if (auto ni = QGuiApplication::platformNativeInterface()) {
+ const QVariant darkModeStyleP = ni->property("darkModeStyle");
+ result = darkModeStyleP.type() == QVariant::Bool
+ && darkModeStyleP.value<bool>()
+ && ni->property("darkMode").value<bool>();
+ }
+#endif
+ return result;
+}
+
// Returns \c true if the toplevel parent of \a widget has seen the Alt-key
bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const
{
diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h
index 4f6ffcefc2b..a25f5c41660 100644
--- a/src/widgets/styles/qwindowsstyle_p_p.h
+++ b/src/widgets/styles/qwindowsstyle_p_p.h
@@ -74,6 +74,7 @@ public:
static qreal devicePixelRatio(const QWidget *widget = nullptr)
{ return widget ? widget->devicePixelRatioF() : QWindowsStylePrivate::appDevicePixelRatio(); }
static qreal nativeMetricScaleFactor(const QWidget *widget = nullptr);
+ static bool isDarkMode();
bool hasSeenAlt(const QWidget *widget) const;
bool altDown() const { return alt_down; }
diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp
index 9ca83a1da25..a39276a2b8d 100644
--- a/src/widgets/util/qundoview.cpp
+++ b/src/widgets/util/qundoview.cpp
@@ -358,8 +358,8 @@ QUndoStack *QUndoView::stack() const
}
/*!
- Sets the stack displayed by this view to \a stack. If \a stack is 0, the view
- will be empty.
+ Sets the stack displayed by this view to \a stack. If \a stack is \nullptr,
+ the view will be empty.
If the view was previously looking at a QUndoGroup, the group is set to \nullptr.
@@ -378,10 +378,10 @@ void QUndoView::setStack(QUndoStack *stack)
#if QT_CONFIG(undogroup)
/*!
- Sets the group displayed by this view to \a group. If \a group is 0, the view will
- be empty.
+ Sets the group displayed by this view to \a group. If \a group is \nullptr,
+ the view will be empty.
- The view will update itself autmiatically whenever the active stack of the group changes.
+ The view will update itself automatically whenever the active stack of the group changes.
\sa group(), setStack()
*/
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 320b3bf7ef2..257cffda62c 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -512,8 +512,8 @@ QAbstractScrollArea::~QAbstractScrollArea()
Sets the viewport to be the given \a widget.
The QAbstractScrollArea will take ownership of the given \a widget.
- If \a widget is 0, QAbstractScrollArea will assign a new QWidget instance
- for the viewport.
+ If \a widget is \nullptr, QAbstractScrollArea will assign a new QWidget
+ instance for the viewport.
\sa viewport()
*/
@@ -720,7 +720,7 @@ QWidget *QAbstractScrollArea::cornerWidget() const
You will probably also want to set at least one of the scroll bar
modes to \c AlwaysOn.
- Passing 0 shows no widget in the corner.
+ Passing \nullptr shows no widget in the corner.
Any previous corner widget is hidden.
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 6a0d2f50199..04176ab5e26 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -570,7 +570,7 @@ void QAbstractSpinBox::clear()
QAbstractSpinBox::StepEnabled QAbstractSpinBox::stepEnabled() const
{
Q_D(const QAbstractSpinBox);
- if (d->readOnly || d->type == QVariant::Invalid)
+ if (d->readOnly || d->type == QMetaType::UnknownType)
return StepNone;
if (d->wrapping)
return StepEnabled(StepUpEnabled | StepDownEnabled);
@@ -723,7 +723,7 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit)
d->edit->setFocusProxy(this);
d->edit->setAcceptDrops(false);
- if (d->type != QVariant::Invalid) {
+ if (d->type != QMetaType::UnknownType) {
connect(d->edit, SIGNAL(textChanged(QString)),
this, SLOT(_q_editorTextChanged(QString)));
connect(d->edit, SIGNAL(cursorPositionChanged(int,int)),
@@ -1421,7 +1421,7 @@ void QAbstractSpinBox::mouseReleaseEvent(QMouseEvent *event)
*/
QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate()
- : edit(nullptr), type(QVariant::Invalid), spinClickTimerId(-1),
+ : edit(nullptr), type(QMetaType::UnknownType), spinClickTimerId(-1),
spinClickTimerInterval(100), spinClickThresholdTimerId(-1), spinClickThresholdTimerInterval(-1),
effectiveSpinRepeatRate(1), buttonState(None), cachedText(QLatin1String("\x01")),
cachedState(QValidator::Invalid), pendingEmit(false), readOnly(false), wrapping(false),
@@ -1805,7 +1805,7 @@ void QAbstractSpinBoxPrivate::setValue(const QVariant &val, EmitPolicy ep,
void QAbstractSpinBoxPrivate::updateEdit()
{
Q_Q(QAbstractSpinBox);
- if (type == QVariant::Invalid)
+ if (type == QMetaType::UnknownType)
return;
const QString newText = specialValue() ? specialValueText : prefix + textFromValue(value) + suffix;
if (newText == edit->displayText() || cleared)
@@ -1865,8 +1865,8 @@ QVariant QAbstractSpinBoxPrivate::getZeroVariant() const
{
QVariant ret;
switch (type) {
- case QVariant::Int: ret = QVariant((int)0); break;
- case QVariant::Double: ret = QVariant((double)0.0); break;
+ case QMetaType::Int: ret = QVariant(0); break;
+ case QMetaType::Double: ret = QVariant(0.0); break;
default: break;
}
return ret;
@@ -1913,7 +1913,7 @@ QVariant QAbstractSpinBoxPrivate::valueFromText(const QString &) const
void QAbstractSpinBoxPrivate::interpret(EmitPolicy ep)
{
Q_Q(QAbstractSpinBox);
- if (type == QVariant::Invalid || cleared)
+ if (type == QMetaType::UnknownType || cleared)
return;
QVariant v = getZeroVariant();
@@ -2013,11 +2013,11 @@ void QSpinBoxValidator::fixup(QString &input) const
QVariant operator+(const QVariant &arg1, const QVariant &arg2)
{
QVariant ret;
- if (Q_UNLIKELY(arg1.type() != arg2.type()))
+ if (Q_UNLIKELY(arg1.userType() != arg2.userType()))
qWarning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)",
arg1.typeName(), arg2.typeName(), __FILE__, __LINE__);
- switch (arg1.type()) {
- case QVariant::Int: {
+ switch (arg1.userType()) {
+ case QMetaType::Int: {
const int int1 = arg1.toInt();
const int int2 = arg2.toInt();
if (int1 > 0 && (int2 >= INT_MAX - int1)) {
@@ -2031,9 +2031,9 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2)
}
break;
}
- case QVariant::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break;
+ case QMetaType::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break;
#if QT_CONFIG(datetimeparser)
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QDateTime a2 = arg2.toDateTime();
QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATE_MIN.daysTo(a2.date()));
a1.setTime(a1.time().addMSecs(a2.time().msecsSinceStartOfDay()));
@@ -2055,13 +2055,13 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2)
QVariant operator-(const QVariant &arg1, const QVariant &arg2)
{
QVariant ret;
- if (Q_UNLIKELY(arg1.type() != arg2.type()))
+ if (Q_UNLIKELY(arg1.userType() != arg2.userType()))
qWarning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)",
arg1.typeName(), arg2.typeName(), __FILE__, __LINE__);
- switch (arg1.type()) {
- case QVariant::Int: ret = QVariant(arg1.toInt() - arg2.toInt()); break;
- case QVariant::Double: ret = QVariant(arg1.toDouble() - arg2.toDouble()); break;
- case QVariant::DateTime: {
+ switch (arg1.userType()) {
+ case QMetaType::Int: ret = QVariant(arg1.toInt() - arg2.toInt()); break;
+ case QMetaType::Double: ret = QVariant(arg1.toDouble() - arg2.toDouble()); break;
+ case QMetaType::QDateTime: {
QDateTime a1 = arg1.toDateTime();
QDateTime a2 = arg2.toDateTime();
int days = a2.daysTo(a1);
@@ -2090,13 +2090,13 @@ QVariant operator*(const QVariant &arg1, double multiplier)
{
QVariant ret;
- switch (arg1.type()) {
- case QVariant::Int:
+ switch (arg1.userType()) {
+ case QMetaType::Int:
ret = static_cast<int>(qBound<double>(INT_MIN, arg1.toInt() * multiplier, INT_MAX));
break;
- case QVariant::Double: ret = QVariant(arg1.toDouble() * multiplier); break;
+ case QMetaType::Double: ret = QVariant(arg1.toDouble() * multiplier); break;
#if QT_CONFIG(datetimeparser)
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
double days = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDateTime().date()) * multiplier;
const qint64 daysInt = qint64(days);
days -= daysInt;
@@ -2119,17 +2119,17 @@ double operator/(const QVariant &arg1, const QVariant &arg2)
double a1 = 0;
double a2 = 0;
- switch (arg1.type()) {
- case QVariant::Int:
+ switch (arg1.userType()) {
+ case QMetaType::Int:
a1 = (double)arg1.toInt();
a2 = (double)arg2.toInt();
break;
- case QVariant::Double:
+ case QMetaType::Double:
a1 = arg1.toDouble();
a2 = arg2.toDouble();
break;
#if QT_CONFIG(datetimeparser)
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
a1 = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDate());
a2 = QDATETIMEEDIT_DATE_MIN.daysTo(arg2.toDate());
a1 += arg1.toDateTime().time().msecsSinceStartOfDay() / (36e5 * 24);
@@ -2144,9 +2144,9 @@ double operator/(const QVariant &arg1, const QVariant &arg2)
int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant &arg2)
{
- switch (arg2.type()) {
- case QVariant::Date:
- Q_ASSERT_X(arg1.type() == QVariant::Date, "QAbstractSpinBoxPrivate::variantCompare",
+ switch (arg2.userType()) {
+ case QMetaType::QDate:
+ Q_ASSERT_X(arg1.userType() == QMetaType::QDate, "QAbstractSpinBoxPrivate::variantCompare",
qPrintable(QString::fromLatin1("Internal error 1 (%1)").
arg(QString::fromLatin1(arg1.typeName()))));
if (arg1.toDate() == arg2.toDate()) {
@@ -2156,8 +2156,8 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
} else {
return 1;
}
- case QVariant::Time:
- Q_ASSERT_X(arg1.type() == QVariant::Time, "QAbstractSpinBoxPrivate::variantCompare",
+ case QMetaType::QTime:
+ Q_ASSERT_X(arg1.userType() == QMetaType::QTime, "QAbstractSpinBoxPrivate::variantCompare",
qPrintable(QString::fromLatin1("Internal error 2 (%1)").
arg(QString::fromLatin1(arg1.typeName()))));
if (arg1.toTime() == arg2.toTime()) {
@@ -2169,7 +2169,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
}
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
if (arg1.toDateTime() == arg2.toDateTime()) {
return 0;
} else if (arg1.toDateTime() < arg2.toDateTime()) {
@@ -2177,7 +2177,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
} else {
return 1;
}
- case QVariant::Int:
+ case QMetaType::Int:
if (arg1.toInt() == arg2.toInt()) {
return 0;
} else if (arg1.toInt() < arg2.toInt()) {
@@ -2185,7 +2185,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
} else {
return 1;
}
- case QVariant::Double:
+ case QMetaType::Double:
if (arg1.toDouble() == arg2.toDouble()) {
return 0;
} else if (arg1.toDouble() < arg2.toDouble()) {
@@ -2193,8 +2193,8 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
} else {
return 1;
}
- case QVariant::Invalid:
- if (arg2.type() == QVariant::Invalid)
+ case QMetaType::UnknownType:
+ if (arg2.userType() == QMetaType::UnknownType)
return 0;
Q_FALLTHROUGH();
default:
diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h
index ad169fde199..63b19c7317f 100644
--- a/src/widgets/widgets/qabstractspinbox_p.h
+++ b/src/widgets/widgets/qabstractspinbox_p.h
@@ -127,7 +127,7 @@ public:
QLineEdit *edit;
QString prefix, suffix, specialValueText;
QVariant value, minimum, maximum, singleStep;
- QVariant::Type type;
+ QMetaType::Type type;
int spinClickTimerId, spinClickTimerInterval, spinClickThresholdTimerId, spinClickThresholdTimerInterval;
int effectiveSpinRepeatRate;
uint buttonState;
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 785de350902..53a711adc4e 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -144,11 +144,11 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
menuOption.menuItemType = QStyleOptionMenuItem::Normal;
QVariant variant = index.model()->data(index, Qt::DecorationRole);
- switch (variant.type()) {
- case QVariant::Icon:
+ switch (variant.userType()) {
+ case QMetaType::QIcon:
menuOption.icon = qvariant_cast<QIcon>(variant);
break;
- case QVariant::Color: {
+ case QMetaType::QColor: {
static QPixmap pixmap(option.decorationSize);
pixmap.fill(qvariant_cast<QColor>(variant));
menuOption.icon = pixmap;
@@ -1888,7 +1888,7 @@ void QComboBoxPrivate::updateDelegate(bool force)
QIcon QComboBoxPrivate::itemIcon(const QModelIndex &index) const
{
QVariant decoration = model->data(index, Qt::DecorationRole);
- if (decoration.type() == QVariant::Pixmap)
+ if (decoration.userType() == QMetaType::QPixmap)
return QIcon(qvariant_cast<QPixmap>(decoration));
else
return qvariant_cast<QIcon>(decoration);
@@ -2044,7 +2044,7 @@ const QValidator *QComboBox::validator() const
\since 4.2
Sets the \a completer to use instead of the current completer.
- If \a completer is 0, auto completion is disabled.
+ If \a completer is \nullptr, auto completion is disabled.
By default, for an editable combo box, a QCompleter that
performs case insensitive inline completion is automatically created.
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index e4abb896369..4880b5ee462 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -198,11 +198,19 @@ QDateTimeEdit::QDateTimeEdit(const QTime &time, QWidget *parent)
d->init(time.isValid() ? time : QDATETIMEEDIT_TIME_MIN);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/*!
\internal
*/
-
QDateTimeEdit::QDateTimeEdit(const QVariant &var, QVariant::Type parserType, QWidget *parent)
+ : QDateTimeEdit(var, QMetaType::Type(parserType), parent)
+{ }
+/*!
+ \internal
+*/
+#endif
+
+QDateTimeEdit::QDateTimeEdit(const QVariant &var, QMetaType::Type parserType, QWidget *parent)
: QAbstractSpinBox(*new QDateTimeEditPrivate, parent)
{
Q_D(QDateTimeEdit);
@@ -1570,7 +1578,7 @@ void QDateTimeEdit::mousePressEvent(QMouseEvent *event)
QTimeEdit::QTimeEdit(QWidget *parent)
- : QDateTimeEdit(QDATETIMEEDIT_TIME_MIN, QVariant::Time, parent)
+ : QDateTimeEdit(QDATETIMEEDIT_TIME_MIN, QMetaType::QTime, parent)
{
connect(this, &QTimeEdit::timeChanged, this, &QTimeEdit::userTimeChanged);
}
@@ -1581,7 +1589,7 @@ QTimeEdit::QTimeEdit(QWidget *parent)
*/
QTimeEdit::QTimeEdit(const QTime &time, QWidget *parent)
- : QDateTimeEdit(time, QVariant::Time, parent)
+ : QDateTimeEdit(time, QMetaType::QTime, parent)
{
connect(this, &QTimeEdit::timeChanged, this, &QTimeEdit::userTimeChanged);
}
@@ -1640,7 +1648,7 @@ QTimeEdit::~QTimeEdit()
*/
QDateEdit::QDateEdit(QWidget *parent)
- : QDateTimeEdit(QDATETIMEEDIT_DATE_INITIAL, QVariant::Date, parent)
+ : QDateTimeEdit(QDATETIMEEDIT_DATE_INITIAL, QMetaType::QDate, parent)
{
connect(this, &QDateEdit::dateChanged, this, &QDateEdit::userDateChanged);
}
@@ -1651,7 +1659,7 @@ QDateEdit::QDateEdit(QWidget *parent)
*/
QDateEdit::QDateEdit(const QDate &date, QWidget *parent)
- : QDateTimeEdit(date, QVariant::Date, parent)
+ : QDateTimeEdit(date, QMetaType::QDate, parent)
{
connect(this, &QDateEdit::dateChanged, this, &QDateEdit::userDateChanged);
}
@@ -1688,13 +1696,13 @@ QDateEdit::~QDateEdit()
QDateTimeEditPrivate::QDateTimeEditPrivate()
- : QDateTimeParser(QVariant::DateTime, QDateTimeParser::DateTimeEdit, QCalendar())
+ : QDateTimeParser(QMetaType::QDateTime, QDateTimeParser::DateTimeEdit, QCalendar())
{
hasHadFocus = false;
formatExplicitlySet = false;
cacheGuard = false;
fixday = true;
- type = QVariant::DateTime;
+ type = QMetaType::QDateTime;
sections = { };
cachedDay = -1;
currentSectionIndex = FirstSectionIndex;
@@ -2428,22 +2436,22 @@ void QDateTimeEdit::initStyleOption(QStyleOptionSpinBox *option) const
void QDateTimeEditPrivate::init(const QVariant &var)
{
Q_Q(QDateTimeEdit);
- switch (var.type()) {
- case QVariant::Date:
+ switch (var.userType()) {
+ case QMetaType::QDate:
value = var.toDate().startOfDay();
updateTimeSpec();
q->setDisplayFormat(defaultDateFormat);
if (sectionNodes.isEmpty()) // ### safeguard for broken locale
q->setDisplayFormat(QLatin1String("dd/MM/yyyy"));
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
value = var;
updateTimeSpec();
q->setDisplayFormat(defaultDateTimeFormat);
if (sectionNodes.isEmpty()) // ### safeguard for broken locale
q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss"));
break;
- case QVariant::Time:
+ case QMetaType::QTime:
value = QDateTime(QDATETIMEEDIT_DATE_INITIAL, var.toTime());
updateTimeSpec();
q->setDisplayFormat(defaultTimeFormat);
@@ -2522,7 +2530,7 @@ void QDateTimeEditPrivate::updateEditFieldGeometry()
QVariant QDateTimeEditPrivate::getZeroVariant() const
{
- Q_ASSERT(type == QVariant::DateTime);
+ Q_ASSERT(type == QMetaType::QDateTime);
return QDateTime(QDATETIMEEDIT_DATE_INITIAL, QTime(), spec);
}
diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h
index 03994675ae1..8905ad4a9ca 100644
--- a/src/widgets/widgets/qdatetimeedit.h
+++ b/src/widgets/widgets/qdatetimeedit.h
@@ -195,7 +195,10 @@ protected:
void paintEvent(QPaintEvent *event) override;
void initStyleOption(QStyleOptionSpinBox *option) const;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = nullptr);
+#endif
+ QDateTimeEdit(const QVariant &val, QMetaType::Type parserType, QWidget *parent = nullptr);
private:
Q_DECLARE_PRIVATE(QDateTimeEdit)
Q_DISABLE_COPY(QDateTimeEdit)
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 2e12320bc39..28c4f59d0d9 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -699,7 +699,7 @@ QList<QAbstractButton *> QDialogButtonBox::buttons() const
/*!
Returns the button role for the specified \a button. This function returns
- \l InvalidRole if \a button is 0 or has not been added to the button box.
+ \l InvalidRole if \a button is \nullptr or has not been added to the button box.
\sa buttons(), addButton()
*/
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 299e5da8d34..1d358c493e2 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -1674,8 +1674,8 @@ QAction * QDockWidget::toggleViewAction() const
\since 4.3
Sets an arbitrary \a widget as the dock widget's title bar. If \a widget
- is 0, any custom title bar widget previously set on the dock widget is
- removed, but not deleted, and the default title bar will be used
+ is \nullptr, any custom title bar widget previously set on the dock widget
+ is removed, but not deleted, and the default title bar will be used
instead.
If a title bar widget is set, QDockWidget will not use native window
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 7bd7283adf8..147ab9b8558 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -187,8 +187,13 @@ QLabelPrivate::~QLabelPrivate()
*/
#ifndef QT_NO_PICTURE
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
- Returns the label's picture or nullptr if the label doesn't have a
+ \deprecated
+
+ New code should use the other overload which returns QPicture by-value.
+
+ This function returns the label's picture or \c nullptr if the label doesn't have a
picture.
*/
@@ -197,6 +202,37 @@ const QPicture *QLabel::picture() const
Q_D(const QLabel);
return d->picture;
}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+/*!
+ \since 5.15
+ Returns the label's picture.
+
+ Previously, Qt provided a version of \c picture() which returned the picture
+ by-pointer. That version is now deprecated. To maintain compatibility
+ with old code, you can explicitly differentiate between the by-pointer
+ function and the by-value function:
+
+ \code
+ const QPicture *picPtr = label->picture();
+ QPicture picVal = label->picture(Qt::ReturnByValue);
+ \endcode
+
+ If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE
+ macro, then you can omit \c Qt::ReturnByValue as shown below:
+
+ \code
+ QPicture picVal = label->picture();
+ \endcode
+*/
+
+QPicture QLabel::picture(Qt::ReturnByValue_t) const
+{
+ Q_D(const QLabel);
+ if (d->picture)
+ return *(d->picture);
+ return QPicture();
+}
#endif
@@ -351,9 +387,27 @@ void QLabel::clear()
/*!
\property QLabel::pixmap
- \brief the label's pixmap
+ \brief the label's pixmap.
- If no pixmap has been set this will return nullptr.
+ Previously, Qt provided a version of \c pixmap() which returned the pixmap
+ by-pointer. That version is now deprecated. To maintain compatibility
+ with old code, you can explicitly differentiate between the by-pointer
+ function and the by-value function:
+
+ \code
+ const QPixmap *pixmapPtr = label->pixmap();
+ QPixmap pixmapVal = label->pixmap(Qt::ReturnByValue);
+ \endcode
+
+ If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE
+ macro, then you can omit \c Qt::ReturnByValue as shown below:
+
+ \code
+ QPixmap pixmapVal = label->pixmap();
+ \endcode
+
+ If no pixmap has been set, the deprecated getter function will return
+ \c nullptr.
Setting the pixmap clears any previous content. The buddy
shortcut, if any, is disabled.
@@ -372,11 +426,29 @@ void QLabel::setPixmap(const QPixmap &pixmap)
d->updateLabel();
}
+#if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \deprecated
+
+ New code should use the other overload which returns QPixmap by-value.
+*/
const QPixmap *QLabel::pixmap() const
{
Q_D(const QLabel);
return d->pixmap;
}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+/*!
+ \since 5.15
+*/
+QPixmap QLabel::pixmap(Qt::ReturnByValue_t) const
+{
+ Q_D(const QLabel);
+ if (d->pixmap)
+ return *(d->pixmap);
+ return QPixmap();
+}
#ifndef QT_NO_PICTURE
/*!
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
index 2f5db5a7d3e..288022a71e3 100644
--- a/src/widgets/widgets/qlabel.h
+++ b/src/widgets/widgets/qlabel.h
@@ -72,9 +72,25 @@ public:
~QLabel();
QString text() const;
- const QPixmap *pixmap() const;
+
+#if QT_DEPRECATED_SINCE(5,15)
+ QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QPixmap by-value")
+ const QPixmap *pixmap() const; // ### Qt 7: Remove function
+
+ QPixmap pixmap(Qt::ReturnByValue_t) const;
+#else
+ QPixmap pixmap(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg
+#endif // QT_DEPRECATED_SINCE(5,15)
+
#ifndef QT_NO_PICTURE
- const QPicture *picture() const;
+# if QT_DEPRECATED_SINCE(5,15)
+ QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QPicture by-value")
+ const QPicture *picture() const; // ### Qt 7: Remove function
+
+ QPicture picture(Qt::ReturnByValue_t) const;
+# else
+ QPicture picture(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg
+# endif // QT_DEPRECATED_SINCE(5,15)
#endif
#if QT_CONFIG(movie)
QMovie *movie() const;
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index 3272ac440b9..da6eb473723 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -103,8 +103,8 @@
\fn void QMdiArea::subWindowActivated(QMdiSubWindow *window)
QMdiArea emits this signal after \a window has been activated. When \a
- window is 0, QMdiArea has just deactivated its last active window, and
- there are no active windows on the workspace.
+ window is \nullptr, QMdiArea has just deactivated its last active window,
+ and there are no active windows on the workspace.
\sa QMdiArea::activeSubWindow()
*/
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index fc7e2dbbcb1..daa50aa8ee0 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -2326,76 +2326,86 @@ QSize QMenu::sizeHint() const
void QMenu::popup(const QPoint &p, QAction *atAction)
{
Q_D(QMenu);
- if (d->scroll) { // reset scroll state from last popup
- if (d->scroll->scrollOffset)
- d->itemsDirty = 1; // sizeHint will be incorrect if there is previous scroll
- d->scroll->scrollOffset = 0;
- d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
+ d->popup(p, atAction);
+}
+
+void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction positionFunction)
+{
+ Q_Q(QMenu);
+ if (scroll) { // reset scroll state from last popup
+ if (scroll->scrollOffset)
+ itemsDirty = 1; // sizeHint will be incorrect if there is previous scroll
+ scroll->scrollOffset = 0;
+ scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
}
- d->tearoffHighlighted = 0;
- d->motions = 0;
- d->doChildEffects = true;
- d->updateLayoutDirection();
+ tearoffHighlighted = 0;
+ motions = 0;
+ doChildEffects = true;
+ updateLayoutDirection();
// Ensure that we get correct sizeHints by placing this window on the correct screen.
// However if the QMenu was constructed with a QDesktopScreenWidget as its parent,
// then initialScreenIndex was set, so we should respect that for the lifetime of this menu.
// Use d->popupScreen to remember, because initialScreenIndex will be reset after the first showing.
// However if eventLoop exists, then exec() already did this by calling createWinId(); so leave it alone. (QTBUG-76162)
- if (!d->eventLoop) {
- const int screenIndex = d->topData()->initialScreenIndex;
+ if (!eventLoop) {
+ const int screenIndex = topData()->initialScreenIndex;
if (screenIndex >= 0)
- d->popupScreen = screenIndex;
- if (auto s = QGuiApplication::screens().value(d->popupScreen)) {
- if (d->setScreen(s))
- d->itemsDirty = true;
- } else if (d->setScreenForPoint(p)) {
- d->itemsDirty = true;
+ popupScreen = screenIndex;
+ if (auto s = QGuiApplication::screens().value(popupScreen)) {
+ if (setScreen(s))
+ itemsDirty = true;
+ } else if (setScreenForPoint(p)) {
+ itemsDirty = true;
}
}
- const bool contextMenu = d->isContextMenu();
- if (d->lastContextMenu != contextMenu) {
- d->itemsDirty = true;
- d->lastContextMenu = contextMenu;
+ const bool contextMenu = isContextMenu();
+ if (lastContextMenu != contextMenu) {
+ itemsDirty = true;
+ lastContextMenu = contextMenu;
}
#if QT_CONFIG(menubar)
// if this menu is part of a chain attached to a QMenuBar, set the
// _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type
- setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(d->topCausedWidget()) != 0);
+ q->setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(topCausedWidget()) != nullptr);
#endif
- ensurePolished(); // Get the right font
- emit aboutToShow();
- const bool actionListChanged = d->itemsDirty;
+ q->ensurePolished(); // Get the right font
+ emit q->aboutToShow();
+ const bool actionListChanged = itemsDirty;
QRect screen;
#if QT_CONFIG(graphicsview)
- bool isEmbedded = !bypassGraphicsProxyWidget(this) && QMenuPrivate::nearestGraphicsProxyWidget(this);
+ bool isEmbedded = !bypassGraphicsProxyWidget(q) && QMenuPrivate::nearestGraphicsProxyWidget(q);
if (isEmbedded)
- screen = d->popupGeometry();
+ screen = popupGeometry();
else
#endif
- screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
- d->updateActionRects(screen);
+ screen = popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
+ updateActionRects(screen);
QPoint pos;
- QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget);
+ QPushButton *causedButton = qobject_cast<QPushButton*>(causedPopup.widget);
if (actionListChanged && causedButton)
pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
else
pos = p;
- const QSize menuSizeHint(sizeHint());
+ const QSize menuSizeHint(q->sizeHint());
QSize size = menuSizeHint;
- const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, nullptr, this);
- bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen);
+
+ if (positionFunction)
+ pos = positionFunction(menuSizeHint);
+
+ const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, nullptr, q);
+ bool adjustToDesktop = !q->window()->testAttribute(Qt::WA_DontShowOnScreen);
// if the screens have very different geometries and the menu is too big, we have to recalculate
if ((size.height() > screen.height() || size.width() > screen.width()) ||
// Layout is not right, we might be able to save horizontal space
- (d->ncols >1 && size.height() < screen.height())) {
+ (ncols >1 && size.height() < screen.height())) {
size.setWidth(qMin(menuSizeHint.width(), screen.width() - desktopFrame * 2));
size.setHeight(qMin(menuSizeHint.height(), screen.height() - desktopFrame * 2));
adjustToDesktop = true;
@@ -2404,61 +2414,61 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
#ifdef QT_KEYPAD_NAVIGATION
if (!atAction && QApplicationPrivate::keypadNavigationEnabled()) {
// Try to have one item activated
- if (d->defaultAction && d->defaultAction->isEnabled()) {
- atAction = d->defaultAction;
+ if (defaultAction && defaultAction->isEnabled()) {
+ atAction = defaultAction;
// TODO: This works for first level menus, not yet sub menus
} else {
- for (QAction *action : qAsConst(d->actions))
+ for (QAction *action : qAsConst(actions))
if (action->isEnabled()) {
atAction = action;
break;
}
}
- d->currentAction = atAction;
+ currentAction = atAction;
}
#endif
- if (d->ncols > 1) {
+ if (ncols > 1) {
pos.setY(screen.top() + desktopFrame);
} else if (atAction) {
- for (int i = 0, above_height = 0; i < d->actions.count(); i++) {
- QAction *action = d->actions.at(i);
+ for (int i = 0, above_height = 0; i < actions.count(); i++) {
+ QAction *action = actions.at(i);
if (action == atAction) {
int newY = pos.y() - above_height;
- if (d->scroll && newY < desktopFrame) {
- d->scroll->scrollFlags = d->scroll->scrollFlags
+ if (scroll && newY < desktopFrame) {
+ scroll->scrollFlags = scroll->scrollFlags
| QMenuPrivate::QMenuScroller::ScrollUp;
- d->scroll->scrollOffset = newY;
+ scroll->scrollOffset = newY;
newY = desktopFrame;
}
pos.setY(newY);
- if (d->scroll && d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
- && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, nullptr, this)) {
- int below_height = above_height + d->scroll->scrollOffset;
- for (int i2 = i; i2 < d->actionRects.count(); i2++)
- below_height += d->actionRects.at(i2).height();
+ if (scroll && scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
+ && !q->style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, nullptr, q)) {
+ int below_height = above_height + scroll->scrollOffset;
+ for (int i2 = i; i2 < actionRects.count(); i2++)
+ below_height += actionRects.at(i2).height();
size.setHeight(below_height);
}
break;
} else {
- above_height += d->actionRects.at(i).height();
+ above_height += actionRects.at(i).height();
}
}
}
QPoint mouse = QCursor::pos();
- d->mousePopupPos = mouse;
- const bool snapToMouse = !d->causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
+ mousePopupPos = mouse;
+ const bool snapToMouse = !causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
if (adjustToDesktop) {
// handle popup falling "off screen"
- if (isRightToLeft()) {
+ if (q->isRightToLeft()) {
if (snapToMouse) // position flowing left from the mouse
pos.setX(mouse.x() - size.width());
#if QT_CONFIG(menubar)
// if the menu is in a menubar or is a submenu, it should be right-aligned
- if (qobject_cast<QMenuBar*>(d->causedPopup.widget) || qobject_cast<QMenu*>(d->causedPopup.widget))
+ if (qobject_cast<QMenuBar*>(causedPopup.widget) || qobject_cast<QMenu*>(causedPopup.widget))
pos.rx() -= size.width();
#endif // QT_CONFIG(menubar)
@@ -2482,8 +2492,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (pos.y() < screen.top() + desktopFrame)
pos.setY(screen.top() + desktopFrame);
if (pos.y() + menuSizeHint.height() - 1 > screen.bottom() - desktopFrame) {
- if (d->scroll) {
- d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
+ if (scroll) {
+ scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
int y = qMax(screen.y(),pos.y());
size.setHeight(screen.bottom() - (desktopFrame * 2) - y);
} else {
@@ -2492,13 +2502,13 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
}
}
- const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, nullptr, this);
- QMenu *caused = qobject_cast<QMenu*>(d_func()->causedPopup.widget);
+ const int subMenuOffset = q->style()->pixelMetric(QStyle::PM_SubMenuOverlap, nullptr, q);
+ QMenu *caused = qobject_cast<QMenu*>(causedPopup.widget);
if (caused && caused->geometry().width() + menuSizeHint.width() + subMenuOffset < screen.width()) {
QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction));
const QPoint actionTopLeft = caused->mapToGlobal(parentActionRect.topLeft());
parentActionRect.moveTopLeft(actionTopLeft);
- if (isRightToLeft()) {
+ if (q->isRightToLeft()) {
if ((pos.x() + menuSizeHint.width() > parentActionRect.left() - subMenuOffset)
&& (pos.x() < parentActionRect.right()))
{
@@ -2520,61 +2530,61 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
}
}
- setGeometry(QRect(pos, size));
+ q->setGeometry(QRect(pos, size));
#if QT_CONFIG(effects)
- int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
+ int hGuess = q->isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
int vGuess = QEffects::DownScroll;
- if (isRightToLeft()) {
+ if (q->isRightToLeft()) {
if ((snapToMouse && (pos.x() + size.width() / 2 > mouse.x())) ||
- (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 > d->causedPopup.widget->x()))
+ (qobject_cast<QMenu*>(causedPopup.widget) && pos.x() + size.width() / 2 > causedPopup.widget->x()))
hGuess = QEffects::RightScroll;
} else {
if ((snapToMouse && (pos.x() + size.width() / 2 < mouse.x())) ||
- (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 < d->causedPopup.widget->x()))
+ (qobject_cast<QMenu*>(causedPopup.widget) && pos.x() + size.width() / 2 < causedPopup.widget->x()))
hGuess = QEffects::LeftScroll;
}
#if QT_CONFIG(menubar)
if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) ||
- (qobject_cast<QMenuBar*>(d->causedPopup.widget) &&
- pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
+ (qobject_cast<QMenuBar*>(causedPopup.widget) &&
+ pos.y() + size.width() / 2 < causedPopup.widget->mapToGlobal(causedPopup.widget->pos()).y()))
vGuess = QEffects::UpScroll;
#endif
if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) {
bool doChildEffects = true;
#if QT_CONFIG(menubar)
- if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) {
+ if (QMenuBar *mb = qobject_cast<QMenuBar*>(causedPopup.widget)) {
doChildEffects = mb->d_func()->doChildEffects;
mb->d_func()->doChildEffects = false;
} else
#endif
- if (QMenu *m = qobject_cast<QMenu*>(d->causedPopup.widget)) {
+ if (QMenu *m = qobject_cast<QMenu*>(causedPopup.widget)) {
doChildEffects = m->d_func()->doChildEffects;
m->d_func()->doChildEffects = false;
}
if (doChildEffects) {
if (QApplication::isEffectEnabled(Qt::UI_FadeMenu))
- qFadeEffect(this);
- else if (d->causedPopup.widget)
- qScrollEffect(this, qobject_cast<QMenu*>(d->causedPopup.widget) ? hGuess : vGuess);
+ qFadeEffect(q);
+ else if (causedPopup.widget)
+ qScrollEffect(q, qobject_cast<QMenu*>(causedPopup.widget) ? hGuess : vGuess);
else
- qScrollEffect(this, hGuess | vGuess);
+ qScrollEffect(q, hGuess | vGuess);
} else {
// kill any running effect
qFadeEffect(nullptr);
qScrollEffect(nullptr);
- show();
+ q->show();
}
} else
#endif
{
- show();
+ q->show();
}
#ifndef QT_NO_ACCESSIBILITY
- QAccessibleEvent event(this, QAccessible::PopupMenuStart);
+ QAccessibleEvent event(q, QAccessible::PopupMenuStart);
QAccessible::updateAccessibility(&event);
#endif
}
@@ -2640,20 +2650,26 @@ QAction *QMenu::exec()
QAction *QMenu::exec(const QPoint &p, QAction *action)
{
Q_D(QMenu);
- ensurePolished();
- createWinId();
- QEventLoop eventLoop;
- d->eventLoop = &eventLoop;
- popup(p, action);
-
- QPointer<QObject> guard = this;
- (void) eventLoop.exec();
+ return d->exec(p, action);
+}
+
+QAction *QMenuPrivate::exec(const QPoint &p, QAction *action, PositionFunction positionFunction)
+{
+ Q_Q(QMenu);
+ q->ensurePolished();
+ q->createWinId();
+ QEventLoop evtLoop;
+ eventLoop = &evtLoop;
+ popup(p, action, positionFunction);
+
+ QPointer<QObject> guard = q;
+ (void) evtLoop.exec();
if (guard.isNull())
return nullptr;
- action = d->syncAction;
- d->syncAction = nullptr;
- d->eventLoop = nullptr;
+ action = syncAction;
+ syncAction = nullptr;
+ eventLoop = nullptr;
return action;
}
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index efbbc099a13..02fe9f31a1d 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -64,6 +64,8 @@
#include <qpa/qplatformmenu.h>
+#include <functional>
+
QT_REQUIRE_CONFIG(menu);
QT_BEGIN_NAMESPACE
@@ -302,6 +304,8 @@ class QMenuPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QMenu)
public:
+ using PositionFunction = std::function<QPoint(const QSize &)>;
+
QMenuPrivate() :
itemsDirty(false),
hasCheckableItems(false),
@@ -351,6 +355,8 @@ public:
QRect popupGeometry(int screen) const;
bool useFullScreenForPopup() const;
int getLastVisibleAction() const;
+ void popup(const QPoint &p, QAction *atAction, PositionFunction positionFunction = {});
+ QAction *exec(const QPoint &p, QAction *action, PositionFunction positionFunction = {});
//selection
static QMenu *mouseDown;
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index d54c0d0b20d..87e8af13825 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -2250,17 +2250,17 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant a
}
const QPointF offset = contentOffset();
- switch (argument.type()) {
- case QVariant::RectF:
+ switch (argument.userType()) {
+ case QMetaType::QRectF:
argument = argument.toRectF().translated(-offset);
break;
- case QVariant::PointF:
+ case QMetaType::QPointF:
argument = argument.toPointF() - offset;
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
argument = argument.toRect().translated(-offset.toPoint());
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
argument = argument.toPoint() - offset;
break;
default:
@@ -2268,14 +2268,14 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant a
}
const QVariant v = d->control->inputMethodQuery(query, argument);
- switch (v.type()) {
- case QVariant::RectF:
+ switch (v.userType()) {
+ case QMetaType::QRectF:
return v.toRectF().translated(offset);
- case QVariant::PointF:
+ case QMetaType::QPointF:
return v.toPointF() + offset;
- case QVariant::Rect:
+ case QMetaType::QRect:
return v.toRect().translated(offset.toPoint());
- case QVariant::Point:
+ case QMetaType::QPoint:
return v.toPoint() + offset.toPoint();
default:
break;
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index 61ea81c8925..08428f673ed 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -1081,7 +1081,7 @@ QSpinBoxPrivate::QSpinBoxPrivate()
value = minimum;
displayIntegerBase = 10;
singleStep = QVariant((int)1);
- type = QVariant::Int;
+ type = QMetaType::Int;
}
/*!
@@ -1238,7 +1238,7 @@ QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate()
value = minimum;
singleStep = QVariant(1.0);
decimals = 2;
- type = QVariant::Double;
+ type = QMetaType::Double;
}
/*!
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index a7b115a1bc6..df480629dac 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -208,7 +208,7 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex)
option->selectedPosition = QStyleOptionTab::NotAdjacent;
const bool paintBeginning = (tabIndex == firstVisible) || (dragInProgress && tabIndex == pressedIndex + 1);
- const bool paintEnd = (tabIndex == lastVisible - 1) || (dragInProgress && tabIndex == pressedIndex - 1);
+ const bool paintEnd = (tabIndex == lastVisible) || (dragInProgress && tabIndex == pressedIndex - 1);
if (paintBeginning) {
if (paintEnd)
option->position = QStyleOptionTab::OnlyOneTab;
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index f0bfe67e3ab..a19dacda521 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -612,7 +612,7 @@ void QTabWidget::setTabVisible(int index, bool visible)
Only the horizontal element of the \a corner will be used.
- Passing 0 shows no widget in the corner.
+ Passing \nullptr shows no widget in the corner.
Any previously set corner widget is hidden.
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index d0ccd435b35..78fde94fadf 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -152,6 +152,16 @@ public:
QTextCursor prevFocus;
int lastKeypadScrollValue;
#endif
+ void emitHighlighted(const QUrl &url)
+ {
+ Q_Q(QTextBrowser);
+ emit q->highlighted(url);
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ emit q->highlighted(url.toString());
+#endif
+ }
};
Q_DECLARE_TYPEINFO(QTextBrowserPrivate::HistoryEntry, Q_MOVABLE_TYPE);
@@ -256,24 +266,20 @@ void QTextBrowserPrivate::_q_activateAnchor(const QString &href)
void QTextBrowserPrivate::_q_highlightLink(const QString &anchor)
{
- Q_Q(QTextBrowser);
if (anchor.isEmpty()) {
#ifndef QT_NO_CURSOR
if (viewport->cursor().shape() != Qt::PointingHandCursor)
oldCursor = viewport->cursor();
viewport->setCursor(oldCursor);
#endif
- emit q->highlighted(QUrl());
- emit q->highlighted(QString());
+ emitHighlighted(QUrl());
} else {
#ifndef QT_NO_CURSOR
viewport->setCursor(Qt::PointingHandCursor);
#endif
const QUrl url = resolveUrl(anchor);
- emit q->highlighted(url);
- // convenience to ease connecting to QStatusBar::showMessage(const QString &)
- emit q->highlighted(url.toString());
+ emitHighlighted(url);
}
}
@@ -310,9 +316,9 @@ void QTextBrowserPrivate::setSource(const QUrl &url, QTextDocument::ResourceType
if (url.isValid()
&& (newUrlWithoutFragment != currentUrlWithoutFragment || forceLoadOnSourceChange)) {
QVariant data = q->loadResource(type, resolveUrl(url));
- if (data.type() == QVariant::String) {
+ if (data.userType() == QMetaType::QString) {
txt = data.toString();
- } else if (data.type() == QVariant::ByteArray) {
+ } else if (data.userType() == QMetaType::QByteArray) {
if (type == QTextDocument::HtmlResource) {
#if QT_CONFIG(textcodec)
QByteArray ba = data.toByteArray();
@@ -383,8 +389,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url, QTextDocument::ResourceType
}
#ifdef QT_KEYPAD_NAVIGATION
lastKeypadScrollValue = vbar->value();
- emit q->highlighted(QUrl());
- emit q->highlighted(QString());
+ emitHighlighted(QUrl());
#endif
#ifndef QT_NO_CURSOR
@@ -559,8 +564,7 @@ void QTextBrowserPrivate::keypadMove(bool next)
// Ensure that the new selection is highlighted.
const QString href = control->anchorAtCursor();
QUrl url = resolveUrl(href);
- emit q->highlighted(url);
- emit q->highlighted(url.toString());
+ emitHighlighted(url);
} else {
// Scroll
vbar->setValue(scrollYOffset);
@@ -575,8 +579,7 @@ void QTextBrowserPrivate::keypadMove(bool next)
hbar->setValue(savedXOffset);
vbar->setValue(scrollYOffset);
- emit q->highlighted(QUrl());
- emit q->highlighted(QString());
+ emitHighlighted(QUrl());
}
}
#endif
@@ -619,8 +622,7 @@ void QTextBrowserPrivate::restoreHistoryEntry(const HistoryEntry &entry)
Q_Q(QTextBrowser);
const QString href = prevFocus.charFormat().anchorHref();
QUrl url = resolveUrl(href);
- emit q->highlighted(url);
- emit q->highlighted(url.toString());
+ emitHighlighted(url);
#endif
}
@@ -927,6 +929,7 @@ void QTextBrowser::doSetSource(const QUrl &url, QTextDocument::ResourceType type
/*! \fn void QTextBrowser::highlighted(const QString &link)
\overload
+ \obsolete
Convenience signal that allows connecting to a slot
that takes just a QString, like for example QStatusBar's
@@ -1127,8 +1130,7 @@ bool QTextBrowser::focusNextPrevChild(bool next)
if (d->prevFocus != d->control->textCursor() && d->control->textCursor().hasSelection()) {
const QString href = d->control->anchorAtCursor();
QUrl url = d->resolveUrl(href);
- emit highlighted(url);
- emit highlighted(url.toString());
+ emitHighlighted(url);
}
d->prevFocus = d->control->textCursor();
#endif
@@ -1136,8 +1138,7 @@ bool QTextBrowser::focusNextPrevChild(bool next)
} else {
#ifdef QT_KEYPAD_NAVIGATION
// We assume we have no highlight now.
- emit highlighted(QUrl());
- emit highlighted(QString());
+ emitHighlighted(QUrl());
#endif
}
return QTextEdit::focusNextPrevChild(next);
diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h
index 33e5b3980c4..4b3ec491ee0 100644
--- a/src/widgets/widgets/qtextbrowser.h
+++ b/src/widgets/widgets/qtextbrowser.h
@@ -107,7 +107,10 @@ Q_SIGNALS:
void historyChanged();
void sourceChanged(const QUrl &);
void highlighted(const QUrl &);
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_VERSION_X_5_15("Use QTextBrowser::highlighted(QUrl) instead")
void highlighted(const QString &);
+#endif
void anchorClicked(const QUrl &);
protected:
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 10de7d0b9e3..913ca6ec164 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -1502,7 +1502,7 @@ void QTextEdit::resizeEvent(QResizeEvent *e)
QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment");
if (!doc->pageSize().isNull()
- && alignmentProperty.type() == QVariant::Bool
+ && alignmentProperty.userType() == QMetaType::Bool
&& !alignmentProperty.toBool()) {
d->_q_adjustScrollbars();
@@ -1547,7 +1547,7 @@ void QTextEditPrivate::relayoutDocument()
width = lineWrapColumnOrWidth;
else if (lineWrap == QTextEdit::NoWrap) {
QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment");
- if (alignmentProperty.type() == QVariant::Bool && !alignmentProperty.toBool()) {
+ if (alignmentProperty.userType() == QMetaType::Bool && !alignmentProperty.toBool()) {
width = 0;
}
@@ -1835,17 +1835,17 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argume
}
const QPointF offset(-d->horizontalOffset(), -d->verticalOffset());
- switch (argument.type()) {
- case QVariant::RectF:
+ switch (argument.userType()) {
+ case QMetaType::QRectF:
argument = argument.toRectF().translated(-offset);
break;
- case QVariant::PointF:
+ case QMetaType::QPointF:
argument = argument.toPointF() - offset;
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
argument = argument.toRect().translated(-offset.toPoint());
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
argument = argument.toPoint() - offset;
break;
default:
@@ -1853,14 +1853,14 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argume
}
const QVariant v = d->control->inputMethodQuery(query, argument);
- switch (v.type()) {
- case QVariant::RectF:
+ switch (v.userType()) {
+ case QMetaType::QRectF:
return v.toRectF().translated(offset);
- case QVariant::PointF:
+ case QMetaType::QPointF:
return v.toPointF() + offset;
- case QVariant::Rect:
+ case QMetaType::QRect:
return v.toRect().translated(offset.toPoint());
- case QVariant::Point:
+ case QMetaType::QPoint:
return v.toPoint() + offset.toPoint();
default:
break;
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index 127960b23cc..cfa4782d785 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -723,38 +723,12 @@ void QToolButtonPrivate::_q_buttonReleased()
popupTimer.stop();
}
-void QToolButtonPrivate::popupTimerDone()
+static QPoint positionMenu(const QToolButton *q, bool horizontal,
+ const QSize &sh)
{
- Q_Q(QToolButton);
- popupTimer.stop();
- if (!menuButtonDown && !down)
- return;
-
- menuButtonDown = true;
- QPointer<QMenu> actualMenu;
- bool mustDeleteActualMenu = false;
- if(menuAction) {
- actualMenu = menuAction->menu();
- } else if (defaultAction && defaultAction->menu()) {
- actualMenu = defaultAction->menu();
- } else {
- actualMenu = new QMenu(q);
- mustDeleteActualMenu = true;
- for(int i = 0; i < actions.size(); i++)
- actualMenu->addAction(actions.at(i));
- }
- repeat = q->autoRepeat();
- q->setAutoRepeat(false);
- bool horizontal = true;
-#if QT_CONFIG(toolbar)
- QToolBar *tb = qobject_cast<QToolBar*>(parent);
- if (tb && tb->orientation() == Qt::Vertical)
- horizontal = false;
-#endif
QPoint p;
const QRect rect = q->rect(); // Find screen via point in case of QGraphicsProxyWidget.
QRect screen = QDesktopWidgetPrivate::availableGeometry(q->mapToGlobal(rect.center()));
- QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
if (horizontal) {
if (q->isRightToLeft()) {
if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.bottom()) {
@@ -788,6 +762,37 @@ void QToolButtonPrivate::popupTimerDone()
}
p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width()));
p.ry() += 1;
+ return p;
+}
+
+void QToolButtonPrivate::popupTimerDone()
+{
+ Q_Q(QToolButton);
+ popupTimer.stop();
+ if (!menuButtonDown && !down)
+ return;
+
+ menuButtonDown = true;
+ QPointer<QMenu> actualMenu;
+ bool mustDeleteActualMenu = false;
+ if (menuAction) {
+ actualMenu = menuAction->menu();
+ } else if (defaultAction && defaultAction->menu()) {
+ actualMenu = defaultAction->menu();
+ } else {
+ actualMenu = new QMenu(q);
+ mustDeleteActualMenu = true;
+ for (int i = 0; i < actions.size(); i++)
+ actualMenu->addAction(actions.at(i));
+ }
+ repeat = q->autoRepeat();
+ q->setAutoRepeat(false);
+ bool horizontal = true;
+#if QT_CONFIG(toolbar)
+ QToolBar *tb = qobject_cast<QToolBar*>(parent);
+ if (tb && tb->orientation() == Qt::Vertical)
+ horizontal = false;
+#endif
QPointer<QToolButton> that = q;
actualMenu->setNoReplayFor(q);
if (!mustDeleteActualMenu) //only if action are not in this widget
@@ -796,7 +801,11 @@ void QToolButtonPrivate::popupTimerDone()
actualMenu->d_func()->causedPopup.widget = q;
actualMenu->d_func()->causedPopup.action = defaultAction;
actionsCopy = q->actions(); //(the list of action may be modified in slots)
- actualMenu->exec(p);
+
+ // QTBUG-78966, Delay positioning until after aboutToShow().
+ auto positionFunction = [q, horizontal](const QSize &sizeHint) {
+ return positionMenu(q, horizontal, sizeHint); };
+ actualMenu->d_func()->exec({}, nullptr, positionFunction);
if (!that)
return;
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 90e97f512c9..647e22bf263 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -60,6 +60,9 @@
#include <qshareddata.h>
#include <qdebug.h>
#include <qxmlstream.h>
+#include <private/qduplicatetracker_p.h>
+
+
#include <stdio.h>
QT_BEGIN_NAMESPACE
@@ -4081,10 +4084,10 @@ void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const
}
s << '<' << qName << nsDecl;
- QSet<QString> outputtedPrefixes;
/* Write out attributes. */
if (!m_attr->map.isEmpty()) {
+ QDuplicateTracker<QString> outputtedPrefixes;
QHash<QString, QDomNodePrivate *>::const_iterator it = m_attr->map.constBegin();
for (; it != m_attr->map.constEnd(); ++it) {
s << ' ';
@@ -4105,9 +4108,8 @@ void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const
* arrive in those situations. */
if((!it.value()->ownerNode ||
it.value()->ownerNode->prefix != it.value()->prefix) &&
- !outputtedPrefixes.contains(it.value()->prefix)) {
+ !outputtedPrefixes.hasSeen(it.value()->prefix)) {
s << " xmlns:" << it.value()->prefix << "=\"" << encodeText(it.value()->namespaceURI, s, true, true) << '\"';
- outputtedPrefixes.insert(it.value()->prefix);
}
}
}
diff --git a/tests/auto/gui/rhi/qrhi/data/compile.bat b/tests/auto/gui/rhi/qrhi/data/buildshaders.bat
index 5b8a77b8337..5b8a77b8337 100644
--- a/tests/auto/gui/rhi/qrhi/data/compile.bat
+++ b/tests/auto/gui/rhi/qrhi/data/buildshaders.bat
diff --git a/tests/auto/gui/rhi/qrhi/data/simple.frag.qsb b/tests/auto/gui/rhi/qrhi/data/simple.frag.qsb
index 264b71ec0f5..c235108d39e 100644
--- a/tests/auto/gui/rhi/qrhi/data/simple.frag.qsb
+++ b/tests/auto/gui/rhi/qrhi/data/simple.frag.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/simple.vert.qsb b/tests/auto/gui/rhi/qrhi/data/simple.vert.qsb
index 59080b60c69..68cfeb8f1d8 100644
--- a/tests/auto/gui/rhi/qrhi/data/simple.vert.qsb
+++ b/tests/auto/gui/rhi/qrhi/data/simple.vert.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletextured.frag.qsb b/tests/auto/gui/rhi/qrhi/data/simpletextured.frag.qsb
index f302702aa99..397961c2388 100644
--- a/tests/auto/gui/rhi/qrhi/data/simpletextured.frag.qsb
+++ b/tests/auto/gui/rhi/qrhi/data/simpletextured.frag.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletextured.vert.qsb b/tests/auto/gui/rhi/qrhi/data/simpletextured.vert.qsb
index e4f12bfb9e7..a9067949a57 100644
--- a/tests/auto/gui/rhi/qrhi/data/simpletextured.vert.qsb
+++ b/tests/auto/gui/rhi/qrhi/data/simpletextured.vert.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/textured.frag.qsb b/tests/auto/gui/rhi/qrhi/data/textured.frag.qsb
index 0a039137ec4..018d732e2f3 100644
--- a/tests/auto/gui/rhi/qrhi/data/textured.frag.qsb
+++ b/tests/auto/gui/rhi/qrhi/data/textured.frag.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/textured.vert.qsb b/tests/auto/gui/rhi/qrhi/data/textured.vert.qsb
index 7853f779435..44454d226ea 100644
--- a/tests/auto/gui/rhi/qrhi/data/textured.vert.qsb
+++ b/tests/auto/gui/rhi/qrhi/data/textured.vert.qsb
Binary files differ
diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
index 14718ad373f..a7a81e9f0b0 100644
--- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
@@ -86,6 +86,8 @@ private slots:
void fromDevice();
void fromPath_data();
void fromPath();
+ void fromPath_qregularexpression_data();
+ void fromPath_qregularexpression();
void certInfo();
void certInfoQByteArray();
void task256066toPem();
@@ -434,7 +436,7 @@ void tst_QSslCertificate::subjectAlternativeNames()
void tst_QSslCertificate::utf8SubjectNames()
{
QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert-ss-san-utf8.pem", QSsl::Pem,
- QRegExp::FixedString).first();
+ QSslCertificate::FixedString).first();
QVERIFY(!cert.isNull());
// O is "Heavy Metal Records" with heavy use of "decorations" like accents, umlauts etc.,
@@ -625,6 +627,88 @@ void tst_QSslCertificate::fromPath()
numCerts);
}
+void tst_QSslCertificate::fromPath_qregularexpression_data()
+{
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<int>("syntax");
+ QTest::addColumn<bool>("pemencoding");
+ QTest::addColumn<int>("numCerts");
+
+ QTest::newRow("empty fixed pem") << QString() << int(QSslCertificate::FixedString) << true << 0;
+ QTest::newRow("empty fixed der") << QString() << int(QSslCertificate::FixedString) << false << 0;
+ QTest::newRow("empty regexp pem") << QString() << int(QSslCertificate::RegExp) << true << 0;
+ QTest::newRow("empty regexp der") << QString() << int(QSslCertificate::RegExp) << false << 0;
+ QTest::newRow("empty wildcard pem") << QString() << int(QSslCertificate::Wildcard) << true << 0;
+ QTest::newRow("empty wildcard der") << QString() << int(QSslCertificate::Wildcard) << false << 0;
+ QTest::newRow("\"certificates\" fixed pem") << (testDataDir + "certificates") << int(QSslCertificate::FixedString) << true << 0;
+ QTest::newRow("\"certificates\" fixed der") << (testDataDir + "certificates") << int(QSslCertificate::FixedString) << false << 0;
+ QTest::newRow("\"certificates\" regexp pem") << (testDataDir + "certificates") << int(QSslCertificate::RegExp) << true << 0;
+ QTest::newRow("\"certificates\" regexp der") << (testDataDir + "certificates") << int(QSslCertificate::RegExp) << false << 0;
+ QTest::newRow("\"certificates\" wildcard pem") << (testDataDir + "certificates") << int(QSslCertificate::Wildcard) << true << 0;
+ QTest::newRow("\"certificates\" wildcard der") << (testDataDir + "certificates") << int(QSslCertificate::Wildcard) << false << 0;
+ QTest::newRow("\"certificates/cert.pem\" fixed pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::FixedString) << true << 1;
+ QTest::newRow("\"certificates/cert.pem\" fixed der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::FixedString) << false << 0;
+ QTest::newRow("\"certificates/cert.pem\" regexp pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::RegExp) << true << 1;
+ QTest::newRow("\"certificates/cert.pem\" regexp der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::RegExp) << false << 0;
+ QTest::newRow("\"certificates/cert.pem\" wildcard pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::Wildcard) << true << 1;
+ QTest::newRow("\"certificates/cert.pem\" wildcard der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::Wildcard) << false << 0;
+ QTest::newRow("\"certificates/*\" fixed pem") << (testDataDir + "certificates/*") << int(QSslCertificate::FixedString) << true << 0;
+ QTest::newRow("\"certificates/*\" fixed der") << (testDataDir + "certificates/*") << int(QSslCertificate::FixedString) << false << 0;
+ QTest::newRow("\"certificates/*\" regexp pem") << (testDataDir + "certificates/*") << int(QSslCertificate::RegExp) << true << 0;
+ QTest::newRow("\"certificates/*\" regexp der") << (testDataDir + "certificates/*") << int(QSslCertificate::RegExp) << false << 0;
+ QTest::newRow("\"certificates/*\" wildcard pem") << (testDataDir + "certificates/*") << int(QSslCertificate::Wildcard) << true << 7;
+ QTest::newRow("\"certificates/ca*\" wildcard pem") << (testDataDir + "certificates/ca*") << int(QSslCertificate::Wildcard) << true << 1;
+ QTest::newRow("\"certificates/cert*\" wildcard pem") << (testDataDir + "certificates/cert*") << int(QSslCertificate::Wildcard) << true << 4;
+ QTest::newRow("\"certificates/cert-[sure]*\" wildcard pem") << (testDataDir + "certificates/cert-[sure]*") << int(QSslCertificate::Wildcard) << true << 3;
+ QTest::newRow("\"certificates/cert-[not]*\" wildcard pem") << (testDataDir + "certificates/cert-[not]*") << int(QSslCertificate::Wildcard) << true << 0;
+ QTest::newRow("\"certificates/*\" wildcard der") << (testDataDir + "certificates/*") << int(QSslCertificate::Wildcard) << false << 2;
+ QTest::newRow("\"c*/c*.pem\" fixed pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::FixedString) << true << 0;
+ QTest::newRow("\"c*/c*.pem\" fixed der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::FixedString) << false << 0;
+ QTest::newRow("\"c*/c*.pem\" regexp pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::RegExp) << true << 0;
+ QTest::newRow("\"c*/c*.pem\" regexp der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::RegExp) << false << 0;
+ QTest::newRow("\"c*/c*.pem\" wildcard pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::Wildcard) << true << 5;
+ QTest::newRow("\"c*/c*.pem\" wildcard der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::Wildcard) << false << 0;
+ QTest::newRow("\"d*/c*.pem\" fixed pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::FixedString) << true << 0;
+ QTest::newRow("\"d*/c*.pem\" fixed der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::FixedString) << false << 0;
+ QTest::newRow("\"d*/c*.pem\" regexp pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::RegExp) << true << 0;
+ QTest::newRow("\"d*/c*.pem\" regexp der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::RegExp) << false << 0;
+ QTest::newRow("\"d*/c*.pem\" wildcard pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::Wildcard) << true << 0;
+ QTest::newRow("\"d*/c*.pem\" wildcard der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::Wildcard) << false << 0;
+ QTest::newRow("\"c.*/c.*.pem\" fixed pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::FixedString) << true << 0;
+ QTest::newRow("\"c.*/c.*.pem\" fixed der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::FixedString) << false << 0;
+ QTest::newRow("\"c.*/c.*.pem\" regexp pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::RegExp) << true << 5;
+ QTest::newRow("\"c.*/c.*.pem\" regexp der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::RegExp) << false << 0;
+ QTest::newRow("\"c.*/c.*.pem\" wildcard pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::Wildcard) << true << 0;
+ QTest::newRow("\"c.*/c.*.pem\" wildcard der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::Wildcard) << false << 0;
+ QTest::newRow("\"d.*/c.*.pem\" fixed pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::FixedString) << true << 0;
+ QTest::newRow("\"d.*/c.*.pem\" fixed der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::FixedString) << false << 0;
+ QTest::newRow("\"d.*/c.*.pem\" regexp pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::RegExp) << true << 0;
+ QTest::newRow("\"d.*/c.*.pem\" regexp der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::RegExp) << false << 0;
+ QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::Wildcard) << true << 0;
+ QTest::newRow("\"d.*/c.*.pem\" wildcard der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::Wildcard) << false << 0;
+#ifdef Q_OS_LINUX
+ QTest::newRow("absolute path wildcard pem") << (testDataDir + "certificates/*.pem") << int(QSslCertificate::Wildcard) << true << 7;
+#endif
+
+ QTest::newRow("trailing-whitespace") << (testDataDir + "more-certificates/trailing-whitespace.pem") << int(QSslCertificate::FixedString) << true << 1;
+ QTest::newRow("no-ending-newline") << (testDataDir + "more-certificates/no-ending-newline.pem") << int(QSslCertificate::FixedString) << true << 1;
+ QTest::newRow("malformed-just-begin") << (testDataDir + "more-certificates/malformed-just-begin.pem") << int(QSslCertificate::FixedString) << true << 0;
+ QTest::newRow("malformed-just-begin-no-newline") << (testDataDir + "more-certificates/malformed-just-begin-no-newline.pem") << int(QSslCertificate::FixedString) << true << 0;
+}
+
+void tst_QSslCertificate::fromPath_qregularexpression()
+{
+ QFETCH(QString, path);
+ QFETCH(int, syntax);
+ QFETCH(bool, pemencoding);
+ QFETCH(int, numCerts);
+
+ QCOMPARE(QSslCertificate::fromPath(path,
+ pemencoding ? QSsl::Pem : QSsl::Der,
+ QSslCertificate::PatternSyntax(syntax)).size(),
+ numCerts);
+}
+
void tst_QSslCertificate::certInfo()
{
// MD5 Fingerprint=B6:CF:57:34:DA:A9:73:21:82:F7:CF:4D:3D:85:31:88
@@ -711,7 +795,7 @@ void tst_QSslCertificate::certInfo()
"55:ba:e7:fb:95:5d:91";
QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem,
- QRegExp::FixedString).first();
+ QSslCertificate::FixedString).first();
QVERIFY(!cert.isNull());
QCOMPARE(cert.issuerInfo(QSslCertificate::Organization)[0], QString("CryptSoft Pty Ltd"));
@@ -768,7 +852,7 @@ void tst_QSslCertificate::certInfo()
void tst_QSslCertificate::certInfoQByteArray()
{
QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem,
- QRegExp::FixedString).first();
+ QSslCertificate::FixedString).first();
QVERIFY(!cert.isNull());
// in this test, check the bytearray variants before the enum variants to see if
@@ -820,7 +904,7 @@ void tst_QSslCertificate::nulInCN()
QSKIP("Generic QSslCertificatePrivate fails this test");
#endif
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "more-certificates/badguy-nul-cn.crt");
+ QSslCertificate::fromPath(testDataDir + "more-certificates/badguy-nul-cn.crt", QSsl::Pem, QSslCertificate::FixedString);
QCOMPARE(certList.size(), 1);
const QSslCertificate &cert = certList.at(0);
@@ -839,7 +923,7 @@ void tst_QSslCertificate::nulInSan()
QSKIP("Generic QSslCertificatePrivate fails this test");
#endif
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "more-certificates/badguy-nul-san.crt");
+ QSslCertificate::fromPath(testDataDir + "more-certificates/badguy-nul-san.crt", QSsl::Pem, QSslCertificate::FixedString);
QCOMPARE(certList.size(), 1);
const QSslCertificate &cert = certList.at(0);
@@ -859,7 +943,7 @@ void tst_QSslCertificate::nulInSan()
void tst_QSslCertificate::largeSerialNumber()
{
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-serial-number.pem");
+ QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-serial-number.pem", QSsl::Pem, QSslCertificate::FixedString);
QCOMPARE(certList.size(), 1);
@@ -871,7 +955,7 @@ void tst_QSslCertificate::largeSerialNumber()
void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489
{
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem");
+ QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem", QSsl::Pem, QSslCertificate::FixedString);
QCOMPARE(certList.size(), 1);
@@ -884,7 +968,7 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489
void tst_QSslCertificate::blacklistedCertificates()
{
- QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath(testDataDir + "more-certificates/blacklisted*.pem", QSsl::Pem, QRegExp::Wildcard);
+ QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath(testDataDir + "more-certificates/blacklisted*.pem", QSsl::Pem, QSslCertificate::Wildcard);
QVERIFY(blacklistedCerts.count() > 0);
for (int a = 0; a < blacklistedCerts.count(); a++) {
QVERIFY(blacklistedCerts.at(a).isBlacklisted());
@@ -893,15 +977,15 @@ void tst_QSslCertificate::blacklistedCertificates()
void tst_QSslCertificate::selfsignedCertificates()
{
- QVERIFY(QSslCertificate::fromPath(testDataDir + "certificates/cert-ss.pem").first().isSelfSigned());
- QVERIFY(!QSslCertificate::fromPath(testDataDir + "certificates/cert.pem").first().isSelfSigned());
+ QVERIFY(QSslCertificate::fromPath(testDataDir + "certificates/cert-ss.pem", QSsl::Pem, QSslCertificate::FixedString).first().isSelfSigned());
+ QVERIFY(!QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem, QSslCertificate::FixedString).first().isSelfSigned());
QVERIFY(!QSslCertificate().isSelfSigned());
}
void tst_QSslCertificate::toText()
{
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem");
+ QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem", QSsl::Pem, QSslCertificate::FixedString);
QCOMPARE(certList.size(), 1);
const QSslCertificate &cert = certList.at(0);
@@ -943,7 +1027,7 @@ void tst_QSslCertificate::toText()
void tst_QSslCertificate::multipleCommonNames()
{
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-two-cns-cert.pem");
+ QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-two-cns-cert.pem", QSsl::Pem, QSslCertificate::FixedString);
QVERIFY(certList.count() > 0);
QStringList commonNames = certList[0].subjectInfo(QSslCertificate::CommonName);
@@ -954,14 +1038,14 @@ void tst_QSslCertificate::multipleCommonNames()
void tst_QSslCertificate::subjectAndIssuerAttributes()
{
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-with-drink-cert.pem");
+ QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-with-drink-cert.pem", QSsl::Pem, QSslCertificate::FixedString);
QVERIFY(certList.count() > 0);
QList<QByteArray> attributes = certList[0].subjectInfoAttributes();
QVERIFY(attributes.contains(QByteArray("favouriteDrink")));
attributes.clear();
- certList = QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem");
+ certList = QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::FixedString);
QVERIFY(certList.count() > 0);
QByteArray shortName("1.3.6.1.4.1.311.60.2.1.3");
@@ -996,17 +1080,17 @@ void tst_QSslCertificate::verify()
errors.clear();
// Verify a valid cert signed by a CA
- QList<QSslCertificate> caCerts = QSslCertificate::fromPath(testDataDir + "verify-certs/cacert.pem");
+ QList<QSslCertificate> caCerts = QSslCertificate::fromPath(testDataDir + "verify-certs/cacert.pem", QSsl::Pem, QSslCertificate::FixedString);
QSslSocket::addDefaultCaCertificate(caCerts.first());
- toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem");
+ toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::FixedString);
errors = QSslCertificate::verify(toVerify);
VERIFY_VERBOSE(errors.count() == 0);
errors.clear();
// Test a blacklisted certificate
- toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem");
+ toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem", QSsl::Pem, QSslCertificate::FixedString);
errors = QSslCertificate::verify(toVerify);
bool foundBlack = false;
foreach (const QSslError &error, errors) {
@@ -1019,7 +1103,7 @@ void tst_QSslCertificate::verify()
errors.clear();
// This one is expired and untrusted
- toVerify = QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-serial-number.pem");
+ toVerify = QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-serial-number.pem", QSsl::Pem, QSslCertificate::FixedString);
errors = QSslCertificate::verify(toVerify);
VERIFY_VERBOSE(errors.contains(QSslError(QSslError::SelfSignedCertificate, toVerify[0])));
VERIFY_VERBOSE(errors.contains(QSslError(QSslError::CertificateExpired, toVerify[0])));
@@ -1027,15 +1111,15 @@ void tst_QSslCertificate::verify()
toVerify.clear();
// This one is signed by a valid cert, but the signer is not a valid CA
- toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-not-ca-cert.pem").first();
- toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem").first();
+ toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-not-ca-cert.pem", QSsl::Pem, QSslCertificate::FixedString).first();
+ toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::FixedString).first();
errors = QSslCertificate::verify(toVerify);
VERIFY_VERBOSE(errors.contains(QSslError(QSslError::InvalidCaCertificate, toVerify[1])));
toVerify.clear();
// This one is signed by a valid cert, and the signer is a valid CA
- toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-is-ca-cert.pem").first();
- toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-ca-cert.pem").first();
+ toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-is-ca-cert.pem", QSsl::Pem, QSslCertificate::FixedString).first();
+ toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-ca-cert.pem", QSsl::Pem, QSslCertificate::FixedString).first();
errors = QSslCertificate::verify(toVerify);
VERIFY_VERBOSE(errors.count() == 0);
@@ -1065,7 +1149,7 @@ QString tst_QSslCertificate::toString(const QList<QSslError>& errors)
void tst_QSslCertificate::extensions()
{
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem");
+ QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::FixedString);
QVERIFY(certList.count() > 0);
QSslCertificate cert = certList[0];
@@ -1163,7 +1247,7 @@ void tst_QSslCertificate::extensions()
void tst_QSslCertificate::extensionsCritical()
{
QList<QSslCertificate> certList =
- QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem");
+ QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem", QSsl::Pem, QSslCertificate::FixedString);
QVERIFY(certList.count() > 0);
QSslCertificate cert = certList[0];
@@ -1284,12 +1368,12 @@ void tst_QSslCertificate::version_data()
QTest::newRow("null certificate") << QSslCertificate() << QByteArray();
QList<QSslCertificate> certs;
- certs << QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem");
+ certs << QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::FixedString);
QTest::newRow("v3 certificate") << certs.first() << QByteArrayLiteral("3");
certs.clear();
- certs << QSslCertificate::fromPath(testDataDir + "certificates/cert.pem");
+ certs << QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem, QSslCertificate::FixedString);
QTest::newRow("v1 certificate") << certs.first() << QByteArrayLiteral("1");
}
@@ -1326,7 +1410,7 @@ void tst_QSslCertificate::pkcs12()
QVERIFY(ok);
f.close();
- QList<QSslCertificate> leafCert = QSslCertificate::fromPath(testDataDir + QLatin1String("pkcs12/leaf.crt"));
+ QList<QSslCertificate> leafCert = QSslCertificate::fromPath(testDataDir + QLatin1String("pkcs12/leaf.crt"), QSsl::Pem, QSslCertificate::FixedString);
QVERIFY(!leafCert.isEmpty());
QCOMPARE(cert, leafCert.first());
@@ -1341,7 +1425,7 @@ void tst_QSslCertificate::pkcs12()
QVERIFY(!leafKey.isNull());
QCOMPARE(key, leafKey);
- QList<QSslCertificate> caCert = QSslCertificate::fromPath(testDataDir + QLatin1String("pkcs12/inter.crt"));
+ QList<QSslCertificate> caCert = QSslCertificate::fromPath(testDataDir + QLatin1String("pkcs12/inter.crt"), QSsl::Pem, QSslCertificate::FixedString);
QVERIFY(!caCert.isEmpty());
QVERIFY(!caCerts.isEmpty());
diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json
index 2a70a525879..0ce464a709b 100644
--- a/tests/auto/tools/moc/allmocs_baseline_in.json
+++ b/tests/auto/tools/moc/allmocs_baseline_in.json
@@ -1023,6 +1023,7 @@
"final": false,
"name": "prop1",
"read": "getProp1",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "FwdClass1",
@@ -1035,6 +1036,7 @@
"final": false,
"name": "prop2",
"read": "getProp2",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "FwdClass2",
@@ -1047,6 +1049,7 @@
"final": false,
"name": "prop3",
"read": "getProp3",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "FwdClass3",
@@ -1157,6 +1160,7 @@
"final": false,
"name": "flags",
"read": "flags",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Flags",
@@ -1181,6 +1185,7 @@
"final": false,
"name": "flags",
"read": "flags",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Foo::Bar::Flags",
@@ -1193,6 +1198,7 @@
"final": false,
"name": "flagsList",
"read": "flagsList",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "QVector<Foo::Bar::Flags>",
@@ -1706,6 +1712,7 @@
"final": false,
"name": "blah",
"read": "blah",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "A::SomeEnum",
@@ -1755,6 +1762,7 @@
"final": false,
"name": "blah",
"read": "blah",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "A::SomeEnum",
@@ -1924,6 +1932,7 @@
"final": false,
"name": "gadgetPoperty",
"read": "gadgetPoperty",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Gadget::SomeEnum",
@@ -1935,6 +1944,7 @@
"final": false,
"name": "objectPoperty",
"read": "objectPoperty",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Object::SomeEnum",
@@ -1958,6 +1968,7 @@
"final": false,
"name": "nestedGadgetPoperty",
"read": "nestedGadgetPoperty",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Nested::Gadget::SomeEnum",
@@ -1981,6 +1992,7 @@
"final": false,
"name": "nestedObjectPoperty",
"read": "nestedObjectPoperty",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Nested::Object::SomeEnum",
@@ -2109,6 +2121,7 @@
"final": false,
"name": "gadgetPoperty",
"read": "gadgetPoperty",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Gadget::SomeEnum",
@@ -2120,6 +2133,7 @@
"final": false,
"name": "objectPoperty",
"read": "objectPoperty",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Object::SomeEnum",
@@ -2143,6 +2157,7 @@
"final": false,
"name": "nestedGadgetPoperty",
"read": "nestedGadgetPoperty",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Nested::Gadget::SomeEnum",
@@ -2166,6 +2181,7 @@
"final": false,
"name": "nestedObjectPoperty",
"read": "nestedObjectPoperty",
+ "required": false,
"scriptable": true,
"stored": true,
"type": "Nested::Object::SomeEnum",
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 2bad8f2e63d..a4ee6795c41 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2020 Olivier Goffart <[email protected]>
** Contact: https://www.qt.io/licensing/
**
@@ -721,6 +721,7 @@ private slots:
void cxxAttributes();
void mocJsonOutput();
void mocInclude();
+ void requiredProperties();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -4029,6 +4030,29 @@ void tst_Moc::mocInclude()
QCOMPARE(obj.prop1->x, 45);
}
+class RequiredTest :public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int required MEMBER m_required REQUIRED)
+ Q_PROPERTY(int notRequired MEMBER m_notRequired)
+
+private:
+ int m_required;
+ int m_notRequired;
+};
+
+void tst_Moc::requiredProperties()
+{
+ QMetaObject mo = RequiredTest::staticMetaObject;
+ QMetaProperty required = mo.property(mo.indexOfProperty("required"));
+ QVERIFY(required.isValid());
+ QVERIFY(required.isRequired());
+ QMetaProperty notRequired = mo.property(mo.indexOfProperty("notRequired"));
+ QVERIFY(notRequired.isValid());
+ QVERIFY(!notRequired.isRequired());
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 207327f0737..8ad4324c9eb 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -40,6 +40,7 @@
#include <QWidgetAction>
#include <QDesktopWidget>
#include <QScreen>
+#include <QSpinBox>
#include <qdialog.h>
#include <qmenu.h>
@@ -114,6 +115,7 @@ private slots:
void QTBUG30595_rtl_submenu();
void QTBUG20403_nested_popup_on_shortcut_trigger();
void QTBUG47515_widgetActionEnterLeave();
+ void QTBUG8122_widgetActionCrashOnClose();
void QTBUG_10735_crashWithDialog();
#ifdef Q_OS_MAC
@@ -1352,6 +1354,60 @@ void tst_QMenu::QTBUG47515_widgetActionEnterLeave()
}
}
+void tst_QMenu::QTBUG8122_widgetActionCrashOnClose()
+{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("Window activation is not supported");
+ if (QGuiApplication::platformName() == QLatin1String("cocoa"))
+ QSKIP("See QTBUG-63031");
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT does not support QTest::mouseMove");
+#endif
+
+ const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
+ QRect geometry(QPoint(), availableGeometry.size() / 3);
+ geometry.moveCenter(availableGeometry.center());
+ QPoint pointOutsideMenu = geometry.bottomRight() - QPoint(5, 5);
+
+ QMainWindow topLevel;
+ topLevel.setGeometry(geometry);
+
+ auto menuBar = topLevel.menuBar();
+ auto menu = menuBar->addMenu("Menu");
+ auto wAct = new QWidgetAction(menu);
+ auto spinBox1 = new QSpinBox(menu);
+ wAct->setDefaultWidget(spinBox1);
+ menu->addAction(wAct);
+ auto subMenu = menu->addMenu("Submenu");
+ auto nextMenuAct = menu->addMenu(subMenu);
+ auto wAct2 = new QWidgetAction(menu);
+ auto spinBox2 = new QSpinBox(menu);
+ wAct2->setDefaultWidget(spinBox2);
+ subMenu->addAction(wAct2);
+ QObject::connect(spinBox2, &QSpinBox::editingFinished, menu, &QMenu::hide);
+
+ topLevel.show();
+ topLevel.setWindowTitle(QTest::currentTestFunction());
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
+ QWindow *topLevelWindow = topLevel.windowHandle();
+ QVERIFY(topLevelWindow);
+
+ const QPoint menuActionPos = menuBar->mapTo(&topLevel, menuBar->actionGeometry(menu->menuAction()).center());
+ QTest::mouseClick(topLevelWindow, Qt::LeftButton, Qt::KeyboardModifiers(), menuActionPos);
+ QVERIFY(QTest::qWaitForWindowExposed(menu));
+
+ QPoint w1Center = topLevel.mapFromGlobal(spinBox1->mapToGlobal(spinBox1->rect().center()));
+ QTest::mouseClick(topLevelWindow, Qt::LeftButton, Qt::KeyboardModifiers(), w1Center);
+ menu->setActiveAction(nextMenuAct);
+ QVERIFY(QTest::qWaitForWindowExposed(subMenu));
+
+ QPoint w2Center = topLevel.mapFromGlobal(spinBox2->mapToGlobal(spinBox2->rect().center()));
+ QTest::mouseClick(topLevelWindow, Qt::LeftButton, Qt::KeyboardModifiers(), w2Center);
+ QTest::mouseMove(topLevelWindow, topLevel.mapFromGlobal(pointOutsideMenu));
+ QTRY_VERIFY(menu->isHidden());
+}
+
+
class MyMenu : public QMenu
{
Q_OBJECT
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
index bc1496d0f60..e27600bad20 100644
--- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
+++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
@@ -33,6 +33,7 @@
#include <qpushbutton.h>
#include <qstyle.h>
+#include <qstyleoption.h>
class tst_QTabBar : public QObject
{
@@ -279,30 +280,53 @@ void tst_QTabBar::hideTab()
QTEST(tabbar.currentIndex(), "finalIndex");
}
+class TabBar : public QTabBar
+{
+public:
+ using QTabBar::QTabBar;
+ using QTabBar::initStyleOption;
+ using QTabBar::moveTab;
+};
+
void tst_QTabBar::hideAllTabs()
{
- QTabBar tabbar;
+ TabBar tabbar;
+ auto checkPositions = [&tabbar](const QVector<int> &positions)
+ {
+ QStyleOptionTab option;
+ int iPos = 0;
+ for (int i = 0; i < tabbar.count(); ++i) {
+ if (!tabbar.isTabVisible(i))
+ continue;
+ tabbar.initStyleOption(&option, i);
+ QCOMPARE(option.position, positions.at(iPos++));
+ }
+ };
tabbar.addTab("foo");
tabbar.addTab("bar");
tabbar.addTab("baz");
tabbar.setCurrentIndex(0);
+ checkPositions({QStyleOptionTab::Beginning, QStyleOptionTab::Middle, QStyleOptionTab::End});
// Check we don't crash trying to hide an unexistant tab
QSize prevSizeHint = tabbar.sizeHint();
tabbar.setTabVisible(3, false);
+ checkPositions({QStyleOptionTab::Beginning, QStyleOptionTab::Middle, QStyleOptionTab::End});
QCOMPARE(tabbar.currentIndex(), 0);
QSize sizeHint = tabbar.sizeHint();
QVERIFY(sizeHint.width() == prevSizeHint.width());
prevSizeHint = sizeHint;
tabbar.setTabVisible(1, false);
+ checkPositions({QStyleOptionTab::Beginning, QStyleOptionTab::End});
QCOMPARE(tabbar.currentIndex(), 0);
sizeHint = tabbar.sizeHint();
QVERIFY(sizeHint.width() < prevSizeHint.width());
prevSizeHint = sizeHint;
tabbar.setTabVisible(2, false);
+ checkPositions({QStyleOptionTab::OnlyOneTab});
QCOMPARE(tabbar.currentIndex(), 0);
sizeHint = tabbar.sizeHint();
QVERIFY(sizeHint.width() < prevSizeHint.width());
@@ -571,14 +595,6 @@ void tst_QTabBar::selectionBehaviorOnRemove()
QCOMPARE(tabbar.currentIndex(), expected);
}
-class TabBar : public QTabBar
-{
- Q_OBJECT
-public:
- void callMoveTab(int from, int to){ moveTab(from, to); }
-};
-
-
Q_DECLARE_METATYPE(QTabBar::Shape)
void tst_QTabBar::moveTab_data()
{
@@ -613,7 +629,7 @@ void tst_QTabBar::moveTab()
bar.setShape(shape);
while(--tabs >= 0)
bar.addTab(QString::number(tabs));
- bar.callMoveTab(from, to);
+ bar.moveTab(from, to);
}
diff --git a/tests/benchmarks/corelib/text/qstringlist/main.cpp b/tests/benchmarks/corelib/text/qstringlist/main.cpp
index ae355a8b893..9f184d0cf58 100644
--- a/tests/benchmarks/corelib/text/qstringlist/main.cpp
+++ b/tests/benchmarks/corelib/text/qstringlist/main.cpp
@@ -41,6 +41,9 @@ private slots:
void join() const;
void join_data() const;
+ void removeDuplicates() const;
+ void removeDuplicates_data() const;
+
void split_qlist_qbytearray() const;
void split_qlist_qbytearray_data() const { return split_data(); }
@@ -116,6 +119,42 @@ void tst_QStringList::join_data() const
<< QString();
}
+void tst_QStringList::removeDuplicates() const
+{
+ QFETCH(const QStringList, input);
+
+ QBENCHMARK {
+ auto copy = input;
+ copy.removeDuplicates();
+ }
+}
+
+void tst_QStringList::removeDuplicates_data() const
+{
+ QTest::addColumn<QStringList>("input");
+
+ const QStringList s = {"one", "two", "three"};
+
+ QTest::addRow("empty") << QStringList();
+ QTest::addRow("short-dup-0.00") << s;
+ QTest::addRow("short-dup-0.50") << (s + s);
+ QTest::addRow("short-dup-0.66") << (s + s + s);
+ QTest::addRow("short-dup-0.75") << (s + s + s + s);
+
+ const QStringList l = []() {
+ QStringList result;
+ const int n = 1000;
+ result.reserve(n);
+ for (int i = 0; i < n; ++i)
+ result.push_back(QString::number(i));
+ return result;
+ }();
+ QTest::addRow("long-dup-0.00") << l;
+ QTest::addRow("long-dup-0.50") << (l + l);
+ QTest::addRow("long-dup-0.66") << (l + l + l);
+ QTest::addRow("long-dup-0.75") << (l + l + l + l);
+}
+
void tst_QStringList::split_data() const
{
QTest::addColumn<QString>("input");
diff --git a/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro b/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro
index 5803e7da0e1..2e7ae058f7c 100644
--- a/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro
+++ b/tests/benchmarks/corelib/text/qstringlist/qstringlist.pro
@@ -1,5 +1,6 @@
TARGET = tst_bench_qstringlist
CONFIG -= debug
CONFIG += release
+CONFIG += benchmark
QT = core testlib
SOURCES += main.cpp
diff --git a/tests/manual/rhi/computebuffer/buffer.comp.qsb b/tests/manual/rhi/computebuffer/buffer.comp.qsb
index b1a666f185c..6cb7e583652 100644
--- a/tests/manual/rhi/computebuffer/buffer.comp.qsb
+++ b/tests/manual/rhi/computebuffer/buffer.comp.qsb
Binary files differ
diff --git a/tests/manual/rhi/computebuffer/main.frag.qsb b/tests/manual/rhi/computebuffer/main.frag.qsb
index f05da411e52..09012b08008 100644
--- a/tests/manual/rhi/computebuffer/main.frag.qsb
+++ b/tests/manual/rhi/computebuffer/main.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/computebuffer/main.vert.qsb b/tests/manual/rhi/computebuffer/main.vert.qsb
index 944645ffbf0..7eb200a3da9 100644
--- a/tests/manual/rhi/computebuffer/main.vert.qsb
+++ b/tests/manual/rhi/computebuffer/main.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/computeimage/image.comp.qsb b/tests/manual/rhi/computeimage/image.comp.qsb
index 725629f7ab6..41a6225063f 100644
--- a/tests/manual/rhi/computeimage/image.comp.qsb
+++ b/tests/manual/rhi/computeimage/image.comp.qsb
Binary files differ
diff --git a/tests/manual/rhi/cubemap/cubemap.frag.qsb b/tests/manual/rhi/cubemap/cubemap.frag.qsb
index d7cc0255548..f63e73e5cb3 100644
--- a/tests/manual/rhi/cubemap/cubemap.frag.qsb
+++ b/tests/manual/rhi/cubemap/cubemap.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/cubemap/cubemap.vert.qsb b/tests/manual/rhi/cubemap/cubemap.vert.qsb
index fae136337c2..39419d6e463 100644
--- a/tests/manual/rhi/cubemap/cubemap.vert.qsb
+++ b/tests/manual/rhi/cubemap/cubemap.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/instancing/inst.frag.qsb b/tests/manual/rhi/instancing/inst.frag.qsb
index f19a2f0a713..cd6b9482279 100644
--- a/tests/manual/rhi/instancing/inst.frag.qsb
+++ b/tests/manual/rhi/instancing/inst.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/instancing/inst.vert.qsb b/tests/manual/rhi/instancing/inst.vert.qsb
index de05eae80fa..4b891636e7e 100644
--- a/tests/manual/rhi/instancing/inst.vert.qsb
+++ b/tests/manual/rhi/instancing/inst.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/mrt/mrt.frag.qsb b/tests/manual/rhi/mrt/mrt.frag.qsb
index 389b6affa33..0c83b71ee66 100644
--- a/tests/manual/rhi/mrt/mrt.frag.qsb
+++ b/tests/manual/rhi/mrt/mrt.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/mrt/mrt.vert.qsb b/tests/manual/rhi/mrt/mrt.vert.qsb
index ff8c0e50bbf..ecd4a2eb713 100644
--- a/tests/manual/rhi/mrt/mrt.vert.qsb
+++ b/tests/manual/rhi/mrt/mrt.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/shadowmap/buildshaders.sh b/tests/manual/rhi/shadowmap/buildshaders.sh
deleted file mode 100755
index 8991bb074aa..00000000000
--- a/tests/manual/rhi/shadowmap/buildshaders.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-qsb --glsl "120,300 es" --hlsl 50 --msl 12 shadowmap.vert -o shadowmap.vert.qsb
-qsb --glsl "120,300 es" --hlsl 50 --msl 12 shadowmap.frag -o shadowmap.frag.qsb
-qsb --glsl "120,300 es" --hlsl 50 --msl 12 main.vert -o main.vert.qsb
-qsb --glsl "120,300 es" --hlsl 50 --msl 12 main.frag -o main.frag.qsb
diff --git a/tests/manual/rhi/shadowmap/main.frag.qsb b/tests/manual/rhi/shadowmap/main.frag.qsb
index 3001908b85b..373c62f76dc 100644
--- a/tests/manual/rhi/shadowmap/main.frag.qsb
+++ b/tests/manual/rhi/shadowmap/main.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/shadowmap/main.vert.qsb b/tests/manual/rhi/shadowmap/main.vert.qsb
index 8b81a93c005..6392d17cd63 100644
--- a/tests/manual/rhi/shadowmap/main.vert.qsb
+++ b/tests/manual/rhi/shadowmap/main.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/shadowmap/shadowmap.frag.qsb b/tests/manual/rhi/shadowmap/shadowmap.frag.qsb
index 3cad114cf45..fabeb32e656 100644
--- a/tests/manual/rhi/shadowmap/shadowmap.frag.qsb
+++ b/tests/manual/rhi/shadowmap/shadowmap.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/shadowmap/shadowmap.vert.qsb b/tests/manual/rhi/shadowmap/shadowmap.vert.qsb
index 37a5e6ecbf1..f224728ff2e 100644
--- a/tests/manual/rhi/shadowmap/shadowmap.vert.qsb
+++ b/tests/manual/rhi/shadowmap/shadowmap.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/shared/color.frag.qsb b/tests/manual/rhi/shared/color.frag.qsb
index 3a965682eb3..51501ad5e6f 100644
--- a/tests/manual/rhi/shared/color.frag.qsb
+++ b/tests/manual/rhi/shared/color.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/shared/color.vert.qsb b/tests/manual/rhi/shared/color.vert.qsb
index e34eae79a08..e342718fecc 100644
--- a/tests/manual/rhi/shared/color.vert.qsb
+++ b/tests/manual/rhi/shared/color.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/shared/texture.frag.qsb b/tests/manual/rhi/shared/texture.frag.qsb
index 31bcd7105ea..ad11300a594 100644
--- a/tests/manual/rhi/shared/texture.frag.qsb
+++ b/tests/manual/rhi/shared/texture.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/shared/texture.vert.qsb b/tests/manual/rhi/shared/texture.vert.qsb
index 1b9e52890d6..288cce81764 100644
--- a/tests/manual/rhi/shared/texture.vert.qsb
+++ b/tests/manual/rhi/shared/texture.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/shared/texture_ms4.frag.qsb b/tests/manual/rhi/shared/texture_ms4.frag.qsb
index 7f187ce7f0e..278313111b0 100644
--- a/tests/manual/rhi/shared/texture_ms4.frag.qsb
+++ b/tests/manual/rhi/shared/texture_ms4.frag.qsb
Binary files differ