From e416ffdbffee4bdc68df2290d56273a06bd99d48 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 11 Jun 2025 23:31:10 +0800 Subject: [PATCH] =?UTF-8?q?chore:=E6=98=BE=E7=A4=BA=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E7=99=BE=E5=88=86=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/downloadmanager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index bcc7a80..1603928 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -25,16 +25,20 @@ void DownloadManager::startDownload(const QString &url, const QString &outputPat void DownloadManager::onAria2Progress() { QString output = m_aria2Process.readAllStandardOutput(); - QRegularExpression regex(R"(Download Progress: (\d+)%.*)"); - QRegularExpressionMatch match = regex.match(output); + QRegularExpression regex(R"(\((\d+)%\))"); + QRegularExpressionMatchIterator i = regex.globalMatch(output); - if (match.hasMatch()) { - int progress = match.captured(1).toInt(); - emit downloadProgress(progress); // 发送进度信号 - qDebug() << "下载进度:" << progress << "%"; + while (i.hasNext()) { + QRegularExpressionMatch match = i.next(); + if (match.hasMatch()) { + int progress = match.captured(1).toInt(); + emit downloadProgress(progress); // 发送进度信号 + qDebug() << "下载进度:" << progress << "%"; + } } } + void DownloadManager::onAria2Finished(int exitCode, QProcess::ExitStatus exitStatus) { if (exitCode == 0 && exitStatus == QProcess::NormalExit) {