Skip to content

Commit

Permalink
Make code Qt 6 compatible / raises minimum Qt 5 version to 5.14
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
maxnet committed Mar 20, 2023
1 parent 08599d0 commit c8a05b9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions src/OptionsPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/devicewrapperfatpartition.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "devicewrapperfatpartition.h"
#include "devicewrapperstructs.h"
#include "qdebug.h"

/*
* SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit c8a05b9

Please sign in to comment.