From a7f17baf2f5cee4a9946d987a74348ab75375d25 Mon Sep 17 00:00:00 2001 From: Morten Borup Petersen Date: Sat, 15 Apr 2023 18:15:22 +0200 Subject: [PATCH] Update to Qt6.5 --- CMakeLists.txt | 9 ++------- README.md | 2 +- core/CMakeLists.txt | 4 ++++ graphics/CMakeLists.txt | 7 ++++++- graphics/vsrtl_componentgraphic.cpp | 6 +++--- graphics/vsrtl_netlistdelegate.cpp | 10 +++++----- graphics/vsrtl_netlistdelegate.h | 4 ++-- graphics/vsrtl_radix.cpp | 1 + graphics/vsrtl_radix.h | 10 +++++----- test/CMakeLists.txt | 4 ++-- 10 files changed, 31 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 351330d..d47188e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,14 +17,9 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) # Find Qt5Core and Qt5Widgets -find_package(Qt5Core REQUIRED) -find_package(Qt5Widgets CONFIG REQUIRED) +find_package(Qt6 COMPONENTS Core Widgets REQUIRED) find_package(Threads REQUIRED) -# Finding Qt includes -include_directories(${Qt5Widgets_INCLUDE_DIRS}) -include_directories(${Qt5Core_INCLUDE_DIRS}) - include_directories(SYSTEM external/cereal/include) include_directories(SYSTEM external/Signals) @@ -72,6 +67,6 @@ option(VSRTL_BUILD_APP "Build the VSRTL standalone application" ON) if(VSRTL_BUILD_APP) set(APP_NAME VSRTL) add_executable(${APP_NAME} app.cpp) - target_link_libraries(${APP_NAME} Qt5::Core Qt5::Widgets) + target_link_libraries(${APP_NAME} Qt6::Core Qt6::Widgets) target_link_libraries(${APP_NAME} ${VSRTL_CORE_LIB} ${VSRTL_GRAPHICS_LIB} ${VSRTL_COMPONENTS_LIB}) endif() diff --git a/README.md b/README.md index f23a300..5a11eb4 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ make -j$(nproc) * C++17 toolchain * CMake * **Graphics** - * Qt 5.14+: https://www.qt.io/download + * Qt 6.5.0+: https://www.qt.io/download --- In papers and reports, please refer to VSRTL as follows: 'Morten Borup Petersen. VSRTL. https://github.com/mortbopet/VSRTL', e.g. using the following BibTeX code: diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 4bb3373..eb155fa 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -5,6 +5,10 @@ file(GLOB LIB_HEADERS *.h) add_library(${VSRTL_CORE_LIB} STATIC ${LIB_SOURCES} ${LIB_HEADERS} ) target_include_directories (${VSRTL_CORE_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") + # https://doc.qt.io/qt-6/wasm.html#asyncify + target_link_options(${VSRTL_CORE_LIB} PUBLIC -sASYNCIFY -Os) +endif() if(VSRTL_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") target_link_libraries(${VSRTL_CORE_LIB} ${COVERAGE_LIB} ${VSRTL_INTERFACE_LIB}) diff --git a/graphics/CMakeLists.txt b/graphics/CMakeLists.txt index cb18ffd..a45ab88 100644 --- a/graphics/CMakeLists.txt +++ b/graphics/CMakeLists.txt @@ -22,7 +22,7 @@ if(VSRTL_DEBUG_DRAWING) target_compile_definitions(${VSRTL_GRAPHICS_LIB} PRIVATE VSRTL_DEBUG_DRAW=1) endif() -target_link_libraries(${VSRTL_GRAPHICS_LIB} Qt5::Core Qt5::Widgets) +target_link_libraries(${VSRTL_GRAPHICS_LIB} Qt6::Core Qt6::Widgets) target_include_directories(${VSRTL_GRAPHICS_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) @@ -31,6 +31,11 @@ include_directories("../core/") set_target_properties(${VSRTL_GRAPHICS_LIB} PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries(${VSRTL_GRAPHICS_LIB} ${VSRTL_CORE} ${VSRTL_INTERFACE_LIB} ${CMAKE_THREAD_LIBS_INIT}) +if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") + # https://doc.qt.io/qt-6/wasm.html#asyncify + target_link_options(${VSRTL_GRAPHICS_LIB} PUBLIC -sASYNCIFY -Os) +endif() + if(VSRTL_COVERAGE) target_link_libraries(${VSRTL_GRAPHICS_LIB} ${COVERAGE_LIB}) diff --git a/graphics/vsrtl_componentgraphic.cpp b/graphics/vsrtl_componentgraphic.cpp index 2f7c307..4a1e9ec 100644 --- a/graphics/vsrtl_componentgraphic.cpp +++ b/graphics/vsrtl_componentgraphic.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -371,10 +371,10 @@ void ComponentGraphic::updateGeometry() { // Next, separately apply the scaling through a secondary matrix (The transformation gets a lot simpler like // this, rather than composing translation + rotation +translation + scaling in a single matrix. QTransform t; - QMatrix mat; + QMatrix4x4 mat; mat.scale(sceneRect.width(), sceneRect.height()); t.translate(0.5, 0.5).rotate(gridRotation()).translate(-0.5, -0.5); - m_shape = mat.map(ShapeRegister::getTypeShape(m_component->getGraphicsType(), t)); + m_shape = mat.toTransform().map(ShapeRegister::getTypeShape(m_component->getGraphicsType(), t)); // Position the expand-button if (hasSubcomponents()) { diff --git a/graphics/vsrtl_netlistdelegate.cpp b/graphics/vsrtl_netlistdelegate.cpp index f76fd3a..fd22128 100644 --- a/graphics/vsrtl_netlistdelegate.cpp +++ b/graphics/vsrtl_netlistdelegate.cpp @@ -13,7 +13,7 @@ namespace vsrtl { NetlistDelegate::NetlistDelegate(QObject* parent) : QStyledItemDelegate(parent) { // The validator does not concern itself whether the value is actually writeable to the register. Any hex input is // accepted. When a register is forced to a value, the value is truncated to the bit width of the register. - m_validator = new QRegExpValidator(this); + m_validator = new QRegularExpressionValidator(this); } QWidget* NetlistDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const { @@ -33,19 +33,19 @@ void NetlistDelegate::setEditorData(QWidget* e, const QModelIndex& index) const switch (treeItem->m_radix) { case Radix::Binary: { - m_validator->setRegExp(binRegex); + m_validator->setRegularExpression(binRegex); break; } case Radix::Hex: { - m_validator->setRegExp(hexRegex); + m_validator->setRegularExpression(hexRegex); break; } case Radix::Unsigned: { - m_validator->setRegExp(unsignedRegex); + m_validator->setRegularExpression(unsignedRegex); break; } case Radix::Signed: { - m_validator->setRegExp(signedRegex); + m_validator->setRegularExpression(signedRegex); break; } case Radix::Enum: { diff --git a/graphics/vsrtl_netlistdelegate.h b/graphics/vsrtl_netlistdelegate.h index 519d147..d338e78 100644 --- a/graphics/vsrtl_netlistdelegate.h +++ b/graphics/vsrtl_netlistdelegate.h @@ -1,7 +1,7 @@ #ifndef VSRTL_NETLISTDELEGATE_H #define VSRTL_NETLISTDELEGATE_H -#include +#include #include namespace vsrtl { @@ -14,7 +14,7 @@ class NetlistDelegate : public QStyledItemDelegate { void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; private: - QRegExpValidator* m_validator; + QRegularExpressionValidator* m_validator; }; } // namespace vsrtl diff --git a/graphics/vsrtl_radix.cpp b/graphics/vsrtl_radix.cpp index 18f5a70..e6b9ff6 100644 --- a/graphics/vsrtl_radix.cpp +++ b/graphics/vsrtl_radix.cpp @@ -6,6 +6,7 @@ #include "../interface/vsrtl_interface.h" #include +#include #include #include #include diff --git a/graphics/vsrtl_radix.h b/graphics/vsrtl_radix.h index c4f05e9..cd93c1e 100644 --- a/graphics/vsrtl_radix.h +++ b/graphics/vsrtl_radix.h @@ -1,7 +1,7 @@ #ifndef VSRTL_Radix_H #define VSRTL_Radix_H -#include +#include #include "../interface/vsrtl_defines.h" QT_FORWARD_DECLARE_CLASS(QString) @@ -11,10 +11,10 @@ namespace vsrtl { class SimPort; enum class Radix { Hex, Unsigned, Signed, Binary, Enum }; -static const auto hexRegex = QRegExp("0[xX][0-9a-fA-F]+"); -static const auto binRegex = QRegExp("0[bB][0-1]+"); -static const auto unsignedRegex = QRegExp("[0-9]+"); -static const auto signedRegex = QRegExp("[-]*[0-9]+"); +static const auto hexRegex = QRegularExpression("0[xX][0-9a-fA-F]+"); +static const auto binRegex = QRegularExpression("0[bB][0-1]+"); +static const auto unsignedRegex = QRegularExpression("[0-9]+"); +static const auto signedRegex = QRegularExpression("[-]*[0-9]+"); VSRTL_VT_U decodePortRadixValue(const SimPort& port, const Radix type, const QString& valueString); QString encodePortRadixValue(const SimPort* port, const Radix type); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 33cb961..1b5c0b4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.9) file(GLOB TST_SOURCES *.cpp) -find_package(Qt5Test REQUIRED) +find_package(Qt6 COMPONENTS Test REQUIRED) macro(create_qtest name) add_executable(${name} ${name}.cpp) add_test(${name} ${name}) - target_link_libraries(${name} Qt5::Core Qt5::Widgets Qt5::Test) + target_link_libraries(${name} Qt6::Core Qt6::Widgets Qt6::Test) target_link_libraries(${name} ${VSRTL_CORE_LIB} ${VSRTL_GRAPHICS_LIB} ${VSRTL_COMPONENTS_LIB}) if (COVERAGE) target_link_libraries(${name} ${COVERAGE_LIB})