From d760546acad69f879d42e43e6c6f836056cc8594 Mon Sep 17 00:00:00 2001 From: u-235 Date: Wed, 2 Oct 2024 21:11:56 +0300 Subject: [PATCH] Parse tooltip files as utf-8 encoded --- gcodeworkshop/src/gcoderdocument.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcodeworkshop/src/gcoderdocument.cpp b/gcodeworkshop/src/gcoderdocument.cpp index 2e0562a..889781f 100644 --- a/gcodeworkshop/src/gcoderdocument.cpp +++ b/gcodeworkshop/src/gcoderdocument.cpp @@ -49,7 +49,7 @@ #include // for QVariant #include // for QWidget #include // for CaseInsensitive, CaseSensitive, CaseSensitivity, WA_DeleteOnClose, Custo... -#include // for QFlags, QFlags<>::enum_type, qDebug +#include // for QFlags, QFlags<>::enum_type, qDebug, QT_VERSION, QT_VERSION_CHECK class QMenu; @@ -639,7 +639,14 @@ void GCoderDocument::loadToolTips(QHash& tips, const QString& { if (QFile::exists(fileName)) { QSettings settings(fileName, QSettings::IniFormat); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + // Qt5: By default QSettings will accept Latin-1 encoded INI files, + // where non-ASCII values are encoded using standard INI escape sequences. + // Qt6: QSettings will assume that values in the INI file are utf-8 encoded. + settings.setIniCodec("utf-8"); +#endif settings.beginGroup(group); + const QStringList& keys = settings.childKeys(); for (const QString& k : keys) {