diff --git a/Resource.qrc b/Resource.qrc index 5298933..4b48c5d 100644 --- a/Resource.qrc +++ b/Resource.qrc @@ -17,5 +17,6 @@ <file>data/new/en_US.html</file> <file>data/new/zh_CN.html</file> <file>data/version</file> + <file>shell/kernel-installer-upgrade-template.sh</file> </qresource> </RCC> diff --git a/data/new/zh_CN.html b/data/new/zh_CN.html index 119207d..75ab83c 100644 --- a/data/new/zh_CN.html +++ b/data/new/zh_CN.html @@ -2,6 +2,8 @@ <pre> <b>※1、支持从 apt 源读取内核数据并显示安装 ※2、支持只显示与当前系统相同架构的内核 +※3、下载/更新内核时支持调用 aptss 提升下载速度 </b> -3、优化表格显示 +4、优化表格显示效果 +5、支持显示内核描述 </pre> \ No newline at end of file diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..01867f3 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,2 @@ +#!/bin/bash +apt update | true \ No newline at end of file diff --git a/kernelinformation.cpp b/kernelinformation.cpp index 0819684..f222a5b 100644 --- a/kernelinformation.cpp +++ b/kernelinformation.cpp @@ -10,14 +10,23 @@ KernelInformation::KernelInformation() void KernelInformation::LoadInfo() { - // 从 apt 获取信息 - //QStringList data = this->GetAptPackageList("linux-*"); - /*for(QString i: data) { - - }*/ - AptPkgInfo info = AptPkgInfo("linux-", AptPkgInfo::PkgSearchOption::HeadInclude); - QStringList list = info.GetAptPackageList(); + // 添加 GXDE Kernel Manager QJsonArray array; + AptPkgInfo kernelManagerinfo = AptPkgInfo("gxde-kernel-manager", AptPkgInfo::PkgSearchOption::Equal); + QStringList list = kernelManagerinfo.GetAptPackageList(); + for(QString i: list) { + QJsonObject object; + kernelManagerinfo.SetPkgName(i); + object.insert("Name", i); + object.insert("Author", kernelManagerinfo.get_maintainer(i)); + object.insert("Des", kernelManagerinfo.get_description(i)); + object.insert("Arch", QJsonArray::fromStringList(QStringList() << arch())); + object.insert("PkgName", QJsonArray::fromStringList(QStringList() << i)); + array.append(object); + } + AptPkgInfo info = AptPkgInfo("linux-", AptPkgInfo::PkgSearchOption::HeadInclude); + list = info.GetAptPackageList(); + indexMap = {}; for(QString i: list) { QJsonObject object; @@ -72,19 +81,7 @@ void KernelInformation::LoadInfo() indexMap.insert(strTemp, array.count()); array.append(object); } - // 添加 GXDE Kernel Manager - AptPkgInfo kernelManagerinfo = AptPkgInfo("gxde-kernel-manager", AptPkgInfo::PkgSearchOption::Equal); - list = kernelManagerinfo.GetAptPackageList(); - for(QString i: list) { - QJsonObject object; - info.SetPkgName(i); - object.insert("Name", i); - object.insert("Author", kernelManagerinfo.get_maintainer(i)); - object.insert("Des", kernelManagerinfo.get_description(i)); - object.insert("Arch", QJsonArray::fromStringList(QStringList() << arch())); - object.insert("PkgName", QJsonArray::fromStringList(QStringList() << i)); - array.append(object); - } + this->listData = array; emit loadFinished(NULL); @@ -160,7 +157,6 @@ QStringList KernelInformation::get_arch(int value) const } if(!result.count()) { result << "all"; - qDebug() << get_kernelData(value); } return result; } diff --git a/kernelinstaller.cpp b/kernelinstaller.cpp index a92a375..ce3354a 100644 --- a/kernelinstaller.cpp +++ b/kernelinstaller.cpp @@ -35,6 +35,9 @@ KernelInstaller::KernelInstaller(Option option, QStringList kernelList, QWidget case Option::Update: ui->m_status->setText(tr("Try to update apt cache")); break; + case Option::Upgrade: + ui->m_status->setText(tr("Try to upgrade ") + kernel); + break; } @@ -93,6 +96,9 @@ QString KernelInstaller::BuildKernelInstallerBash(QStringList kernelList, QStrin case Option::Update: filePath = ":/shell/kernel-installer-update-template.sh"; break; + case Option::Upgrade: + filePath = ":/shell/kernel-installer-upgrade-template.sh"; + break; } QFile file(filePath); diff --git a/kernelinstaller.h b/kernelinstaller.h index 105fac6..884fd83 100644 --- a/kernelinstaller.h +++ b/kernelinstaller.h @@ -18,7 +18,8 @@ public: Install, Remove, Reconfigure, - Update + Update, + Upgrade }; explicit KernelInstaller(Option option, QStringList kernelList, QWidget *parent = nullptr); diff --git a/mainwindow.cpp b/mainwindow.cpp index 1c7fc76..bf58886 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -174,3 +174,16 @@ void MainWindow::on_actionUpdate_apt_cache_triggered() installer->show(); } + +void MainWindow::on_actionAbout_QT_triggered() +{ + QMessageBox::aboutQt(this); +} + + +void MainWindow::on_actionUpgrade_triggered() +{ + KernelInstaller *installer = new KernelInstaller(KernelInstaller::Option::Upgrade, QStringList()); + installer->show(); +} + diff --git a/mainwindow.h b/mainwindow.h index 4336838..d96255a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -39,6 +39,10 @@ private slots: void on_actionUpdate_apt_cache_triggered(); + void on_actionAbout_QT_triggered(); + + void on_actionUpgrade_triggered(); + private: Ui::MainWindow *ui; KernelInformation *kernelInformation; diff --git a/mainwindow.ui b/mainwindow.ui index 4a1b973..516674b 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -118,8 +118,6 @@ <property name="title"> <string>Program</string> </property> - <addaction name="actionUpdate_apt_cache"/> - <addaction name="separator"/> <addaction name="actionExit"/> </widget> <widget class="QMenu" name="menuHelp"> @@ -129,9 +127,19 @@ <addaction name="actionGitee"/> <addaction name="actionGithub"/> <addaction name="separator"/> + <addaction name="actionAbout_QT"/> <addaction name="actionAbout"/> </widget> + <widget class="QMenu" name="menuApt"> + <property name="title"> + <string>Apt</string> + </property> + <addaction name="actionUpdate_apt_cache"/> + <addaction name="separator"/> + <addaction name="actionUpgrade"/> + </widget> <addaction name="menuProgram"/> + <addaction name="menuApt"/> <addaction name="menuHelp"/> </widget> <widget class="QStatusBar" name="statusbar"/> @@ -160,6 +168,16 @@ <string>Update apt cache</string> </property> </action> + <action name="actionAbout_QT"> + <property name="text"> + <string>About QT</string> + </property> + </action> + <action name="actionUpgrade"> + <property name="text"> + <string>Upgrade</string> + </property> + </action> </widget> <resources> <include location="Resource.qrc"/> diff --git a/shell/kernel-installer-upgrade-template.sh b/shell/kernel-installer-upgrade-template.sh new file mode 100644 index 0000000..2f585ff --- /dev/null +++ b/shell/kernel-installer-upgrade-template.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e +rm /tmp/gxde-kernel-manager-installer-status -f +aptPath="apt" +which aptss > /dev/null +if [[ $? == 0 ]]; then + # 如果 aptss 存在,则使用 aptss + aptPath="aptss" +fi +$aptPath update +$aptPath full-upgrade ${KernelList} -y +rm -f "${kernelInstallerShellTempPath}" \ No newline at end of file diff --git a/translation/gxde-kernel-manager_zh_CN.ts b/translation/gxde-kernel-manager_zh_CN.ts index 44affb8..88fdae1 100644 --- a/translation/gxde-kernel-manager_zh_CN.ts +++ b/translation/gxde-kernel-manager_zh_CN.ts @@ -19,17 +19,22 @@ <translation>确定</translation> </message> <message> - <location filename="../aboutwindow.cpp" line="13"/> + <location filename="../aboutwindow.cpp" line="18"/> <source>A kernel manager allows users to install or remove kernels easily.</source> <translation>GXDE 内核管理器是一个帮助用户更方便获取、安装、移除内核的工具。</translation> </message> <message> - <location filename="../aboutwindow.cpp" line="14"/> + <location filename="../aboutwindow.cpp" line="19"/> <source>Warning: You may damage your system unless you know what you will do!</source> <translation>警告:请不要随意操作内核除非你知道你在做什么!</translation> </message> <message> - <location filename="../aboutwindow.cpp" line="17"/> + <location filename="../aboutwindow.cpp" line="20"/> + <source>Built Time: </source> + <translation>构建时间: </translation> + </message> + <message> + <location filename="../aboutwindow.cpp" line="25"/> <source>Website</source> <translation>网址</translation> </message> @@ -46,7 +51,6 @@ <translation>配置内核</translation> </message> <message> - <location filename="../kernelinstaller.ui" line="33"/> <location filename="../kernelinstaller.ui" line="46"/> <source>TextLabel</source> <translation>文本标签</translation> @@ -54,20 +58,35 @@ <message> <location filename="../kernelinstaller.cpp" line="27"/> <source>Try to install </source> - <translation>正在尝试安装 </translation> + <translation>正在尝试安装内核 </translation> </message> <message> <location filename="../kernelinstaller.cpp" line="30"/> <source>Try to remove </source> - <translation>尝试移除 </translation> + <translation>尝试移除内核 </translation> </message> <message> - <location filename="../kernelinstaller.cpp" line="135"/> + <location filename="../kernelinstaller.cpp" line="33"/> + <source>Try to reconfigure </source> + <translation>尝试重新配置内核 </translation> + </message> + <message> + <location filename="../kernelinstaller.cpp" line="36"/> + <source>Try to update apt cache</source> + <translation>尝试刷新 apt 缓存</translation> + </message> + <message> + <location filename="../kernelinstaller.cpp" line="39"/> + <source>Try to upgrade </source> + <translation>尝试升级 </translation> + </message> + <message> + <location filename="../kernelinstaller.cpp" line="156"/> <source>Done</source> <translation>完成</translation> </message> <message> - <location filename="../kernelinstaller.cpp" line="140"/> + <location filename="../kernelinstaller.cpp" line="161"/> <source>Something error, exit code: </source> <translation>出现错误,退出代码: </translation> </message> @@ -84,99 +103,136 @@ <translation>GXDE 内核管理器</translation> </message> <message> - <location filename="../mainwindow.ui" line="43"/> + <location filename="../mainwindow.ui" line="49"/> <source>TextLabel</source> <translation>文本标签</translation> </message> <message> - <location filename="../mainwindow.ui" line="63"/> + <location filename="../mainwindow.ui" line="69"/> + <source>Show local PC architecture only</source> + <translation>支持当前架构</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="79"/> <source>Refresh</source> <translation>刷新</translation> </message> <message> - <location filename="../mainwindow.ui" line="70"/> + <location filename="../mainwindow.ui" line="86"/> + <source>Reconfigure</source> + <translation>重新配置</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="93"/> <source>Install</source> <translation>安装</translation> </message> <message> - <location filename="../mainwindow.ui" line="77"/> + <location filename="../mainwindow.ui" line="100"/> <source>Remove</source> <translation>卸载</translation> </message> <message> - <location filename="../mainwindow.ui" line="96"/> + <location filename="../mainwindow.ui" line="119"/> <source>Program</source> <translation>程序</translation> </message> <message> - <location filename="../mainwindow.ui" line="102"/> + <location filename="../mainwindow.ui" line="125"/> <source>Help</source> <translation>帮助</translation> </message> <message> - <location filename="../mainwindow.ui" line="115"/> + <location filename="../mainwindow.ui" line="135"/> + <source>Apt</source> + <translation>Apt</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="148"/> <source>Exit</source> <translation>退出</translation> </message> <message> - <location filename="../mainwindow.ui" line="120"/> + <location filename="../mainwindow.ui" line="153"/> <source>About</source> <translation>关于</translation> </message> <message> - <location filename="../mainwindow.ui" line="125"/> + <location filename="../mainwindow.ui" line="158"/> <source>Gitee</source> <translation>Gitee</translation> </message> <message> - <location filename="../mainwindow.ui" line="130"/> + <location filename="../mainwindow.ui" line="163"/> <source>Github</source> <translation>Github</translation> </message> <message> - <location filename="../mainwindow.cpp" line="21"/> + <location filename="../mainwindow.ui" line="168"/> + <source>Update apt cache</source> + <translation>刷新 apt 缓存</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="173"/> + <source>About QT</source> + <translation>关于 QT</translation> + </message> + <message> + <location filename="../mainwindow.ui" line="178"/> + <source>Upgrade</source> + <translation>升级</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="23"/> <source>Kernel: </source> <translation>内核: </translation> </message> <message> - <location filename="../mainwindow.cpp" line="21"/> + <location filename="../mainwindow.cpp" line="23"/> <source>Arch: </source> <translation>架构: </translation> </message> <message> - <location filename="../mainwindow.cpp" line="34"/> + <location filename="../mainwindow.cpp" line="35"/> <source>ID</source> <translation>ID</translation> </message> <message> - <location filename="../mainwindow.cpp" line="34"/> + <location filename="../mainwindow.cpp" line="35"/> <source>Kernel Name</source> <translation>内核名称</translation> </message> <message> - <location filename="../mainwindow.cpp" line="34"/> + <location filename="../mainwindow.cpp" line="35"/> <source>Author</source> <translation>维护者</translation> </message> <message> - <location filename="../mainwindow.cpp" line="34"/> + <location filename="../mainwindow.cpp" line="35"/> <source>Arch</source> <translation>架构</translation> </message> <message> - <location filename="../mainwindow.cpp" line="34"/> + <location filename="../mainwindow.cpp" line="35"/> <source>Installed</source> <translation>是否安装</translation> </message> <message> - <location filename="../mainwindow.cpp" line="63"/> - <location filename="../mainwindow.cpp" line="106"/> + <location filename="../mainwindow.cpp" line="35"/> + <source>Description</source> + <translation>描述</translation> + </message> + <message> + <location filename="../mainwindow.cpp" line="85"/> + <location filename="../mainwindow.cpp" line="132"/> + <location filename="../mainwindow.cpp" line="156"/> <source>Error</source> <translation>错误</translation> </message> <message> - <location filename="../mainwindow.cpp" line="63"/> - <location filename="../mainwindow.cpp" line="106"/> + <location filename="../mainwindow.cpp" line="85"/> + <location filename="../mainwindow.cpp" line="132"/> + <location filename="../mainwindow.cpp" line="156"/> <source>Nothing to choose</source> <translation>没有选择任何选项</translation> </message>