From 6749e47c2234e2d29b20482b7350d9f188a110ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Tue, 27 Feb 2024 12:23:24 +0800 Subject: [PATCH] update --- src/FluApp.cpp | 14 +- src/FluApp.h | 5 +- src/FluCaptcha.h | 3 + src/FluEventBus.h | 6 + src/FluFramelessHelper.h | 6 + src/FluNetwork.cpp | 142 +++---- src/FluNetwork.h | 100 ++--- src/{QRCode.cpp => FluQrCodeItem.cpp} | 14 +- src/{QRCode.h => FluQrCodeItem.h} | 15 +- src/FluRectangle.h | 3 + src/FluTextStyle.h | 3 + src/FluTreeModel.h | 3 + src/FluViewModel.cpp | 46 +-- src/FluViewModel.h | 29 +- src/FluWatermark.h | 4 +- src/FluWindowLifecycle.cpp | 33 ++ ...WindowLifecycle.h => FluWindowLifecycle.h} | 14 +- src/FluentUI.cpp | 12 +- src/FluentUI.h | 3 + src/MainThread.cpp | 32 -- src/MainThread.h | 23 -- .../imports/FluentUI/Controls/FluQRCode.qml | 2 +- .../imports/FluentUI/Controls/FluWindow.qml | 2 +- src/Qt5/imports/FluentUI/plugins.qmltypes | 350 ++++++++++-------- .../imports/FluentUI/Controls/FluQRCode.qml | 2 +- .../imports/FluentUI/Controls/FluWindow.qml | 2 +- src/WindowLifecycle.cpp | 33 -- src/fluentuiplugin.h | 3 + src/singleton.h | 3 + 29 files changed, 466 insertions(+), 441 deletions(-) rename src/{QRCode.cpp => FluQrCodeItem.cpp} (76%) rename src/{QRCode.h => FluQrCodeItem.h} (53%) create mode 100644 src/FluWindowLifecycle.cpp rename src/{WindowLifecycle.h => FluWindowLifecycle.h} (63%) delete mode 100644 src/MainThread.cpp delete mode 100644 src/MainThread.h delete mode 100644 src/WindowLifecycle.cpp diff --git a/src/FluApp.cpp b/src/FluApp.cpp index 7fbbb765..55e869b9 100644 --- a/src/FluApp.cpp +++ b/src/FluApp.cpp @@ -10,19 +10,14 @@ #include FluApp::FluApp(QObject *parent):QObject{parent}{ - vsync(true); useSystemAppBar(false); } FluApp::~FluApp(){ } -void FluApp::init(QObject *application){ - this->_application = application; - QJSEngine * jsEngine = qjsEngine(_application); - std::string jsFunction = R"( (function () { console.log("FluentUI");}) )"; - QJSValue function = jsEngine->evaluate(QString::fromStdString(jsFunction)); - jsEngine->globalObject().setProperty("__fluentui",function); +void FluApp::init(QObject *target){ + _engine = qmlEngine(target); } void FluApp::run(){ @@ -31,11 +26,10 @@ void FluApp::run(){ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){ if(!routes().contains(route)){ - qCritical()<<"No route found "< _windows; - QObject* _application = nullptr; + QQmlEngine *_engine; }; #endif // FLUAPP_H diff --git a/src/FluCaptcha.h b/src/FluCaptcha.h index 932b0a60..4a260c5f 100644 --- a/src/FluCaptcha.h +++ b/src/FluCaptcha.h @@ -6,6 +6,9 @@ #include #include "stdafx.h" +/** + * @brief The FluCaptcha class + */ class FluCaptcha : public QQuickPaintedItem { Q_OBJECT diff --git a/src/FluEventBus.h b/src/FluEventBus.h index 0622c5f5..badddf90 100644 --- a/src/FluEventBus.h +++ b/src/FluEventBus.h @@ -6,6 +6,9 @@ #include "stdafx.h" #include "singleton.h" +/** + * @brief The FluEvent class + */ class FluEvent : public QObject{ Q_OBJECT Q_PROPERTY_AUTO(QString,name); @@ -15,6 +18,9 @@ public: Q_SIGNAL void triggered(QMap data); }; +/** + * @brief The FluEventBus class + */ class FluEventBus : public QObject { Q_OBJECT diff --git a/src/FluFramelessHelper.h b/src/FluFramelessHelper.h index 898c6c20..3b79baa7 100644 --- a/src/FluFramelessHelper.h +++ b/src/FluFramelessHelper.h @@ -17,6 +17,9 @@ using QT_ENTER_EVENT_TYPE = QEvent; class FluFramelessHelper; +/** + * @brief The FramelessEventFilter class + */ class FramelessEventFilter : public QAbstractNativeEventFilter { public: @@ -27,6 +30,9 @@ public: qint64 _current = 0; }; +/** + * @brief The FluFramelessHelper class + */ class FluFramelessHelper : public QObject, public QQmlParserStatus { Q_OBJECT diff --git a/src/FluNetwork.cpp b/src/FluNetwork.cpp index 4b3c8978..a030a9e0 100644 --- a/src/FluNetwork.cpp +++ b/src/FluNetwork.cpp @@ -18,11 +18,11 @@ #include #include -NetworkCallable::NetworkCallable(QObject *parent):QObject{parent}{ +FluNetworkCallable::FluNetworkCallable(QObject *parent):QObject{parent}{ } -QString NetworkParams::method2String(){ +QString FluNetworkParams::method2String(){ switch (_method) { case METHOD_GET: return "GET"; @@ -41,45 +41,45 @@ QString NetworkParams::method2String(){ } } -int NetworkParams::getTimeout(){ +int FluNetworkParams::getTimeout(){ if(_timeout != -1){ return _timeout; } return FluNetwork::getInstance()->timeout(); } -int NetworkParams::getRetry(){ +int FluNetworkParams::getRetry(){ if(_retry != -1){ return _retry; } return FluNetwork::getInstance()->retry(); } -bool NetworkParams::getOpenLog(){ +bool FluNetworkParams::getOpenLog(){ if(!_openLog.isNull()){ return _openLog.toBool(); } return FluNetwork::getInstance()->openLog(); } -DownloadParam::DownloadParam(QObject *parent) +FluDownloadParam::FluDownloadParam(QObject *parent) : QObject{parent} { } -DownloadParam::DownloadParam(QString destPath,bool append,QObject *parent) +FluDownloadParam::FluDownloadParam(QString destPath,bool append,QObject *parent) : QObject{parent} { this->_destPath = destPath; this->_append = append; } -NetworkParams::NetworkParams(QObject *parent) +FluNetworkParams::FluNetworkParams(QObject *parent) : QObject{parent} { } -NetworkParams::NetworkParams(QString url,Type type,Method method,QObject *parent) +FluNetworkParams::FluNetworkParams(QString url,Type type,Method method,QObject *parent) : QObject{parent} { this->_method = method; @@ -87,62 +87,62 @@ NetworkParams::NetworkParams(QString url,Type type,Method method,QObject *parent this->_type = type; } -NetworkParams* NetworkParams::add(QString key,QVariant val){ +FluNetworkParams* FluNetworkParams::add(QString key,QVariant val){ _paramMap.insert(key,val); return this; } -NetworkParams* NetworkParams::addFile(QString key,QVariant val){ +FluNetworkParams* FluNetworkParams::addFile(QString key,QVariant val){ _fileMap.insert(key,val); return this; } -NetworkParams* NetworkParams::addHeader(QString key,QVariant val){ +FluNetworkParams* FluNetworkParams::addHeader(QString key,QVariant val){ _headerMap.insert(key,val); return this; } -NetworkParams* NetworkParams::addQuery(QString key,QVariant val){ +FluNetworkParams* FluNetworkParams::addQuery(QString key,QVariant val){ _queryMap.insert(key,val); return this; } -NetworkParams* NetworkParams::setBody(QString val){ +FluNetworkParams* FluNetworkParams::setBody(QString val){ _body = val; return this; } -NetworkParams* NetworkParams::setTimeout(int val){ +FluNetworkParams* FluNetworkParams::setTimeout(int val){ _timeout = val; return this; } -NetworkParams* NetworkParams::setRetry(int val){ +FluNetworkParams* FluNetworkParams::setRetry(int val){ _retry = val; return this; } -NetworkParams* NetworkParams::setCacheMode(int val){ +FluNetworkParams* FluNetworkParams::setCacheMode(int val){ _cacheMode = val; return this; } -NetworkParams* NetworkParams::toDownload(QString destPath,bool append){ - _downloadParam = new DownloadParam(destPath,append,this); +FluNetworkParams* FluNetworkParams::toDownload(QString destPath,bool append){ + _downloadParam = new FluDownloadParam(destPath,append,this); return this; } -NetworkParams* NetworkParams::bind(QObject* target){ +FluNetworkParams* FluNetworkParams::bind(QObject* target){ _target = target; return this; } -NetworkParams* NetworkParams::openLog(QVariant val){ +FluNetworkParams* FluNetworkParams::openLog(QVariant val){ _openLog = val; return this; } -QString NetworkParams::buildCacheKey(){ +QString FluNetworkParams::buildCacheKey(){ QJsonObject obj; obj.insert("url",_url); obj.insert("method",method2String()); @@ -161,7 +161,7 @@ QString NetworkParams::buildCacheKey(){ return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex(); } -void NetworkParams::go(NetworkCallable* callable){ +void FluNetworkParams::go(FluNetworkCallable* callable){ QJSValueList data; data<newQObject(this); FluNetwork::getInstance()->_interceptor.call(data); @@ -172,8 +172,8 @@ void NetworkParams::go(NetworkCallable* callable){ } } -void FluNetwork::handle(NetworkParams* params,NetworkCallable* c){ - QPointer callable(c); +void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){ + QPointer callable(c); QThreadPool::globalInstance()->start([=](){ if(!callable.isNull()){ callable->start(); @@ -228,7 +228,7 @@ void FluNetwork::handle(NetworkParams* params,NetworkCallable* c){ disconnect(conn_quit); } QString response; - if(params->_method == NetworkParams::METHOD_HEAD){ + if(params->_method == FluNetworkParams::METHOD_HEAD){ response = headerList2String(reply->rawHeaderPairs()); }else{ if(reply->isOpen()){ @@ -267,8 +267,8 @@ void FluNetwork::handle(NetworkParams* params,NetworkCallable* c){ }); } -void FluNetwork::handleDownload(NetworkParams* params,NetworkCallable* c){ - QPointer callable(c); +void FluNetwork::handleDownload(FluNetworkParams* params,FluNetworkCallable* c){ + QPointer callable(c); QThreadPool::globalInstance()->start([=](){ if(!callable.isNull()){ callable->start(); @@ -433,10 +433,10 @@ QString FluNetwork::map2String(const QMap& map){ return parameters.join(" "); } -void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer callable){ +void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer callable){ QByteArray verb = params->method2String().toUtf8(); switch (params->_type) { - case NetworkParams::TYPE_FORM:{ + case FluNetworkParams::TYPE_FORM:{ bool isFormData = !params->_fileMap.isEmpty(); if(isFormData){ QHttpMultiPart *multiPart = new QHttpMultiPart(); @@ -484,7 +484,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ } break; } - case NetworkParams::TYPE_JSON:{ + case FluNetworkParams::TYPE_JSON:{ request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8")); QJsonObject json; for (const auto& each : params->_paramMap.toStdMap()) @@ -495,7 +495,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ reply = manager->sendCustomRequest(request,verb,data); break; } - case NetworkParams::TYPE_JSONARRAY:{ + case FluNetworkParams::TYPE_JSONARRAY:{ request.setHeader(QNetworkRequest::ContentTypeHeader, QString("application/json;charset=utf-8")); QJsonArray jsonArray; for (const auto& each : params->_paramMap.toStdMap()) @@ -508,7 +508,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ reply = manager->sendCustomRequest(request,params->method2String().toUtf8(),data); break; } - case NetworkParams::TYPE_BODY:{ + case FluNetworkParams::TYPE_BODY:{ request.setHeader(QNetworkRequest::ContentTypeHeader, QString("text/plain;charset=utf-8")); QByteArray data = params->_body.toUtf8(); reply = manager->sendCustomRequest(request,verb,data); @@ -523,7 +523,7 @@ void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest requ } } -void FluNetwork::printRequestStartLog(QNetworkRequest request,NetworkParams* params){ +void FluNetwork::printRequestStartLog(QNetworkRequest request,FluNetworkParams* params){ if(!params->getOpenLog()){ return; } @@ -551,7 +551,7 @@ void FluNetwork::printRequestStartLog(QNetworkRequest request,NetworkParams* par } } -void FluNetwork::printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response){ +void FluNetwork::printRequestEndLog(QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,const QString& response){ if(!params->getOpenLog()){ return; } @@ -599,76 +599,76 @@ FluNetwork::FluNetwork(QObject *parent): QObject{parent} cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation).append(QDir::separator()).append("network")); } -NetworkParams* FluNetwork::get(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_GET,this); +FluNetworkParams* FluNetwork::get(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_NONE,FluNetworkParams::METHOD_GET,this); } -NetworkParams* FluNetwork::head(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_NONE,NetworkParams::METHOD_HEAD,this); +FluNetworkParams* FluNetwork::head(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_NONE,FluNetworkParams::METHOD_HEAD,this); } -NetworkParams* FluNetwork::postBody(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_POST,this); +FluNetworkParams* FluNetwork::postBody(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_POST,this); } -NetworkParams* FluNetwork::putBody(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PUT,this); +FluNetworkParams* FluNetwork::putBody(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_PUT,this); } -NetworkParams* FluNetwork::patchBody(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_PATCH,this); +FluNetworkParams* FluNetwork::patchBody(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_PATCH,this); } -NetworkParams* FluNetwork::deleteBody(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_BODY,NetworkParams::METHOD_DELETE,this); +FluNetworkParams* FluNetwork::deleteBody(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_BODY,FluNetworkParams::METHOD_DELETE,this); } -NetworkParams* FluNetwork::postForm(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_POST,this); +FluNetworkParams* FluNetwork::postForm(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_POST,this); } -NetworkParams* FluNetwork::putForm(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PUT,this); +FluNetworkParams* FluNetwork::putForm(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_PUT,this); } -NetworkParams* FluNetwork::patchForm(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_PATCH,this); +FluNetworkParams* FluNetwork::patchForm(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_PATCH,this); } -NetworkParams* FluNetwork::deleteForm(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_FORM,NetworkParams::METHOD_DELETE,this); +FluNetworkParams* FluNetwork::deleteForm(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_FORM,FluNetworkParams::METHOD_DELETE,this); } -NetworkParams* FluNetwork::postJson(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_POST,this); +FluNetworkParams* FluNetwork::postJson(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_POST,this); } -NetworkParams* FluNetwork::putJson(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PUT,this); +FluNetworkParams* FluNetwork::putJson(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_PUT,this); } -NetworkParams* FluNetwork::patchJson(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_PATCH,this); +FluNetworkParams* FluNetwork::patchJson(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_PATCH,this); } -NetworkParams* FluNetwork::deleteJson(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_JSON,NetworkParams::METHOD_DELETE,this); +FluNetworkParams* FluNetwork::deleteJson(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_JSON,FluNetworkParams::METHOD_DELETE,this); } -NetworkParams* FluNetwork::postJsonArray(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_POST,this); +FluNetworkParams* FluNetwork::postJsonArray(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_POST,this); } -NetworkParams* FluNetwork::putJsonArray(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PUT,this); +FluNetworkParams* FluNetwork::putJsonArray(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_PUT,this); } -NetworkParams* FluNetwork::patchJsonArray(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_PATCH,this); +FluNetworkParams* FluNetwork::patchJsonArray(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_PATCH,this); } -NetworkParams* FluNetwork::deleteJsonArray(const QString& url){ - return new NetworkParams(url,NetworkParams::TYPE_JSONARRAY,NetworkParams::METHOD_DELETE,this); +FluNetworkParams* FluNetwork::deleteJsonArray(const QString& url){ + return new FluNetworkParams(url,FluNetworkParams::TYPE_JSONARRAY,FluNetworkParams::METHOD_DELETE,this); } void FluNetwork::setInterceptor(QJSValue interceptor){ diff --git a/src/FluNetwork.h b/src/FluNetwork.h index 410dc8e5..5ff67e7a 100644 --- a/src/FluNetwork.h +++ b/src/FluNetwork.h @@ -12,11 +12,14 @@ #include "stdafx.h" #include "singleton.h" -class NetworkCallable : public QObject{ +/** + * @brief The NetworkCallable class + */ +class FluNetworkCallable : public QObject{ Q_OBJECT QML_NAMED_ELEMENT(FluNetworkCallable) public: - explicit NetworkCallable(QObject *parent = nullptr); + explicit FluNetworkCallable(QObject *parent = nullptr); Q_SIGNAL void start(); Q_SIGNAL void finish(); Q_SIGNAL void error(int status,QString errorString,QString result); @@ -26,17 +29,23 @@ public: Q_SIGNAL void downloadProgress(qint64 recv, qint64 total); }; -class DownloadParam : public QObject{ +/** + * @brief The FluDownloadParam class + */ +class FluDownloadParam : public QObject{ Q_OBJECT public: - explicit DownloadParam(QObject *parent = nullptr); - DownloadParam(QString destPath,bool append,QObject *parent = nullptr); + explicit FluDownloadParam(QObject *parent = nullptr); + FluDownloadParam(QString destPath,bool append,QObject *parent = nullptr); public: QString _destPath; bool _append; }; -class NetworkParams : public QObject +/** + * @brief The FluNetworkParams class + */ +class FluNetworkParams : public QObject { Q_OBJECT QML_NAMED_ELEMENT(FluNetworkParams) @@ -56,27 +65,27 @@ public: TYPE_JSONARRAY, TYPE_BODY }; - explicit NetworkParams(QObject *parent = nullptr); - NetworkParams(QString url,Type type,Method method,QObject *parent = nullptr); - Q_INVOKABLE NetworkParams* addQuery(QString key,QVariant val); - Q_INVOKABLE NetworkParams* addHeader(QString key,QVariant val); - Q_INVOKABLE NetworkParams* add(QString key,QVariant val); - Q_INVOKABLE NetworkParams* addFile(QString key,QVariant val); - Q_INVOKABLE NetworkParams* setBody(QString val); - Q_INVOKABLE NetworkParams* setTimeout(int val); - Q_INVOKABLE NetworkParams* setRetry(int val); - Q_INVOKABLE NetworkParams* setCacheMode(int val); - Q_INVOKABLE NetworkParams* toDownload(QString destPath,bool append = false); - Q_INVOKABLE NetworkParams* bind(QObject* target); - Q_INVOKABLE NetworkParams* openLog(QVariant val); - Q_INVOKABLE void go(NetworkCallable* result); + explicit FluNetworkParams(QObject *parent = nullptr); + FluNetworkParams(QString url,Type type,Method method,QObject *parent = nullptr); + Q_INVOKABLE FluNetworkParams* addQuery(QString key,QVariant val); + Q_INVOKABLE FluNetworkParams* addHeader(QString key,QVariant val); + Q_INVOKABLE FluNetworkParams* add(QString key,QVariant val); + Q_INVOKABLE FluNetworkParams* addFile(QString key,QVariant val); + Q_INVOKABLE FluNetworkParams* setBody(QString val); + Q_INVOKABLE FluNetworkParams* setTimeout(int val); + Q_INVOKABLE FluNetworkParams* setRetry(int val); + Q_INVOKABLE FluNetworkParams* setCacheMode(int val); + Q_INVOKABLE FluNetworkParams* toDownload(QString destPath,bool append = false); + Q_INVOKABLE FluNetworkParams* bind(QObject* target); + Q_INVOKABLE FluNetworkParams* openLog(QVariant val); + Q_INVOKABLE void go(FluNetworkCallable* result); QString buildCacheKey(); QString method2String(); int getTimeout(); int getRetry(); bool getOpenLog(); public: - DownloadParam* _downloadParam = nullptr; + FluDownloadParam* _downloadParam = nullptr; QObject* _target = nullptr; Method _method; Type _type; @@ -92,6 +101,9 @@ public: int _cacheMode = FluNetworkType::CacheMode::NoCache; }; +/** + * @brief The FluNetwork class + */ class FluNetwork : public QObject { Q_OBJECT @@ -106,29 +118,29 @@ private: public: SINGLETON(FluNetwork) static FluNetwork *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();} - Q_INVOKABLE NetworkParams* get(const QString& url); - Q_INVOKABLE NetworkParams* head(const QString& url); - Q_INVOKABLE NetworkParams* postBody(const QString& url); - Q_INVOKABLE NetworkParams* putBody(const QString& url); - Q_INVOKABLE NetworkParams* patchBody(const QString& url); - Q_INVOKABLE NetworkParams* deleteBody(const QString& url); - Q_INVOKABLE NetworkParams* postForm(const QString& url); - Q_INVOKABLE NetworkParams* putForm(const QString& url); - Q_INVOKABLE NetworkParams* patchForm(const QString& url); - Q_INVOKABLE NetworkParams* deleteForm(const QString& url); - Q_INVOKABLE NetworkParams* postJson(const QString& url); - Q_INVOKABLE NetworkParams* putJson(const QString& url); - Q_INVOKABLE NetworkParams* patchJson(const QString& url); - Q_INVOKABLE NetworkParams* deleteJson(const QString& url); - Q_INVOKABLE NetworkParams* postJsonArray(const QString& url); - Q_INVOKABLE NetworkParams* putJsonArray(const QString& url); - Q_INVOKABLE NetworkParams* patchJsonArray(const QString& url); - Q_INVOKABLE NetworkParams* deleteJsonArray(const QString& url); + Q_INVOKABLE FluNetworkParams* get(const QString& url); + Q_INVOKABLE FluNetworkParams* head(const QString& url); + Q_INVOKABLE FluNetworkParams* postBody(const QString& url); + Q_INVOKABLE FluNetworkParams* putBody(const QString& url); + Q_INVOKABLE FluNetworkParams* patchBody(const QString& url); + Q_INVOKABLE FluNetworkParams* deleteBody(const QString& url); + Q_INVOKABLE FluNetworkParams* postForm(const QString& url); + Q_INVOKABLE FluNetworkParams* putForm(const QString& url); + Q_INVOKABLE FluNetworkParams* patchForm(const QString& url); + Q_INVOKABLE FluNetworkParams* deleteForm(const QString& url); + Q_INVOKABLE FluNetworkParams* postJson(const QString& url); + Q_INVOKABLE FluNetworkParams* putJson(const QString& url); + Q_INVOKABLE FluNetworkParams* patchJson(const QString& url); + Q_INVOKABLE FluNetworkParams* deleteJson(const QString& url); + Q_INVOKABLE FluNetworkParams* postJsonArray(const QString& url); + Q_INVOKABLE FluNetworkParams* putJsonArray(const QString& url); + Q_INVOKABLE FluNetworkParams* patchJsonArray(const QString& url); + Q_INVOKABLE FluNetworkParams* deleteJsonArray(const QString& url); Q_INVOKABLE void setInterceptor(QJSValue interceptor); - void handle(NetworkParams* params,NetworkCallable* result); - void handleDownload(NetworkParams* params,NetworkCallable* result); + void handle(FluNetworkParams* params,FluNetworkCallable* result); + void handleDownload(FluNetworkParams* params,FluNetworkCallable* result); private: - void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer callable); + void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer callable); void addQueryParam(QUrl* url,const QMap& params); void addHeaders(QNetworkRequest* request,const QMap& headers); void saveResponse(QString key,QString response); @@ -137,8 +149,8 @@ private: QString getCacheFilePath(const QString& key); QString map2String(const QMap& map); QString headerList2String(const QList& data); - void printRequestStartLog(QNetworkRequest request,NetworkParams* params); - void printRequestEndLog(QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,const QString& response); + void printRequestStartLog(QNetworkRequest request,FluNetworkParams* params); + void printRequestEndLog(QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,const QString& response); public: QJSValue _interceptor; }; diff --git a/src/QRCode.cpp b/src/FluQrCodeItem.cpp similarity index 76% rename from src/QRCode.cpp rename to src/FluQrCodeItem.cpp index 94c3764b..f8ccd9ed 100644 --- a/src/QRCode.cpp +++ b/src/FluQrCodeItem.cpp @@ -1,17 +1,17 @@ -#include "QRCode.h" +#include "FluQrCodeItem.h" #include "qrcode/qrencode.h" -QRCode::QRCode(QQuickItem* parent):QQuickPaintedItem(parent){ +FluQrCodeItem::FluQrCodeItem(QQuickItem* parent):QQuickPaintedItem(parent){ color(QColor(0,0,0,255)); bgColor(QColor(255,255,255,255)); size(100); setWidth(_size); setHeight(_size); - connect(this,&QRCode::textChanged,this,[=]{update();}); - connect(this,&QRCode::colorChanged,this,[=]{update();}); - connect(this,&QRCode::bgColorChanged,this,[=]{update();}); - connect(this,&QRCode::sizeChanged,this,[=]{ + connect(this,&FluQrCodeItem::textChanged,this,[=]{update();}); + connect(this,&FluQrCodeItem::colorChanged,this,[=]{update();}); + connect(this,&FluQrCodeItem::bgColorChanged,this,[=]{update();}); + connect(this,&FluQrCodeItem::sizeChanged,this,[=]{ setWidth(_size); setHeight(_size); update(); @@ -19,7 +19,7 @@ QRCode::QRCode(QQuickItem* parent):QQuickPaintedItem(parent){ } -void QRCode::paint(QPainter* painter){ +void FluQrCodeItem::paint(QPainter* painter){ if(_text.isEmpty()){ return; } diff --git a/src/QRCode.h b/src/FluQrCodeItem.h similarity index 53% rename from src/QRCode.h rename to src/FluQrCodeItem.h index 88b08bee..3e2a5814 100644 --- a/src/QRCode.h +++ b/src/FluQrCodeItem.h @@ -1,22 +1,25 @@ -#ifndef QRCODE_H -#define QRCODE_H +#ifndef FLUQRCODEITEM_H +#define FLUQRCODEITEM_H #include #include #include #include "stdafx.h" -class QRCode : public QQuickPaintedItem +/** + * @brief The FluQrCodeItem class + */ +class FluQrCodeItem : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY_AUTO(QString,text) Q_PROPERTY_AUTO(QColor,color) Q_PROPERTY_AUTO(QColor,bgColor) Q_PROPERTY_AUTO(int,size); - QML_NAMED_ELEMENT(QRCode) + QML_NAMED_ELEMENT(FluQrCodeItem) public: - explicit QRCode(QQuickItem *parent = nullptr); + explicit FluQrCodeItem(QQuickItem *parent = nullptr); void paint(QPainter* painter) override; }; -#endif // QRCODE_H +#endif // FLUQRCODEITEM_H diff --git a/src/FluRectangle.h b/src/FluRectangle.h index 51e87ebe..7a505b43 100644 --- a/src/FluRectangle.h +++ b/src/FluRectangle.h @@ -6,6 +6,9 @@ #include #include "stdafx.h" +/** + * @brief The FluRectangle class + */ class FluRectangle : public QQuickPaintedItem { Q_OBJECT diff --git a/src/FluTextStyle.h b/src/FluTextStyle.h index 6dafc45f..60736254 100644 --- a/src/FluTextStyle.h +++ b/src/FluTextStyle.h @@ -7,6 +7,9 @@ #include "stdafx.h" #include "singleton.h" +/** + * @brief The FluTextStyle class + */ class FluTextStyle : public QObject { Q_OBJECT diff --git a/src/FluTreeModel.h b/src/FluTreeModel.h index be10945f..403b43e6 100644 --- a/src/FluTreeModel.h +++ b/src/FluTreeModel.h @@ -7,6 +7,9 @@ #include #include "stdafx.h" +/** + * @brief The Node class + */ class Node : public QObject{ Q_OBJECT Q_PROPERTY(QString key READ key CONSTANT) diff --git a/src/FluViewModel.cpp b/src/FluViewModel.cpp index a8395565..8a05bfd5 100644 --- a/src/FluViewModel.cpp +++ b/src/FluViewModel.cpp @@ -3,36 +3,30 @@ #include #include "Def.h" -Model::Model(QObject *parent):QObject{parent}{ +FluViewModelManager::FluViewModelManager(QObject *parent): QObject{parent}{ } -Model::~Model(){ -} - -ViewModelManager::ViewModelManager(QObject *parent): QObject{parent}{ -} - -void ViewModelManager::insertViewModel(FluViewModel* value){ +void FluViewModelManager::insertViewModel(FluViewModel* value){ _viewmodel.append(value); } -void ViewModelManager::deleteViewModel(FluViewModel* value){ +void FluViewModelManager::deleteViewModel(FluViewModel* value){ _viewmodel.removeOne(value); } -QObject* ViewModelManager::getModel(const QString& key){ +QObject* FluViewModelManager::getModel(const QString& key){ return _data.value(key); } -void ViewModelManager::insert(const QString& key,QObject* value){ +void FluViewModelManager::insert(const QString& key,QObject* value){ _data.insert(key,value); } -bool ViewModelManager::exist(const QString& key){ +bool FluViewModelManager::exist(const QString& key){ return _data.contains(key); } -void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){ +void FluViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){ foreach (auto item, _viewmodel) { if(item->getKey() == viewModel->getKey()){ item->enablePropertyChange = false; @@ -42,32 +36,32 @@ void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVar } } -PropertyObserver::PropertyObserver(QString name,QObject* model,QObject *parent):QObject{parent}{ +FluPropertyObserver::FluPropertyObserver(QString name,QObject* model,QObject *parent):QObject{parent}{ _name = name; _model = model; _property = QQmlProperty(parent,_name); _property.connectNotifySignal(this,SLOT(_propertyChange())); } -PropertyObserver::~PropertyObserver(){ +FluPropertyObserver::~FluPropertyObserver(){ } -void PropertyObserver::_propertyChange(){ +void FluPropertyObserver::_propertyChange(){ auto viewModel = (FluViewModel*)parent(); if(viewModel->enablePropertyChange){ auto value = _property.read(); _model->setProperty(_name.toLatin1().constData(),value); - ViewModelManager::getInstance()->refreshViewModel(viewModel,_name,value); + FluViewModelManager::getInstance()->refreshViewModel(viewModel,_name,value); } } FluViewModel::FluViewModel(QObject *parent):QObject{parent}{ scope(FluViewModelType::Scope::Window); - ViewModelManager::getInstance()->insertViewModel(this); + FluViewModelManager::getInstance()->insertViewModel(this); } FluViewModel::~FluViewModel(){ - ViewModelManager::getInstance()->deleteViewModel(this); + FluViewModelManager::getInstance()->deleteViewModel(this); } void FluViewModel::classBegin(){ @@ -86,11 +80,11 @@ void FluViewModel::componentComplete(){ _key = property("objectName").toString(); } QObject * model; - if(!ViewModelManager::getInstance()->exist(_key)){ + if(!FluViewModelManager::getInstance()->exist(_key)){ if(_scope == FluViewModelType::Scope::Window){ - model = new Model(_window); + model = new QObject(_window); }else{ - model = new Model(); + model = new QObject(); } Q_EMIT initData(); for (int i = 0; i < obj->propertyCount(); ++i) { @@ -98,15 +92,15 @@ void FluViewModel::componentComplete(){ QString propertyName = property.name(); auto value = property.read(this); model->setProperty(propertyName.toLatin1().constData(),value); - new PropertyObserver(propertyName,model,this); + new FluPropertyObserver(propertyName,model,this); } - ViewModelManager::getInstance()->insert(_key,model); + FluViewModelManager::getInstance()->insert(_key,model); }else{ - model = ViewModelManager::getInstance()->getModel(_key); + model = FluViewModelManager::getInstance()->getModel(_key); for (int i = 0; i < obj->propertyCount(); ++i) { const QMetaProperty property = obj->property(i); QString propertyName = property.name(); - new PropertyObserver(propertyName,model,this); + new FluPropertyObserver(propertyName,model,this); } } foreach (auto key, model->dynamicPropertyNames()) { diff --git a/src/FluViewModel.h b/src/FluViewModel.h index c82c1661..4f90d50e 100644 --- a/src/FluViewModel.h +++ b/src/FluViewModel.h @@ -8,13 +8,9 @@ #include "stdafx.h" #include "singleton.h" -class Model : public QObject{ - Q_OBJECT -public: - explicit Model(QObject *parent = nullptr); - ~Model(); -}; - +/** + * @brief The FluViewModel class + */ class FluViewModel : public QObject, public QQmlParserStatus { Q_OBJECT @@ -34,11 +30,14 @@ private: QString _key = ""; }; -class PropertyObserver: public QObject{ +/** + * @brief The FluPropertyObserver class + */ +class FluPropertyObserver: public QObject{ Q_OBJECT public: - explicit PropertyObserver(QString name,QObject* model,QObject *parent = nullptr); - ~PropertyObserver(); + explicit FluPropertyObserver(QString name,QObject* model,QObject *parent = nullptr); + ~FluPropertyObserver(); private: Q_SLOT void _propertyChange(); private: @@ -47,13 +46,15 @@ private: QObject* _model = nullptr; }; - -class ViewModelManager:public QObject{ +/** + * @brief The FluViewModelManager class + */ +class FluViewModelManager:public QObject{ Q_OBJECT private: - explicit ViewModelManager(QObject *parent = nullptr); + explicit FluViewModelManager(QObject *parent = nullptr); public: - SINGLETON(ViewModelManager) + SINGLETON(FluViewModelManager) bool exist(const QString& key); void insert(const QString& key,QObject* value); QObject* getModel(const QString& key); diff --git a/src/FluWatermark.h b/src/FluWatermark.h index b5ee166d..26381047 100644 --- a/src/FluWatermark.h +++ b/src/FluWatermark.h @@ -6,6 +6,9 @@ #include #include "stdafx.h" +/** + * @brief The FluWatermark class + */ class FluWatermark : public QQuickPaintedItem { Q_OBJECT @@ -19,7 +22,6 @@ class FluWatermark : public QQuickPaintedItem public: explicit FluWatermark(QQuickItem *parent = nullptr); void paint(QPainter* painter) override; - }; #endif // FLUWATERMARK_H diff --git a/src/FluWindowLifecycle.cpp b/src/FluWindowLifecycle.cpp new file mode 100644 index 00000000..c12e4c44 --- /dev/null +++ b/src/FluWindowLifecycle.cpp @@ -0,0 +1,33 @@ +#include "FluWindowLifecycle.h" + +#include "FluApp.h" +#include "FluRegister.h" + +FluWindowLifecycle::FluWindowLifecycle(QObject *parent):QObject{parent}{ + +} + +void FluWindowLifecycle::onCompleted(QQuickWindow* window){ + this->_window = window; + FluApp::getInstance()->addWindow(this->_window); +} + +void FluWindowLifecycle::onDestoryOnClose(){ + if(_window){ + FluApp::getInstance()->removeWindow(this->_window); + _window = nullptr; + } +} + +void FluWindowLifecycle::onDestruction(){ +} + +void FluWindowLifecycle::onVisible(bool visible){ +} + +QVariant FluWindowLifecycle::createRegister(QQuickWindow* window,const QString& path){ + FluRegister *p = new FluRegister(window); + p->from(window); + p->path(path); + return QVariant::fromValue(p); +} diff --git a/src/WindowLifecycle.h b/src/FluWindowLifecycle.h similarity index 63% rename from src/WindowLifecycle.h rename to src/FluWindowLifecycle.h index f8a1f0da..9c6643d2 100644 --- a/src/WindowLifecycle.h +++ b/src/FluWindowLifecycle.h @@ -1,5 +1,5 @@ -#ifndef WINDOWLIFECYCLE_H -#define WINDOWLIFECYCLE_H +#ifndef FLUWINDOWLIFECYCLE_H +#define FLUWINDOWLIFECYCLE_H #include #include @@ -9,14 +9,14 @@ #include /** - * @brief The WindowLifecycle class + * @brief The FluWindowLifecycle class */ -class WindowLifecycle : public QObject +class FluWindowLifecycle : public QObject { Q_OBJECT - QML_NAMED_ELEMENT(WindowLifecycle) + QML_NAMED_ELEMENT(FluWindowLifecycle) public: - explicit WindowLifecycle(QObject *parent = nullptr); + explicit FluWindowLifecycle(QObject *parent = nullptr); Q_INVOKABLE void onCompleted(QQuickWindow* window); Q_INVOKABLE void onDestruction(); Q_INVOKABLE void onVisible(bool visible); @@ -26,4 +26,4 @@ private: QQuickWindow* _window = nullptr; }; -#endif // WINDOWLIFECYCLE_H +#endif // FLUWINDOWLIFECYCLE_H diff --git a/src/FluentUI.cpp b/src/FluentUI.cpp index da76f39d..e7417927 100644 --- a/src/FluentUI.cpp +++ b/src/FluentUI.cpp @@ -1,7 +1,7 @@ #include "FluentUI.h" #include -#include "WindowLifecycle.h" +#include "FluWindowLifecycle.h" #include "Def.h" #include "FluApp.h" #include "FluColors.h" @@ -16,7 +16,7 @@ #include "FluRectangle.h" #include "FluNetwork.h" #include "FluFramelessHelper.h" -#include "QRCode.h" +#include "FluQrCodeItem.h" void FluentUI::registerTypes(QQmlEngine *engine){ initializeEngine(engine,uri); @@ -27,8 +27,8 @@ void FluentUI::registerTypes(const char *uri){ #if (QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) Q_INIT_RESOURCE(fluentui); #endif - qmlRegisterType(uri,major,minor,"WindowLifecycle"); - qmlRegisterType(uri,major,minor,"QRCode"); + qmlRegisterType(uri,major,minor,"FluWindowLifecycle"); + qmlRegisterType(uri,major,minor,"FluQrCodeItem"); qmlRegisterType(uri,major,minor,"FluCaptcha"); qmlRegisterType(uri,major,minor,"FluWatermark"); qmlRegisterType(uri,major,minor,"FluColorSet"); @@ -36,8 +36,8 @@ void FluentUI::registerTypes(const char *uri){ qmlRegisterType(uri,major,minor,"FluViewModel"); qmlRegisterType(uri,major,minor,"FluTreeModel"); qmlRegisterType(uri,major,minor,"FluRectangle"); - qmlRegisterType(uri,major,minor,"FluNetworkCallable"); - qmlRegisterType(uri,major,minor,"FluNetworkParams"); + qmlRegisterType(uri,major,minor,"FluNetworkCallable"); + qmlRegisterType(uri,major,minor,"FluNetworkParams"); qmlRegisterType(uri,major,minor,"FluFramelessHelper"); qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/ColorPicker.qml"),uri,major,minor,"ColorPicker"); diff --git a/src/FluentUI.h b/src/FluentUI.h index b9c4977c..caf6c664 100644 --- a/src/FluentUI.h +++ b/src/FluentUI.h @@ -5,6 +5,9 @@ #include #include "singleton.h" +/** + * @brief The FluentUI class + */ class FluentUI : public QObject { Q_OBJECT diff --git a/src/MainThread.cpp b/src/MainThread.cpp deleted file mode 100644 index 33936ffe..00000000 --- a/src/MainThread.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "MainThread.h" -#include -#include - -std::shared_ptr MainThread::createShared(QObject* bindObject){ - return std::shared_ptr(new MainThread(bindObject), [=](QObject* mainThread) { - mainThread->deleteLater(); - }); -} - -MainThread::MainThread(QObject* bindObject): _bindObject(bindObject), _ignoreNullObject(bindObject == nullptr){ - qRegisterMetaType>("std::function"); - auto mainUIThread = qApp->thread(); - if (this->thread() != mainUIThread) - { - this->moveToThread(mainUIThread); - } -} - -MainThread::~MainThread(){ -} - -void MainThread::post(std::function func){ - QMetaObject::invokeMethod(createShared().get(), "mainThreadSlot", Q_ARG(std::function, func)); -} - -void MainThread::mainThreadSlot(std::function func){ - if ((_ignoreNullObject || _bindObject) && func) - { - func(); - } -} diff --git a/src/MainThread.h b/src/MainThread.h deleted file mode 100644 index 6e77eaa5..00000000 --- a/src/MainThread.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAINTHREAD_H -#define MAINTHREAD_H - -#include -#include -#include - -class MainThread : public QObject -{ - Q_OBJECT -public: - static void post(std::function func); - ~MainThread(); -private: - static std::shared_ptr createShared(QObject* bindObject = nullptr); -private slots: - void mainThreadSlot(std::function func); -private: - MainThread(QObject* bindObject = nullptr); - QPointer _bindObject; - bool _ignoreNullObject{ false }; -}; -#endif // MAINTHREAD_H diff --git a/src/Qt5/imports/FluentUI/Controls/FluQRCode.qml b/src/Qt5/imports/FluentUI/Controls/FluQRCode.qml index c7a8f287..498942d4 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluQRCode.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluQRCode.qml @@ -15,7 +15,7 @@ Item{ color: bgColor anchors.fill: parent } - QRCode{ + FluQrCodeItem{ id:qrcode size:control.size-margins anchors.centerIn: parent diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index ea29d9de..38e7766d 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -259,7 +259,7 @@ Window { id:infoBar root: window } - WindowLifecycle{ + FluWindowLifecycle{ id:lifecycle } Rectangle{ diff --git a/src/Qt5/imports/FluentUI/plugins.qmltypes b/src/Qt5/imports/FluentUI/plugins.qmltypes index 8635b3e2..dd0bdc5e 100644 --- a/src/Qt5/imports/FluentUI/plugins.qmltypes +++ b/src/Qt5/imports/FluentUI/plugins.qmltypes @@ -105,6 +105,113 @@ Module { } } } + Component { + name: "FluNetworkCallable" + prototype: "QObject" + exports: ["FluentUI/FluNetworkCallable 1.0"] + exportMetaObjectRevisions: [0] + Signal { name: "start" } + Signal { name: "finish" } + Signal { + name: "error" + Parameter { name: "status"; type: "int" } + Parameter { name: "errorString"; type: "string" } + Parameter { name: "result"; type: "string" } + } + Signal { + name: "success" + Parameter { name: "result"; type: "string" } + } + Signal { + name: "cache" + Parameter { name: "result"; type: "string" } + } + Signal { + name: "uploadProgress" + Parameter { name: "sent"; type: "qlonglong" } + Parameter { name: "total"; type: "qlonglong" } + } + Signal { + name: "downloadProgress" + Parameter { name: "recv"; type: "qlonglong" } + Parameter { name: "total"; type: "qlonglong" } + } + } + Component { + name: "FluNetworkParams" + prototype: "QObject" + exports: ["FluentUI/FluNetworkParams 1.0"] + exportMetaObjectRevisions: [0] + Method { + name: "addQuery" + type: "FluNetworkParams*" + Parameter { name: "key"; type: "string" } + Parameter { name: "val"; type: "QVariant" } + } + Method { + name: "addHeader" + type: "FluNetworkParams*" + Parameter { name: "key"; type: "string" } + Parameter { name: "val"; type: "QVariant" } + } + Method { + name: "add" + type: "FluNetworkParams*" + Parameter { name: "key"; type: "string" } + Parameter { name: "val"; type: "QVariant" } + } + Method { + name: "addFile" + type: "FluNetworkParams*" + Parameter { name: "key"; type: "string" } + Parameter { name: "val"; type: "QVariant" } + } + Method { + name: "setBody" + type: "FluNetworkParams*" + Parameter { name: "val"; type: "string" } + } + Method { + name: "setTimeout" + type: "FluNetworkParams*" + Parameter { name: "val"; type: "int" } + } + Method { + name: "setRetry" + type: "FluNetworkParams*" + Parameter { name: "val"; type: "int" } + } + Method { + name: "setCacheMode" + type: "FluNetworkParams*" + Parameter { name: "val"; type: "int" } + } + Method { + name: "toDownload" + type: "FluNetworkParams*" + Parameter { name: "destPath"; type: "string" } + Parameter { name: "append"; type: "bool" } + } + Method { + name: "toDownload" + type: "FluNetworkParams*" + Parameter { name: "destPath"; type: "string" } + } + Method { + name: "bind" + type: "FluNetworkParams*" + Parameter { name: "target"; type: "QObject"; isPointer: true } + } + Method { + name: "openLog" + type: "FluNetworkParams*" + Parameter { name: "val"; type: "QVariant" } + } + Method { + name: "go" + Parameter { name: "result"; type: "FluNetworkCallable"; isPointer: true } + } + } Component { name: "FluNetworkType" exports: ["FluentUI/FluNetworkType 1.0"] @@ -135,6 +242,17 @@ Module { } } } + Component { + name: "FluQrCodeItem" + defaultProperty: "data" + prototype: "QQuickPaintedItem" + exports: ["FluentUI/FluQrCodeItem 1.0"] + exportMetaObjectRevisions: [0] + Property { name: "text"; type: "string" } + Property { name: "color"; type: "QColor" } + Property { name: "bgColor"; type: "QColor" } + Property { name: "size"; type: "int" } + } Component { name: "FluRectangle" defaultProperty: "data" @@ -336,6 +454,28 @@ Module { Property { name: "rotate"; type: "int" } Property { name: "textSize"; type: "int" } } + Component { + name: "FluWindowLifecycle" + prototype: "QObject" + exports: ["FluentUI/FluWindowLifecycle 1.0"] + exportMetaObjectRevisions: [0] + Method { + name: "onCompleted" + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + } + Method { name: "onDestruction" } + Method { + name: "onVisible" + Parameter { name: "visible"; type: "bool" } + } + Method { name: "onDestoryOnClose" } + Method { + name: "createRegister" + type: "QVariant" + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + Parameter { name: "path"; type: "string" } + } + } Component { name: "FluWindowType" exports: ["FluentUI/FluWindowType 1.0"] @@ -1764,113 +1904,6 @@ Module { } } } - Component { - name: "NetworkCallable" - prototype: "QObject" - exports: ["FluentUI/FluNetworkCallable 1.0"] - exportMetaObjectRevisions: [0] - Signal { name: "start" } - Signal { name: "finish" } - Signal { - name: "error" - Parameter { name: "status"; type: "int" } - Parameter { name: "errorString"; type: "string" } - Parameter { name: "result"; type: "string" } - } - Signal { - name: "success" - Parameter { name: "result"; type: "string" } - } - Signal { - name: "cache" - Parameter { name: "result"; type: "string" } - } - Signal { - name: "uploadProgress" - Parameter { name: "sent"; type: "qlonglong" } - Parameter { name: "total"; type: "qlonglong" } - } - Signal { - name: "downloadProgress" - Parameter { name: "recv"; type: "qlonglong" } - Parameter { name: "total"; type: "qlonglong" } - } - } - Component { - name: "NetworkParams" - prototype: "QObject" - exports: ["FluentUI/FluNetworkParams 1.0"] - exportMetaObjectRevisions: [0] - Method { - name: "addQuery" - type: "NetworkParams*" - Parameter { name: "key"; type: "string" } - Parameter { name: "val"; type: "QVariant" } - } - Method { - name: "addHeader" - type: "NetworkParams*" - Parameter { name: "key"; type: "string" } - Parameter { name: "val"; type: "QVariant" } - } - Method { - name: "add" - type: "NetworkParams*" - Parameter { name: "key"; type: "string" } - Parameter { name: "val"; type: "QVariant" } - } - Method { - name: "addFile" - type: "NetworkParams*" - Parameter { name: "key"; type: "string" } - Parameter { name: "val"; type: "QVariant" } - } - Method { - name: "setBody" - type: "NetworkParams*" - Parameter { name: "val"; type: "string" } - } - Method { - name: "setTimeout" - type: "NetworkParams*" - Parameter { name: "val"; type: "int" } - } - Method { - name: "setRetry" - type: "NetworkParams*" - Parameter { name: "val"; type: "int" } - } - Method { - name: "setCacheMode" - type: "NetworkParams*" - Parameter { name: "val"; type: "int" } - } - Method { - name: "toDownload" - type: "NetworkParams*" - Parameter { name: "destPath"; type: "string" } - Parameter { name: "append"; type: "bool" } - } - Method { - name: "toDownload" - type: "NetworkParams*" - Parameter { name: "destPath"; type: "string" } - } - Method { - name: "bind" - type: "NetworkParams*" - Parameter { name: "target"; type: "QObject"; isPointer: true } - } - Method { - name: "openLog" - type: "NetworkParams*" - Parameter { name: "val"; type: "QVariant" } - } - Method { - name: "go" - Parameter { name: "result"; type: "NetworkCallable"; isPointer: true } - } - } Component { name: "QAbstractItemModel" prototype: "QObject" @@ -2144,39 +2177,6 @@ Module { Parameter { name: "value"; type: "QVariant" } } } - Component { - name: "QRCode" - defaultProperty: "data" - prototype: "QQuickPaintedItem" - exports: ["FluentUI/QRCode 1.0"] - exportMetaObjectRevisions: [0] - Property { name: "text"; type: "string" } - Property { name: "color"; type: "QColor" } - Property { name: "bgColor"; type: "QColor" } - Property { name: "size"; type: "int" } - } - Component { - name: "WindowLifecycle" - prototype: "QObject" - exports: ["FluentUI/WindowLifecycle 1.0"] - exportMetaObjectRevisions: [0] - Method { - name: "onCompleted" - Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } - } - Method { name: "onDestruction" } - Method { - name: "onVisible" - Parameter { name: "visible"; type: "bool" } - } - Method { name: "onDestoryOnClose" } - Method { - name: "createRegister" - type: "QVariant" - Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } - Parameter { name: "path"; type: "string" } - } - } Component { prototype: "QQuickGrid" name: "FluentUI/Checkerboard 1.0" @@ -2187,7 +2187,7 @@ Module { Property { name: "cellSide"; type: "int" } } Component { - prototype: "QQuickRectangle" + prototype: "QQuickItem" name: "FluentUI/ColorPicker 1.0" exports: ["FluentUI/ColorPicker 1.0"] exportMetaObjectRevisions: [0] @@ -2293,18 +2293,50 @@ Module { Property { name: "iconSize"; type: "int" } Property { name: "isMac"; type: "bool" } Property { name: "borerlessColor"; type: "QColor" } + Property { name: "systemMoveEnable"; type: "bool" } Property { name: "maxClickListener"; type: "QVariant" } Property { name: "minClickListener"; type: "QVariant" } Property { name: "closeClickListener"; type: "QVariant" } Property { name: "stayTopClickListener"; type: "QVariant" } Property { name: "darkClickListener"; type: "QVariant" } Property { name: "systemMenuListener"; type: "QVariant" } - Method { name: "stayTopButton"; type: "QVariant" } - Method { name: "minimizeButton"; type: "QVariant" } - Method { name: "maximizeButton"; type: "QVariant" } - Method { name: "closeButton"; type: "QVariant" } - Method { name: "darkButton"; type: "QVariant" } - Method { name: "maximizeButtonHover"; type: "QVariant" } + Property { + name: "buttonStayTop" + type: "FluIconButton_QMLTYPE_26" + isReadonly: true + isPointer: true + } + Property { + name: "buttonMinimize" + type: "FluIconButton_QMLTYPE_26" + isReadonly: true + isPointer: true + } + Property { + name: "buttonMaximize" + type: "FluIconButton_QMLTYPE_26" + isReadonly: true + isPointer: true + } + Property { + name: "buttonClose" + type: "FluIconButton_QMLTYPE_26" + isReadonly: true + isPointer: true + } + Property { + name: "buttonDark" + type: "FluToggleSwitch_QMLTYPE_31" + isReadonly: true + isPointer: true + } + Method { name: "_maximizeButtonHover"; type: "QVariant" } + Method { name: "_appBarHover"; type: "QVariant" } + Method { + name: "setHitTestVisible" + type: "QVariant" + Parameter { name: "id"; type: "QVariant" } + } } Component { prototype: "QQuickRectangle" @@ -2972,20 +3004,33 @@ Module { defaultProperty: "data" Property { name: "logo"; type: "QUrl" } Property { name: "title"; type: "string" } - Property { name: "items"; type: "FluObject_QMLTYPE_156"; isPointer: true } - Property { name: "footerItems"; type: "FluObject_QMLTYPE_156"; isPointer: true } + Property { name: "items"; type: "FluObject_QMLTYPE_163"; isPointer: true } + Property { name: "footerItems"; type: "FluObject_QMLTYPE_163"; isPointer: true } Property { name: "displayMode"; type: "int" } Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true } Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true } Property { name: "topPadding"; type: "int" } Property { name: "pageMode"; type: "int" } - Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_49"; isPointer: true } - Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_49"; isPointer: true } + Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_51"; isPointer: true } + Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_51"; isPointer: true } Property { name: "navCompactWidth"; type: "int" } Property { name: "navTopMargin"; type: "int" } Property { name: "cellHeight"; type: "int" } Property { name: "cellWidth"; type: "int" } Property { name: "hideNavAppBar"; type: "bool" } + Property { + name: "buttonMenu" + type: "FluIconButton_QMLTYPE_26" + isReadonly: true + isPointer: true + } + Property { + name: "buttonBack" + type: "FluIconButton_QMLTYPE_26" + isReadonly: true + isPointer: true + } + Property { name: "imageLogo"; type: "QQuickImage"; isReadonly: true; isPointer: true } Signal { name: "logoClicked" } Method { name: "collapseAll"; type: "QVariant" } Method { @@ -3007,9 +3052,6 @@ Module { type: "QVariant" Parameter { name: "data"; type: "QVariant" } } - Method { name: "backButton"; type: "QVariant" } - Method { name: "navButton"; type: "QVariant" } - Method { name: "logoButton"; type: "QVariant" } } Component { prototype: "QObject" diff --git a/src/Qt6/imports/FluentUI/Controls/FluQRCode.qml b/src/Qt6/imports/FluentUI/Controls/FluQRCode.qml index 60bfcc77..9a6428b4 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluQRCode.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluQRCode.qml @@ -15,7 +15,7 @@ Item{ color: bgColor anchors.fill: parent } - QRCode{ + FluQrCodeItem{ id:qrcode size:control.size-margins anchors.centerIn: parent diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index d5c672f3..3d8b2f81 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -254,7 +254,7 @@ Window { id:infoBar root: window } - WindowLifecycle{ + FluWindowLifecycle{ id:lifecycle } Rectangle{ diff --git a/src/WindowLifecycle.cpp b/src/WindowLifecycle.cpp deleted file mode 100644 index 85f04a3e..00000000 --- a/src/WindowLifecycle.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "WindowLifecycle.h" - -#include "FluApp.h" -#include "FluRegister.h" - -WindowLifecycle::WindowLifecycle(QObject *parent):QObject{parent}{ - -} - -void WindowLifecycle::onCompleted(QQuickWindow* window){ - this->_window = window; - FluApp::getInstance()->addWindow(this->_window); -} - -void WindowLifecycle::onDestoryOnClose(){ - if(_window){ - FluApp::getInstance()->removeWindow(this->_window); - _window = nullptr; - } -} - -void WindowLifecycle::onDestruction(){ -} - -void WindowLifecycle::onVisible(bool visible){ -} - -QVariant WindowLifecycle::createRegister(QQuickWindow* window,const QString& path){ - FluRegister *p = new FluRegister(window); - p->from(window); - p->path(path); - return QVariant::fromValue(p); -} diff --git a/src/fluentuiplugin.h b/src/fluentuiplugin.h index 7cd6542e..d87b9b3f 100644 --- a/src/fluentuiplugin.h +++ b/src/fluentuiplugin.h @@ -3,6 +3,9 @@ #include +/** + * @brief The FluentUIPlugin class + */ class FluentUIPlugin : public QQmlExtensionPlugin { Q_OBJECT diff --git a/src/singleton.h b/src/singleton.h index 5c6480c1..a0fcdd8e 100644 --- a/src/singleton.h +++ b/src/singleton.h @@ -3,6 +3,9 @@ #include +/** + * @brief The Singleton class + */ template class Singleton { public: