diff --git a/Resource.qrc b/Resource.qrc index b08bc43..5298933 100644 --- a/Resource.qrc +++ b/Resource.qrc @@ -14,5 +14,8 @@ <file>translation/gxde-kernel-manager_zh_CN.qm</file> <file>shell/kernel-installer-reconfigure-template.sh</file> <file>shell/kernel-installer-update-template.sh</file> + <file>data/new/en_US.html</file> + <file>data/new/zh_CN.html</file> + <file>data/version</file> </qresource> </RCC> diff --git a/aboutwindow.cpp b/aboutwindow.cpp index 7bbb698..ad6724d 100644 --- a/aboutwindow.cpp +++ b/aboutwindow.cpp @@ -1,19 +1,27 @@ #include "aboutwindow.h" #include "ui_aboutwindow.h" +#include "programinfo.h" #include <QDateTime> +#include <QProcessEnvironment> +#include <QFile> AboutWindow::AboutWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::AboutWindow) { ui->setupUi(this); + + QString info = ""; info += "<pre>"; info += tr("A kernel manager allows users to install or remove kernels easily.") + "\n\n"; info += "<b>" + tr("Warning: You may damage your system unless you know what you will do!") + "</b>\n"; + info += "Built Time: " + QString(__DATE__) + " " + __TIME__; info += "</pre>"; info += "<hr/>"; + info += ProgramInfo::updateInfo(); + info += "<hr/>"; info += "<h3>" + tr("Website") + "</h3>"; info += "<p>Gitee: <a href='https://gitee.com/GXDE-OS/gxde-kernel-manager'>https://gitee.com/GXDE-OS/gxde-kernel-manager</a></p>"; info += "<p>Github: <a href='https://github.com/GXDE-OS/gxde-kernel-manager'>https://github.com/GXDE-OS/gxde-kernel-manager</a></p>"; diff --git a/data/new/en_US.html b/data/new/en_US.html new file mode 100644 index 0000000..cecbbf2 --- /dev/null +++ b/data/new/en_US.html @@ -0,0 +1,2 @@ +<h1>What's new?</h1> +<p>Test</p> \ No newline at end of file diff --git a/data/new/zh_CN.html b/data/new/zh_CN.html new file mode 100644 index 0000000..b28f22c --- /dev/null +++ b/data/new/zh_CN.html @@ -0,0 +1,2 @@ +<h1>更新内容</h1> +<p>测试</p> \ No newline at end of file diff --git a/data/version b/data/version new file mode 100644 index 0000000..1cc5f65 --- /dev/null +++ b/data/version @@ -0,0 +1 @@ +1.1.0 \ No newline at end of file diff --git a/gxde-kernel-manager.pro b/gxde-kernel-manager.pro index e93d290..fe0dd9e 100644 --- a/gxde-kernel-manager.pro +++ b/gxde-kernel-manager.pro @@ -14,14 +14,16 @@ SOURCES += \ kernelinformation.cpp \ kernelinstaller.cpp \ main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + programinfo.cpp HEADERS += \ aboutwindow.h \ aptpkginfo.h \ kernelinformation.h \ kernelinstaller.h \ - mainwindow.h + mainwindow.h \ + programinfo.h FORMS += \ aboutwindow.ui \ diff --git a/kernelinformation.cpp b/kernelinformation.cpp index dfcdf17..359c603 100644 --- a/kernelinformation.cpp +++ b/kernelinformation.cpp @@ -60,12 +60,25 @@ void KernelInformation::LoadInfo() info.SetPkgName(strTemp); object.insert("Name", strTemp); object.insert("Author", info.get_maintainer(i)); - object.insert("Des", info.get_maintainer(i)); + object.insert("Des", info.get_description(i)); object.insert("Arch", info.get_architecture(i)); object.insert("PkgName", QJsonArray::fromStringList(QStringList() << i)); indexMap.insert(strTemp, array.count()); array.append(object); } + // 添加 GXDE Kernel Manager + AptPkgInfo kernelManagerinfo = AptPkgInfo("gxde-kernel-manager", AptPkgInfo::PkgSearchOption::Equal); + list = info.GetAptPackageList(); + for(QString i: list) { + QJsonObject object; + info.SetPkgName(i); + object.insert("Name", i); + object.insert("Author", info.get_maintainer(i)); + object.insert("Des", info.get_description(i)); + object.insert("Arch", info.get_architecture(i)); + object.insert("PkgName", QJsonArray::fromStringList(QStringList() << i)); + array.append(object); + } this->listData = array; emit loadFinished(NULL); diff --git a/main.cpp b/main.cpp index ca07900..4d34b7e 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,7 @@ #include "mainwindow.h" +#include "programinfo.h" + #include <QApplication> #include <QFile> @@ -11,9 +13,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); QTranslator translator; - // 检查系统语言以加载翻译 - if(QProcessEnvironment::systemEnvironment().value("LANG").contains("zh")) { - // 中文,加载中文翻译 + if(ProgramInfo::systemLANG() == ProgramInfo::LANG::zh_CN) { translator.load(":/translation/gxde-kernel-manager_zh_CN.qm"); } a.installTranslator(&translator); diff --git a/mainwindow.cpp b/mainwindow.cpp index 2831bad..1c7fc76 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" #include "aboutwindow.h" +#include "programinfo.h" #include "kernelinformation.h" @@ -12,6 +13,7 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindow) { ui->setupUi(this); + this->setWindowTitle(this->windowTitle() + " " + ProgramInfo::version()); kernelInformation = new KernelInformation(); RefreshKernelList(); } @@ -30,7 +32,7 @@ void MainWindow::RefreshKernelListView(KernelInformation *info, bool showLocalAr // 更新列表 int count = info->get_count(); QStandardItemModel *model = new QStandardItemModel(); - model->setHorizontalHeaderLabels(QStringList() << tr("ID") << tr("Kernel Name") << tr("Author") << tr("Arch") << tr("Installed")); + model->setHorizontalHeaderLabels(QStringList() << tr("ID") << tr("Kernel Name") << tr("Author") << tr("Arch") << tr("Installed") << tr("Description")); const QString arch = info->arch(); int line = 0; for(int i = 0; i < count; i++) { @@ -55,6 +57,7 @@ void MainWindow::RefreshKernelListView(KernelInformation *info, bool showLocalAr model->setItem(line, 2, new QStandardItem(info->get_author(i))); model->setItem(line, 3, new QStandardItem(kernelArch)); model->setItem(line, 4, new QStandardItem((QStringList() << "" << "Y").at(info->get_installedAlready(i)))); + model->setItem(line, 5, new QStandardItem(info->get_des(i))); line++; } ui->m_kernelShow->setModel(model); diff --git a/programinfo.cpp b/programinfo.cpp new file mode 100644 index 0000000..5ffd276 --- /dev/null +++ b/programinfo.cpp @@ -0,0 +1,38 @@ +#include "programinfo.h" + +#include <QFile> +#include <QProcessEnvironment> + +ProgramInfo::LANG ProgramInfo::systemLANG() +{ + if(QProcessEnvironment::systemEnvironment().value("LANG").contains("zh")) { + return LANG::zh_CN; + } + return LANG::en_US; +} + + +QString ProgramInfo::updateInfo() +{ + // 读取更新日志 + // 检查系统语言以加载对应语言的更新日志 + QString updateInfoPath = ":/data/new/en_US.html"; + if(QProcessEnvironment::systemEnvironment().value("LANG").contains("zh")) { + // 中文,加载中文更新日志 + updateInfoPath = ":/data/new/zh_CN.html"; + } + QFile file(updateInfoPath); + file.open(QFile::ReadOnly); + QString data = file.readAll(); + file.close(); + return data; +} + +QString ProgramInfo::version() +{ + QFile file(":/data/version"); + file.open(QFile::ReadOnly); + QString data = file.readAll(); + file.close(); + return data; +} diff --git a/programinfo.h b/programinfo.h new file mode 100644 index 0000000..b68d19d --- /dev/null +++ b/programinfo.h @@ -0,0 +1,18 @@ +#ifndef PROGRAMINFO_H +#define PROGRAMINFO_H + +#include <QString> + +namespace ProgramInfo +{ + enum LANG { + zh_CN = 0, + en_US = 1, + other = en_US + }; + LANG systemLANG() ; + QString updateInfo(); + QString version(); +}; + +#endif // PROGRAMINFO_H