diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-05-26 22:23:25 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-05-28 19:43:45 +0300 |
commit | 9c4dd932c6d692178bb8d5265c634126cb415767 (patch) | |
tree | 527300f8e710859965c142aed4e779a16b9d4ab6 /lib/downloads | |
parent | Update ProfileEditor plugin (diff) | |
download | smolbote-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')
-rw-r--r-- | lib/downloads/widgets/downloaditemwidget.cpp | 21 | ||||
-rw-r--r-- | lib/downloads/widgets/downloaditemwidget.h | 2 |
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: |