From 90219afcdb5f652ba15fc439de3a7bef6e6fe284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=96=87=E9=AA=90?= <50741705+swq11@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:01:21 +0800 Subject: [PATCH] fix: Adapt user experience plan agreement md format document (#380) Log: Adapt user experience plan agreement md format document Bug: https://pms.uniontech.com/bug-view-281497.html Co-authored-by: swq --- dde-license-dialog/src/content.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dde-license-dialog/src/content.cpp b/dde-license-dialog/src/content.cpp index f1ee51d8..01d8ff54 100644 --- a/dde-license-dialog/src/content.cpp +++ b/dde-license-dialog/src/content.cpp @@ -180,7 +180,32 @@ void Content::setSource(const QString &source) if (source.isEmpty()) return; - m_source->setText(source); + // pandoc将md转换成html + static QMap sourceMap; + if (sourceMap[source].isEmpty()) { + QProcess process; + QString para; + QString tempPath = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first(); + tempPath.append("/license_temp.html"); + if (QFile::exists(tempPath)) + QFile::remove(tempPath); + para = QString("pandoc %1 --output %2").arg(source, tempPath); + QStringList args; + args << "-c"; + args << para; + process.start("sh", args); + process.waitForFinished(); + process.waitForReadyRead(); + QFile file(tempPath); + if (!file.open(QIODevice::Text | QIODevice::ReadOnly)) { + qWarning() << "Set source error: " << file.errorString(); + return; + } + sourceMap.insert(source, file.readAll()); + file.close(); + } + + m_source->setText(sourceMap[source]); updateWindowHeight(); }