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