下载页面雏形,修复SpkPopup(改用弹出),添加应用列表固定图标缓存

This commit is contained in:
RigoLigoRLC
2021-12-12 00:25:19 +08:00
parent f5a31affff
commit 179e57b9b5
19 changed files with 354 additions and 26 deletions

View File

@@ -37,6 +37,10 @@ namespace SpkUi
SpkStretchLayout *mItemLay;
QList<SpkAppItem *> mAppItemList;
// Cached icons
QPixmap *mLoadingIcon,
*mBrokenIcon;
QIntValidator *mPageValidator;
int mCategoryId, mCurrentPage;

View File

@@ -2,6 +2,7 @@
#pragma once
#include "spkstore.h"
#include <QTimer>
/**
* @note SpkDownloadMgr does NOT do download scheduling and other things; it's only a multithreaded
@@ -68,6 +69,8 @@ class SpkDownloadMgr : public QObject
QFile mDestFile;
QString mDestFolder, mCurrentRemotePath;
RemoteFileInfo mCurrentRemoteFileInfo;
QTimer mProgressEmitterTimer;
qint64 mDownloadedBytes;
int mCurrentDownloadId;
int mActiveWorkerCount;
@@ -88,6 +91,7 @@ class SpkDownloadMgr : public QObject
private slots:
void WorkerFinish();
void WorkerDownloadProgress(); ///< Be connected to ***QNetworkReply::readyRead***
void ProgressTimer();
private:
void LinkReplyWithMe(QNetworkReply*);
@@ -95,7 +99,7 @@ class SpkDownloadMgr : public QObject
void TryScheduleFailureRetries(int i); ///< Try schedule on a specific task slot.
signals:
void DownloadProgressed(qint64 bytes, qint64 total);
void DownloadProgressed(qint64 bytes, qint64 total, int id);
void DownloadStopped(TaskResult status, int id);

52
inc/spkdownloadentry.h Normal file
View File

@@ -0,0 +1,52 @@
#pragma once
#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include "qt/elidedlabel.h"
#include "spkloading.h"
#include <QProgressBar>
#include <QHBoxLayout>
#include <QVBoxLayout>
class SpkDownloadEntry : public QWidget
{
Q_OBJECT
public:
explicit SpkDownloadEntry(QWidget* parent = nullptr);
~SpkDownloadEntry();
static constexpr QSize IconSize { 64, 64 };
enum DownloadEntryStatus
{
Invalid = -1,
Waiting,
Downloading,
Paused,
Failed,
ToBeInstalled,
Installing,
Installed,
InstallFailed
};
public slots:
void SetBasicInfo(QString name, QPixmap icon);
void SetStatus(DownloadEntryStatus status);
void SetProgress(int);
private:
QLabel *mIcon, *mMessage;
ElidedLabel *mAppName;
QProgressBar *mProgress;
QPushButton *mBtnDelete,
*mBtnActions; // Actions include Retry Pause Install etc, one status at a time
SpkLoading *mLoading;
QHBoxLayout *mLayMsgs, *mLayMain;
QVBoxLayout *mLayInfo;
};

View File

@@ -18,6 +18,7 @@
#include "page/spkpageuitest.h"
#include "page/spkpageapplist.h"
#include "page/spkpageappdetails.h"
#include "page/spkpagedownloads.h"
class QNetworkReply;
@@ -28,6 +29,7 @@ namespace SpkUi
PgInvalid = -1,
PgAppList,
PgAppDetails,
PgDownloads,
PgQssTest // Must be at last
};
@@ -152,6 +154,7 @@ namespace SpkUi
QTreeWidgetItem *CategoryParentItem,
*AppDetailsItem,
*DownloadsItem,
*UiTestItem;
// Title bar search bar
@@ -163,6 +166,7 @@ namespace SpkUi
SpkPageUiTest *PageQssTest;
SpkPageAppList *PageAppList;
SpkPageAppDetails *PageAppDetails;
SpkPageDownloads *PageDownloads;
};
}

View File

@@ -45,6 +45,8 @@ class SpkResource : public QObject
inline QString GetCachePath(const ResourceTask &task);
ResourceResult CacheLookup(QString pkgName, ResourceType type, QVariant info);
/**
* @brief When the resource context was changed, the new context needs to acquire the resource
* manager, so the resource manager can download resource for the new context.

View File

@@ -8,9 +8,10 @@
#include <QtNetwork/QNetworkAccessManager>
#include "spklogging.h"
#include "spkmainwindow.h"
#include "spkresource.h"
class SpkMainWindow;
/**
* @brief SpkStore class is the core of the store client side program, it is constructed first and
* handling all processing after the launch. All client side data should be held by it,