mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-18 09:02:21 +08:00
fix: 多个应用安装可能会出现某一个应用没有安装
This commit is contained in:
parent
d742e85332
commit
33ea9ee065
@ -61,8 +61,21 @@ QString DownloadItem::getName()
|
|||||||
return ui->label_filename->text();
|
return ui->label_filename->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::readyInstall()
|
|
||||||
|
/***************************************************************
|
||||||
|
* @brief 告知界面,准备安装
|
||||||
|
* @param
|
||||||
|
* @note 如果正在安装,返回-1
|
||||||
|
* @Sample usage: DownloadItem::install(0);
|
||||||
|
**************************************************************/
|
||||||
|
int DownloadItem::readyInstall()
|
||||||
{
|
{
|
||||||
|
// 检查是否正在安装,如果是返回错误 -1
|
||||||
|
if (isInstall)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!close)
|
if (!close)
|
||||||
{
|
{
|
||||||
ui->progressBar->hide();
|
ui->progressBar->hide();
|
||||||
@ -70,7 +83,9 @@ void DownloadItem::readyInstall()
|
|||||||
ui->pushButton_install->show();
|
ui->pushButton_install->show();
|
||||||
DownloadItem::install(0);
|
DownloadItem::install(0);
|
||||||
ui->pushButton_2->hide();
|
ui->pushButton_2->hide();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::setFileName(QString fileName)
|
void DownloadItem::setFileName(QString fileName)
|
||||||
@ -93,6 +108,12 @@ void DownloadItem::setSpeed(QString s)
|
|||||||
speed = s;
|
speed = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
* @brief 安装当前应用
|
||||||
|
* @param int t, t为安装方式,可以为 0,1,2
|
||||||
|
* @note 备注
|
||||||
|
* @Sample usage: DownloadItem::install(0);
|
||||||
|
**************************************************************/
|
||||||
void DownloadItem::install(int t)
|
void DownloadItem::install(int t)
|
||||||
{
|
{
|
||||||
if (!isInstall)
|
if (!isInstall)
|
||||||
@ -142,6 +163,12 @@ void DownloadItem::on_pushButton_3_clicked()
|
|||||||
output_w->show();
|
output_w->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
* @brief 实际安装应用
|
||||||
|
* @param int t, t为安装方式,可以为 0,1,2
|
||||||
|
* @note 备注
|
||||||
|
* @Sample usage: slotAsyncInstall(0);
|
||||||
|
**************************************************************/
|
||||||
void DownloadItem::slotAsyncInstall(int t)
|
void DownloadItem::slotAsyncInstall(int t)
|
||||||
{
|
{
|
||||||
QProcess installer;
|
QProcess installer;
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
void setMax(qint64);
|
void setMax(qint64);
|
||||||
void setName(QString);
|
void setName(QString);
|
||||||
QString getName();
|
QString getName();
|
||||||
void readyInstall();
|
int readyInstall();
|
||||||
|
|
||||||
void setFileName(QString);
|
void setFileName(QString);
|
||||||
void seticon(const QPixmap);
|
void seticon(const QPixmap);
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <QGraphicsOpacityEffect>
|
#include <QGraphicsOpacityEffect>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
|
||||||
DownloadListWidget::DownloadListWidget(QWidget *parent) : DBlurEffectWidget(parent),
|
DownloadListWidget::DownloadListWidget(QWidget *parent) : DBlurEffectWidget(parent),
|
||||||
ui(new Ui::DownloadListWidget)
|
ui(new Ui::DownloadListWidget)
|
||||||
{
|
{
|
||||||
@ -65,20 +67,6 @@ DownloadListWidget::~DownloadListWidget()
|
|||||||
|
|
||||||
void DownloadListWidget::clearItem()
|
void DownloadListWidget::clearItem()
|
||||||
{
|
{
|
||||||
// QListWidgetItem *item = nullptr;
|
|
||||||
// while ((item = ui->listWidget->takeItem(0)) != nullptr)
|
|
||||||
// {
|
|
||||||
// QWidget *card = ui->listWidget->itemWidget(item);
|
|
||||||
// if (card)
|
|
||||||
// {
|
|
||||||
// card->deleteLater();
|
|
||||||
// card = nullptr;
|
|
||||||
// }
|
|
||||||
// delete item;
|
|
||||||
// item = nullptr;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ui->listWidget->vScrollBar->scrollTop();
|
|
||||||
ui->listWidget->clear();
|
ui->listWidget->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,30 +130,47 @@ void DownloadListWidget::startRequest(QUrl url, QString fileName)
|
|||||||
downloadController->startDownload(url.toString());
|
downloadController->startDownload(url.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************
|
||||||
|
* @brief 下载列表完成下载的回调函数
|
||||||
|
* @param
|
||||||
|
* @note 如果正在安装,则在新开的线程空间中等待上一个安装完
|
||||||
|
* @Sample usage:
|
||||||
|
**************************************************************/
|
||||||
void DownloadListWidget::httpFinished() // 完成下载
|
void DownloadListWidget::httpFinished() // 完成下载
|
||||||
{
|
{
|
||||||
isdownload = false;
|
isdownload = false;
|
||||||
isBusy = false;
|
isBusy = false;
|
||||||
downloaditemlist[nowDownload - 1]->readyInstall();
|
|
||||||
downloaditemlist[nowDownload - 1]->free = true;
|
QtConcurrent::run([=]()
|
||||||
emit downloadFinished();
|
|
||||||
if (nowDownload < allDownload)
|
|
||||||
{
|
{
|
||||||
// 如果有排队则下载下一个
|
while (downloaditemlist[nowDownload - 1]->readyInstall() == -1)
|
||||||
qDebug() << "切换下一个下载...";
|
|
||||||
nowDownload += 1;
|
|
||||||
while (downloaditemlist[nowDownload - 1]->close)
|
|
||||||
{
|
{
|
||||||
nowDownload += 1;
|
continue;
|
||||||
if (nowDownload >= allDownload)
|
|
||||||
{
|
|
||||||
nowDownload = allDownload;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QString fileName = downloaditemlist[nowDownload - 1]->getName();
|
|
||||||
startRequest(urList.at(nowDownload - 1), fileName);
|
downloaditemlist[nowDownload - 1]->free = true;
|
||||||
}
|
emit downloadFinished();
|
||||||
|
if (nowDownload < allDownload)
|
||||||
|
{
|
||||||
|
// 如果有排队则下载下一个
|
||||||
|
qDebug() << "切换下一个下载...";
|
||||||
|
nowDownload += 1;
|
||||||
|
while (downloaditemlist[nowDownload - 1]->close)
|
||||||
|
{
|
||||||
|
nowDownload += 1;
|
||||||
|
if (nowDownload >= allDownload)
|
||||||
|
{
|
||||||
|
nowDownload = allDownload;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QString fileName = downloaditemlist[nowDownload - 1]->getName();
|
||||||
|
startRequest(urList.at(nowDownload - 1), fileName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadListWidget::updateDataReadProgress(QString speedInfo, qint64 bytesRead, qint64 totalBytes)
|
void DownloadListWidget::updateDataReadProgress(QString speedInfo, qint64 bytesRead, qint64 totalBytes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user