aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/downloaditemform.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-01-15 15:39:42 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-01-15 15:39:42 +0100
commit8c25c63acf839b09e10d398cfa44d5a45d3ba7c0 (patch)
tree22fa7a27414d12910c1d360b89aac1221f89ab25 /src/webengine/downloaditemform.cpp
parentUpdated firejail profile (diff)
downloadsmolbote-8c25c63acf839b09e10d398cfa44d5a45d3ba7c0.tar.xz
Download manager
Diffstat (limited to 'src/webengine/downloaditemform.cpp')
-rw-r--r--src/webengine/downloaditemform.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/webengine/downloaditemform.cpp b/src/webengine/downloaditemform.cpp
new file mode 100644
index 0000000..717a41d
--- /dev/null
+++ b/src/webengine/downloaditemform.cpp
@@ -0,0 +1,57 @@
+#include "downloaditemform.h"
+#include "ui_downloaditemform.h"
+
+#include <QUrl>
+#include <QLabel>
+
+DownloadItemForm::DownloadItemForm(QWebEngineDownloadItem *item, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::DownloadItemForm)
+{
+ ui->setupUi(this);
+ ui->url_lineEdit->setText(item->url().toString());
+
+ connect(item, SIGNAL(stateChanged(QWebEngineDownloadItem::DownloadState)), this, SLOT(updateState(QWebEngineDownloadItem::DownloadState)));
+ connect(item, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateProgress(qint64,qint64)));
+ connect(item, SIGNAL(finished()), this, SLOT(updateFinished()));
+}
+
+DownloadItemForm::~DownloadItemForm()
+{
+ delete ui;
+}
+
+void DownloadItemForm::updateState(QWebEngineDownloadItem::DownloadState state)
+{
+ switch (state) {
+ case QWebEngineDownloadItem::DownloadRequested:
+ ui->status_label->setText(tr("Requested"));
+ break;
+ case QWebEngineDownloadItem::DownloadInProgress:
+ ui->status_label->setText(tr("In progress"));
+ break;
+ case QWebEngineDownloadItem::DownloadCompleted:
+ ui->status_label->setText(tr("Completed"));
+ break;
+ case QWebEngineDownloadItem::DownloadCancelled:
+ ui->status_label->setText(tr("Cancelled"));
+ break;
+ case QWebEngineDownloadItem::DownloadInterrupted:
+ ui->status_label->setText(tr("Interrupted"));
+ break;
+ default:
+ break;
+ }
+}
+
+void DownloadItemForm::updateProgress(qint64 value, qint64 total)
+{
+ ui->progressBar->setMaximum(total);
+ ui->progressBar->setValue(value);
+}
+
+void DownloadItemForm::updateFinished()
+{
+ ui->progressBar->setMaximum(100);
+ ui->progressBar->setValue(100);
+}