From c1643af18bd7faedc89cf462a9906cb56751700d Mon Sep 17 00:00:00 2001 From: Takaaki Numai Date: Tue, 6 Aug 2024 11:45:56 +0900 Subject: [PATCH 1/3] Support Qt 5.12.8 --- configparams.cpp | 24 ++++++++++++++++++++++++ pages/pageloganalysis.cpp | 12 ++++++++++-- pages/pagevescpackage.cpp | 26 ++++++++++++++++++++++++++ pages/pagevescpackage.h | 3 +++ vescinterface.cpp | 17 +++++++++++++++++ widgets/aspectimglabel.cpp | 4 ++++ widgets/helpdialog.cpp | 4 ++++ 7 files changed, 88 insertions(+), 2 deletions(-) diff --git a/configparams.cpp b/configparams.cpp index de3064560..1afc4ec8a 100644 --- a/configparams.cpp +++ b/configparams.cpp @@ -1841,7 +1841,11 @@ bool ConfigParams::moveGroupUp(QString group) for (int i = 0;i < mParamGrouping.size();i++) { if (mParamGrouping.at(i).first.toLower() == group.toLower()) { if (i > 0) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) mParamGrouping.swapItemsAt(i, i - 1); +#else + qSwap(mParamGrouping[i], mParamGrouping[i - 1]); +#endif return true; } else { return false; @@ -1856,7 +1860,11 @@ bool ConfigParams::moveGroupDown(QString group) for (int i = 0;i < mParamGrouping.size();i++) { if (mParamGrouping.at(i).first.toLower() == group.toLower()) { if (i < (mParamGrouping.size() - 1)) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) mParamGrouping.swapItemsAt(i, i + 1); +#else + qSwap(mParamGrouping[i], mParamGrouping[i + 1]); +#endif return true; } else { return false; @@ -1873,7 +1881,11 @@ bool ConfigParams::moveSubgroupUp(QString group, QString subgroup) for (int j = 0;j < mParamGrouping.at(i).second.size();j++) { if (mParamGrouping.at(i).second.at(j).first.toLower() == subgroup.toLower()) { if (j > 0) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) mParamGrouping[i].second.swapItemsAt(j, j - 1); +#else + qSwap(mParamGrouping[i].second[j], mParamGrouping[i].second[j - 1]); +#endif return true; } else { return false; @@ -1892,7 +1904,11 @@ bool ConfigParams::moveSubgroupDown(QString group, QString subgroup) for (int j = 0;j < mParamGrouping.at(i).second.size();j++) { if (mParamGrouping.at(i).second.at(j).first.toLower() == subgroup.toLower()) { if (j < (mParamGrouping.at(i).second.size() - 1)) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) mParamGrouping[i].second.swapItemsAt(j, j + 1); +#else + qSwap(mParamGrouping[i].second[j], mParamGrouping[i].second[j + 1]); +#endif return true; } else { return false; @@ -1913,7 +1929,11 @@ bool ConfigParams::moveSubgroupParamUp(QString group, QString subgroup, QString for (int k = 0;k < mParamGrouping.at(i).second.at(j).second.size();k++) { if (mParamGrouping.at(i).second.at(j).second.at(k).toLower() == param.toLower()) { if (k > 0) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) mParamGrouping[i].second[j].second.swapItemsAt(k, k - 1); +#else + qSwap(mParamGrouping[i].second[j].second[k], mParamGrouping[i].second[j].second[k - 1]); +#endif return true; } else { return false; @@ -1936,7 +1956,11 @@ bool ConfigParams::moveSubgroupParamDown(QString group, QString subgroup, QStrin for (int k = 0;k < mParamGrouping.at(i).second.at(j).second.size();k++) { if (mParamGrouping.at(i).second.at(j).second.at(k).toLower() == param.toLower()) { if (k < (mParamGrouping.at(i).second.at(j).second.size() - 1)) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) mParamGrouping[i].second[j].second.swapItemsAt(k, k + 1); +#else + qSwap(mParamGrouping[i].second[j].second[k], mParamGrouping[i].second[j].second[k + 1]); +#endif return true; } else { return false; diff --git a/pages/pageloganalysis.cpp b/pages/pageloganalysis.cpp index 37bcdc2a1..47686ea46 100644 --- a/pages/pageloganalysis.cpp +++ b/pages/pageloganalysis.cpp @@ -181,7 +181,11 @@ PageLogAnalysis::PageLogAnalysis(QWidget *parent) : ui->plot->axisRect()->setRangeDrag(Qt::Orientations()); double upper = ui->plot->xAxis->range().upper; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) double progress = ui->plot->xAxis->pixelToCoord(event->position().x()) / upper; +#else + double progress = ui->plot->xAxis->pixelToCoord(event->x()) / upper; +#endif double diff = event->angleDelta().y(); double d1 = diff * progress; double d2 = diff * (1.0 - progress); @@ -1712,8 +1716,12 @@ void PageLogAnalysis::on_saveCsvButton_clicked() for (int i = 0;i < mLog.size();i++) { for (int j = 0;j < mLog.at(i).size();j++) { - os << Qt::fixed - << qSetRealNumberPrecision(mLogHeader.at(j).precision) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + os << Qt::fixed; +#else + os.setRealNumberNotation(QTextStream::FixedNotation); +#endif + os << qSetRealNumberPrecision(mLogHeader.at(j).precision) << mLog.at(i).at(j); if (j < (mLog.at(i).size() - 1)) { diff --git a/pages/pagevescpackage.cpp b/pages/pagevescpackage.cpp index b25d7a8bc..835558f26 100644 --- a/pages/pagevescpackage.cpp +++ b/pages/pagevescpackage.cpp @@ -267,6 +267,26 @@ void PageVescPackage::on_writeButton_clicked() mLoader.installVescPackageFromPath(ui->loadEdit->text()); } +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) +QString PageVescPackage::convertHtmlToMarkdown(const QString &html) { + QString markdown = html; + + // and to ** + markdown.replace(QRegularExpression("(.*?)"), "**\\1**"); + + // and to * + markdown.replace(QRegularExpression("(.*?)"), "*\\1*"); + + //
and
to newline + markdown.replace(QRegularExpression(""), "\n"); + + // Remove other HTML tags + markdown.remove(QRegularExpression("<[^>]*>")); + + return markdown; +} +#endif + void PageVescPackage::on_outputRefreshButton_clicked() { QFile f(ui->outputEdit->text()); @@ -287,7 +307,13 @@ void PageVescPackage::on_outputRefreshButton_clicked() QString line1 = QTextStream(&pkg.description).readLine(); if (line1.contains("descriptionEdit->document()->setHtml(pkg.description); + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) QString md = ui->descriptionEdit->document()->toMarkdown(); +#else + QString md = convertHtmlToMarkdown(ui->descriptionEdit->document()->toHtml()); +#endif + ui->descriptionEdit->document()->setPlainText(md); } else { ui->descriptionEdit->document()->setPlainText(pkg.description); diff --git a/pages/pagevescpackage.h b/pages/pagevescpackage.h index d7a31c0c3..5ba017897 100644 --- a/pages/pagevescpackage.h +++ b/pages/pagevescpackage.h @@ -50,6 +50,9 @@ private slots: void on_saveButton_clicked(); void on_loadRefreshButton_clicked(); void on_writeButton_clicked(); +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) + QString convertHtmlToMarkdown(const QString &html); +#endif void on_outputRefreshButton_clicked(); void on_dlArchiveButton_clicked(); void on_uninstallButton_clicked(); diff --git a/vescinterface.cpp b/vescinterface.cpp index f10876027..dbfdae45b 100755 --- a/vescinterface.cpp +++ b/vescinterface.cpp @@ -495,8 +495,17 @@ VescInterface::VescInterface(QObject *parent) : QObject(parent) os << mLastImuValues.gyroZ << ";"; os << msPos << ";"; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) os << Qt::fixed << qSetRealNumberPrecision(8) << lat << ";"; os << Qt::fixed << qSetRealNumberPrecision(8) << lon << ";"; +#else + os.setRealNumberNotation(QTextStream::FixedNotation); + os.setRealNumberPrecision(8); + os << lat << ";"; + os.setRealNumberNotation(QTextStream::FixedNotation); + os.setRealNumberPrecision(8); + os << lon << ";"; +#endif os << alt << ";"; os << gVel << ";"; os << vVel << ";"; @@ -808,7 +817,11 @@ void VescInterface::deleteProfile(int index) void VescInterface::moveProfileUp(int index) { if (index > 0 && index < mProfiles.size()) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) mProfiles.swapItemsAt(index, index - 1); +#else + qSwap(mProfiles[index], mProfiles[index - 1]); +#endif emit profilesUpdated(); } } @@ -816,7 +829,11 @@ void VescInterface::moveProfileUp(int index) void VescInterface::moveProfileDown(int index) { if (index >= 0 && index < (mProfiles.size() - 1)) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) mProfiles.swapItemsAt(index, index + 1); +#else + qSwap(mProfiles[index], mProfiles[index + 1]); +#endif emit profilesUpdated(); } } diff --git a/widgets/aspectimglabel.cpp b/widgets/aspectimglabel.cpp index 56493f446..3df7a5fd7 100644 --- a/widgets/aspectimglabel.cpp +++ b/widgets/aspectimglabel.cpp @@ -29,7 +29,11 @@ void AspectImgLabel::resizeEvent(QResizeEvent *event) { QLabel::resizeEvent(event); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) const QPixmap &pix = pixmap(Qt::ReturnByValue); +#else + const QPixmap &pix = *pixmap(); +#endif if (!pix.isNull()) { int wLabel = width(); diff --git a/widgets/helpdialog.cpp b/widgets/helpdialog.cpp index 295e6d6db..78266e70a 100644 --- a/widgets/helpdialog.cpp +++ b/widgets/helpdialog.cpp @@ -35,11 +35,15 @@ HelpDialog::HelpDialog(QString title, QString text, QWidget *parent) : setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(title); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) if (text.trimmed().startsWith('#')) { ui->textEdit->setMarkdown(text); } else { ui->textEdit->setText(text); } +#else + ui->textEdit->setText(text); +#endif ui->textEdit->viewport()->setAutoFillBackground(false); } From 0de1eb8bb967a62b8a5d2e015bb5c1f1b65e9db9 Mon Sep 17 00:00:00 2001 From: Takaaki Numai Date: Wed, 7 Aug 2024 11:22:50 +0900 Subject: [PATCH 2/3] Fix bug --- main.cpp | 14 ++++++++++++++ pages/pagevescpackage.cpp | 25 +++++++++++++++++++++++++ widgets/helpdialog.cpp | 2 ++ 3 files changed, 41 insertions(+) diff --git a/main.cpp b/main.cpp index 5da4a3df2..bfb752ca9 100755 --- a/main.cpp +++ b/main.cpp @@ -158,6 +158,20 @@ static void addFonts() { int main(int argc, char *argv[]) { + // Set the platform plugin to xcb + qputenv("QT_QPA_PLATFORM", QByteArray("xcb")); + qputenv("QT_XCB_GL_INTEGRATION", QByteArray("glx")); + qputenv("LIBGL_ALWAYS_SOFTWARE", QByteArray("1")); + qputenv("QT_QUICK_BACKEND", QByteArray("software")); + + // Set OpenGL format + QSurfaceFormat format; + format.setDepthBufferSize(24); + format.setStencilBufferSize(8); + format.setVersion(2, 0); // Set OpenGL version to 2.0 + format.setProfile(QSurfaceFormat::NoProfile); + QSurfaceFormat::setDefaultFormat(format); + // Settings QCoreApplication::setOrganizationName("VESC"); QCoreApplication::setOrganizationDomain("vesc-project.com"); diff --git a/pages/pagevescpackage.cpp b/pages/pagevescpackage.cpp index 835558f26..fd077c02b 100644 --- a/pages/pagevescpackage.cpp +++ b/pages/pagevescpackage.cpp @@ -280,6 +280,31 @@ QString PageVescPackage::convertHtmlToMarkdown(const QString &html) { //
and
to newline markdown.replace(QRegularExpression(""), "\n"); + //

to

to # + markdown.replace(QRegularExpression("

(.*?)

"), "# \\1\n"); + markdown.replace(QRegularExpression("

(.*?)

"), "## \\1\n"); + markdown.replace(QRegularExpression("

(.*?)

"), "### \\1\n"); + markdown.replace(QRegularExpression("

(.*?)

"), "#### \\1\n"); + markdown.replace(QRegularExpression("
(.*?)
"), "##### \\1\n"); + markdown.replace(QRegularExpression("
(.*?)
"), "###### \\1\n"); + + //
    and
      to list + markdown.replace(QRegularExpression("
        "), ""); + markdown.replace(QRegularExpression("
          "), ""); + markdown.replace(QRegularExpression("
        1. (.*?)
        2. "), "- \\1\n"); + markdown.replace(QRegularExpression("
      "), ""); + markdown.replace(QRegularExpression("
    "), ""); + + // text to [text](url) + markdown.replace(QRegularExpression("(.*?)"), "[\\2](\\1)"); + + // alt to ![alt](url) + markdown.replace(QRegularExpression(""), "!\\[\\2\\](\\1)"); + + //

    to newline and

    to another newline + markdown.replace(QRegularExpression("

    "), ""); + markdown.replace(QRegularExpression("

    "), "\n\n"); + // Remove other HTML tags markdown.remove(QRegularExpression("<[^>]*>")); diff --git a/widgets/helpdialog.cpp b/widgets/helpdialog.cpp index 78266e70a..2008bfdcd 100644 --- a/widgets/helpdialog.cpp +++ b/widgets/helpdialog.cpp @@ -36,12 +36,14 @@ HelpDialog::HelpDialog(QString title, QString text, QWidget *parent) : setWindowTitle(title); #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + // For Qt 5.14.0 and above, set text as Markdown if it starts with '#' if (text.trimmed().startsWith('#')) { ui->textEdit->setMarkdown(text); } else { ui->textEdit->setText(text); } #else + // For Qt versions below 5.14.0, always set text as plain text ui->textEdit->setText(text); #endif From d00c7b633d0de581b926dde9f4d8d514998fe539 Mon Sep 17 00:00:00 2001 From: saitenntaisei Date: Wed, 4 Sep 2024 15:54:35 +0900 Subject: [PATCH 3/3] add p_pid_offset_pot_calib --- res/config/6.06/parameters_mcconf.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/res/config/6.06/parameters_mcconf.xml b/res/config/6.06/parameters_mcconf.xml index 5efec28c7..95f722275 100644 --- a/res/config/6.06/parameters_mcconf.xml +++ b/res/config/6.06/parameters_mcconf.xml @@ -3187,6 +3187,18 @@ p, li { white-space: pre-wrap; } ° 9 + + Use Potentionmeter for Offset Angle Calibration + 5 + 1 + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Roboto'; ; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Allow the speed controller to to apply braking current. In general this option should be enabled, but for some applications it might make sense to disable braking during speed control.</p></body></html> + MCCONF_P_PID_OFFSET_POT_CALIB + 0 + Position PID Kd Process 1 @@ -4671,6 +4683,7 @@ p, li { white-space: pre-wrap; } p_pid_ang_div p_pid_gain_dec_angle p_pid_offset + p_pid_offset_pot_calib cc_startup_boost_duty cc_min_current cc_gain @@ -5069,6 +5082,7 @@ p, li { white-space: pre-wrap; } p_pid_ang_div p_pid_gain_dec_angle p_pid_offset + p_pid_offset_pot_calib