diff --git a/Resource.qrc b/Resource.qrc index 537d56a..a8001f1 100644 --- a/Resource.qrc +++ b/Resource.qrc @@ -12,5 +12,6 @@ <file>icon/icon.svg</file> <file>shell/kernel-installer-remove-template.sh</file> <file>translation/gxde-kernel-manager_zh_CN.qm</file> + <file>shell/kernel-installer-reconfigure-template.sh</file> </qresource> </RCC> diff --git a/kernelinformation.cpp b/kernelinformation.cpp index a983056..dfcdf17 100644 --- a/kernelinformation.cpp +++ b/kernelinformation.cpp @@ -52,12 +52,9 @@ void KernelInformation::LoadInfo() alreadyIndex = indexMap.value(strTemp); QJsonArray pkgArray = array.at(alreadyIndex).toObject().value("PkgName").toArray(); pkgArray.append(i); - qDebug() << pkgArray; - //array.replace(alreadyIndex, array.at(alreadyIndex).toObject().insert("PkgName", pkgArray)->toObject()); - qDebug() << alreadyIndex << array.count(); QJsonObject pkgObject = array.at(alreadyIndex).toObject(); pkgObject["PkgName"] = pkgArray; - array.replace(alreadyIndex, pkgObject);//.insert("PkgName", pkgArray)->toObject()); + array.replace(alreadyIndex, pkgObject); continue; } info.SetPkgName(strTemp); diff --git a/kernelinstaller.cpp b/kernelinstaller.cpp index be7d066..2cd82e4 100644 --- a/kernelinstaller.cpp +++ b/kernelinstaller.cpp @@ -23,12 +23,15 @@ KernelInstaller::KernelInstaller(Option option, QStringList kernelList, QWidget } switch(runOption) { - case Option::Install: - ui->m_status->setText(tr("Try to install ") + kernel); - break; - case Option::Remove: - ui->m_status->setText(tr("Try to remove ") + kernel); - break; + case Option::Install: + ui->m_status->setText(tr("Try to install ") + kernel); + break; + case Option::Remove: + ui->m_status->setText(tr("Try to remove ") + kernel); + break; + case Option::Reconfigure: + ui->m_status->setText(tr("Try to reconfigure ") + kernel); + break; } @@ -75,12 +78,15 @@ QString KernelInstaller::BuildKernelInstallerBash(QStringList kernelList, QStrin } QString filePath = ":/shell/kernel-installer-template.sh"; switch(runOption) { - case Option::Install: - filePath = ":/shell/kernel-installer-template.sh"; - break; - case Option::Remove: - filePath = ":/shell/kernel-installer-remove-template.sh"; - break; + case Option::Install: + filePath = ":/shell/kernel-installer-template.sh"; + break; + case Option::Remove: + filePath = ":/shell/kernel-installer-remove-template.sh"; + break; + case Option::Reconfigure: + filePath = ":/shell/kernel-installer-reconfigure-template.sh"; + break; } QFile file(filePath); diff --git a/kernelinstaller.h b/kernelinstaller.h index 1816927..735d653 100644 --- a/kernelinstaller.h +++ b/kernelinstaller.h @@ -16,7 +16,8 @@ class KernelInstaller : public QMainWindow public: enum Option { Install, - Remove + Remove, + Reconfigure }; explicit KernelInstaller(Option option, QStringList kernelList, QWidget *parent = nullptr); diff --git a/mainwindow.cpp b/mainwindow.cpp index 2725095..905cd1f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -142,3 +142,21 @@ void MainWindow::on_m_showLocalArchOnly_stateChanged(int arg1) RefreshKernelListView(this->kernelInformation, ui->m_showLocalArchOnly->isChecked()); } + +void MainWindow::on_m_reconfigureButton_clicked() +{ + QModelIndex list = ui->m_kernelShow->selectionModel()->currentIndex(); + int row = list.row(); + if(row < 0) { + // 未选中任何内容 + QMessageBox::critical(this, tr("Error"), tr("Nothing to choose")); + return; + } + // 获取 ID + QModelIndex index = ui->m_kernelShow->model()->index(row, 0); + int id = ui->m_kernelShow->model()->data(index).toUInt(); + // 获取选中行 + KernelInstaller *installer = new KernelInstaller(KernelInstaller::Option::Reconfigure, kernelInformation->get_pkgName(id)); + installer->show(); +} + diff --git a/mainwindow.h b/mainwindow.h index db0e9ca..b7765e0 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -35,6 +35,8 @@ private slots: void on_m_showLocalArchOnly_stateChanged(int arg1); + void on_m_reconfigureButton_clicked(); + private: Ui::MainWindow *ui; KernelInformation *kernelInformation; diff --git a/mainwindow.ui b/mainwindow.ui index e585956..db92900 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -74,6 +74,13 @@ </property> </widget> </item> + <item> + <widget class="QPushButton" name="m_reconfigureButton"> + <property name="text"> + <string>Reconfigure</string> + </property> + </widget> + </item> <item> <widget class="QPushButton" name="m_installButton"> <property name="text"> diff --git a/shell/kernel-installer-reconfigure-template.sh b/shell/kernel-installer-reconfigure-template.sh new file mode 100644 index 0000000..89f67db --- /dev/null +++ b/shell/kernel-installer-reconfigure-template.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +rm /tmp/gxde-kernel-manager-installer-status -f +dpkg-reconfigure ${KernelList} +rm -f "${kernelInstallerShellTempPath}" \ No newline at end of file