mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 12:52:04 +08:00
添加API调用接口,添加读取分类,添加SpkUtils实用函数
使用了SpkSidebarTree子类实现对TreeWidget的特殊要求:不能取消选择,不能拖拽选择。 API调用接口暂时写死。API会获取 配置文件已添加但暂不使用。
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMap>
|
||||
#include <QJsonDocument>
|
||||
#include <QString>
|
||||
#include <QSettings>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
|
||||
@@ -20,35 +21,19 @@ class SpkStore : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
static SpkStore *Instance;
|
||||
QSettings *mCfg;
|
||||
SpkStore(bool aCli, QString &aLogPath);
|
||||
~SpkStore();
|
||||
|
||||
SpkMainWindow* GetRootWindow() { return mMainWindow; }
|
||||
|
||||
void SetApiResuestUrl(QString aUrlStr) { mApiRequestUrl = aUrlStr; }
|
||||
QString GetApiRequestUrl() { return mApiRequestUrl; }
|
||||
QNetworkReply *SendApiRequest(QString path, QJsonDocument param = QJsonDocument());
|
||||
|
||||
private:
|
||||
SpkLogger *mLogger;
|
||||
SpkMainWindow *mMainWindow = nullptr;
|
||||
|
||||
QNetworkAccessManager *mNetMgr = nullptr;
|
||||
|
||||
// Following are stationary signal-slot bindings between UI and Store, mostly for handling
|
||||
// API calls and resource downloading.
|
||||
public slots:
|
||||
|
||||
// void RequestStoreMetadata(); ///< All required metadata the store needs when launched
|
||||
// void RequestCategoryPage(int aCategoryId);
|
||||
// void RequestApplicationMetadata(int aAppId);
|
||||
// void RequestRefreshApiUrls(QString aCustomUrl);
|
||||
signals:
|
||||
void StatusStoreMetadata(QNetworkReply::NetworkError, QString);
|
||||
void StatusCategoryPage(QNetworkReply::NetworkError, QString);
|
||||
void StatusApplicationMetadata(QNetworkReply::NetworkError, QString);
|
||||
void StatusRefreshApiUrls(QNetworkReply::NetworkError, QString);
|
||||
|
||||
private:
|
||||
// Store manages all kinds of possible replies, and the caller can only get JSON they need
|
||||
QNetworkReply *mReplyStoreMetadata = nullptr,
|
||||
*mReplyCategory = nullptr,
|
||||
*mReplyAppMetadata = nullptr,
|
||||
*mReplyApiUrls = nullptr;
|
||||
QString mDistroName, mApiRequestUrl, mUserAgentStr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user