mirror of
https://github.com/YACReader/yacreader
synced 2025-05-27 19:00:29 -04:00
Do not use QTextCodec in Qt6
This commit is contained in:
parent
e7f3d29477
commit
75060d4f24
@ -6,7 +6,10 @@
|
||||
#include <QPixmap>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QTextCodec>
|
||||
#endif
|
||||
|
||||
ShortcutsDialog::ShortcutsDialog(QWidget *parent)
|
||||
: QDialog(parent) //,Qt::FramelessWindowHint)
|
||||
@ -44,7 +47,13 @@ ShortcutsDialog::ShortcutsDialog(QWidget *parent)
|
||||
QFile f(":/files/shortcuts.html");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
QTextStream txtS(&f);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
txtS.setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
txtS.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
#endif
|
||||
|
||||
QString content = txtS.readAll();
|
||||
|
||||
f.close();
|
||||
|
@ -6,9 +6,12 @@
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QTextCodec>
|
||||
#include <QScreen>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QTextCodec>
|
||||
#endif
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
HelpAboutDialog::HelpAboutDialog(QWidget *parent)
|
||||
@ -80,7 +83,11 @@ QString HelpAboutDialog::fileToString(const QString &path)
|
||||
f.open(QIODevice::ReadOnly);
|
||||
QTextStream txtS(&f);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
txtS.setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
txtS.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
#endif
|
||||
|
||||
QString content = txtS.readAll();
|
||||
f.close();
|
||||
|
17
third_party/QsLog/QsLogDestFile.cpp
vendored
17
third_party/QsLog/QsLogDestFile.cpp
vendored
@ -24,12 +24,15 @@
|
||||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "QsLogDestFile.h"
|
||||
#include <QTextCodec>
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
#include <iostream>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QTextCodec>
|
||||
#endif
|
||||
|
||||
const int QsLogging::SizeRotationStrategy::MaxBackupCount = 10;
|
||||
|
||||
QsLogging::RotationStrategy::~RotationStrategy() noexcept = default;
|
||||
@ -148,8 +151,14 @@ QsLogging::FileDestination::FileDestination(const QString& filePath, RotationStr
|
||||
if (!mFile.open(QFile::WriteOnly | QFile::Text | mRotationStrategy->recommendedOpenModeFlag())) {
|
||||
std::cerr << "QsLog: could not open log file " << qPrintable(filePath);
|
||||
}
|
||||
|
||||
mOutputStream.setDevice(&mFile);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
mOutputStream.setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
mOutputStream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
#endif
|
||||
|
||||
mRotationStrategy->setInitialInfo(mFile);
|
||||
}
|
||||
@ -167,10 +176,14 @@ void QsLogging::FileDestination::write(const LogMessage& message)
|
||||
}
|
||||
mRotationStrategy->setInitialInfo(mFile);
|
||||
mOutputStream.setDevice(&mFile);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
mOutputStream.setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
mOutputStream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
#endif
|
||||
}
|
||||
|
||||
mOutputStream << utf8Message << endl;
|
||||
mOutputStream << utf8Message << Qt::endl;
|
||||
mOutputStream.flush();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user