From 43c455331581b7c64fa5c0c9b0e97a859fa7d9ef Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 6 Dec 2024 17:49:12 +0800 Subject: [PATCH] Qt6 Compatibility --- RedPandaIDE/mainwindow.cpp | 14 +++++----- RedPandaIDE/problems/freeprojectsetformat.cpp | 26 +++++++++---------- libs/redpanda_qt_utils/qt_utils/utils.cpp | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index ef205ace3..7cfedebf1 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -137,12 +137,14 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); - /** Qt 6.8.0 fix: Crash when debug **/ - QFont font(pSettings->environment().interfaceFont()); - font.setPixelSize(pointToPixel(pSettings->environment().interfaceFontSize())); - font.setStyleStrategy(QFont::PreferAntialias); - qApp->setFont(font); - this->setFont(font); + /** Msys2 MinGW 64 Qt 6.8.0 fix: Crash when debug **/ +#if defined(QT_DEBUG) && defined(Q_OS_WINDOWS) && QT_VERSION_MAJOR == 6 + QFont font(pSettings->environment().interfaceFont()); + font.setPixelSize(pointToPixel(pSettings->environment().interfaceFontSize())); + font.setStyleStrategy(QFont::PreferAntialias); + qApp->setFont(font); + this->setFont(font); +#endif /** **/ ui->cbProblemCaseValidateType->blockSignals(true); diff --git a/RedPandaIDE/problems/freeprojectsetformat.cpp b/RedPandaIDE/problems/freeprojectsetformat.cpp index 32f78ce67..2d8fe79cf 100644 --- a/RedPandaIDE/problems/freeprojectsetformat.cpp +++ b/RedPandaIDE/problems/freeprojectsetformat.cpp @@ -21,40 +21,40 @@ QList importFreeProblemSet(const QString &filename) switch (xml.tokenType()) { case QXmlStreamReader::TokenType::StartElement: currentEleName = xml.name().toString(); - if (xml.name()=="item") { + if (xml.name() == QLatin1String("item")) { currentProblem=std::make_shared(); } else if (currentProblem && - (xml.name()=="test_input")) { + (xml.name() == QLatin1String("test_input"))) { currentCase = std::make_shared(); foreach (const QXmlStreamAttribute& attr, xml.attributes()) { - if (attr.name() == "name") { + if (attr.name() == QLatin1String("name")) { currentCase->name = attr.value().toString().trimmed(); break; } } currentCase->name = QObject::tr("Problem Case %1").arg(currentProblem->cases.count()+1); } else if (currentProblem && - xml.name()=="time_limit") { + xml.name()==QLatin1String("time_limit")) { currentEleName = xml.name().toString(); foreach (const QXmlStreamAttribute& attr, xml.attributes()) { - if (attr.name() == "unit") { - if (attr.value()=="ms") + if (attr.name() == QLatin1String("unit")) { + if (attr.value()==QLatin1String("ms")) currentProblem->timeLimitUnit = ProblemTimeLimitUnit::Milliseconds; - else if (attr.value()=="s") + else if (attr.value()==QLatin1String("s")) currentProblem->timeLimitUnit = ProblemTimeLimitUnit::Seconds; break; } } } else if (currentProblem && - xml.name()=="memory_limit") { + xml.name()==QLatin1String("memory_limit")) { currentEleName = xml.name().toString(); foreach (const QXmlStreamAttribute& attr, xml.attributes()) { - if (attr.name() == "unit") { - if (attr.value()=="mb") + if (attr.name() == QLatin1String("unit")) { + if (attr.value()==QLatin1String("mb")) currentProblem->memoryLimitUnit = ProblemMemoryLimitUnit::MB; - else if (attr.value()=="kb") + else if (attr.value()==QLatin1String("kb")) currentProblem->memoryLimitUnit = ProblemMemoryLimitUnit::KB; - else if (attr.value()=="gb") + else if (attr.value()==QLatin1String("gb")) currentProblem->memoryLimitUnit = ProblemMemoryLimitUnit::GB; break; } @@ -63,7 +63,7 @@ QList importFreeProblemSet(const QString &filename) break; case QXmlStreamReader::TokenType::EndElement: currentEleName.clear(); - if (currentProblem && xml.name()=="item") { + if (currentProblem && xml.name()==QLatin1String("item")) { problems.append(currentProblem); currentProblem.reset(); } diff --git a/libs/redpanda_qt_utils/qt_utils/utils.cpp b/libs/redpanda_qt_utils/qt_utils/utils.cpp index 69e534f65..3b49ef474 100644 --- a/libs/redpanda_qt_utils/qt_utils/utils.cpp +++ b/libs/redpanda_qt_utils/qt_utils/utils.cpp @@ -541,7 +541,7 @@ QString extractRelativePath(const QString &base, const QString &dest) QString localizePath(const QString &path) { - if (QDir::separator() == "/") + if (QDir::separator() == '/') return path; QString result = path; result.replace("/",QDir::separator());