修复配置文件保存时编码异常问题,修改关于和帮助页面
This commit is contained in:
parent
d891b4f583
commit
edb693e5af
|
|
@ -8,13 +8,14 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||
SOURCES += main.cpp \
|
||||
src/mainwindow/mainwindow.cpp \
|
||||
src/pythonrunner/PythonRunner.cpp \
|
||||
src/pages/about/aboutpage.cpp \
|
||||
src/pages/about/aboutdialog.cpp \
|
||||
src/pages/batchconvert/batchconvertpage.cpp \
|
||||
src/pages/functionsearch/functionsearchpage.cpp \
|
||||
src/pages/functionsearch/uf20functionsearchpage.cpp \
|
||||
src/pages/functionsearch/uft3functionsearchpage.cpp \
|
||||
src/components/elasearchedit.cpp \
|
||||
src/pages/help/helppage.cpp \
|
||||
src/components/interdialog.cpp \
|
||||
src/pages/help/helpdocpage.cpp \
|
||||
src/pages/settings/settingspage.cpp \
|
||||
src/pages/metadatupdate/metadatupdatepage.cpp \
|
||||
src/metadataupdate/filedb.cpp \
|
||||
|
|
@ -31,17 +32,19 @@ SOURCES += main.cpp \
|
|||
src/utils/uf2configreader.cpp \
|
||||
src/utils/uft3configreader.cpp \
|
||||
src/utils/logmanager.cpp \
|
||||
src/utils/configmanager.cpp
|
||||
src/utils/configmanager.cpp \
|
||||
src/utils/version.cpp
|
||||
|
||||
HEADERS += src/mainwindow/mainwindow.h \
|
||||
src/pythonrunner/PythonRunner.h \
|
||||
src/pages/about/aboutpage.h \
|
||||
src/pages/about/aboutdialog.h \
|
||||
src/pages/batchconvert/batchconvertpage.h \
|
||||
src/pages/functionsearch/functionsearchpage.h \
|
||||
src/pages/functionsearch/uf20functionsearchpage.h \
|
||||
src/pages/functionsearch/uft3functionsearchpage.h \
|
||||
src/components/elasearchedit.h \
|
||||
src/pages/help/helppage.h \
|
||||
src/components/interdialog.h \
|
||||
src/pages/help/helpdocpage.h \
|
||||
src/pages/settings/settingspage.h \
|
||||
src/pages/metadatupdate/metadatupdatepage.h \
|
||||
src/metadataupdate/filedb.h \
|
||||
|
|
@ -58,7 +61,8 @@ HEADERS += src/mainwindow/mainwindow.h \
|
|||
src/utils/uf2configreader.h \
|
||||
src/utils/uft3configreader.h \
|
||||
src/utils/logmanager.h \
|
||||
src/utils/configmanager.h
|
||||
src/utils/configmanager.h \
|
||||
src/utils/version.h
|
||||
|
||||
RESOURCES += resources.qrc
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ echo [OK] qmake done
|
|||
echo.
|
||||
|
||||
REM Compile
|
||||
echo [4/4] Compiling Debug version...
|
||||
mingw32-make debug
|
||||
echo [4/4] Compiling Release version...
|
||||
mingw32-make release
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo ERROR: Compilation failed
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
#include "interdialog.h"
|
||||
|
||||
#include "ElaText.h"
|
||||
#include "ElaPushButton.h"
|
||||
|
||||
#include <QSpacerItem>
|
||||
|
||||
InterDialog::InterDialog(QWidget* parent) : ElaDialog(parent)
|
||||
{
|
||||
this->setIsFixedSize(true);
|
||||
this->setWindowModality(Qt::ApplicationModal);
|
||||
this->setWindowButtonFlags(ElaAppBarType::CloseButtonHint);
|
||||
this->setAppBarHeight(30);
|
||||
|
||||
_mainLayout = new QVBoxLayout(this);
|
||||
_mainLayout->setContentsMargins(10, 10, 10, 10);
|
||||
|
||||
_centralWidget = new QWidget(this);
|
||||
auto* centralVLayout = new QVBoxLayout(_centralWidget);
|
||||
centralVLayout->setContentsMargins(0, 0, 0, 0);
|
||||
_messageLabel = new ElaText("这是消息", _centralWidget);
|
||||
_messageLabel->setIsWrapAnywhere(true);
|
||||
centralVLayout->addWidget(_messageLabel);
|
||||
|
||||
_buttonWidget = new QWidget(this);
|
||||
_btnLayout = new QHBoxLayout(_buttonWidget);
|
||||
_btnLayout->setContentsMargins(0, 0, 0, 0);
|
||||
_btnLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Minimum));
|
||||
|
||||
auto *defaultButton = new QPushButton(_buttonWidget);
|
||||
defaultButton->setDefault(true);
|
||||
defaultButton->hide();
|
||||
|
||||
_okButton = new ElaPushButton("确认", _buttonWidget);
|
||||
connect(_okButton, &ElaPushButton::clicked, this, [=]
|
||||
{
|
||||
emit okButtonClicked();
|
||||
accept();
|
||||
});
|
||||
_okButton->setLightDefaultColor(ElaThemeColor(ElaThemeType::Light, PrimaryNormal));
|
||||
_okButton->setLightHoverColor(ElaThemeColor(ElaThemeType::Light, PrimaryHover));
|
||||
_okButton->setLightPressColor(ElaThemeColor(ElaThemeType::Light, PrimaryPress));
|
||||
_okButton->setLightTextColor(ElaThemeColor(ElaThemeType::Dark, BasicText));
|
||||
_okButton->setDarkDefaultColor(ElaThemeColor(ElaThemeType::Dark, PrimaryNormal));
|
||||
_okButton->setDarkHoverColor(ElaThemeColor(ElaThemeType::Dark, PrimaryHover));
|
||||
_okButton->setDarkPressColor(ElaThemeColor(ElaThemeType::Dark, PrimaryPress));
|
||||
_okButton->setDarkTextColor(ElaThemeColor(ElaThemeType::Light, BasicText));
|
||||
_okButton->setMinimumSize(0, 0);
|
||||
_okButton->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||
_okButton->setFixedHeight(38);
|
||||
_btnLayout->addWidget(_okButton);
|
||||
|
||||
_cancelButton = new ElaPushButton("取消", _buttonWidget);
|
||||
connect(_cancelButton, &ElaPushButton::clicked, this, [=]
|
||||
{
|
||||
emit cancelButtonClicked();
|
||||
reject();
|
||||
});
|
||||
_cancelButton->setMinimumSize(0, 0);
|
||||
_cancelButton->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||
_cancelButton->setFixedHeight(38);
|
||||
_btnLayout->addWidget(_cancelButton);
|
||||
|
||||
_mainLayout->addWidget(_centralWidget);
|
||||
_mainLayout->addWidget(_buttonWidget);
|
||||
|
||||
setFocus();
|
||||
}
|
||||
|
||||
InterDialog::~InterDialog() = default;
|
||||
|
||||
void InterDialog::setMessage(const QString& message)
|
||||
{
|
||||
if (_messageLabel)
|
||||
{
|
||||
_messageLabel->setText(message);
|
||||
}
|
||||
}
|
||||
|
||||
void InterDialog::setCentralWidget(QWidget* centralWidget)
|
||||
{
|
||||
_mainLayout->removeWidget(_centralWidget);
|
||||
delete _messageLabel;
|
||||
_messageLabel = nullptr;
|
||||
delete _centralWidget;
|
||||
_centralWidget = centralWidget;
|
||||
QSizePolicy sizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Expanding);
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
sizePolicy.setHeightForWidth(centralWidget->sizePolicy().hasHeightForWidth());
|
||||
centralWidget->setSizePolicy(sizePolicy);
|
||||
_mainLayout->insertWidget(0, _centralWidget);
|
||||
}
|
||||
|
||||
void InterDialog::setStandardButtons(const QDialogButtonBox::StandardButtons buttons) const
|
||||
{
|
||||
if (buttons.testFlag(QDialogButtonBox::NoButton))
|
||||
{
|
||||
_buttonWidget->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_okButton->setVisible(buttons.testFlag(QDialogButtonBox::StandardButton::Ok));
|
||||
_cancelButton->setVisible(buttons.testFlag(QDialogButtonBox::StandardButton::Cancel));
|
||||
}
|
||||
}
|
||||
|
||||
void InterDialog::addFirstButton(QPushButton* button) const
|
||||
{
|
||||
_btnLayout->insertWidget(1, button);
|
||||
}
|
||||
|
||||
void InterDialog::addLastButton(QPushButton* button) const
|
||||
{
|
||||
_btnLayout->addWidget(button);
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
#ifndef METASEARCH_INTERDIALOG_H
|
||||
#define METASEARCH_INTERDIALOG_H
|
||||
|
||||
#include "ElaDialog.h"
|
||||
#include "ElaTheme.h"
|
||||
#include "ElaText.h"
|
||||
#include "ElaPushButton.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 带按钮栏的弹窗
|
||||
*/
|
||||
class InterDialog : public ElaDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterDialog(QWidget* parent = nullptr);
|
||||
~InterDialog() override;
|
||||
|
||||
// 设置消息
|
||||
virtual void setMessage(const QString& message);
|
||||
|
||||
// 设置中心区域
|
||||
void setCentralWidget(QWidget* centralWidget);
|
||||
|
||||
// 设置按钮
|
||||
void setStandardButtons(QDialogButtonBox::StandardButtons buttons) const;
|
||||
|
||||
// 头部添加按钮
|
||||
void addFirstButton(QPushButton* button) const;
|
||||
|
||||
// 尾部添加按钮
|
||||
void addLastButton(QPushButton* button) const;
|
||||
|
||||
signals:
|
||||
void okButtonClicked();
|
||||
void cancelButtonClicked();
|
||||
|
||||
protected:
|
||||
// 主题
|
||||
ElaThemeType::ThemeMode _themeMode;
|
||||
|
||||
// 主布局
|
||||
QVBoxLayout* _mainLayout{nullptr};
|
||||
|
||||
// 中心区域
|
||||
QWidget* _centralWidget{nullptr};
|
||||
// 中心区域文本
|
||||
ElaText* _messageLabel{nullptr};
|
||||
|
||||
// 按钮区域
|
||||
QWidget* _buttonWidget{nullptr};
|
||||
// 按钮区域布局
|
||||
QHBoxLayout* _btnLayout{nullptr};
|
||||
// 确认按钮
|
||||
ElaPushButton* _okButton{nullptr};
|
||||
// 取消按钮
|
||||
ElaPushButton* _cancelButton{nullptr};
|
||||
};
|
||||
|
||||
|
||||
#endif //METASEARCH_INTERDIALOG_H
|
||||
|
|
@ -22,6 +22,8 @@
|
|||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include <QApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: ElaWindow(parent)
|
||||
|
|
@ -57,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(m_pythonRunner, &PythonRunner::standardOutput, this, &MainWindow::onPythonRunnerOutput);
|
||||
connect(m_pythonRunner, &PythonRunner::standardError, this, &MainWindow::onPythonRunnerError);
|
||||
|
||||
connect(this, &ElaWindow::navigationNodeClicked, this, &MainWindow::onNavigationNodeClicked);
|
||||
|
||||
QTimer::singleShot(100, this, &MainWindow::updateNavigationButtonIcon);
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +104,7 @@ MainWindow::~MainWindow()
|
|||
|
||||
void MainWindow::initWindow()
|
||||
{
|
||||
setWindowTitle("UFT30 Change Code");
|
||||
setWindowTitle(QString("UFT30 Change Code %1").arg(Version::getVersionString()));
|
||||
setWindowIcon(QIcon(":/resources/images/ChangeCode.png"));
|
||||
resize(900, 600);
|
||||
setMinimumSize(800, 500);
|
||||
|
|
@ -114,26 +118,19 @@ void MainWindow::initWindow()
|
|||
|
||||
void MainWindow::initContent()
|
||||
{
|
||||
QString helpKey;
|
||||
QString aboutKey;
|
||||
QString settingKey;
|
||||
QString funcSearchKey;
|
||||
QString funcConvertKey;
|
||||
QString metadataKey;
|
||||
addExpanderNode("功能转码", m_funcConvertKey, ElaIconType::FileCode);
|
||||
addPageNode("业务转码", createBatchConvertPage(), m_funcConvertKey, ElaIconType::ArrowsRepeat);
|
||||
|
||||
addExpanderNode("功能转码", funcConvertKey, ElaIconType::FileCode);
|
||||
addPageNode("业务转码", createBatchConvertPage(), funcConvertKey, ElaIconType::ArrowsRepeat);
|
||||
addExpanderNode("功能查询", m_funcSearchKey, ElaIconType::MagnifyingGlass);
|
||||
addPageNode("UF20功能查询", createUF20FunctionSearchPage(), m_funcSearchKey, ElaIconType::MagnifyingGlassPlus);
|
||||
addPageNode("UFT3功能查询", createUFT3FunctionSearchPage(), m_funcSearchKey, ElaIconType::MagnifyingGlassPlus);
|
||||
expandNavigationNode(m_funcConvertKey);
|
||||
|
||||
addExpanderNode("功能查询", funcSearchKey, ElaIconType::MagnifyingGlass);
|
||||
addPageNode("UF20功能查询", createUF20FunctionSearchPage(), funcSearchKey, ElaIconType::MagnifyingGlassPlus);
|
||||
addPageNode("UFT3功能查询", createUFT3FunctionSearchPage(), funcSearchKey, ElaIconType::MagnifyingGlassPlus);
|
||||
expandNavigationNode(funcConvertKey);
|
||||
addPageNode("元数据更新", createMetadataUpdatePage(), m_metadataKey, ElaIconType::ArrowsRotate);
|
||||
|
||||
addPageNode("元数据更新", createMetadataUpdatePage(), ElaIconType::ArrowsRotate);
|
||||
|
||||
addFooterNode("帮助", createHelpPage(), helpKey, 0, ElaIconType::CircleQuestion);
|
||||
addFooterNode("关于", createAboutPage(), aboutKey, 0, ElaIconType::Info);
|
||||
addFooterNode("设置", createSettingsPage(), settingKey, 0, ElaIconType::GearComplex);
|
||||
addFooterNode("帮助", m_helpKey, 0, ElaIconType::CircleQuestion);
|
||||
addFooterNode("关于", m_aboutKey, 0, ElaIconType::Info);
|
||||
addFooterNode("设置", createSettingsPage(), m_settingKey, 0, ElaIconType::GearComplex);
|
||||
}
|
||||
|
||||
QWidget* MainWindow::createBatchConvertPage()
|
||||
|
|
@ -162,16 +159,6 @@ QWidget* MainWindow::createUFT3FunctionSearchPage()
|
|||
return new UFT3FunctionSearchPage;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::createHelpPage()
|
||||
{
|
||||
return new HelpPage;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::createAboutPage()
|
||||
{
|
||||
return new AboutPage;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::createSettingsPage()
|
||||
{
|
||||
return new SettingsPage();
|
||||
|
|
@ -394,3 +381,13 @@ void MainWindow::onNavigationButtonClicked()
|
|||
}
|
||||
m_navigationButton->update();
|
||||
}
|
||||
|
||||
void MainWindow::onNavigationNodeClicked(ElaNavigationType::NavigationNodeType nodeType, QString nodeKey)
|
||||
{
|
||||
Q_UNUSED(nodeType);
|
||||
if (nodeKey == m_helpKey) {
|
||||
QDesktopServices::openUrl(QUrl("http://10.20.163.105:6045/uft3changecode"));
|
||||
} else if (nodeKey == m_aboutKey) {
|
||||
std::make_unique<AboutDialog>(this)->exec();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@
|
|||
#include "src/pages/functionsearch/functionsearchpage.h"
|
||||
#include "src/pages/functionsearch/uf20functionsearchpage.h"
|
||||
#include "src/pages/functionsearch/uft3functionsearchpage.h"
|
||||
#include "src/pages/help/helppage.h"
|
||||
#include "src/pages/about/aboutpage.h"
|
||||
|
||||
#include "src/pages/about/aboutdialog.h"
|
||||
#include "src/pages/settings/settingspage.h"
|
||||
#include "src/pages/metadatupdate/metadatupdatepage.h"
|
||||
#include "src/utils/version.h"
|
||||
|
||||
class MainWindow : public ElaWindow
|
||||
{
|
||||
|
|
@ -30,8 +31,6 @@ private:
|
|||
QWidget* createFunctionSearchPage();
|
||||
QWidget* createUF20FunctionSearchPage();
|
||||
QWidget* createUFT3FunctionSearchPage();
|
||||
QWidget* createHelpPage();
|
||||
QWidget* createAboutPage();
|
||||
QWidget* createSettingsPage();
|
||||
QWidget* createMetadataUpdatePage();
|
||||
|
||||
|
|
@ -46,6 +45,7 @@ private:
|
|||
void updateNavigationButtonIcon();
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
void onNavigationButtonClicked();
|
||||
void onNavigationNodeClicked(ElaNavigationType::NavigationNodeType nodeType, QString nodeKey);
|
||||
|
||||
PythonRunner *m_pythonRunner;
|
||||
bool m_iconsSet;
|
||||
|
|
@ -56,6 +56,12 @@ private:
|
|||
int m_totalFunctions;
|
||||
int m_currentFunctionIndex;
|
||||
QStringList m_functionList;
|
||||
QString m_helpKey;
|
||||
QString m_aboutKey;
|
||||
QString m_settingKey;
|
||||
QString m_funcSearchKey;
|
||||
QString m_funcConvertKey;
|
||||
QString m_metadataKey;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -106,6 +106,16 @@ bool ConfigManager::saveConfig()
|
|||
LogManager::instance()->log(QString("========== 保存配置文件 =========="));
|
||||
LogManager::instance()->log(QString("配置文件路径: %1").arg(m_configFilePath));
|
||||
|
||||
bool isUtf8 = true;
|
||||
if (QFile::exists(m_configFilePath)) {
|
||||
QFile readFile(m_configFilePath);
|
||||
if (readFile.open(QIODevice::ReadOnly)) {
|
||||
QByteArray data = readFile.readAll();
|
||||
readFile.close();
|
||||
isUtf8 = isValidUtf8(data);
|
||||
}
|
||||
}
|
||||
|
||||
QFile file(m_configFilePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
LogManager::instance()->logError(QString("无法打开配置文件进行写入: %1").arg(m_configFilePath));
|
||||
|
|
@ -117,13 +127,21 @@ bool ConfigManager::saveConfig()
|
|||
content += QString("[%1]\n").arg(section);
|
||||
for (const QString& key : m_configCache[section].keys()) {
|
||||
QString value = m_configCache[section][key];
|
||||
value.replace("/", "\\");
|
||||
if (section == "projectPath" && (key == "uft30" || key == "uf20" || key == "ufAcct20" || key == "createPath" || key == "uft30pub")) {
|
||||
value.replace("/", "\\");
|
||||
}
|
||||
content += QString("%1=%2\n").arg(key).arg(value);
|
||||
}
|
||||
content += "\n";
|
||||
}
|
||||
|
||||
file.write(content.toUtf8());
|
||||
QByteArray outData;
|
||||
if (isUtf8) {
|
||||
outData = content.toUtf8();
|
||||
} else {
|
||||
outData = content.toLocal8Bit();
|
||||
}
|
||||
file.write(outData);
|
||||
file.close();
|
||||
|
||||
LogManager::instance()->log("配置文件保存完成");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
#include "version.h"
|
||||
#include <QDateTime>
|
||||
|
||||
namespace Version {
|
||||
QString getVersionString() {
|
||||
return "1.0.0";
|
||||
}
|
||||
|
||||
QString getBuildDateTime() {
|
||||
return QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace Version {
|
||||
QString getVersionString();
|
||||
QString getBuildDateTime();
|
||||
}
|
||||
|
||||
#endif // VERSION_H
|
||||
Loading…
Reference in New Issue