aboutsummaryrefslogtreecommitdiff
path: root/lib/downloads
diff options
context:
space:
mode:
Diffstat (limited to 'lib/downloads')
-rw-r--r--lib/downloads/widgets/downloaditemwidget.cpp21
-rw-r--r--lib/downloads/widgets/downloaditemwidget.h2
2 files changed, 9 insertions, 14 deletions
diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp
index 241b90b..e0c8a60 100644
--- a/lib/downloads/widgets/downloaditemwidget.cpp
+++ b/lib/downloads/widgets/downloaditemwidget.cpp
@@ -13,7 +13,7 @@
#include <QDesktopServices>
#include <QBuffer>
-inline QString sizeString(int size)
+inline QString sizeString(qint64 size)
{
if(size < 1024) {
return QString("%1 bytes").arg(size);
@@ -30,12 +30,12 @@ inline QString sizeString(int size)
return QString("%1 GB").arg(size / (1024 * 1024 * 1024));
}
-DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent)
+DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *m_item, QWidget *parent)
: QWidget(parent)
, ui(new Ui::DownloadItemForm)
{
Q_CHECK_PTR(item);
- this->item = item;
+ m_item = item;
ui->setupUi(this);
{
// pause/resume icons
@@ -56,15 +56,11 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa
connect(item, &QWebEngineDownloadItem::finished, this, &DownloadItemWidget::updateFinished);
connect(ui->abort_toolButton, &QToolButton::clicked, item, &QWebEngineDownloadItem::cancel);
- connect(ui->pause_toolButton, &QToolButton::clicked, item, [item](bool clicked) {
- if(clicked) {
- item->pause();
- } else {
- item->resume();
- }
+ connect(ui->pause_toolButton, &QToolButton::clicked, item, [m_item](bool clicked) {
+ clicked ? m_item->pause() : m_item->resume();
});
- connect(ui->open_toolButton, &QToolButton::clicked, item, [item]() {
- QDesktopServices::openUrl(QUrl::fromLocalFile(item->downloadDirectory()+'/'+item->downloadFileName()));
+ connect(ui->open_toolButton, &QToolButton::clicked, item, [m_item]() {
+ QDesktopServices::openUrl(QUrl::fromLocalFile(m_item->downloadDirectory() + '/' + m_item->downloadFileName()));
});
}
@@ -113,8 +109,7 @@ void DownloadItemWidget::updateState(QWebEngineDownloadItem::DownloadState state
void DownloadItemWidget::updateProgress(qint64 value, qint64 total)
{
- ui->progressBar->setMaximum(total);
- ui->progressBar->setValue(value);
+ ui->progressBar->setValue(static_cast<int>((static_cast<long double>(value) / static_cast<long double>(total)) * 100));
ui->progressBar->setFormat(QString("%1 / %2").arg(sizeString(value), sizeString(total)));
}
diff --git a/lib/downloads/widgets/downloaditemwidget.h b/lib/downloads/widgets/downloaditemwidget.h
index c2809d2..a1de175 100644
--- a/lib/downloads/widgets/downloaditemwidget.h
+++ b/lib/downloads/widgets/downloaditemwidget.h
@@ -22,7 +22,7 @@ class DownloadItemWidget : public QWidget
Q_OBJECT
public:
- explicit DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent = 0);
+ explicit DownloadItemWidget(QWebEngineDownloadItem *m_item, QWidget *parent = 0);
~DownloadItemWidget() override;
private slots: