From 65fac30780d66e081fd222e1e116220a84fa144f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 11 Feb 2024 18:19:54 +0100 Subject: [PATCH] Always use the core5compat module for code page transformations on Android --- gpxsee.pro | 11 +++++------ src/common/textcodec.cpp | 17 ++++++++++++++--- src/common/textcodec.h | 8 ++++---- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/gpxsee.pro b/gpxsee.pro index 1bc8613f..22ecc0fe 100644 --- a/gpxsee.pro +++ b/gpxsee.pro @@ -17,12 +17,9 @@ QT += core \ positioning \ svg \ serialport -greaterThan(QT_MAJOR_VERSION, 5) { - QT += openglwidgets - lessThan(QT_MINOR_VERSION, 5) { - QT += core5compat + greaterThan(QT_MAJOR_VERSION, 5) { + QT += openglwidgets } -} CONFIG += object_parallel_to_source INCLUDEPATH += ./src @@ -581,11 +578,13 @@ unix:!macx:!android { } android { - RESOURCES += theme-color.qrc + QT += core5compat HEADERS += src/GUI/navigationwidget.h SOURCES += src/GUI/navigationwidget.cpp + RESOURCES += theme-color.qrc + defineReplace(versionCode) { segments = $$split(1, ".") for (segment, segments): \ diff --git a/src/common/textcodec.cpp b/src/common/textcodec.cpp index fd64e3aa..04e6e4a1 100644 --- a/src/common/textcodec.cpp +++ b/src/common/textcodec.cpp @@ -1,6 +1,17 @@ #include "textcodec.h" -#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) +/* + QStringDecoder can use the ICU library for codepage transformations since + Qt 6.5, but we use QTextCodec from the core5compat module on Android to + reduce the size of the app bundle (the ICU library has ~30MB). + + On all other platforms, we require a Qt6 build with ICU support for all + the CP* encodings to work. On Linux, most distros compile Qt6 with ICU + support, on Windows and OS X a special Qt6 build is required as + the "official" Qt6 installers have ICU support disabled (QTBUG-121353). +*/ + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) || defined(Q_OS_ANDROID) static QTextCodec *codec(int mib) { @@ -74,7 +85,7 @@ QString TextCodec::toString(const QByteArray &ba) return _codec ? _codec->toUnicode(ba) : QString::fromLatin1(ba); } -#else // QT 6.5 +#else // QT 6 || ANDROID TextCodec::TextCodec() { @@ -97,4 +108,4 @@ QString TextCodec::toString(const QByteArray &ba) { return _decoder.isValid() ? _decoder.decode(ba) : QString::fromLatin1(ba); } -#endif // QT 6.5 +#endif // QT 6 || ANDROID diff --git a/src/common/textcodec.h b/src/common/textcodec.h index 26da6e3b..8caec33d 100644 --- a/src/common/textcodec.h +++ b/src/common/textcodec.h @@ -2,11 +2,11 @@ #define TEXTCODEC_H #include -#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) || defined(Q_OS_ANDROID) #include -#else // QT 6.5 +#else // QT 6 || ANDROID #include -#endif // QT 6.5 +#endif // QT 6 || ANDROID class TextCodec { @@ -17,7 +17,7 @@ public: QString toString(const QByteArray &ba); private: -#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) || defined(Q_OS_ANDROID) QTextCodec *_codec; #else // QT 6.5 QStringDecoder _decoder;