From 63b88fed74445e64f05f4cade352a56c7291375e Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Thu, 10 Dec 2020 21:15:56 +0100 Subject: Adapt to Qt6 text codec changes In Qt6 QTextCodec/QTextStream::setCodec is replaced with QTextStream::setEncoding(QStringConverter::Encoding) Also UTF-8 is the new default for QTextStream. --- src/kconf_update/kconf_update.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index 99f6fd5c..08b4e224 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -18,6 +17,10 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif + #include #include @@ -219,7 +222,11 @@ bool KonfUpdate::checkFile(const QString &filename) } QTextStream ts(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ts.setCodec(QTextCodec::codecForName("ISO-8859-1")); +#else + ts.setEncoding(QStringConverter::Encoding::Latin1); +#endif int lineCount = 0; resetOptions(); QString id; @@ -307,7 +314,11 @@ bool KonfUpdate::updateFile(const QString &filename) qCDebug(KCONF_UPDATE_LOG) << "Checking update-file" << filename << "for new updates"; QTextStream ts(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ts.setCodec(QTextCodec::codecForName("ISO-8859-1")); +#else + ts.setEncoding(QStringConverter::Encoding::Latin1); +#endif m_lineCount = 0; resetOptions(); bool foundVersion = false; @@ -848,7 +859,9 @@ void KonfUpdate::gotScript(const QString &_script) // Copy script stderr to log file { QTextStream ts(proc.readAllStandardError()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ts.setCodec(QTextCodec::codecForName("UTF-8")); +#endif while (!ts.atEnd()) { QString line = ts.readLine(); qCDebug(KCONF_UPDATE_LOG) << "[Script]" << line; @@ -882,7 +895,9 @@ void KonfUpdate::gotScript(const QString &_script) QFile output(scriptOut.fileName()); if (output.open(QIODevice::ReadOnly)) { QTextStream ts(&output); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ts.setCodec(QTextCodec::codecForName("UTF-8")); +#endif while (!ts.atEnd()) { QString line = ts.readLine(); if (line.startsWith('[')) { -- cgit v1.2.1