aboutsummaryrefslogtreecommitdiff
path: root/src/webengine
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
parentUpdated firejail profile (diff)
downloadsmolbote-8c25c63acf839b09e10d398cfa44d5a45d3ba7c0.tar.xz
Download manager
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/downloaditemform.cpp57
-rw-r--r--src/webengine/downloaditemform.h28
-rw-r--r--src/webengine/downloaditemform.ui57
3 files changed, 142 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);
+}
diff --git a/src/webengine/downloaditemform.h b/src/webengine/downloaditemform.h
new file mode 100644
index 0000000..996b876
--- /dev/null
+++ b/src/webengine/downloaditemform.h
@@ -0,0 +1,28 @@
+#ifndef DOWNLOADITEMFORM_H
+#define DOWNLOADITEMFORM_H
+
+#include <QWidget>
+#include <QWebEngineDownloadItem>
+
+namespace Ui {
+class DownloadItemForm;
+}
+
+class DownloadItemForm : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit DownloadItemForm(QWebEngineDownloadItem *item, QWidget *parent = 0);
+ ~DownloadItemForm();
+
+private slots:
+ void updateState(QWebEngineDownloadItem::DownloadState state);
+ void updateProgress(qint64 value, qint64 total);
+ void updateFinished();
+
+private:
+ Ui::DownloadItemForm *ui;
+};
+
+#endif // DOWNLOADITEMFORM_H
diff --git a/src/webengine/downloaditemform.ui b/src/webengine/downloaditemform.ui
new file mode 100644
index 0000000..5aa46bd
--- /dev/null
+++ b/src/webengine/downloaditemform.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DownloadItemForm</class>
+ <widget class="QWidget" name="DownloadItemForm">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>80</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>URL</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="url_lineEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="status_label">
+ <property name="text">
+ <string>Unknown</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="value">
+ <number>24</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>