From c8a05b995f1158cbf83aca124aae8a69dcd5ab1b Mon Sep 17 00:00:00 2001 From: Floris Bos Date: Sun, 19 Mar 2023 21:54:00 +0100 Subject: [PATCH] Make code Qt 6 compatible / raises minimum Qt 5 version to 5.14 In addition to replacing Qt5 with Qt6 in CMakeLists.txt two small changes to the code are needed to make things build on Qt 6 (which in turn is needed for Apple M1/M2 support). The cost of this change is that when building on Qt 5, at least version 5.14 is needed. Certain older but still used Linux distributions such as Ubuntu 10.04 LTS still use 5.12, so revert this commit if you are building on those... --- src/CMakeLists.txt | 2 +- src/OptionsPopup.qml | 6 ++---- src/devicewrapperfatpartition.cpp | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 63c250373..762d6c2c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,7 +100,7 @@ set(SOURCES "main.cpp" "imagewriter.cpp" "networkaccessmanagerfactory.cpp" "devicewrapper.cpp" "devicewrapperblockcacheentry.cpp" "devicewrapperpartition.cpp" "devicewrapperfatpartition.cpp" "driveformatthread.cpp" "localfileextractthread.cpp" "powersaveblocker.cpp" "downloadstatstelemetry.cpp" "qml.qrc" "dependencies/sha256crypt/sha256crypt.c" "cli.cpp") -find_package(Qt5 COMPONENTS Core Quick LinguistTools Svg OPTIONAL_COMPONENTS Widgets) +find_package(Qt5 5.14 COMPONENTS Core Quick LinguistTools Svg OPTIONAL_COMPONENTS Widgets) if (Qt5Widgets_FOUND) set(EXTRALIBS ${EXTRALIBS} Qt5::Widgets) endif() diff --git a/src/OptionsPopup.qml b/src/OptionsPopup.qml index da0272d86..a1f855e61 100644 --- a/src/OptionsPopup.qml +++ b/src/OptionsPopup.qml @@ -3,7 +3,7 @@ * Copyright (C) 2021 Raspberry Pi Ltd */ -import QtQuick 2.9 +import QtQuick 2.15 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.0 import QtQuick.Controls.Material 2.2 @@ -128,9 +128,7 @@ Popup { id: fieldHostname enabled: chkHostname.checked text: "raspberrypi" - /* FIXME: use RegularExpressionValidator instead when moving to newer Qt version. - It is not available in 5.12 that is still being used by Ubuntu 20 LTS though */ - validator: RegExpValidator { regExp: /[0-9A-Za-z][0-9A-Za-z-]{0,62}/ } + validator: RegularExpressionValidator { regularExpression: /[0-9A-Za-z][0-9A-Za-z-]{0,62}/ } } Text { text : ".local" diff --git a/src/devicewrapperfatpartition.cpp b/src/devicewrapperfatpartition.cpp index a05d2c450..5b566c421 100644 --- a/src/devicewrapperfatpartition.cpp +++ b/src/devicewrapperfatpartition.cpp @@ -1,6 +1,5 @@ #include "devicewrapperfatpartition.h" #include "devicewrapperstructs.h" -#include "qdebug.h" /* * SPDX-License-Identifier: Apache-2.0 @@ -314,7 +313,7 @@ void DeviceWrapperFatPartition::writeFile(const QString &filename, const QByteAr for (uint32_t cluster : qAsConst(clusterList)) { seekCluster(cluster); - write(contents.data()+pos, qMin(_bytesPerCluster, contents.length()-pos)); + write(contents.data()+pos, qMin((qsizetype)_bytesPerCluster, (qsizetype)(contents.length()-pos))); pos += _bytesPerCluster; if (pos >= contents.length())