mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-11 22:02:21 +08:00
chore:异步更新
This commit is contained in:
parent
b5e0b709cc
commit
b68029f5db
@ -9,8 +9,8 @@ set(CMAKE_AUTORCC ON)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network Concurrent)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Concurrent)
|
||||||
|
|
||||||
set(PROJECT_SOURCES
|
set(PROJECT_SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
@ -47,7 +47,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(Spark-Update-Tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)
|
target_link_libraries(Spark-Update-Tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Concurrent)
|
||||||
|
|
||||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
||||||
# If you are developing for iOS or macOS you should consider setting an
|
# If you are developing for iOS or macOS you should consider setting an
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
#include <QtConcurrent> // 新增
|
||||||
|
#include <QFutureWatcher> // 新增
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
@ -9,8 +12,19 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
, m_model(new AppListModel(this))
|
, m_model(new AppListModel(this))
|
||||||
, m_delegate(new AppDelegate(this))
|
, m_delegate(new AppDelegate(this))
|
||||||
{
|
{
|
||||||
runAptssUpgrade();
|
QProgressDialog *progressDialog = new QProgressDialog("正在与服务器通信,获取更新信息中...", QString(), 0, 0, this);
|
||||||
|
progressDialog->setWindowModality(Qt::ApplicationModal);
|
||||||
|
progressDialog->setCancelButton(nullptr);
|
||||||
|
progressDialog->setWindowTitle("请稍候");
|
||||||
|
progressDialog->setMinimumDuration(0);
|
||||||
|
progressDialog->setWindowFlags(progressDialog->windowFlags() & ~Qt::WindowCloseButtonHint); // 禁用关闭按钮
|
||||||
|
progressDialog->show();
|
||||||
|
//异步执行runAptssUpgrade
|
||||||
|
QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this);
|
||||||
|
connect(watcher, &QFutureWatcher<void>::finished, this, [=]() {
|
||||||
|
progressDialog->close();
|
||||||
|
progressDialog->deleteLater();
|
||||||
|
watcher->deleteLater();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// 创建 QListView 并设置父控件为 ui->appWidget
|
// 创建 QListView 并设置父控件为 ui->appWidget
|
||||||
@ -43,6 +57,12 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
checkUpdates();
|
checkUpdates();
|
||||||
initStyle();
|
initStyle();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 启动异步任务
|
||||||
|
watcher->setFuture(QtConcurrent::run([this](){
|
||||||
|
runAptssUpgrade();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
//初始化控件样式
|
//初始化控件样式
|
||||||
void MainWindow::initStyle()
|
void MainWindow::initStyle()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user