mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-20 11:11:36 +08:00
chore:显示下载百分比
This commit is contained in:
@@ -25,16 +25,20 @@ void DownloadManager::startDownload(const QString &url, const QString &outputPat
|
|||||||
void DownloadManager::onAria2Progress()
|
void DownloadManager::onAria2Progress()
|
||||||
{
|
{
|
||||||
QString output = m_aria2Process.readAllStandardOutput();
|
QString output = m_aria2Process.readAllStandardOutput();
|
||||||
QRegularExpression regex(R"(Download Progress: (\d+)%.*)");
|
QRegularExpression regex(R"(\((\d+)%\))");
|
||||||
QRegularExpressionMatch match = regex.match(output);
|
QRegularExpressionMatchIterator i = regex.globalMatch(output);
|
||||||
|
|
||||||
if (match.hasMatch()) {
|
while (i.hasNext()) {
|
||||||
int progress = match.captured(1).toInt();
|
QRegularExpressionMatch match = i.next();
|
||||||
emit downloadProgress(progress); // 发送进度信号
|
if (match.hasMatch()) {
|
||||||
qDebug() << "下载进度:" << progress << "%";
|
int progress = match.captured(1).toInt();
|
||||||
|
emit downloadProgress(progress); // 发送进度信号
|
||||||
|
qDebug() << "下载进度:" << progress << "%";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DownloadManager::onAria2Finished(int exitCode, QProcess::ExitStatus exitStatus)
|
void DownloadManager::onAria2Finished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||||
{
|
{
|
||||||
if (exitCode == 0 && exitStatus == QProcess::NormalExit) {
|
if (exitCode == 0 && exitStatus == QProcess::NormalExit) {
|
||||||
|
|||||||
Reference in New Issue
Block a user