spark-store/inc/spkstore.h
RigoLigoRLC 6491b19f6e 支持图标跟随主题,改进详情页,加入更好的多线程下载
新的下载会重试一个线程上的错误,一个线程崩溃次数过多会转移到队列里等待重新安排,其他的暂时没写
2021-11-28 02:11:54 +08:00

50 lines
1.5 KiB
C++

#pragma once
#include <QJsonDocument>
#include <QString>
#include <QSettings>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkAccessManager>
#include "spklogging.h"
#include "spkmainwindow.h"
#include "spkresource.h"
/**
* @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,
* including preferences class, category names, request URLs, downloads status, packaging
* backend interfaces and so on.
*/
class SpkStore : public QObject
{
Q_OBJECT
public:
static SpkStore *Instance;
QSettings *mCfg;
SpkStore(bool aCli, QString &aLogPath);
~SpkStore();
SpkMainWindow* GetRootWindow() { return mMainWindow; }
void SetApiRequestUrl(QString aUrlStr) { mApiRequestUrl = aUrlStr; }
QString GetApiRequestUrl() { return mApiRequestUrl; }
QNetworkReply *SendApiRequest(QString path, QJsonDocument param = QJsonDocument());
QNetworkReply *SendResourceRequest(QString path); ///< WARNING: Only intended for SpkResource!
QNetworkReply *SendDownloadRequest(QUrl file, qint64 fromByte = -1, qint64 toByte = -1);
QNetworkReply *SendCustomHeadRequest(QNetworkRequest);
private:
SpkLogger *mLogger;
SpkMainWindow *mMainWindow = nullptr;
SpkResource *mResMgr = nullptr;
QNetworkAccessManager *mNetMgr = nullptr;
QString mDistroName,
mApiRequestUrl,
mResourceRequestUrl,
mUserAgentStr,
mConfigPath;
};