aboutsummaryrefslogtreecommitdiff
path: root/lib/downloads/widgets/downloaditemwidget.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-05-26 22:23:25 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-05-28 19:43:45 +0300
commit9c4dd932c6d692178bb8d5265c634126cb415767 (patch)
tree527300f8e710859965c142aed4e779a16b9d4ab6 /lib/downloads/widgets/downloaditemwidget.cpp
parentUpdate ProfileEditor plugin (diff)
downloadsmolbote-9c4dd932c6d692178bb8d5265c634126cb415767.tar.xz
Turn on more warnings by default
- fix clazy warnings - fix various other compiler warnings - bugfix: connect profiles' downloadRequested signal
Diffstat (limited to 'lib/downloads/widgets/downloaditemwidget.cpp')
-rw-r--r--lib/downloads/widgets/downloaditemwidget.cpp21
1 files changed, 8 insertions, 13 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)));
}