From 951c112fcc543e410c9d1b769d2adcb91ac6eb93 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 26 Jun 2020 13:27:35 +0200 Subject: [PATCH 1/6] QmlDesigner: Simply use qFuzzyCompare I think this was done to avoid "ugly" floats, but any rounding should be done in the rewriter. Task-number: QDS-2190 Change-Id: Ibc5fc2609b5ac332191b68fe17d76d9afca21f40 Reviewed-by: Miikka Heikkinen --- .../components/propertyeditor/propertyeditorvalue.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index 84e8b527910..b2f44710ade 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -62,10 +62,7 @@ QVariant PropertyEditorValue::value() const static bool cleverDoubleCompare(const QVariant &value1, const QVariant &value2) { //we ignore slight changes on doubles if ((value1.type() == QVariant::Double) && (value2.type() == QVariant::Double)) { - int a = value1.toDouble() * 100; - int b = value2.toDouble() * 100; - - if (qFuzzyCompare((qreal(a) / 100), (qreal(b) / 100))) + if (qFuzzyCompare(value1.toDouble(), value2.toDouble())) return true; } return false; From e245abec9ebfee7fa6f2310b9cb35e33da87c0b9 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 26 Jun 2020 13:25:33 +0200 Subject: [PATCH 2/6] QmlDesigner: Increase precision for float properties The precision for float properties in QML was quite low. We keep the reduced precision for a few known 2d related properties, but increase it in general. Task-number: QDS-2190 Change-Id: Ie82ac03485aa52f9b400151153ccaf37a80e39b0 Reviewed-by: Miikka Heikkinen --- .../designercore/model/qmltextgenerator.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp index 9534752282a..3349a5df54b 100644 --- a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp @@ -49,9 +49,16 @@ inline static QString properColorName(const QColor &color) return QString::asprintf("#%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue()); } -inline static QString doubleToString(double d) +inline static QString doubleToString(const PropertyName &propertyName, double d) { - QString string = QString::number(d, 'f', 3); + static QVector lowPrecisionProperties + = {"width", "height", "x", "y", "rotation", "scale", "opacity"}; + int precision = 5; + if (propertyName.contains("anchors") || propertyName.contains("font") + || lowPrecisionProperties.contains(propertyName)) + precision = 3; + + QString string = QString::number(d, 'f', precision); if (string.contains(QLatin1Char('.'))) { while (string.at(string.length()- 1) == QLatin1Char('0')) string.chop(1); @@ -142,7 +149,7 @@ QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDept case QMetaType::Float: case QMetaType::Double: - return doubleToString(value.toDouble()); + return doubleToString(property.name(), value.toDouble()); case QMetaType::Int: case QMetaType::LongLong: case QMetaType::UInt: From 1522dc98c136b3db94c594486135ba76ec46b208 Mon Sep 17 00:00:00 2001 From: Artur Shepilko Date: Thu, 25 Jun 2020 19:56:21 -0500 Subject: [PATCH 3/6] Qmlpuppet: Remove an explicit bool type for fitAndHideBox() function Explicit return values in qml functions cause errors in some Qt versions, so remove the need for it. Change-Id: Idd3035b19b56c25e94bc846c3de8f7aa5381e1eb Reviewed-by: Artur Shepilko Reviewed-by: Mahmoud Badri --- .../qml/qmlpuppet/mockfiles/IconRenderer3D.qml | 11 +++-------- .../qml2puppet/iconrenderer/iconrenderer.cpp | 7 +++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/IconRenderer3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/IconRenderer3D.qml index afaf8481ca6..99c20047a46 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/IconRenderer3D.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/IconRenderer3D.qml @@ -40,20 +40,15 @@ Item { selectionBox.targetNode = view3D.importScene; } - function fitAndHideBox() : bool + function fitAndHideBox() { cameraControl.focusObject(selectionBox.model, viewCamera.eulerRotation, true, true); - if (cameraControl._zoomFactor < 0.1) { + if (cameraControl._zoomFactor < 0.1) view3D.importScene.scale = view3D.importScene.scale.times(10); - return false; - } - if (cameraControl._zoomFactor > 100) { + if (cameraControl._zoomFactor > 100) view3D.importScene.scale = view3D.importScene.scale.times(0.1); - return false; - } selectionBox.visible = false; - return true } View3D { diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp index 9f9b7736d7b..54ba6bed07c 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp @@ -117,17 +117,16 @@ void IconRenderer::setupRender() // Render once to make sure scene is up to date before we set up the selection box render({}); QMetaObject::invokeMethod(containerItem, "setSceneToBox"); - bool success = false; int tries = 0; - while (!success && tries < 10) { + while (tries < 10) { ++tries; render({}); - QMetaObject::invokeMethod(containerItem, "fitAndHideBox", - Q_RETURN_ARG(bool, success)); + QMetaObject::invokeMethod(containerItem, "fitAndHideBox"); } } #else Q_UNUSED(is3D) + Q_UNUSED(containerItem) #endif QFileInfo fi(m_filePath); From 70c4889ac9a0d75c93809dd5bb321fcb2272a202 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 26 Jun 2020 13:04:30 +0200 Subject: [PATCH 4/6] Debugger: Show text representation for 'char *' typedefs etc 'tryPutSimpleFormattedPointer' takes care of nicely showing the actual string representation of character arrays if the innerType is one of 'char', 'signed char', unsigned char', 'CHAR'. To make this work for typedefs of those types as well, first resolve the typedef before passing the value to 'tryPutSimpleFormattedPointer' from 'putFormattedPointerX'. This e.g. improves the display of variables of type 'const gchar *'. Fixes: QTCREATORBUG-24264 Change-Id: I477b6d7552f9c30c12d819aa5f37e64e4f444969 Reviewed-by: hjk --- share/qtcreator/debugger/dumper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index f8db816729d..5e211885ce5 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -1336,7 +1336,10 @@ class DumperBase(): return displayFormat = self.currentItemFormat(value.type.name) + innerType = value.type.target() # .unqualified() + if innerType.code == TypeCode.Typedef: + innerType = innerType.ltarget if innerType.name == 'void': #DumperBase.warn('VOID POINTER: %s' % displayFormat) From 569ad988525e29140b47d7338468bd60cac37614 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 26 Jun 2020 11:59:19 +0200 Subject: [PATCH 5/6] CMake build: Fix library version numbers on macOS The plugin libraries got version 0 and compatibility version 0 and libraries compatibility version 4.0.0, which is not compatible to plugins built with qmake and the runtime linker prevents loading. Use the correct IDE_VERSION and IDE_VERSION_COMPAT. Change-Id: I9a17627c5d212052df644bbc6711dc8fb8307315 Reviewed-by: Alessandro Portale --- cmake/QtCreatorAPI.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake index 1e1c362ad59..24264f9c600 100644 --- a/cmake/QtCreatorAPI.cmake +++ b/cmake/QtCreatorAPI.cmake @@ -152,6 +152,8 @@ function(add_qtc_library name) SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}" VERSION "${IDE_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}" + MACHO_CURRENT_VERSION ${IDE_VERSION} + MACHO_COMPATIBILITY_VERSION ${IDE_VERSION_COMPAT} CXX_EXTENSIONS OFF CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON @@ -400,6 +402,8 @@ function(add_qtc_plugin target_name) qtc_output_binary_dir(_output_binary_dir) set_target_properties(${target_name} PROPERTIES SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}" + MACHO_CURRENT_VERSION ${IDE_VERSION} + MACHO_COMPATIBILITY_VERSION ${IDE_VERSION_COMPAT} CXX_EXTENSIONS OFF CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON From c0bbbc2f7072059dfe105947a07b193679232d7d Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 18 Jun 2020 14:23:06 +0200 Subject: [PATCH 6/6] Wizards: Update CMakeLists.txt files to handle Qt 6 and Qt 5 Update wizards to produce CMakeLists.txt files that can work with both Qt 5 and Qt 6. Bump minimum CMake version to 3.14 since that is the first version that accepts Qt with major version 6 in AUTOMOC/AUTOUIC. Task-number: QTCREATORBUG-24206 Change-Id: I2ff462e67f01d84939c02be579579f358bc0b20e Reviewed-by: Cristian Adam Reviewed-by: hjk --- .../wizards/projects/consoleapp/CMakeLists.txt | 7 ++++--- .../wizards/projects/cpplibrary/CMakeLists.txt | 10 ++++++---- .../wizards/projects/qtquickapplication/CMakeLists.txt | 10 ++++++---- .../projects/qtwidgetsapplication/CMakeLists.txt | 8 +++++--- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/share/qtcreator/templates/wizards/projects/consoleapp/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/consoleapp/CMakeLists.txt index d7eda0b02d0..12653a1671e 100644 --- a/share/qtcreator/templates/wizards/projects/consoleapp/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/consoleapp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.14) project(%{ProjectName} LANGUAGES CXX) @@ -12,7 +12,8 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) @if %{HasTranslation} -find_package(Qt5 COMPONENTS Core LinguistTools REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Core LinguistTools REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core LinguistTools REQUIRED) set(TS_FILES %{TsFileName}) @else @@ -25,7 +26,7 @@ add_executable(%{ProjectName} ${TS_FILES} @endif ) -target_link_libraries(%{ProjectName} Qt5::Core) +target_link_libraries(%{ProjectName} Qt${QT_VERSION_MAJOR}::Core) @if %{HasTranslation} qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) diff --git a/share/qtcreator/templates/wizards/projects/cpplibrary/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/cpplibrary/CMakeLists.txt index b69799a442a..612f4297776 100644 --- a/share/qtcreator/templates/wizards/projects/cpplibrary/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/cpplibrary/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.14) project(%{ProjectName} LANGUAGES CXX) @@ -13,11 +13,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) @if '%{QtModule}' != 'none' @if %{HasTranslation} -find_package(Qt5 COMPONENTS %{QtModuleUpperCase} LinguistTools REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS %{QtModuleUpperCase} LinguistTools REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS %{QtModuleUpperCase} LinguistTools REQUIRED) set(TS_FILES %{TsFileName}) @else -find_package(Qt5 COMPONENTS %{QtModuleUpperCase} REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS %{QtModuleUpperCase} REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS %{QtModuleUpperCase} REQUIRED) @endif @endif @@ -36,7 +38,7 @@ add_library(%{ProjectName} %{JS: %{IsStatic} ? 'STATIC' : 'SHARED'} ) @if '%{QtModule}' != 'none' -target_link_libraries(%{ProjectName} PRIVATE Qt5::%{QtModuleUpperCase}) +target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::%{QtModuleUpperCase}) @endif @if '%{IsShared}' diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt index beeae355834..3b479a595c4 100644 --- a/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.14) project(%{ProjectName} LANGUAGES CXX) @@ -25,11 +25,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) #endif() @if %{HasTranslation} -find_package(Qt5 COMPONENTS Core Quick LinguistTools REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick LinguistTools REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick LinguistTools REQUIRED) set(TS_FILES %{TsFileName}) @else -find_package(Qt5 COMPONENTS Core Quick REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED) @endif if(ANDROID) @@ -53,7 +55,7 @@ endif() target_compile_definitions(%{ProjectName} PRIVATE $<$,$>:QT_QML_DEBUG>) target_link_libraries(%{ProjectName} - PRIVATE Qt5::Core Qt5::Quick) + PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick) @if %{HasTranslation} qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) diff --git a/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt index 59f7cf0d65f..21fec5e47b8 100644 --- a/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt @@ -25,11 +25,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) #endif() @if %{HasTranslation} -find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets LinguistTools REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools REQUIRED) set(TS_FILES %{TsFileName}) @else -find_package(Qt5 COMPONENTS Widgets REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) @endif if(ANDROID) @@ -58,7 +60,7 @@ else() ) endif() -target_link_libraries(%{ProjectName} PRIVATE Qt5::Widgets) +target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) @if %{HasTranslation} qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})