mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-11 13:52:21 +08:00
chore:显示下载百分比
This commit is contained in:
parent
f071fcb00d
commit
e416ffdbff
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user