修复配置文件保存时编码异常问题,修改关于和帮助页面
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#include "aboutdialog.h"
|
||||
|
||||
#include "ElaImageCard.h"
|
||||
#include "ElaText.h"
|
||||
#include "ElaPushButton.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QFont>
|
||||
#include <QDateTime>
|
||||
|
||||
AboutDialog::AboutDialog(QWidget* parent) : InterDialog(parent)
|
||||
{
|
||||
setFixedSize(354, 180);
|
||||
setWindowTitle("关于");
|
||||
setStandardButtons(QDialogButtonBox::Ok);
|
||||
|
||||
auto* centralWidget = new QWidget(this);
|
||||
auto* centralLayout = new QVBoxLayout(centralWidget);
|
||||
centralLayout->setContentsMargins(0, 10, 0, 10);
|
||||
this->setCentralWidget(centralWidget);
|
||||
|
||||
auto* pixCard = new ElaImageCard(this);
|
||||
pixCard->setFixedSize(64, 64);
|
||||
pixCard->setIsPreserveAspectCrop(false);
|
||||
pixCard->setCardImage(QImage(":/resources/images/ChangeCode.png"));
|
||||
|
||||
auto* pixCardLayout = new QVBoxLayout();
|
||||
pixCardLayout->addWidget(pixCard);
|
||||
pixCardLayout->addStretch();
|
||||
|
||||
auto* nameText = new ElaText(this);
|
||||
QFont nameTextFont = nameText->font();
|
||||
nameTextFont.setWeight(QFont::Bold);
|
||||
nameText->setFont(nameTextFont);
|
||||
nameText->setTextPixelSize(17);
|
||||
nameText->setText("UFT30 ChangeCode");
|
||||
|
||||
auto* versionText = new ElaText(this);
|
||||
versionText->setText(QString("版本: %1").arg(Version::getVersionString()));
|
||||
versionText->setTextPixelSize(12);
|
||||
|
||||
auto* dateText = new ElaText(this);
|
||||
dateText->setText(QString("构建日期: %1").arg(Version::getBuildDateTime()));
|
||||
dateText->setTextPixelSize(12);
|
||||
|
||||
auto* textLayout = new QVBoxLayout();
|
||||
textLayout->setSpacing(10);
|
||||
textLayout->addWidget(nameText);
|
||||
textLayout->addWidget(versionText);
|
||||
textLayout->addWidget(dateText);
|
||||
textLayout->addStretch();
|
||||
|
||||
auto* downloadBtn = new ElaPushButton("下载最新", this);
|
||||
connect(downloadBtn, &ElaPushButton::clicked, []
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl("http://10.20.163.105:6045/uft3changecode/下载.html"));
|
||||
});
|
||||
addFirstButton(downloadBtn);
|
||||
|
||||
auto* contentLayout = new QHBoxLayout();
|
||||
contentLayout->addSpacing(10);
|
||||
contentLayout->addLayout(pixCardLayout);
|
||||
contentLayout->addSpacing(15);
|
||||
contentLayout->addLayout(textLayout);
|
||||
|
||||
centralLayout->addLayout(contentLayout);
|
||||
}
|
||||
|
||||
AboutDialog::~AboutDialog() = default;
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef METASEARCH_ABOUTDIALOG_H
|
||||
#define METASEARCH_ABOUTDIALOG_H
|
||||
|
||||
#include "components/interdialog.h"
|
||||
#include "utils/version.h"
|
||||
|
||||
/**
|
||||
* 关于弹窗
|
||||
*/
|
||||
class AboutDialog final : public InterDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutDialog(QWidget *parent = nullptr);
|
||||
~AboutDialog() override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //METASEARCH_ABOUTDIALOG_H
|
||||
@@ -1,41 +0,0 @@
|
||||
#include "aboutpage.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
AboutPage::AboutPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
initUI();
|
||||
}
|
||||
|
||||
AboutPage::~AboutPage()
|
||||
{
|
||||
}
|
||||
|
||||
void AboutPage::initUI()
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(30, 30, 30, 30);
|
||||
layout->setAlignment(Qt::AlignCenter);
|
||||
|
||||
QLabel *logoLabel = new QLabel;
|
||||
logoLabel->setStyleSheet("font-size: 48px; text-align: center;");
|
||||
logoLabel->setText("UFT30");
|
||||
layout->addWidget(logoLabel, 0, Qt::AlignCenter);
|
||||
|
||||
QLabel *title = new QLabel("<h1>UFT30 Change Code</h1>");
|
||||
title->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(title);
|
||||
|
||||
QLabel *version = new QLabel("<p style='font-size: 16px;'>版本: 1.0.0</p>");
|
||||
version->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(version);
|
||||
|
||||
QLabel *description = new QLabel("<p style='font-size: 14px; color: #666;'>一款强大的编码转换工具,支持批量转码和非LS格式转换。</p>");
|
||||
description->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(description);
|
||||
|
||||
QLabel *copyright = new QLabel("<p style='font-size: 12px; color: #999;'>Copyright © 2024 UFT30 Team. All rights reserved.</p>");
|
||||
copyright->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(copyright);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef ABOUTPAGE_H
|
||||
#define ABOUTPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class AboutPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutPage(QWidget *parent = nullptr);
|
||||
~AboutPage();
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
};
|
||||
|
||||
#endif // ABOUTPAGE_H
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "helpdocpage.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
HelpDocPage::HelpDocPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
initUI();
|
||||
}
|
||||
|
||||
HelpDocPage::~HelpDocPage()
|
||||
{
|
||||
}
|
||||
|
||||
void HelpDocPage::initUI()
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QLabel *label = new QLabel("<a href='https://github.com'>点击此处跳转帮助文档</a>");
|
||||
label->setStyleSheet("font-size: 14px; color: #4a90d9;");
|
||||
label->setOpenExternalLinks(true);
|
||||
layout->addWidget(label, 0, Qt::AlignCenter);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef HELPPAGE_H
|
||||
#define HELPPAGE_H
|
||||
#ifndef HELPDOCPAGE_H
|
||||
#define HELPDOCPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
@@ -7,13 +7,13 @@
|
||||
#include <QTextBrowser>
|
||||
#include "ElaTreeView.h"
|
||||
|
||||
class HelpPage : public QWidget
|
||||
class HelpDocPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HelpPage(QWidget *parent = nullptr);
|
||||
~HelpPage();
|
||||
explicit HelpDocPage(QWidget *parent = nullptr);
|
||||
~HelpDocPage();
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
@@ -31,4 +31,4 @@ private:
|
||||
QString m_helpContent;
|
||||
};
|
||||
|
||||
#endif // HELPPAGE_H
|
||||
#endif // HELPDOCPAGE_H
|
||||
@@ -1,215 +0,0 @@
|
||||
#include "helppage.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QTextBrowser>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardItemModel>
|
||||
#include <QModelIndex>
|
||||
#include "ElaTreeView.h"
|
||||
|
||||
HelpPage::HelpPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
initUI();
|
||||
}
|
||||
|
||||
HelpPage::~HelpPage()
|
||||
{
|
||||
}
|
||||
|
||||
void HelpPage::initUI()
|
||||
{
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
||||
mainLayout->setContentsMargins(10, 10, 10, 10);
|
||||
mainLayout->setSpacing(10);
|
||||
|
||||
initTreeView();
|
||||
initContentPages();
|
||||
|
||||
mainLayout->addWidget(m_treeView);
|
||||
mainLayout->addWidget(m_stackedWidget);
|
||||
}
|
||||
|
||||
void HelpPage::initTreeView()
|
||||
{
|
||||
m_treeView = new ElaTreeView;
|
||||
m_treeView->setFixedWidth(200);
|
||||
|
||||
QStandardItemModel *model = new QStandardItemModel(this);
|
||||
model->setHorizontalHeaderLabels(QStringList() << "功能导航");
|
||||
|
||||
QStandardItem *overviewItem = new QStandardItem("📋 概述");
|
||||
overviewItem->setData("概述", Qt::UserRole);
|
||||
model->appendRow(overviewItem);
|
||||
|
||||
QStandardItem *convertItem = new QStandardItem("📦 功能转码");
|
||||
convertItem->setData("功能转码", Qt::UserRole);
|
||||
QStandardItem *businessConvertItem = new QStandardItem("业务转码");
|
||||
businessConvertItem->setData("功能转码", Qt::UserRole);
|
||||
convertItem->appendRow(businessConvertItem);
|
||||
model->appendRow(convertItem);
|
||||
|
||||
QStandardItem *searchItem = new QStandardItem("🔍 功能查询");
|
||||
searchItem->setData("功能查询", Qt::UserRole);
|
||||
QStandardItem *uf20SearchItem = new QStandardItem("UF20功能查询");
|
||||
uf20SearchItem->setData("功能查询", Qt::UserRole);
|
||||
QStandardItem *uft3SearchItem = new QStandardItem("UFT3功能查询");
|
||||
uft3SearchItem->setData("功能查询", Qt::UserRole);
|
||||
searchItem->appendRow(uf20SearchItem);
|
||||
searchItem->appendRow(uft3SearchItem);
|
||||
model->appendRow(searchItem);
|
||||
|
||||
QStandardItem *metadataItem = new QStandardItem("🔄 元数据更新");
|
||||
metadataItem->setData("元数据更新", Qt::UserRole);
|
||||
model->appendRow(metadataItem);
|
||||
|
||||
QStandardItem *settingsItem = new QStandardItem("⚙️ 设置");
|
||||
settingsItem->setData("设置", Qt::UserRole);
|
||||
model->appendRow(settingsItem);
|
||||
|
||||
QStandardItem *aboutItem = new QStandardItem("📖 关于");
|
||||
aboutItem->setData("关于", Qt::UserRole);
|
||||
model->appendRow(aboutItem);
|
||||
|
||||
QStandardItem *tipsItem = new QStandardItem("💡 使用技巧");
|
||||
tipsItem->setData("使用技巧", Qt::UserRole);
|
||||
model->appendRow(tipsItem);
|
||||
|
||||
m_treeView->setModel(model);
|
||||
m_treeView->expand(model->index(1, 0));
|
||||
m_treeView->expand(model->index(2, 0));
|
||||
|
||||
connect(m_treeView, &QTreeView::clicked, this, [this](const QModelIndex& index) {
|
||||
QString section = index.data(Qt::UserRole).toString();
|
||||
updateContent(section);
|
||||
});
|
||||
}
|
||||
|
||||
void HelpPage::initContentPages()
|
||||
{
|
||||
m_stackedWidget = new QStackedWidget;
|
||||
|
||||
QWidget *contentPage = new QWidget;
|
||||
QVBoxLayout *layout = new QVBoxLayout(contentPage);
|
||||
layout->setContentsMargins(30, 30, 30, 30);
|
||||
|
||||
m_titleLabel = new QLabel("<h1>使用帮助</h1>");
|
||||
layout->addWidget(m_titleLabel);
|
||||
|
||||
m_contentBrowser = new QTextBrowser;
|
||||
m_contentBrowser->setReadOnly(true);
|
||||
m_contentBrowser->setStyleSheet("background-color: white;");
|
||||
layout->addWidget(m_contentBrowser);
|
||||
|
||||
m_stackedWidget->addWidget(contentPage);
|
||||
|
||||
loadHelpFile();
|
||||
updateContent("概述");
|
||||
}
|
||||
|
||||
void HelpPage::loadHelpFile()
|
||||
{
|
||||
QString helpFilePath = QDir::currentPath() + "/help/help.md";
|
||||
QFile file(helpFilePath);
|
||||
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&file);
|
||||
m_helpContent = in.readAll();
|
||||
file.close();
|
||||
} else {
|
||||
m_helpContent = "# 使用帮助\n\n## 概述\n\n帮助文档加载失败,请检查资源文件。";
|
||||
}
|
||||
}
|
||||
|
||||
void HelpPage::updateContent(const QString §ion)
|
||||
{
|
||||
QString htmlContent = markdownToHtml(extractSection(section));
|
||||
m_contentBrowser->setHtml(htmlContent);
|
||||
}
|
||||
|
||||
QString HelpPage::extractSection(const QString §ionName)
|
||||
{
|
||||
QStringList lines = m_helpContent.split("\n");
|
||||
QString sectionContent;
|
||||
bool inSection = false;
|
||||
|
||||
for (const QString &line : lines) {
|
||||
if (line.startsWith("## ")) {
|
||||
QString title = line.mid(3).trimmed();
|
||||
if (title == sectionName) {
|
||||
inSection = true;
|
||||
sectionContent = line + "\n";
|
||||
} else if (inSection) {
|
||||
break;
|
||||
}
|
||||
} else if (inSection) {
|
||||
sectionContent += line + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return sectionContent;
|
||||
}
|
||||
|
||||
QString HelpPage::markdownToHtml(const QString &markdown)
|
||||
{
|
||||
QStringList lines = markdown.split("\n");
|
||||
QString html;
|
||||
bool inList = false;
|
||||
|
||||
for (const QString &line : lines) {
|
||||
QString trimmedLine = line.trimmed();
|
||||
|
||||
if (trimmedLine.isEmpty()) {
|
||||
if (!inList) {
|
||||
html += "<br>";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trimmedLine.startsWith("### ")) {
|
||||
if (inList) {
|
||||
html += "</ul>";
|
||||
inList = false;
|
||||
}
|
||||
html += "<h3>" + trimmedLine.mid(4) + "</h3>";
|
||||
} else if (trimmedLine.startsWith("#### ")) {
|
||||
if (inList) {
|
||||
html += "</ul>";
|
||||
inList = false;
|
||||
}
|
||||
html += "<h4>" + trimmedLine.mid(5) + "</h4>";
|
||||
} else if (trimmedLine.startsWith("- ")) {
|
||||
if (!inList) {
|
||||
html += "<ul style='margin-top: 4px; margin-bottom: 4px; padding-left: 20px;'>";
|
||||
inList = true;
|
||||
}
|
||||
QString text = trimmedLine.mid(2);
|
||||
text.replace(QRegularExpression("\\*\\*(.+?)\\*\\*"), "<strong>\\1</strong>");
|
||||
html += "<li style='margin-bottom: 2px;'>" + text + "</li>";
|
||||
} else if (trimmedLine.startsWith("```")) {
|
||||
if (inList) {
|
||||
html += "</ul>";
|
||||
inList = false;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
if (inList) {
|
||||
html += "</ul>";
|
||||
inList = false;
|
||||
}
|
||||
QString text = trimmedLine;
|
||||
text.replace(QRegularExpression("\\*\\*(.+?)\\*\\*"), "<strong>\\1</strong>");
|
||||
html += "<p style='margin-top: 4px; margin-bottom: 4px;'>" + text + "</p>";
|
||||
}
|
||||
}
|
||||
|
||||
if (inList) {
|
||||
html += "</ul>";
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "settingspage.h"
|
||||
#include "settingspage.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
Reference in New Issue
Block a user