mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-11-04 00:02:21 +08:00
chore:使用aptss update更新列表
This commit is contained in:
parent
0607df0967
commit
8e617ceda4
@ -1,5 +1,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "./ui_mainwindow.h"
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
@ -7,6 +9,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
, m_model(new AppListModel(this))
|
||||
, m_delegate(new AppDelegate(this))
|
||||
{
|
||||
runAptssUpgrade();
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
// 创建 QListView 并设置父控件为 ui->appWidget
|
||||
@ -177,6 +181,24 @@ void MainWindow::checkUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::runAptssUpgrade()
|
||||
{
|
||||
QProcess process;
|
||||
QStringList args;
|
||||
args << "aptss" << "upgrade";
|
||||
process.start("sudo", args);
|
||||
if (!process.waitForStarted(5000)) {
|
||||
QMessageBox::warning(this, "升级失败", "无法启动 sudo aptss upgrade。");
|
||||
return;
|
||||
}
|
||||
process.write("n\n");
|
||||
process.closeWriteChannel();
|
||||
process.waitForFinished(-1);
|
||||
if (process.exitCode() != 0) {
|
||||
QMessageBox::warning(this, "升级失败", "执行 sudo aptss upgrade 失败,请检查系统环境。");
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
|
||||
@ -25,6 +25,7 @@ private:
|
||||
Ui::MainWindow *ui;
|
||||
void checkUpdates();
|
||||
void initStyle();
|
||||
void runAptssUpgrade();
|
||||
AppListModel *m_model;
|
||||
AppDelegate *m_delegate;
|
||||
QListView *listView; // 声明 QListView 指针
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user