From ca9006a1bc646185e49d99465de2ce6341290f68 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Sep 2023 22:44:08 +0200 Subject: [PATCH 01/19] i18n: move translation helper-function to CMakeModules --- CMakeModules/CalamaresAddTranslations.cmake | 51 +++++++++++++++++++++ src/libcalamares/CMakeLists.txt | 49 -------------------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/CMakeModules/CalamaresAddTranslations.cmake b/CMakeModules/CalamaresAddTranslations.cmake index 56953187c..a5e256427 100644 --- a/CMakeModules/CalamaresAddTranslations.cmake +++ b/CMakeModules/CalamaresAddTranslations.cmake @@ -100,3 +100,54 @@ function( install_calamares_gettext_translations ) endif() endforeach() endfunction() + +function(calamares_qrc_translations basename) + set(NAME ${ARGV0}) + set(options "") + set(oneValueArgs SUBDIRECTORY OUTPUT_VARIABLE) + set(multiValueArgs LANGUAGES) + cmake_parse_arguments(_qrt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT _qrt_OUTPUT_VARIABLE) + set(_qrt_OUTPUT_VARIABLE "qrc_translations_${basename}") + endif() + + set(translations_qrc_infile ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qrc) + set(translations_qrc_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${basename}.cxx) + + # Must use this variable name because of the @ substitution + set(calamares_i18n_qrc_content "") + set(calamares_i18n_ts_filelist "") + foreach(lang ${_qrt_LANGUAGES}) + string(APPEND calamares_i18n_qrc_content "${basename}_${lang}.qm") + list( + APPEND + calamares_i18n_ts_filelist + "${CMAKE_CURRENT_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${basename}_${lang}.ts" + ) + endforeach() + + configure_file(${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${translations_qrc_infile} @ONLY) + qt_add_translation(QM_FILES ${calamares_i18n_ts_filelist}) + + if(WITH_QT6) + # Simplified build, knows about RCC + set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_infile} PARENT_SCOPE) + else() + # Run the resource compiler (rcc_options should already be set) + add_custom_command( + OUTPUT ${translations_qrc_outfile} + COMMAND "${Qt5Core_RCC_EXECUTABLE}" + ARGS + ${rcc_options} + --format-version 1 + -name ${basename} + -o ${translations_qrc_outfile} + ${translations_qrc_infile} + MAIN_DEPENDENCY ${translations_qrc_infile} + DEPENDS ${QM_FILES} + ) + + set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE) + endif() +endfunction() diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index f326be034..59f615648 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -192,55 +192,6 @@ endforeach() ### TRANSLATION TESTING # -# This is a support function, used just once, to help out the localetest -function(calamares_qrc_translations basename) - set(NAME ${ARGV0}) - set(options "") - set(oneValueArgs SUBDIRECTORY OUTPUT_VARIABLE) - set(multiValueArgs LANGUAGES) - cmake_parse_arguments(_qrt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if(NOT _qrt_OUTPUT_VARIABLE) - set(_qrt_OUTPUT_VARIABLE "qrc_translations_${basename}") - endif() - - set(translations_qrc_infile ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qrc) - set(translations_qrc_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${basename}.cxx) - - # Must use this variable name because of the @ substitution - set(calamares_i18n_qrc_content "") - set(calamares_i18n_ts_filelist "") - foreach(lang ${_qrt_LANGUAGES}) - string(APPEND calamares_i18n_qrc_content "${basename}_${lang}.qm") - list( - APPEND - calamares_i18n_ts_filelist - "${CMAKE_CURRENT_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${basename}_${lang}.ts" - ) - endforeach() - - configure_file(${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${translations_qrc_infile} @ONLY) - qt_add_translation(QM_FILES ${calamares_i18n_ts_filelist}) - - # Run the resource compiler (rcc_options should already be set) - add_custom_command( - OUTPUT ${translations_qrc_outfile} - COMMAND "${Qt5Core_RCC_EXECUTABLE}" - ARGS - ${rcc_options} - --format-version - 1 - -name - ${basename} - -o - ${translations_qrc_outfile} - ${translations_qrc_infile} - MAIN_DEPENDENCY ${translations_qrc_infile} - DEPENDS ${QM_FILES} - ) - - set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE) -endfunction() calamares_qrc_translations( localetest OUTPUT_VARIABLE localetest_qrc SUBDIRECTORY testdata LANGUAGES nl ) From 3173a8ee3c50dab8e987a5ad029c91fbf2416ec7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Sep 2023 22:59:33 +0200 Subject: [PATCH 02/19] i18n: expand helper function to handle more cases - move template QRC file to the module that defines the function - add parameters to accept more files (prefixes) per language --- CMakeModules/CalamaresAddTranslations.cmake | 62 ++++++++++--------- .../i18n.qrc.in | 0 lang/CMakeLists.txt | 34 ++-------- 3 files changed, 37 insertions(+), 59 deletions(-) rename lang/calamares_i18n.qrc.in => CMakeModules/i18n.qrc.in (100%) diff --git a/CMakeModules/CalamaresAddTranslations.cmake b/CMakeModules/CalamaresAddTranslations.cmake index a5e256427..03e655fa4 100644 --- a/CMakeModules/CalamaresAddTranslations.cmake +++ b/CMakeModules/CalamaresAddTranslations.cmake @@ -101,15 +101,24 @@ function( install_calamares_gettext_translations ) endforeach() endfunction() +set(_calamares_qrc_translations_qrc_source ${CMAKE_CURRENT_LIST_DIR}/i18n.qrc.in) # Needs to be set outside of function function(calamares_qrc_translations basename) - set(NAME ${ARGV0}) set(options "") set(oneValueArgs SUBDIRECTORY OUTPUT_VARIABLE) - set(multiValueArgs LANGUAGES) + set(multiValueArgs PREFIXES LANGUAGES) cmake_parse_arguments(_qrt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(NOT _qrt_OUTPUT_VARIABLE) - set(_qrt_OUTPUT_VARIABLE "qrc_translations_${basename}") + message(FATAL_ERROR "No output variable") + endif() + if(NOT _qrt_PREFIXES) + set(_qrt_PREFIXES "${basename}") + endif() + if(NOT _qrt_LANGUAGES) + set(_qrt_LANGUAGES ${CALAMARES_TRANSLATION_LANGUAGES}) + endif() + if(NOT _qrt_SUBDIRECTORY) + set(_qrt_SUBDIRECTORY "") endif() set(translations_qrc_infile ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qrc) @@ -119,35 +128,30 @@ function(calamares_qrc_translations basename) set(calamares_i18n_qrc_content "") set(calamares_i18n_ts_filelist "") foreach(lang ${_qrt_LANGUAGES}) - string(APPEND calamares_i18n_qrc_content "${basename}_${lang}.qm") - list( - APPEND - calamares_i18n_ts_filelist - "${CMAKE_CURRENT_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${basename}_${lang}.ts" - ) + foreach(tlsource ${_qrt_PREFIXES}) + if(EXISTS "${CMAKE_SOURCE_DIR}/{$_qrt_SUBDIRECTORY}/${tlsource}_${lang}.ts") + string(APPEND calamares_i18n_qrc_content "${tlsource}_${lang}.qm\n") + list(APPEND calamares_i18n_ts_filelist "${CMAKE_SOURCE_DIR}/${_qrt_SUBDIRECTORY}/${tlsource}_${lang}.ts") + endif() + endforeach() endforeach() - configure_file(${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${translations_qrc_infile} @ONLY) + configure_file(${_calamares_qrc_translations_qrc_source} ${translations_qrc_infile} @ONLY) qt_add_translation(QM_FILES ${calamares_i18n_ts_filelist}) - if(WITH_QT6) - # Simplified build, knows about RCC - set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_infile} PARENT_SCOPE) - else() - # Run the resource compiler (rcc_options should already be set) - add_custom_command( - OUTPUT ${translations_qrc_outfile} - COMMAND "${Qt5Core_RCC_EXECUTABLE}" - ARGS - ${rcc_options} - --format-version 1 - -name ${basename} - -o ${translations_qrc_outfile} - ${translations_qrc_infile} - MAIN_DEPENDENCY ${translations_qrc_infile} - DEPENDS ${QM_FILES} - ) + # Run the resource compiler (rcc_options should already be set) + add_custom_command( + OUTPUT ${translations_qrc_outfile} + COMMAND ${qtname}::rcc + ARGS + ${rcc_options} + --format-version 1 + -name ${basename} + -o ${translations_qrc_outfile} + ${translations_qrc_infile} + MAIN_DEPENDENCY ${translations_qrc_infile} + DEPENDS ${QM_FILES} + ) - set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE) - endif() + set(${_qrt_OUTPUT_VARIABLE} ${translations_qrc_outfile} PARENT_SCOPE) endfunction() diff --git a/lang/calamares_i18n.qrc.in b/CMakeModules/i18n.qrc.in similarity index 100% rename from lang/calamares_i18n.qrc.in rename to CMakeModules/i18n.qrc.in diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index fc3a1db1e..dd2a47b04 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -30,35 +30,9 @@ install_calamares_gettext_translations(python ### TRANSLATIONS # # -set(TS_FILES "") -set(calamares_i18n_qrc_content "") - -# calamares and qt language files -foreach(lang ${CALAMARES_TRANSLATION_LANGUAGES}) - foreach(tlsource "calamares_${lang}" "tz_${lang}" "kb_${lang}") - if(EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts") - string(APPEND calamares_i18n_qrc_content "${tlsource}.qm\n") - list(APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts") - endif() - endforeach() -endforeach() - -set(trans_file calamares_i18n) -set(trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc) -set(trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/calamares-i18n.cxx) -set(CALAMARES_TRANSLATIONS_SOURCE ${trans_outfile}) - -configure_file(${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY) - -qt_add_translation(QM_FILES ${TS_FILES}) - -# Run the resource compiler (rcc_options should already be set) -add_custom_command( - OUTPUT ${trans_outfile} - COMMAND "${Qt5Core_RCC_EXECUTABLE}" - ARGS ${rcc_options} --format-version 1 -name ${trans_file} -o ${trans_outfile} ${trans_infile} - MAIN_DEPENDENCY ${trans_infile} - DEPENDS ${QM_FILES} +calamares_qrc_translations(calamares-i18n + OUTPUT_VARIABLE translation_outfile + PREFIXES calamares tz kb ) -add_library(calamares-i18n OBJECT ${trans_outfile}) +add_library(calamares-i18n OBJECT ${translation_outfile}) From e07b6c90d3682af4fb53a9abbf696642ae487699 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Sep 2023 23:41:33 +0200 Subject: [PATCH 03/19] contextualprocess: adapt to Qt6 --- src/modules/contextualprocess/ContextualProcessJob.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/contextualprocess/ContextualProcessJob.cpp b/src/modules/contextualprocess/ContextualProcessJob.cpp index 8bc011127..74b259114 100644 --- a/src/modules/contextualprocess/ContextualProcessJob.cpp +++ b/src/modules/contextualprocess/ContextualProcessJob.cpp @@ -15,6 +15,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" +#include "compat/Variant.h" #include "utils/CommandList.h" #include "utils/Logger.h" #include "utils/Variant.h" @@ -62,7 +63,7 @@ ContextualProcessBinding::run( const QString& value ) const static bool fetch( QString& value, QStringList& selector, int index, const QVariant& v ) { - if ( !v.canConvert( QMetaType::QVariantMap ) ) + if ( !v.canConvert< QVariantMap >() ) { return false; } @@ -163,7 +164,7 @@ ContextualProcessJob::setConfigurationMap( const QVariantMap& configurationMap ) continue; } - if ( iter.value().type() != QVariant::Map ) + if ( Calamares::typeOf( iter.value() ) != Calamares::MapVariantType ) { cWarning() << moduleInstanceKey() << "bad configuration values for" << variableName; continue; From 5f8b6ed4371377c8f095eebb751d13ee5b1b77f9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Sep 2023 23:47:34 +0200 Subject: [PATCH 04/19] dummycpp: adapt to Qt6 - since HashVariantType has more than one consumer, move it to header --- src/libcalamares/PythonHelper.cpp | 4 +--- src/libcalamares/compat/Variant.h | 2 ++ src/modules/dummycpp/DummyCppJob.cpp | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index 57fbb4dc9..e9e2b136c 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -33,11 +33,9 @@ variantToPyObject( const QVariant& variant ) #endif #if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) - const auto HashVariantType = QVariant::Hash; const auto IntVariantType = QVariant::Int; const auto UIntVariantType = QVariant::UInt; #else - const auto HashVariantType = QMetaType::Type::QVariantHash; const auto IntVariantType = QMetaType::Type::Int; const auto UIntVariantType = QMetaType::Type::UInt; #endif @@ -47,7 +45,7 @@ variantToPyObject( const QVariant& variant ) case Calamares::MapVariantType: return variantMapToPyDict( variant.toMap() ); - case HashVariantType: + case Calamares::HashVariantType: return variantHashToPyDict( variant.toHash() ); case Calamares::ListVariantType: diff --git a/src/libcalamares/compat/Variant.h b/src/libcalamares/compat/Variant.h index a7a5e03ac..123fce573 100644 --- a/src/libcalamares/compat/Variant.h +++ b/src/libcalamares/compat/Variant.h @@ -19,6 +19,7 @@ namespace Calamares const auto typeOf = []( const QVariant& v ) { return v.type(); }; const auto ListVariantType = QVariant::List; const auto MapVariantType = QVariant::Map; +const auto HashVariantType = QVariant::Hash; const auto StringVariantType = QVariant::String; const auto CharVariantType = QVariant::Char; const auto StringListVariantType = QVariant::StringList; @@ -31,6 +32,7 @@ const auto DoubleVariantType = QVariant::Double; const auto typeOf = []( const QVariant& v ) { return v.typeId(); }; const auto ListVariantType = QMetaType::Type::QVariantList; const auto MapVariantType = QMetaType::Type::QVariantMap; +const auto HashVariantType = QMetaType::Type::QVariantHash; const auto StringVariantType = QMetaType::Type::QString; const auto CharVariantType = QMetaType::Type::Char; const auto StringListVariantType = QMetaType::Type::QStringList; diff --git a/src/modules/dummycpp/DummyCppJob.cpp b/src/modules/dummycpp/DummyCppJob.cpp index afccdc7d5..6f2e0ab0e 100644 --- a/src/modules/dummycpp/DummyCppJob.cpp +++ b/src/modules/dummycpp/DummyCppJob.cpp @@ -18,6 +18,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" +#include "compat/Variant.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" @@ -45,15 +46,16 @@ static QString variantHashToString( const QVariantHash& variantHash ); static QString variantToString( const QVariant& variant ) { - if ( variant.type() == QVariant::Map ) + if ( Calamares::typeOf( variant ) == Calamares::MapVariantType ) { return variantMapToString( variant.toMap() ); } - else if ( variant.type() == QVariant::Hash ) + else if ( Calamares::typeOf( variant ) == Calamares::HashVariantType ) { return variantHashToString( variant.toHash() ); } - else if ( ( variant.type() == QVariant::List ) || ( variant.type() == QVariant::StringList ) ) + else if ( ( Calamares::typeOf( variant ) == Calamares::ListVariantType ) + || ( Calamares::typeOf( variant ) == Calamares::StringListVariantType ) ) { return variantListToString( variant.toList() ); } From 6ffafe1c45f727f7bf426a6a95a9d50bbd734c6b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Sep 2023 23:53:39 +0200 Subject: [PATCH 05/19] interactiveterminal: consider this KF5-only for now It seems unlikely that a KF6-based terminal part from konsole becomes available any time soon, so don't bother. --- src/modules/interactiveterminal/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/interactiveterminal/CMakeLists.txt b/src/modules/interactiveterminal/CMakeLists.txt index 8ade23dbd..45d54f761 100644 --- a/src/modules/interactiveterminal/CMakeLists.txt +++ b/src/modules/interactiveterminal/CMakeLists.txt @@ -3,6 +3,11 @@ # SPDX-FileCopyrightText: 2020 Adriaan de Groot # SPDX-License-Identifier: BSD-2-Clause # +if(WITH_QT6) + calamares_skip_module( "interactiveterminal (KDE Frameworks 5 only)" ) + return() +endif() + find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) set(kf5_ver 5.41) From 93e9990df8f481937ee2614ce1be18e83c0b13cf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Sep 2023 23:55:18 +0200 Subject: [PATCH 06/19] keyboard: adapt to Qt6 --- src/modules/keyboard/CMakeLists.txt | 2 +- src/modules/keyboardq/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/keyboard/CMakeLists.txt b/src/modules/keyboard/CMakeLists.txt index 116aaa132..392842400 100644 --- a/src/modules/keyboard/CMakeLists.txt +++ b/src/modules/keyboard/CMakeLists.txt @@ -21,7 +21,7 @@ calamares_add_plugin(keyboard keyboard.qrc SHARED_LIB LINK_LIBRARIES - Qt5::DBus + ${qtname}::DBus ) calamares_add_test(keyboardtest SOURCES Tests.cpp SetKeyboardLayoutJob.cpp RESOURCES keyboard.qrc) diff --git a/src/modules/keyboardq/CMakeLists.txt b/src/modules/keyboardq/CMakeLists.txt index afd8d4aad..a9d05ab09 100644 --- a/src/modules/keyboardq/CMakeLists.txt +++ b/src/modules/keyboardq/CMakeLists.txt @@ -8,7 +8,7 @@ if(NOT WITH_QML) return() endif() -find_package(Qt5 ${QT_VERSION} CONFIG REQUIRED Core DBus) +find_package(${qtname} ${QT_VERSION} CONFIG REQUIRED Core DBus) set(_keyboard ${CMAKE_CURRENT_SOURCE_DIR}/../keyboard) @@ -27,5 +27,5 @@ calamares_add_plugin(keyboardq keyboardq.qrc SHARED_LIB LINK_LIBRARIES - Qt5::DBus + ${qtname}::DBus ) From 1b5206cb90fe69484e62fb31c9fc9cf3cca2dc81 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Sep 2023 23:57:20 +0200 Subject: [PATCH 07/19] locale: adjust to Qt6 --- src/modules/locale/CMakeLists.txt | 6 ++---- src/modules/localeq/CMakeLists.txt | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 94cae2144..6949ccfcc 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -18,7 +18,6 @@ calamares_add_plugin(locale TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES - ${geoip_src} Config.cpp LCLocaleDialog.cpp LocaleConfiguration.cpp @@ -32,8 +31,7 @@ calamares_add_plugin(locale RESOURCES locale.qrc LINK_PRIVATE_LIBRARIES - Qt5::Network - ${geoip_libs} + ${qtname}::Network yamlcpp::yamlcpp SHARED_LIB ) @@ -48,5 +46,5 @@ calamares_add_test( SetTimezoneJob.cpp timezonewidget/TimeZoneImage.cpp DEFINITIONS SOURCE_DIR="${CMAKE_CURRENT_LIST_DIR}/images" DEBUG_TIMEZONES=1 - LIBRARIES Qt5::Gui + LIBRARIES ${qtname}::Gui ) diff --git a/src/modules/localeq/CMakeLists.txt b/src/modules/localeq/CMakeLists.txt index b8ae6a933..1ac8fc9cb 100644 --- a/src/modules/localeq/CMakeLists.txt +++ b/src/modules/localeq/CMakeLists.txt @@ -16,10 +16,10 @@ if(DEBUG_TIMEZONES) add_definitions(-DDEBUG_TIMEZONES) endif() -find_package(Qt5Location CONFIG) -set_package_properties(Qt5Location PROPERTIES DESCRIPTION "Used for rendering the map" TYPE RUNTIME) -find_package(Qt5Positioning CONFIG) -set_package_properties(Qt5Positioning PROPERTIES DESCRIPTION "Used for GeoLocation and GeoCoding" TYPE RUNTIME) +find_package(${qtname}Location CONFIG) +set_package_properties(${qtname}Location PROPERTIES DESCRIPTION "Used for rendering the map" TYPE RUNTIME) +find_package(${qtname}Positioning CONFIG) +set_package_properties(${qtname}Positioning PROPERTIES DESCRIPTION "Used for GeoLocation and GeoCoding" TYPE RUNTIME) # Because we're sharing sources with the regular locale module set(_locale ${CMAKE_CURRENT_SOURCE_DIR}/../locale) @@ -38,6 +38,6 @@ calamares_add_plugin(localeq RESOURCES localeq.qrc LINK_PRIVATE_LIBRARIES - Qt5::Network + ${qtname}::Network SHARED_LIB ) From 22bd80daaca3756076c9b43698cef9db9d2e37a6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Sep 2023 23:59:25 +0200 Subject: [PATCH 08/19] hostinfo: adjust to Qt6 --- src/modules/hostinfo/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/hostinfo/CMakeLists.txt b/src/modules/hostinfo/CMakeLists.txt index af1b3ff45..320be0243 100644 --- a/src/modules/hostinfo/CMakeLists.txt +++ b/src/modules/hostinfo/CMakeLists.txt @@ -32,9 +32,7 @@ calamares_add_plugin(hostinfo NO_CONFIG ) -if(KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58) - target_compile_definitions(calamares_job_hostinfo PRIVATE WITH_KOSRelease) - target_link_libraries(calamares_job_hostinfo PRIVATE KF5::CoreAddons) -endif() +target_compile_definitions(calamares_job_hostinfo PRIVATE WITH_KOSRelease) +target_link_libraries(calamares_job_hostinfo PRIVATE ${kfname}::CoreAddons) calamares_add_test(hostinfotest SOURCES Tests.cpp HostInfoJob.cpp LIBRARIES yamlcpp::yamlcpp) From 427311f2c31600e87879ddb1587d5a65f30e3645 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 15:18:02 +0200 Subject: [PATCH 09/19] keyboard: port to QRegularExpression --- src/modules/keyboard/Config.cpp | 6 +- .../keyboardwidget/keyboardglobal.cpp | 65 +++++++++++++------ .../keyboard/keyboardwidget/keyboardglobal.h | 8 --- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/modules/keyboard/Config.cpp b/src/modules/keyboard/Config.cpp index d43f83225..2eca1ffb5 100644 --- a/src/modules/keyboard/Config.cpp +++ b/src/modules/keyboard/Config.cpp @@ -23,8 +23,10 @@ #include "utils/Variant.h" #include +#include #include #include +#include #include #include @@ -113,7 +115,7 @@ xkbmap_query_grp_option() } //it's either in the end of line or before the other option so \s or , - int lastIndex = outputLine.indexOf( QRegExp( "[\\s,]" ), index ); + int lastIndex = outputLine.indexOf( QRegularExpression( "[\\s,]" ), index ); return outputLine.mid( index, lastIndex - index ); } @@ -349,7 +351,9 @@ Config::getCurrentKeyboardLayoutXkb( QString& currentLayout, QString& currentVar symbols = true; } else if ( !line.trimmed().startsWith( "xkb_geometry" ) ) + { continue; + } int firstQuote = line.indexOf( '"' ); int lastQuote = line.lastIndexOf( '"' ); diff --git a/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp b/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp index d01c8b591..5dc6de66e 100644 --- a/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp +++ b/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp @@ -19,6 +19,10 @@ #include "utils/Logger.h" +#include +#include +#include + #ifdef Q_OS_FREEBSD static const char XKB_FILE[] = "/usr/local/share/X11/xkb/rules/base.lst"; #else @@ -75,16 +79,22 @@ parseKeyboardModels( const char* filepath ) break; } - // here we are in the model section, otherwise we would continue or break - QRegExp rx; - rx.setPattern( "^\\s+(\\S+)\\s+(\\w.*)\n$" ); + // Here we are in the model section, otherwise we would continue or break. + // Sample model lines: + // + // ! model + // pc86 Generic 86-key PC + // pc101 Generic 101-key PC + // + QRegularExpression rx( "^\\s+(\\S+)\\s+(\\w.*)\n$" ); + QRegularExpressionMatch m; // insert into the model map - if ( rx.indexIn( line ) != -1 ) + if ( QString( line ).indexOf( rx, 0, &m ) != -1 ) { - QString modelDesc = rx.cap( 2 ); - QString model = rx.cap( 1 ); - models.insert( modelDesc, model ); + const QString modelDescription = m.captured( 2 ); + const QString model = m.captured( 1 ); + models.insert( modelDescription, model ); } } @@ -119,16 +129,21 @@ parseKeyboardLayouts( const char* filepath ) break; } - QRegExp rx; - rx.setPattern( "^\\s+(\\S+)\\s+(\\w.*)\n$" ); + // Sample layout lines: + // + // ! layout + // us English (US) + // af Afghani + QRegularExpression rx( "^\\s+(\\S+)\\s+(\\w.*)\n$" ); + QRegularExpressionMatch m; // insert into the layout map - if ( rx.indexIn( line ) != -1 ) + if ( QString( line ).indexOf( rx, 0, &m ) != -1 ) { KeyboardGlobal::KeyboardInfo info; - info.description = rx.cap( 2 ); + info.description = m.captured( 2 ); info.variants.insert( QObject::tr( "Default" ), "" ); - layouts.insert( rx.cap( 1 ), info ); + layouts.insert( m.captured( 1 ), info ); } } @@ -148,25 +163,35 @@ parseKeyboardLayouts( const char* filepath ) break; } - QRegExp rx; - rx.setPattern( "^\\s+(\\S+)\\s+(\\S+): (\\w.*)\n$" ); + // Sample variant lines: + // + // ! variant + // chr us: Cherokee + // haw us: Hawaiian + // ps af: Pashto + // uz af: Uzbek (Afghanistan) + QRegularExpression rx( "^\\s+(\\S+)\\s+(\\S+): (\\w.*)\n$" ); + QRegularExpressionMatch m; // insert into the variants multimap, if the pattern matches - if ( rx.indexIn( line ) != -1 ) + if ( QString( line ).indexOf( rx, 0, &m ) != -1 ) { - if ( layouts.find( rx.cap( 2 ) ) != layouts.end() ) + const QString variantKey = m.captured( 1 ); + const QString baseLayout = m.captured( 2 ); + const QString description = m.captured( 3 ); + if ( layouts.find( baseLayout ) != layouts.end() ) { // in this case we found an entry in the multimap, and add the values to the multimap - layouts.find( rx.cap( 2 ) ).value().variants.insert( rx.cap( 3 ), rx.cap( 1 ) ); + layouts.find( baseLayout ).value().variants.insert( description, variantKey ); } else { // create a new map in the multimap - the value was not found. KeyboardGlobal::KeyboardInfo info; - info.description = rx.cap( 2 ); + info.description = baseLayout; info.variants.insert( QObject::tr( "Default" ), "" ); - info.variants.insert( rx.cap( 3 ), rx.cap( 1 ) ); - layouts.insert( rx.cap( 2 ), info ); + info.variants.insert( description, variantKey ); + layouts.insert( baseLayout, info ); } } } diff --git a/src/modules/keyboard/keyboardwidget/keyboardglobal.h b/src/modules/keyboard/keyboardwidget/keyboardglobal.h index 07c6e5ea2..2d60bd768 100644 --- a/src/modules/keyboard/keyboardwidget/keyboardglobal.h +++ b/src/modules/keyboard/keyboardwidget/keyboardglobal.h @@ -16,16 +16,8 @@ #ifndef KEYBOARDGLOBAL_H #define KEYBOARDGLOBAL_H -#include -#include -#include -#include -#include #include -#include #include -#include -#include class KeyboardGlobal { From e781e4eb5f8ccaf61526af50093a5d3fee2d35ee Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 15:24:02 +0200 Subject: [PATCH 10/19] license: adapt to Qt6 --- src/modules/license/LicenseViewStep.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/license/LicenseViewStep.cpp b/src/modules/license/LicenseViewStep.cpp index aca04a1b3..27612ffc9 100644 --- a/src/modules/license/LicenseViewStep.cpp +++ b/src/modules/license/LicenseViewStep.cpp @@ -13,6 +13,8 @@ #include "GlobalStorage.h" #include "JobQueue.h" #include "LicensePage.h" + +#include "compat/Variant.h" #include "utils/Logger.h" #include @@ -89,12 +91,13 @@ void LicenseViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { QList< LicenseEntry > entriesList; - if ( configurationMap.contains( "entries" ) && configurationMap.value( "entries" ).type() == QVariant::List ) + if ( configurationMap.contains( "entries" ) + && Calamares::typeOf( configurationMap.value( "entries" ) ) == Calamares::ListVariantType ) { const auto entries = configurationMap.value( "entries" ).toList(); for ( const QVariant& entryV : entries ) { - if ( entryV.type() != QVariant::Map ) + if ( Calamares::typeOf( entryV ) != Calamares::MapVariantType ) { continue; } From f56250624fa72374da62c280fd61a8031db5dfba Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 15:34:04 +0200 Subject: [PATCH 11/19] netinstall: adjust to Qt6 --- src/modules/netinstall/CMakeLists.txt | 4 ++-- src/modules/netinstall/Config.cpp | 5 +++-- src/modules/netinstall/PackageModel.cpp | 5 +++-- src/modules/netinstall/groupstreeview.cpp | 5 +++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/modules/netinstall/CMakeLists.txt b/src/modules/netinstall/CMakeLists.txt index e605905c4..1f8d11e22 100644 --- a/src/modules/netinstall/CMakeLists.txt +++ b/src/modules/netinstall/CMakeLists.txt @@ -17,7 +17,7 @@ calamares_add_plugin(netinstall UI page_netinst.ui LINK_PRIVATE_LIBRARIES - Qt5::Network + ${qtname}::Network SHARED_LIB ) @@ -25,6 +25,6 @@ if(KF5CoreAddons_FOUND) calamares_add_test( netinstalltest SOURCES Tests.cpp Config.cpp LoaderQueue.cpp PackageTreeItem.cpp PackageModel.cpp - LIBRARIES Qt5::Gui Qt5::Network KF5::CoreAddons + LIBRARIES ${qtname}::Gui ${qtname}::Network KF5::CoreAddons ) endif() diff --git a/src/modules/netinstall/Config.cpp b/src/modules/netinstall/Config.cpp index c163d72a0..9d92324a9 100644 --- a/src/modules/netinstall/Config.cpp +++ b/src/modules/netinstall/Config.cpp @@ -16,6 +16,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" +#include "compat/Variant.h" #include "network/Manager.h" #include "packages/Globals.h" #include "utils/Logger.h" @@ -137,11 +138,11 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) const QString key = QStringLiteral( "groupsUrl" ); const auto& groupsUrlVariant = configurationMap.value( key ); m_queue = new LoaderQueue( this ); - if ( groupsUrlVariant.type() == QVariant::String ) + if ( Calamares::typeOf( groupsUrlVariant ) == Calamares::StringVariantType ) { m_queue->append( SourceItem::makeSourceItem( groupsUrlVariant.toString(), configurationMap ) ); } - else if ( groupsUrlVariant.type() == QVariant::List ) + else if ( Calamares::typeOf( groupsUrlVariant ) == Calamares::ListVariantType ) { for ( const auto& s : groupsUrlVariant.toStringList() ) { diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index 4e48d3d09..68ed784d6 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -10,6 +10,7 @@ #include "PackageModel.h" +#include "compat/Variant.h" #include "utils/Logger.h" #include "utils/Variant.h" #include "utils/Yaml.h" @@ -279,7 +280,7 @@ PackageModel::setupModelData( const QVariantList& groupList, PackageTreeItem* pa { for ( const auto& packageName : groupMap.value( "packages" ).toList() ) { - if ( packageName.type() == QVariant::String ) + if ( Calamares::typeOf( packageName ) == Calamares::StringVariantType ) { item->appendChild( new PackageTreeItem( packageName.toString(), item ) ); } @@ -301,7 +302,7 @@ PackageModel::setupModelData( const QVariantList& groupList, PackageTreeItem* pa { bool haveWarned = false; const auto& subgroupValue = groupMap.value( "subgroups" ); - if ( !subgroupValue.canConvert( QVariant::List ) ) + if ( !subgroupValue.canConvert< QVariantList >() ) { cWarning() << "*subgroups* under" << item->name() << "is not a list."; haveWarned = true; diff --git a/src/modules/netinstall/groupstreeview.cpp b/src/modules/netinstall/groupstreeview.cpp index 4e5ab8c8d..f8b98eb13 100644 --- a/src/modules/netinstall/groupstreeview.cpp +++ b/src/modules/netinstall/groupstreeview.cpp @@ -22,7 +22,12 @@ GroupsTreeView::drawBranches( QPainter* painter, const QRect& rect, const QModel const QString s = index.data().toString(); if ( s.isEmpty() ) { +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QStyleOptionViewItem opt = viewOptions(); +#else + QStyleOptionViewItem opt; + initViewItemOption( &opt ); +#endif opt.state = QStyle::State_Sibling; opt.rect = QRect( !isRightToLeft() ? rect.left() : rect.right() + 1, rect.top(), indentation(), rect.height() ); painter->eraseRect( opt.rect ); From 07e7757c31e1063bd0e986072f22180d9ed44341 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 15:36:09 +0200 Subject: [PATCH 12/19] oemid: adjust to Qt6 --- src/modules/oemid/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/oemid/CMakeLists.txt b/src/modules/oemid/CMakeLists.txt index 45825c85e..d7c35bbbe 100644 --- a/src/modules/oemid/CMakeLists.txt +++ b/src/modules/oemid/CMakeLists.txt @@ -12,6 +12,6 @@ calamares_add_plugin(oemid UI OEMPage.ui LINK_PRIVATE_LIBRARIES - Qt5::Widgets + ${qtname}::Widgets SHARED_LIB ) From d7df1a8eca96aea7329941fb88ef2980788bc8ba Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 22:58:29 +0200 Subject: [PATCH 13/19] packagechooser: Adapt to Qt6 While here, deal with the WITH_ -> BUILD_ change of options. --- CMakeLists.txt | 8 +++++--- src/modules/packagechooser/CMakeLists.txt | 17 ++++++++--------- src/modules/packagechooser/Config.cpp | 3 ++- src/modules/packagechooserq/CMakeLists.txt | 17 ++++++++--------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cad505366..886f0e64e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,19 +20,21 @@ # SKIP_MODULES : a space or semicolon-separated list of directory names # under src/modules that should not be built. # USE_ : fills in SKIP_MODULES for modules called -. -# WITH_QT6 : use Qt6, rather than Qt5 (default to OFF). # WITH_ : try to enable (these usually default to ON). For # a list of WITH_ grep CMakeCache.txt after running # CMake once. These affect the ABI offered by Calamares. # - PYTHON (enable Python Job modules) # - QML (enable QML UI View modules) +# - QT6 (use Qt6 rather than Qt5, default to OFF) # The WITH_* options affect the ABI of Calamares: you must # build (C++) modules for Calamares with the same WITH_* # settings, or they may not load at all. # BUILD_ : choose additional things to build -# - TESTING (standard CMake option) -# - SCHEMA_TESTING (requires Python, see ci/configvalidator.py) +# - APPDATA (use AppData in packagechooser, requires QtXml) +# - APPSTREAM (use AppStream in packagechooser, requires libappstream-qt) # - BUILD_CRASH_REPORTING (uses KCrash, rather than Calamares internal, for crash reporting) +# - SCHEMA_TESTING (requires Python, see ci/configvalidator.py) +# - TESTING (standard CMake option) # DEBUG_ : special developer flags for debugging. # # Example usage: diff --git a/src/modules/packagechooser/CMakeLists.txt b/src/modules/packagechooser/CMakeLists.txt index e565fd05e..f42029964 100644 --- a/src/modules/packagechooser/CMakeLists.txt +++ b/src/modules/packagechooser/CMakeLists.txt @@ -3,20 +3,19 @@ # SPDX-FileCopyrightText: 2020 Adriaan de Groot # SPDX-License-Identifier: BSD-2-Clause # -find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED) +find_package(${qtname} COMPONENTS Core Gui Widgets REQUIRED) set(_extra_libraries "") set(_extra_src "") ### OPTIONAL AppData XML support in PackageModel # # -# TODO:3.3:WITH->BUILD (this doesn't affect the ABI offered by Calamares) -option(WITH_APPDATA "Support appdata: items in PackageChooser (requires QtXml)" ON) -if(WITH_APPDATA) - find_package(Qt5 COMPONENTS Xml) - if(Qt5Xml_FOUND) +option(BUILD_APPDATA "Support appdata: items in PackageChooser (requires QtXml)" ON) +if(BUILD_APPDATA) + find_package(${qtname} COMPONENTS Xml) + if(TARGET ${qtname}::Xml) add_definitions(-DHAVE_APPDATA) - list(APPEND _extra_libraries Qt5::Xml) + list(APPEND _extra_libraries ${qtname}::Xml) list(APPEND _extra_src ItemAppData.cpp) endif() endif() @@ -24,8 +23,8 @@ endif() ### OPTIONAL AppStream support in PackageModel # # -option(WITH_APPSTREAM "Support appstream: items in PackageChooser (requires libappstream-qt)" ON) -if(WITH_APPSTREAM) +option(BUILD_APPSTREAM "Support appstream: items in PackageChooser (requires libappstream-qt)" ON) +if(BUILD_APPSTREAM) find_package(AppStreamQt) set_package_properties( AppStreamQt diff --git a/src/modules/packagechooser/Config.cpp b/src/modules/packagechooser/Config.cpp index 667621597..b596fe6e8 100644 --- a/src/modules/packagechooser/Config.cpp +++ b/src/modules/packagechooser/Config.cpp @@ -23,6 +23,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" +#include "compat/Variant.h" #include "packages/Globals.h" #include "utils/Logger.h" #include "utils/Variant.h" @@ -175,7 +176,7 @@ Config::updateGlobalStorage( const QStringList& selected ) const if ( gs->contains( "netinstallSelect" ) ) { auto selectedOrig = gs->value( "netinstallSelect" ); - if ( selectedOrig.canConvert( QVariant::StringList ) ) + if ( selectedOrig.canConvert< QStringList >() ) { newSelected += selectedOrig.toStringList(); } diff --git a/src/modules/packagechooserq/CMakeLists.txt b/src/modules/packagechooserq/CMakeLists.txt index 0b2c4b23a..5591f5a8f 100644 --- a/src/modules/packagechooserq/CMakeLists.txt +++ b/src/modules/packagechooserq/CMakeLists.txt @@ -9,7 +9,7 @@ if(NOT WITH_QML) return() endif() -find_package(Qt5 ${QT_VERSION} CONFIG REQUIRED Core) +find_package(${qtname} ${QT_VERSION} CONFIG REQUIRED Core) # Add optional libraries here set(USER_EXTRA_LIB) @@ -21,13 +21,12 @@ include_directories(${_packagechooser}) ### OPTIONAL AppData XML support in PackageModel # # -# TODO:3.3:WITH->BUILD (this doesn't affect the ABI offered by Calamares) -option(WITH_APPDATA "Support appdata: items in PackageChooser (requires QtXml)" ON) -if(WITH_APPDATA) - find_package(Qt5 COMPONENTS Xml) - if(Qt5Xml_FOUND) +option(BUILD_APPDATA "Support appdata: items in PackageChooser (requires QtXml)" ON) +if(BUILD_APPDATA) + find_package(${qtname} COMPONENTS Xml) + if(TARGET ${qtname}::Xml) add_definitions(-DHAVE_APPDATA) - list(APPEND _extra_libraries Qt5::Xml) + list(APPEND _extra_libraries ${qtname}::Xml) list(APPEND _extra_src ${_packagechooser}/ItemAppData.cpp) endif() endif() @@ -35,8 +34,8 @@ endif() ### OPTIONAL AppStream support in PackageModel # # -option(WITH_APPSTREAM "Support appstream: items in PackageChooser (requires libappstream-qt)" ON) -if(WITH_APPSTREAM) +option(BUILD_APPSTREAM "Support appstream: items in PackageChooser (requires libappstream-qt)" ON) +if(BUILD_APPSTREAM) find_package(AppStreamQt) set_package_properties( AppStreamQt From 2eff5f74a5792f5e7792e1694927153440efcdf5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 23:04:43 +0200 Subject: [PATCH 14/19] plasmalnf: not compatible with Qt6 --- src/modules/plasmalnf/CMakeLists.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 9e87b5fec..bd65db603 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -3,19 +3,20 @@ # SPDX-FileCopyrightText: 2020 Adriaan de Groot # SPDX-License-Identifier: BSD-2-Clause # +if(WITH_QT6) + calamares_skip_module( "plasmalnf (KDE Frameworks 5 only)" ) + return() +endif() + find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) # Requires a sufficiently recent Plasma framework, but also # needs a runtime support component (which we don't test for). -set(lnf_ver 5.41) -find_package(KF5Config ${lnf_ver}) +find_package(${kfname} ${KF_VERSION} QUIET COMPONENTS Config Plasma Package) + set_package_properties(KF5Config PROPERTIES PURPOSE "For finding default Plasma Look-and-Feel") - -find_package(KF5Plasma ${lnf_ver}) set_package_properties(KF5Plasma PROPERTIES PURPOSE "For Plasma Look-and-Feel selection") - -find_package(KF5Package ${lnf_ver}) set_package_properties(KF5Package PROPERTIES PURPOSE "For Plasma Look-and-Feel selection") if(KF5Plasma_FOUND AND KF5Package_FOUND) @@ -35,8 +36,8 @@ if(KF5Plasma_FOUND AND KF5Package_FOUND) UI page_plasmalnf.ui LINK_PRIVATE_LIBRARIES - KF5::Package - KF5::Plasma + ${kfname}::Package + ${kfname}::Plasma SHARED_LIB ) if(KF5Config_FOUND) From 680d4f8dc22d5766ea6809d00d3bb62c91703aca Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 23:09:44 +0200 Subject: [PATCH 15/19] preservefiles: adapt to Qt6 --- src/modules/preservefiles/Item.cpp | 7 ++++--- src/modules/preservefiles/PreserveFiles.cpp | 3 ++- src/modules/preservefiles/Tests.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/modules/preservefiles/Item.cpp b/src/modules/preservefiles/Item.cpp index 2ae929e67..98488f951 100644 --- a/src/modules/preservefiles/Item.cpp +++ b/src/modules/preservefiles/Item.cpp @@ -9,6 +9,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" +#include "compat/Variant.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" #include "utils/Units.h" @@ -41,7 +42,7 @@ copy_file( const QString& source, const QString& dest ) { b = sourcef.read( 1_MiB ); destf.write( b ); - } while ( b.count() > 0 ); + } while ( b.size() > 0 ); sourcef.close(); destf.close(); @@ -52,7 +53,7 @@ copy_file( const QString& source, const QString& dest ) Item Item::fromVariant( const QVariant& v, const CalamaresUtils::Permissions& defaultPermissions ) { - if ( v.type() == QVariant::String ) + if ( Calamares::typeOf( v ) == Calamares::StringVariantType ) { QString filename = v.toString(); if ( !filename.isEmpty() ) @@ -65,7 +66,7 @@ Item::fromVariant( const QVariant& v, const CalamaresUtils::Permissions& default return {}; } } - else if ( v.type() == QVariant::Map ) + else if ( Calamares::typeOf( v ) == Calamares::MapVariantType ) { const auto map = v.toMap(); diff --git a/src/modules/preservefiles/PreserveFiles.cpp b/src/modules/preservefiles/PreserveFiles.cpp index 8cbeee75f..15d588182 100644 --- a/src/modules/preservefiles/PreserveFiles.cpp +++ b/src/modules/preservefiles/PreserveFiles.cpp @@ -12,6 +12,7 @@ #include "CalamaresVersion.h" #include "GlobalStorage.h" #include "JobQueue.h" +#include "compat/Variant.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/CommandList.h" #include "utils/Logger.h" @@ -97,7 +98,7 @@ PreserveFiles::setConfigurationMap( const QVariantMap& configurationMap ) return; } - if ( files.type() != QVariant::List ) + if ( Calamares::typeOf( files ) != Calamares::ListVariantType ) { cDebug() << "Configuration key 'files' is not a list for preservefiles."; return; diff --git a/src/modules/preservefiles/Tests.cpp b/src/modules/preservefiles/Tests.cpp index 57cefcf9d..4bd6f138f 100644 --- a/src/modules/preservefiles/Tests.cpp +++ b/src/modules/preservefiles/Tests.cpp @@ -73,7 +73,7 @@ PreserveFilesTests::testItems() QFETCH( bool, ok ); QFETCH( int, type_i ); - QFile fi( QString( "%1/tests/%2" ).arg( BUILD_AS_TEST, filename ) ); + QFileInfo fi( QString( "%1/tests/%2" ).arg( BUILD_AS_TEST, filename ) ); QVERIFY( fi.exists() ); bool config_file_ok = false; From 9d324bcccd0155d3e83dc4bbbcf439613c916186 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 23:37:42 +0200 Subject: [PATCH 16/19] users: adapt to Qt6 --- src/modules/users/CMakeLists.txt | 16 +++++------ src/modules/users/CheckPWQuality.cpp | 4 +-- src/modules/users/Config.cpp | 33 +++++++++++----------- src/modules/users/TestGroupInformation.cpp | 2 +- src/modules/users/Tests.cpp | 6 ++-- src/modules/usersq/CMakeLists.txt | 4 +-- 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/modules/users/CMakeLists.txt b/src/modules/users/CMakeLists.txt index 060c9b691..dced10179 100644 --- a/src/modules/users/CMakeLists.txt +++ b/src/modules/users/CMakeLists.txt @@ -3,7 +3,7 @@ # SPDX-FileCopyrightText: 2020 Adriaan de Groot # SPDX-License-Identifier: BSD-2-Clause # -find_package(Qt5 ${QT_VERSION} CONFIG REQUIRED Core DBus Network) +find_package(${qtname} ${QT_VERSION} CONFIG REQUIRED Core DBus Network) find_package(Crypt REQUIRED) # Add optional libraries here @@ -50,8 +50,8 @@ calamares_add_library( SOURCES ${_users_src} LINK_LIBRARIES - KF5::CoreAddons - Qt5::DBus + ${kfname}::CoreAddons + ${qtname}::DBus ${CRYPT_LIBRARIES} ) @@ -80,8 +80,8 @@ calamares_add_test( TestGroupInformation.cpp ${_users_src} # Build again with test-visibility LIBRARIES - KF5::CoreAddons - Qt5::DBus # HostName job can use DBus to systemd + ${kfname}::CoreAddons + ${qtname}::DBus # HostName job can use DBus to systemd ${CRYPT_LIBRARIES} # SetPassword job uses crypt() ${USER_EXTRA_LIB} ) @@ -90,7 +90,7 @@ calamares_add_test( usershostnametest SOURCES TestSetHostNameJob.cpp SetHostNameJob.cpp LIBRARIES - Qt5::DBus # HostName job can use DBus to systemd + ${qtname}::DBus # HostName job can use DBus to systemd ) calamares_add_test( @@ -99,8 +99,8 @@ calamares_add_test( Tests.cpp ${_users_src} # Build again with test-visibility LIBRARIES - KF5::CoreAddons - Qt5::DBus # HostName job can use DBus to systemd + ${kfname}::CoreAddons + ${qtname}::DBus # HostName job can use DBus to systemd ${CRYPT_LIBRARIES} # SetPassword job uses crypt() ${USER_EXTRA_LIB} ) diff --git a/src/modules/users/CheckPWQuality.cpp b/src/modules/users/CheckPWQuality.cpp index fc692d246..e612a419e 100644 --- a/src/modules/users/CheckPWQuality.cpp +++ b/src/modules/users/CheckPWQuality.cpp @@ -41,7 +41,7 @@ PasswordCheck::PasswordCheck( MessageFunc m, AcceptFunc a, Weight weight ) DEFINE_CHECK_FUNC( minLength ) { int minLength = -1; - if ( value.canConvert( QVariant::Int ) ) + if ( value.canConvert< int >() ) { minLength = value.toInt(); } @@ -57,7 +57,7 @@ DEFINE_CHECK_FUNC( minLength ) DEFINE_CHECK_FUNC( maxLength ) { int maxLength = -1; - if ( value.canConvert( QVariant::Int ) ) + if ( value.canConvert< int >() ) { maxLength = value.toInt(); } diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 8c7316efd..7251f6ff2 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -16,6 +16,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" +#include "compat/Variant.h" #include "utils/Logger.h" #include "utils/String.h" #include "utils/StringExpander.h" @@ -24,7 +25,7 @@ #include #include #include -#include +#include #include #ifdef HAVE_ICU @@ -41,10 +42,10 @@ static const char TRANSLITERATOR_ID[] = "Russian-Latin/BGN;" #include -static const QRegExp USERNAME_RX( "^[a-z_][a-z0-9_-]*[$]?$" ); +static const QRegularExpression USERNAME_RX( "^[a-z_][a-z0-9_-]*[$]?$" ); // Note anchors begin and end static constexpr const int USERNAME_MAX_LENGTH = 31; -static const QRegExp HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" ); +static const QRegularExpression HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" ); // Note anchors begin and end static constexpr const int HOSTNAME_MIN_LENGTH = 2; static constexpr const int HOSTNAME_MAX_LENGTH = 63; @@ -235,12 +236,12 @@ Config::loginNameStatus() const return tr( "Your username is too long." ); } - QRegExp validateFirstLetter( "^[a-z_]" ); - if ( validateFirstLetter.indexIn( m_loginName ) != 0 ) + QRegularExpression validateFirstLetter( "^[a-z_]" ); + if ( m_loginName.indexOf( validateFirstLetter ) != 0 ) { return tr( "Your username must start with a lowercase letter or underscore." ); } - if ( !USERNAME_RX.exactMatch( m_loginName ) ) + if ( m_loginName.indexOf( USERNAME_RX ) != 0 ) { return tr( "Only lowercase letters, numbers, underscore and hyphen are allowed." ); } @@ -310,7 +311,7 @@ Config::hostnameStatus() const return tr( "'%1' is not allowed as hostname." ).arg( m_hostname ); } - if ( !HOSTNAME_RX.exactMatch( m_hostname ) ) + if ( m_hostname.indexOf( HOSTNAME_RX ) != 0 ) { return tr( "Only letters, numbers, underscore and hyphen are allowed." ); } @@ -321,7 +322,7 @@ Config::hostnameStatus() const static QString cleanupForHostname( const QString& s ) { - QRegExp dmirx( "(^Apple|\\(.*\\)|[^a-zA-Z0-9])", Qt::CaseInsensitive ); + QRegularExpression dmirx( "(^Apple|\\(.*\\)|[^a-zA-Z0-9])", QRegularExpression::CaseInsensitiveOption ); return s.toLower().replace( dmirx, " " ).remove( ' ' ); } @@ -412,7 +413,7 @@ makeLoginNameSuggestion( const QStringList& parts ) } } - return USERNAME_RX.indexIn( usernameSuggestion ) != -1 ? usernameSuggestion : QString(); + return usernameSuggestion.indexOf( USERNAME_RX ) != -1 ? usernameSuggestion : QString(); } /** @brief Return an invalid string for use in a hostname, if @p s is empty @@ -445,8 +446,8 @@ makeHostnameSuggestion( const QString& templateString, const QStringList& fullNa QString hostnameSuggestion = d.expand( templateString ); // RegExp for valid hostnames; if the suggestion produces a valid name, return it - static const QRegExp HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" ); - return HOSTNAME_RX.indexIn( hostnameSuggestion ) != -1 ? hostnameSuggestion : QString(); + static const QRegularExpression HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" ); + return hostnameSuggestion.indexOf( HOSTNAME_RX ) != -1 ? hostnameSuggestion : QString(); } void @@ -483,10 +484,10 @@ Config::setFullName( const QString& name ) emit fullNameChanged( name ); // Build login and hostname, if needed - static QRegExp rx( "[^a-zA-Z0-9 ]", Qt::CaseInsensitive ); + static QRegularExpression rx( "[^a-zA-Z0-9 ]" ); const QString cleanName = Calamares::String::removeDiacritics( transliterate( name ) ) - .replace( QRegExp( "[-']" ), "" ) + .replace( QRegularExpression( "[-']" ), "" ) .replace( rx, " " ) .toLower() .simplified(); @@ -751,7 +752,7 @@ setConfigurationDefaultGroups( const QVariantMap& map, QList< GroupDescription > auto groupsFromConfig = map.value( key ).toList(); if ( groupsFromConfig.isEmpty() ) { - if ( map.contains( key ) && map.value( key ).isValid() && map.value( key ).canConvert( QVariant::List ) ) + if ( map.contains( key ) && map.value( key ).isValid() && map.value( key ).canConvert< QVariantList >() ) { // Explicitly set, but empty: this is valid, but unusual. cDebug() << key << "has explicit empty value."; @@ -772,11 +773,11 @@ setConfigurationDefaultGroups( const QVariantMap& map, QList< GroupDescription > { for ( const auto& v : groupsFromConfig ) { - if ( v.type() == QVariant::String ) + if ( Calamares::typeOf( v ) == Calamares::StringVariantType ) { defaultGroups.append( GroupDescription( v.toString() ) ); } - else if ( v.type() == QVariant::Map ) + else if ( Calamares::typeOf( v ) == Calamares::MapVariantType ) { const auto innermap = v.toMap(); QString name = CalamaresUtils::getString( innermap, "name" ); diff --git a/src/modules/users/TestGroupInformation.cpp b/src/modules/users/TestGroupInformation.cpp index 31ca032c7..41b7c6238 100644 --- a/src/modules/users/TestGroupInformation.cpp +++ b/src/modules/users/TestGroupInformation.cpp @@ -79,7 +79,7 @@ void GroupTests::testCreateGroup() { // BUILD_AS_TEST is the source-directory path - QFile fi( QString( "%1/tests/5-issue-1523.conf" ).arg( BUILD_AS_TEST ) ); + QFileInfo fi( QString( "%1/tests/5-issue-1523.conf" ).arg( BUILD_AS_TEST ) ); QVERIFY( fi.exists() ); bool ok = false; diff --git a/src/modules/users/Tests.cpp b/src/modules/users/Tests.cpp index ac27570ca..0039037ae 100644 --- a/src/modules/users/Tests.cpp +++ b/src/modules/users/Tests.cpp @@ -214,7 +214,7 @@ UserTests::testDefaultGroupsYAML() QFETCH( QString, group ); // BUILD_AS_TEST is the source-directory path - QFile fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) ); + QFileInfo fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) ); QVERIFY( fi.exists() ); bool ok = false; @@ -450,7 +450,7 @@ UserTests::testAutoLogin() QFETCH( QString, autoLoginGroupName ); // BUILD_AS_TEST is the source-directory path - QFile fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) ); + QFileInfo fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) ); QVERIFY( fi.exists() ); bool ok = false; @@ -502,7 +502,7 @@ UserTests::testUserYAML() QFETCH( QString, shell ); // BUILD_AS_TEST is the source-directory path - QFile fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) ); + QFileInfo fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) ); QVERIFY( fi.exists() ); bool ok = false; diff --git a/src/modules/usersq/CMakeLists.txt b/src/modules/usersq/CMakeLists.txt index 33133f439..6409f7f55 100644 --- a/src/modules/usersq/CMakeLists.txt +++ b/src/modules/usersq/CMakeLists.txt @@ -8,7 +8,7 @@ if(NOT WITH_QML) return() endif() -find_package(Qt5 ${QT_VERSION} CONFIG REQUIRED Core DBus Network) +find_package(${qtname} ${QT_VERSION} CONFIG REQUIRED Core DBus Network) find_package(Crypt REQUIRED) # Add optional libraries here @@ -46,6 +46,6 @@ calamares_add_plugin(usersq users_internal ${CRYPT_LIBRARIES} ${USER_EXTRA_LIB} - Qt5::DBus + ${qtname}::DBus SHARED_LIB ) From ead610b429bc3c76371335bc5f29f7dd49f12a68 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 23:53:29 +0200 Subject: [PATCH 17/19] zfs: adapt to Qt6 --- src/modules/zfs/ZfsJob.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/zfs/ZfsJob.cpp b/src/modules/zfs/ZfsJob.cpp index c840da846..cc2af7482 100644 --- a/src/modules/zfs/ZfsJob.cpp +++ b/src/modules/zfs/ZfsJob.cpp @@ -18,6 +18,7 @@ #include "Settings.h" #include +#include #include @@ -29,7 +30,7 @@ static QString alphaNumeric( QString input ) { - return input.remove( QRegExp( "[^a-zA-Z\\d\\s]" ) ); + return input.remove( QRegularExpression( "[^a-zA-Z\\d\\s]" ) ); } /** @brief Returns the best available device for zpool creation @@ -107,7 +108,7 @@ ZfsJob::collectMountpoints( const QVariantList& partitions ) m_mountpoints.empty(); for ( const QVariant& partition : partitions ) { - if ( partition.canConvert( QVariant::Map ) ) + if ( partition.canConvert< QVariantMap >() ) { QString mountpoint = partition.toMap().value( "mountPoint" ).toString(); if ( !mountpoint.isEmpty() ) @@ -170,7 +171,7 @@ ZfsJob::exec() { QVariantList partitions; Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - if ( gs && gs->contains( "partitions" ) && gs->value( "partitions" ).canConvert( QVariant::List ) ) + if ( gs && gs->contains( "partitions" ) && gs->value( "partitions" ).canConvert< QVariantList >() ) { partitions = gs->value( "partitions" ).toList(); } @@ -187,7 +188,7 @@ ZfsJob::exec() QVariantList poolNames; // Check to ensure the list of zfs info from the partition module is available and convert it to a list - if ( !gs->contains( "zfsInfo" ) && gs->value( "zfsInfo" ).canConvert( QVariant::List ) ) + if ( !gs->contains( "zfsInfo" ) && gs->value( "zfsInfo" ).canConvert< QVariantList >() ) { return Calamares::JobResult::error( tr( "Internal data missing" ), tr( "Failed to create zpool" ) ); } @@ -196,7 +197,7 @@ ZfsJob::exec() for ( auto& partition : qAsConst( partitions ) ) { QVariantMap pMap; - if ( partition.canConvert( QVariant::Map ) ) + if ( partition.canConvert< QVariantMap >() ) { pMap = partition.toMap(); } @@ -233,7 +234,7 @@ ZfsJob::exec() QString passphrase; for ( const QVariant& zfsInfo : qAsConst( zfsInfoList ) ) { - if ( zfsInfo.canConvert( QVariant::Map ) && zfsInfo.toMap().value( "encrypted" ).toBool() + if ( zfsInfo.canConvert< QVariantMap >() && zfsInfo.toMap().value( "encrypted" ).toBool() && mountpoint == zfsInfo.toMap().value( "mountpoint" ) ) { encrypt = true; From e1bb6f1eb331d37d9d4219acb436eb39bc08f894 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 23:50:33 +0200 Subject: [PATCH 18/19] CMake: remove Qt6 handholding of modules --- src/modules/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index da9b66451..bb7335316 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -21,10 +21,6 @@ string(REPLACE " " ";" SKIP_LIST "${SKIP_MODULES}") file(GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*") list(SORT SUBDIRECTORIES) -if(WITH_QT6) # TODO: Qt6 -set(SUBDIRECTORIES finished finishedq welcome welcomeq) -endif() - foreach(SUBDIRECTORY ${SUBDIRECTORIES}) calamares_add_module_subdirectory( ${SUBDIRECTORY} LIST_SKIPPED_MODULES ) endforeach() From 1a865fd2fbe8dc27697d26f6d4667d87b6c35913 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 5 Sep 2023 22:59:48 +0200 Subject: [PATCH 19/19] CMake: reduce required KF5 version to support Debian --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 886f0e64e..2989a4f04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,8 +179,8 @@ else() set(qtname "Qt5") set(kfname "KF5") set(QT_VERSION 5.15.0) - set(ECM_VERSION 5.100) - set(KF_VERSION 5.100) + set(ECM_VERSION 5.78) + set(KF_VERSION 5.78) # API that was deprecated before Qt 5.15 causes a compile error add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050f00) endif()