支持重新配置内核

This commit is contained in:
gfdgd xi 2024-05-11 21:20:48 +08:00
parent 3c88cc03f8
commit 90c04767ad
8 changed files with 54 additions and 17 deletions

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

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

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

@ -16,7 +16,8 @@ class KernelInstaller : public QMainWindow
public:
enum Option {
Install,
Remove
Remove,
Reconfigure
};
explicit KernelInstaller(Option option, QStringList kernelList, QWidget *parent = nullptr);

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

@ -35,6 +35,8 @@ private slots:
void on_m_showLocalArchOnly_stateChanged(int arg1);
void on_m_reconfigureButton_clicked();
private:
Ui::MainWindow *ui;
KernelInformation *kernelInformation;

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

@ -0,0 +1,5 @@
#!/bin/bash
set -e
rm /tmp/gxde-kernel-manager-installer-status -f
dpkg-reconfigure ${KernelList}
rm -f "${kernelInstallerShellTempPath}"