mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 19:12:11 +01:00
DownloadManager: Start download timer when download is created
Since we block in download options / file dialogs and QtWebEngine download is already running, it will report invalid (faster) download speed. BUG: 401661 FIXED-IN: 3.1.0
This commit is contained in:
parent
a6c266b6c6
commit
9e7011cbed
|
@ -74,8 +74,6 @@ DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadItem* downlo
|
||||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
|
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
|
||||||
connect(ui->button, SIGNAL(clicked(QPoint)), this, SLOT(stop()));
|
connect(ui->button, SIGNAL(clicked(QPoint)), this, SLOT(stop()));
|
||||||
connect(manager, SIGNAL(resized(QSize)), this, SLOT(parentResized(QSize)));
|
connect(manager, SIGNAL(resized(QSize)), this, SLOT(parentResized(QSize)));
|
||||||
|
|
||||||
startDownloading();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::startDownloading()
|
void DownloadItem::startDownloading()
|
||||||
|
@ -84,7 +82,9 @@ void DownloadItem::startDownloading()
|
||||||
connect(m_download, &QWebEngineDownloadItem::downloadProgress, this, &DownloadItem::downloadProgress);
|
connect(m_download, &QWebEngineDownloadItem::downloadProgress, this, &DownloadItem::downloadProgress);
|
||||||
|
|
||||||
m_downloading = true;
|
m_downloading = true;
|
||||||
m_downTimer.start();
|
if (m_downTimer.elapsed() < 1) {
|
||||||
|
m_downTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
updateDownloadInfo(0, m_download->receivedBytes(), m_download->totalBytes());
|
updateDownloadInfo(0, m_download->receivedBytes(), m_download->totalBytes());
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,9 @@ public:
|
||||||
double currentSpeed() { return m_currSpeed; }
|
double currentSpeed() { return m_currSpeed; }
|
||||||
int progress();
|
int progress();
|
||||||
~DownloadItem();
|
~DownloadItem();
|
||||||
|
void setDownTimer(const QTime &timer) { m_downTimer = timer; }
|
||||||
|
|
||||||
|
void startDownloading();
|
||||||
|
|
||||||
static QString remaingTimeToString(QTime time);
|
static QString remaingTimeToString(QTime time);
|
||||||
static QString currentSpeedToString(double speed);
|
static QString currentSpeedToString(double speed);
|
||||||
|
@ -70,8 +73,6 @@ private Q_SLOTS:
|
||||||
void copyDownloadLink();
|
void copyDownloadLink();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startDownloading();
|
|
||||||
|
|
||||||
void updateDownloadInfo(double currSpeed, qint64 received, qint64 total);
|
void updateDownloadInfo(double currSpeed, qint64 received, qint64 total);
|
||||||
void mouseDoubleClickEvent(QMouseEvent* e);
|
void mouseDoubleClickEvent(QMouseEvent* e);
|
||||||
|
|
||||||
|
@ -83,7 +84,6 @@ private:
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
QTime m_downTimer;
|
QTime m_downTimer;
|
||||||
QTime m_remTime;
|
QTime m_remTime;
|
||||||
QBasicTimer m_timer;
|
|
||||||
QUrl m_downUrl;
|
QUrl m_downUrl;
|
||||||
bool m_openFile;
|
bool m_openFile;
|
||||||
|
|
||||||
|
|
|
@ -269,6 +269,9 @@ void DownloadManager::clearList()
|
||||||
|
|
||||||
void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
|
void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
|
||||||
{
|
{
|
||||||
|
QTime downloadTimer;
|
||||||
|
downloadTimer.start();
|
||||||
|
|
||||||
closeDownloadTab(downloadItem->url());
|
closeDownloadTab(downloadItem->url());
|
||||||
|
|
||||||
QString downloadPath;
|
QString downloadPath;
|
||||||
|
@ -373,6 +376,8 @@ void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
|
||||||
// Create download item
|
// Create download item
|
||||||
QListWidgetItem* listItem = new QListWidgetItem(ui->list);
|
QListWidgetItem* listItem = new QListWidgetItem(ui->list);
|
||||||
DownloadItem* downItem = new DownloadItem(listItem, downloadItem, QFileInfo(downloadPath).absolutePath(), QFileInfo(downloadPath).fileName(), openFile, this);
|
DownloadItem* downItem = new DownloadItem(listItem, downloadItem, QFileInfo(downloadPath).absolutePath(), QFileInfo(downloadPath).fileName(), openFile, this);
|
||||||
|
downItem->setDownTimer(downloadTimer);
|
||||||
|
downItem->startDownloading();
|
||||||
connect(downItem, SIGNAL(deleteItem(DownloadItem*)), this, SLOT(deleteItem(DownloadItem*)));
|
connect(downItem, SIGNAL(deleteItem(DownloadItem*)), this, SLOT(deleteItem(DownloadItem*)));
|
||||||
connect(downItem, SIGNAL(downloadFinished(bool)), this, SLOT(downloadFinished(bool)));
|
connect(downItem, SIGNAL(downloadFinished(bool)), this, SLOT(downloadFinished(bool)));
|
||||||
ui->list->setItemWidget(listItem, downItem);
|
ui->list->setItemWidget(listItem, downItem);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user