From 4951fc7dd1e4cc6e863826cd11ecaa11533b0949 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 25 Sep 2025 08:25:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E4=B8=A4=E6=AC=A1=E5=AF=BC=E5=87=BA=E9=80=9A=E7=9F=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/settingspage.cpp | 50 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/pages/settingspage.cpp b/src/pages/settingspage.cpp index 7a27ed4..c40607c 100644 --- a/src/pages/settingspage.cpp +++ b/src/pages/settingspage.cpp @@ -24,8 +24,8 @@ SettingsPage::SettingsPage(QWidget *parent) configCanSave = false; initConfig(); - // 连接导出日志按钮的点击信号 - connect(ui->pushButton_exportLog, &QPushButton::clicked, this, &SettingsPage::on_pushButton_exportLog_clicked); + // 移除了手动连接导出日志按钮的点击信号 + // connect(ui->pushButton_exportLog, &QPushButton::clicked, this, &SettingsPage::on_pushButton_exportLog_clicked); } void SettingsPage::setTheme(bool dark) @@ -283,29 +283,25 @@ void SettingsPage::on_checkBox_disableSandbox_clicked(bool checked) // 修改导出日志按钮的点击事件处理函数 void SettingsPage::on_pushButton_exportLog_clicked() { - auto future = QtConcurrent::run([=]() { - // 禁用按钮防止重复点击 - QMetaObject::invokeMethod(ui->pushButton_exportLog, "setEnabled", Qt::QueuedConnection, Q_ARG(bool, false)); - - QString targetPath = QString::fromUtf8(TMP_PATH); - bool success = Utils::exportLogs(targetPath); - - // 显示导出结果通知 - QString message; - if (success) { - message = tr("Logs exported successfully to: %1").arg(targetPath); - Utils::writeLog("INFO", "User exported logs via settings page"); - } else { - message = tr("Failed to export logs"); - Utils::writeLog("ERROR", "User failed to export logs via settings page"); - } - - // 在主线程显示消息框 - QMetaObject::invokeMethod(this, [message, this]() { - // 使用系统通知代替QMessageBox弹窗,避免重复通知 - Utils::sendNotification("spark-store", tr("Export Logs"), message); - // 重新启用按钮 - ui->pushButton_exportLog->setEnabled(true); - }, Qt::QueuedConnection); - }); + // 禁用按钮防止重复点击 + ui->pushButton_exportLog->setEnabled(false); + + QString targetPath = QString::fromUtf8(TMP_PATH); + bool success = Utils::exportLogs(targetPath); + + // 显示导出结果通知 + QString message; + if (success) { + message = tr("Logs exported successfully to: %1").arg(targetPath); + Utils::writeLog("INFO", "User exported logs via settings page"); + } else { + message = tr("Failed to export logs"); + Utils::writeLog("ERROR", "User failed to export logs via settings page"); + } + + // 只发送一次系统通知 + Utils::sendNotification("spark-store", tr("Export Logs"), message); + + // 重新启用按钮 + ui->pushButton_exportLog->setEnabled(true); } \ No newline at end of file