支持重新配置内核

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

View File

@ -12,5 +12,6 @@
<file>icon/icon.svg</file> <file>icon/icon.svg</file>
<file>shell/kernel-installer-remove-template.sh</file> <file>shell/kernel-installer-remove-template.sh</file>
<file>translation/gxde-kernel-manager_zh_CN.qm</file> <file>translation/gxde-kernel-manager_zh_CN.qm</file>
<file>shell/kernel-installer-reconfigure-template.sh</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -52,12 +52,9 @@ void KernelInformation::LoadInfo()
alreadyIndex = indexMap.value(strTemp); alreadyIndex = indexMap.value(strTemp);
QJsonArray pkgArray = array.at(alreadyIndex).toObject().value("PkgName").toArray(); QJsonArray pkgArray = array.at(alreadyIndex).toObject().value("PkgName").toArray();
pkgArray.append(i); 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(); QJsonObject pkgObject = array.at(alreadyIndex).toObject();
pkgObject["PkgName"] = pkgArray; pkgObject["PkgName"] = pkgArray;
array.replace(alreadyIndex, pkgObject);//.insert("PkgName", pkgArray)->toObject()); array.replace(alreadyIndex, pkgObject);
continue; continue;
} }
info.SetPkgName(strTemp); info.SetPkgName(strTemp);

View File

@ -23,12 +23,15 @@ KernelInstaller::KernelInstaller(Option option, QStringList kernelList, QWidget
} }
switch(runOption) { switch(runOption) {
case Option::Install: case Option::Install:
ui->m_status->setText(tr("Try to install ") + kernel); ui->m_status->setText(tr("Try to install ") + kernel);
break; break;
case Option::Remove: case Option::Remove:
ui->m_status->setText(tr("Try to remove ") + kernel); ui->m_status->setText(tr("Try to remove ") + kernel);
break; 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"; QString filePath = ":/shell/kernel-installer-template.sh";
switch(runOption) { switch(runOption) {
case Option::Install: case Option::Install:
filePath = ":/shell/kernel-installer-template.sh"; filePath = ":/shell/kernel-installer-template.sh";
break; break;
case Option::Remove: case Option::Remove:
filePath = ":/shell/kernel-installer-remove-template.sh"; filePath = ":/shell/kernel-installer-remove-template.sh";
break; break;
case Option::Reconfigure:
filePath = ":/shell/kernel-installer-reconfigure-template.sh";
break;
} }
QFile file(filePath); QFile file(filePath);

View File

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

View File

@ -142,3 +142,21 @@ void MainWindow::on_m_showLocalArchOnly_stateChanged(int arg1)
RefreshKernelListView(this->kernelInformation, ui->m_showLocalArchOnly->isChecked()); 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();
}

View File

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

View File

@ -74,6 +74,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="m_reconfigureButton">
<property name="text">
<string>Reconfigure</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="m_installButton"> <widget class="QPushButton" name="m_installButton">
<property name="text"> <property name="text">

View File

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