Skip to content

Commit

Permalink
chore: remove the dependence of pandoc (#385)
Browse files Browse the repository at this point in the history
as title

Log: as title
  • Loading branch information
yixinshark authored Dec 9, 2024
1 parent 8ab24bf commit 113ecef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
41 changes: 9 additions & 32 deletions dde-license-dialog/src/content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,17 @@

#include <DApplication>
#include <DSuggestButton>
#include <DCommandLinkButton>
#include <DFontSizeManager>

#include <QScrollArea>
#include <QPushButton>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QApplication>
#include <QFile>
#include <QTimer>
#include <QProcess>
#include <QDebug>
#include <QStandardPaths>
#include <QFontMetrics>
#include <QScroller>
#include <QFuture>
#include <QtConcurrent>
#include <QThread>
#include <QTranslator>
Expand Down Expand Up @@ -177,36 +170,20 @@ int Content::calWidgetWidth()

void Content::setSource(const QString &source)
{
if (source.isEmpty())
if (source.isEmpty() || !QFile::exists(source))
return;

// pandoc将md转换成html
static QMap<QString, QString> 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();
QFile file(source);
if (!file.open(QIODevice::Text | QIODevice::ReadOnly)) {
qWarning() << "Set source error: " << file.errorString();
return;
}

m_source->setText(sourceMap[source]);
QTextDocument doc;
doc.setMarkdown(file.readAll());
file.close();

m_source->setText(doc.toHtml());
updateWindowHeight();
}

Expand Down
2 changes: 1 addition & 1 deletion dde-license-dialog/src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MainWindow : public DAbstractDialog
QString m_enTitle;

DIconButton *btnclose;
const int windowFixedWidth = 500;
const int windowFixedWidth = 520;
};

#endif // MAINWINDOW_H
3 changes: 1 addition & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${dist:Depends},
startdde (>=5.8.15),
x11-xserver-utils,
dbus-user-session,
dde-session-shell,
pandoc,
dde-session-shell
Provides: lightdm-greeter
Recommends: onboard
Conflicts: dde-workspace,
Expand Down

0 comments on commit 113ecef

Please sign in to comment.