界面调整

This commit is contained in:
gfdgd xi 2024-05-12 09:45:52 +08:00
parent 20130363fb
commit 6661048433
11 changed files with 97 additions and 7 deletions

@ -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>

@ -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>";

2
data/new/en_US.html Normal file

@ -0,0 +1,2 @@
<h1>What's new?</h1>
<p>Test</p>

2
data/new/zh_CN.html Normal file

@ -0,0 +1,2 @@
<h1>更新内容</h1>
<p>测试</p>

1
data/version Normal file

@ -0,0 +1 @@
1.1.0

@ -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 \

@ -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);

@ -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);

@ -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);

38
programinfo.cpp Normal file

@ -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;
}

18
programinfo.h Normal file

@ -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