mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 21:02:04 +08:00
完善下载页面按钮的功能
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "spkdownload.h"
|
||||
#include "spkdownloadentry.h"
|
||||
#include "page/spkpagebase.h"
|
||||
#include "pkgs/spkpkgmgrbase.h"
|
||||
|
||||
namespace SpkUi
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace SpkUi
|
||||
SpkDownloadMgr *mDownloadMgr;
|
||||
QMap<uint, SpkDownloadEntry*> mEntries;
|
||||
uint mNextDownloadId;
|
||||
QQueue<QPair<uint, QString>> mWaitingDownloads;
|
||||
QQueue<QPair<int, QString>> mWaitingDownloads;
|
||||
enum { Idle, Waiting, Downloading } mCurrentStatus;
|
||||
|
||||
// UI
|
||||
@@ -33,6 +34,11 @@ namespace SpkUi
|
||||
private slots:
|
||||
void DownloadProgress(qint64 downloadedBytes, qint64 totalBytes, int id);
|
||||
void DownloadStopped(SpkDownloadMgr::TaskResult status, int id);
|
||||
void EntryAction(SpkDownloadEntry::EntryAction);
|
||||
void InstallationEnded(int id, SpkPkgMgrBase::PkgInstallResult, int exitCode);
|
||||
|
||||
private:
|
||||
void NewDownloadTask(int id, QString downloadPath);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ class SpkDownloadMgr : public QObject
|
||||
FailCannotCreateFile, ///< Failed because destination file cannot be created
|
||||
FailNoVaibleServer, ///< Failed because no server provides file size or download stalled on
|
||||
///< all of them
|
||||
FailCancel, ///< User has cancelled the task
|
||||
Fail
|
||||
};
|
||||
|
||||
@@ -67,6 +68,8 @@ class SpkDownloadMgr : public QObject
|
||||
*/
|
||||
static RemoteFileInfo GetRemoteFileInfo(QUrl url);
|
||||
|
||||
QString GetDestFilePath(QString downloadPath);
|
||||
|
||||
private:
|
||||
QList<QString> mServers; ///< Multithreaded download
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ class SpkDownloadEntry : public QWidget
|
||||
Invalid = -1,
|
||||
Waiting,
|
||||
Downloading,
|
||||
Paused,
|
||||
Failed,
|
||||
DownloadFailed,
|
||||
ToBeInstalled,
|
||||
Installing,
|
||||
Installed,
|
||||
@@ -35,9 +34,23 @@ class SpkDownloadEntry : public QWidget
|
||||
};
|
||||
|
||||
void SetTotalBytes(qint64 total);
|
||||
void SetBasicInfo(QString name, QPixmap icon);
|
||||
void SetBasicInfo(QString name, QPixmap icon, QString filePath);
|
||||
void SetStatus(DownloadEntryStatus status, QString msg = "");
|
||||
void Progress(qint64 bytes);
|
||||
QString GetTaskName() { return mAppName->text(); }
|
||||
QString GetFilePath() { return mFilePath; }
|
||||
|
||||
enum EntryAction
|
||||
{
|
||||
AbortDownload,
|
||||
RetryDownload,
|
||||
StartInstall,
|
||||
RemoveEntry
|
||||
};
|
||||
|
||||
private slots:
|
||||
void ActionButton();
|
||||
void DeleteButton();
|
||||
|
||||
private:
|
||||
QLabel *mIcon, *mMessage;
|
||||
@@ -54,4 +67,11 @@ class SpkDownloadEntry : public QWidget
|
||||
qint64 mTotalBytes, mDownloadedBytes;
|
||||
QTime mLastReportTime;
|
||||
QString mReadableTotalSize;
|
||||
|
||||
QString mFilePath;
|
||||
|
||||
DownloadEntryStatus mStatus;
|
||||
|
||||
signals:
|
||||
void Action(EntryAction);
|
||||
};
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace SpkUi
|
||||
void GoBack()
|
||||
{
|
||||
emit SwitchToCategory(mLastCategoryPage, 0);
|
||||
mCategoryWidget->currentItem()->setSelected(false);
|
||||
mLastCategoryItem->setSelected(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define STORE (SpkStore::Instance)
|
||||
#define CFG (SpkStore::Instance->mCfg)
|
||||
#define RES (SpkResource::Instance)
|
||||
#define PKG (SpkPkgMgrBase::Instance())
|
||||
|
||||
namespace SpkUtils
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user