Fix Bugs & Improve Features

Restrict downloading one file at a time;
Fix a bug if downloading second file, the progress bar won't show;
Support pause / resume / cancel download operation.
This commit is contained in:
2020-12-01 15:15:47 +08:00
parent e808bd2af7
commit c412743642
4 changed files with 163 additions and 51 deletions

View File

@@ -5,10 +5,13 @@
#include <DAboutDialog>
#include <DToolButton>
#include <DProgressBar>
#include <DPushButton>
#include <DFloatingMessage>
#include <QSystemTrayIcon>
#include <QLayout>
#include <QProcess>
#include <QMutex>
#include "widget.h"
#include "globaldefine.h"
@@ -53,11 +56,19 @@ private:
QAction *t_about;
QAction *t_exit;
QWidget *downloadProgressBar;
DProgressBar *bar;
DPushButton *pause;
DPushButton *resume;
DPushButton *cancel;
QHBoxLayout *progress;
DFloatingMessage *message;
QProcess *process;
QMutex mutex; // 通过 Mutex 互斥量禁止同时下载多个文件(使用简单的 bool 变量应该也可以实现该功能?)
bool isCanceled; // 判断是否为取消下载
bool mtray, mFixSize;
int m_width, m_height;
@@ -76,6 +87,9 @@ private slots:
void on_downloadStart(QWebEngineDownloadItem *item);
void on_downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void on_downloadFinish(QString filePath);
void on_downloadPause(QWebEngineDownloadItem *item);
void on_downloadResume(QWebEngineDownloadItem *item);
void on_downloadCancel(QWebEngineDownloadItem *item);
signals:
void sigQuit();