mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-13 20:32:05 +08:00
fix:修复关闭提示弹窗时机问题
This commit is contained in:
@@ -448,4 +448,9 @@ QSet<QString> AppDelegate::getSelectedPackages() const {
|
||||
|
||||
void AppDelegate::clearSelection() {
|
||||
m_selectedPackages.clear();
|
||||
}
|
||||
|
||||
// 实现获取下载状态信息的方法
|
||||
const QHash<QString, DownloadInfo>& AppDelegate::getDownloads() const {
|
||||
return m_downloads;
|
||||
}
|
||||
@@ -35,6 +35,10 @@ public:
|
||||
void setSelectedPackages(const QSet<QString> &selected);
|
||||
QSet<QString> getSelectedPackages() const;
|
||||
void clearSelection();
|
||||
|
||||
// 获取下载状态信息
|
||||
const QHash<QString, DownloadInfo>& getDownloads() const;
|
||||
|
||||
|
||||
signals:
|
||||
void updateDisplay(const QString &packageName);
|
||||
|
||||
@@ -344,8 +344,31 @@ void MainWindow::runAptssUpgrade()
|
||||
}
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
|
||||
QMessageBox::StandardButton reply = QMessageBox::question(this, "确认关闭", "正在更新,是否确认关闭窗口?", QMessageBox::Yes | QMessageBox::No);
|
||||
// 检查是否正在进行更新
|
||||
bool isUpdating = false;
|
||||
|
||||
// 通过AppDelegate检查是否有正在下载或安装的应用
|
||||
const QHash<QString, DownloadInfo>& downloads = m_delegate->getDownloads();
|
||||
for (auto it = downloads.constBegin(); it != downloads.constEnd(); ++it) {
|
||||
if (it.value().isDownloading || it.value().isInstalling) {
|
||||
isUpdating = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果正在更新,才显示确认对话框
|
||||
if (isUpdating) {
|
||||
QMessageBox::StandardButton reply = QMessageBox::question(this, "确认关闭", "正在更新,是否确认关闭窗口?", QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (reply == QMessageBox::Yes) {
|
||||
event->accept();
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
} else {
|
||||
// 如果没有更新,直接关闭窗口
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
void MainWindow::handleUpdateFinished(bool success)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user