This commit is contained in:
朱子楚\zhuzi 2024-02-27 12:23:24 +08:00
parent fce7f8c40c
commit 6749e47c22
29 changed files with 466 additions and 441 deletions

View File

@ -10,19 +10,14 @@
#include <QClipboard>
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 "<<route;
qCritical()<<"Not Found Route "<<route;
return;
}
QQmlEngine *engine = qmlEngine(_application);
QQmlComponent component(engine, routes().value(route).toString());
QQmlComponent component(_engine, routes().value(route).toString());
if (component.isError()) {
qCritical() << component.errors();
return;

View File

@ -18,7 +18,6 @@
class FluApp : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(bool,vsync)
Q_PROPERTY_AUTO(QString,initialRoute);
Q_PROPERTY_AUTO(QJsonObject,routes);
Q_PROPERTY_AUTO(bool,useSystemAppBar);
@ -33,13 +32,13 @@ public:
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void run();
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
Q_INVOKABLE void init(QObject *window);
Q_INVOKABLE void init(QObject *target);
Q_INVOKABLE void exit(int retCode = 0);
void addWindow(QQuickWindow* window);
void removeWindow(QQuickWindow* window);
private:
QMap<quint64, QQuickWindow*> _windows;
QObject* _application = nullptr;
QQmlEngine *_engine;
};
#endif // FLUAPP_H

View File

@ -6,6 +6,9 @@
#include <QPainter>
#include "stdafx.h"
/**
* @brief The FluCaptcha class
*/
class FluCaptcha : public QQuickPaintedItem
{
Q_OBJECT

View File

@ -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<QString, QVariant> data);
};
/**
* @brief The FluEventBus class
*/
class FluEventBus : public QObject
{
Q_OBJECT

View File

@ -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

View File

@ -18,11 +18,11 @@
#include <QEventLoop>
#include <QGuiApplication>
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<<qjsEngine(callable)->newQObject(this);
FluNetwork::getInstance()->_interceptor.call(data);
@ -172,8 +172,8 @@ void NetworkParams::go(NetworkCallable* callable){
}
}
void FluNetwork::handle(NetworkParams* params,NetworkCallable* c){
QPointer<NetworkCallable> callable(c);
void FluNetwork::handle(FluNetworkParams* params,FluNetworkCallable* c){
QPointer<FluNetworkCallable> 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<NetworkCallable> callable(c);
void FluNetwork::handleDownload(FluNetworkParams* params,FluNetworkCallable* c){
QPointer<FluNetworkCallable> callable(c);
QThreadPool::globalInstance()->start([=](){
if(!callable.isNull()){
callable->start();
@ -433,10 +433,10 @@ QString FluNetwork::map2String(const QMap<QString, QVariant>& map){
return parameters.join(" ");
}
void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,NetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<NetworkCallable> callable){
void FluNetwork::sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<FluNetworkCallable> 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){

View File

@ -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<NetworkCallable> callable);
void sendRequest(QNetworkAccessManager* manager,QNetworkRequest request,FluNetworkParams* params,QNetworkReply*& reply,bool isFirst,QPointer<FluNetworkCallable> callable);
void addQueryParam(QUrl* url,const QMap<QString, QVariant>& params);
void addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>& headers);
void saveResponse(QString key,QString response);
@ -137,8 +149,8 @@ private:
QString getCacheFilePath(const QString& key);
QString map2String(const QMap<QString, QVariant>& map);
QString headerList2String(const QList<QNetworkReply::RawHeaderPair>& 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;
};

View File

@ -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;
}

View File

@ -1,22 +1,25 @@
#ifndef QRCODE_H
#define QRCODE_H
#ifndef FLUQRCODEITEM_H
#define FLUQRCODEITEM_H
#include <QQuickItem>
#include <QQuickPaintedItem>
#include <QPainter>
#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

View File

@ -6,6 +6,9 @@
#include <QPainter>
#include "stdafx.h"
/**
* @brief The FluRectangle class
*/
class FluRectangle : public QQuickPaintedItem
{
Q_OBJECT

View File

@ -7,6 +7,9 @@
#include "stdafx.h"
#include "singleton.h"
/**
* @brief The FluTextStyle class
*/
class FluTextStyle : public QObject
{
Q_OBJECT

View File

@ -7,6 +7,9 @@
#include <QtQml/qqml.h>
#include "stdafx.h"
/**
* @brief The Node class
*/
class Node : public QObject{
Q_OBJECT
Q_PROPERTY(QString key READ key CONSTANT)

View File

@ -3,36 +3,30 @@
#include <QQuickItem>
#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()) {

View File

@ -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);

View File

@ -6,6 +6,9 @@
#include <QPainter>
#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

View File

@ -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);
}

View File

@ -1,5 +1,5 @@
#ifndef WINDOWLIFECYCLE_H
#define WINDOWLIFECYCLE_H
#ifndef FLUWINDOWLIFECYCLE_H
#define FLUWINDOWLIFECYCLE_H
#include <QObject>
#include <QQuickWindow>
@ -9,14 +9,14 @@
#include <QJsonObject>
/**
* @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

View File

@ -1,7 +1,7 @@
#include "FluentUI.h"
#include <QGuiApplication>
#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<WindowLifecycle>(uri,major,minor,"WindowLifecycle");
qmlRegisterType<QRCode>(uri,major,minor,"QRCode");
qmlRegisterType<FluWindowLifecycle>(uri,major,minor,"FluWindowLifecycle");
qmlRegisterType<FluQrCodeItem>(uri,major,minor,"FluQrCodeItem");
qmlRegisterType<FluCaptcha>(uri,major,minor,"FluCaptcha");
qmlRegisterType<FluWatermark>(uri,major,minor,"FluWatermark");
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
@ -36,8 +36,8 @@ void FluentUI::registerTypes(const char *uri){
qmlRegisterType<FluViewModel>(uri,major,minor,"FluViewModel");
qmlRegisterType<FluTreeModel>(uri,major,minor,"FluTreeModel");
qmlRegisterType<FluRectangle>(uri,major,minor,"FluRectangle");
qmlRegisterType<NetworkCallable>(uri,major,minor,"FluNetworkCallable");
qmlRegisterType<NetworkParams>(uri,major,minor,"FluNetworkParams");
qmlRegisterType<FluNetworkCallable>(uri,major,minor,"FluNetworkCallable");
qmlRegisterType<FluNetworkParams>(uri,major,minor,"FluNetworkParams");
qmlRegisterType<FluFramelessHelper>(uri,major,minor,"FluFramelessHelper");
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/ColorPicker/ColorPicker.qml"),uri,major,minor,"ColorPicker");

View File

@ -5,6 +5,9 @@
#include <QQmlEngine>
#include "singleton.h"
/**
* @brief The FluentUI class
*/
class FluentUI : public QObject
{
Q_OBJECT

View File

@ -1,32 +0,0 @@
#include "MainThread.h"
#include <QGuiApplication>
#include <QMetaMethod>
std::shared_ptr<MainThread> MainThread::createShared(QObject* bindObject){
return std::shared_ptr<MainThread>(new MainThread(bindObject), [=](QObject* mainThread) {
mainThread->deleteLater();
});
}
MainThread::MainThread(QObject* bindObject): _bindObject(bindObject), _ignoreNullObject(bindObject == nullptr){
qRegisterMetaType<std::function<void()>>("std::function<void()>");
auto mainUIThread = qApp->thread();
if (this->thread() != mainUIThread)
{
this->moveToThread(mainUIThread);
}
}
MainThread::~MainThread(){
}
void MainThread::post(std::function<void()> func){
QMetaObject::invokeMethod(createShared().get(), "mainThreadSlot", Q_ARG(std::function<void()>, func));
}
void MainThread::mainThreadSlot(std::function<void()> func){
if ((_ignoreNullObject || _bindObject) && func)
{
func();
}
}

View File

@ -1,23 +0,0 @@
#ifndef MAINTHREAD_H
#define MAINTHREAD_H
#include <QObject>
#include <QPointer>
#include <QDebug>
class MainThread : public QObject
{
Q_OBJECT
public:
static void post(std::function<void()> func);
~MainThread();
private:
static std::shared_ptr<MainThread> createShared(QObject* bindObject = nullptr);
private slots:
void mainThreadSlot(std::function<void()> func);
private:
MainThread(QObject* bindObject = nullptr);
QPointer<QObject> _bindObject;
bool _ignoreNullObject{ false };
};
#endif // MAINTHREAD_H

View File

@ -15,7 +15,7 @@ Item{
color: bgColor
anchors.fill: parent
}
QRCode{
FluQrCodeItem{
id:qrcode
size:control.size-margins
anchors.centerIn: parent

View File

@ -259,7 +259,7 @@ Window {
id:infoBar
root: window
}
WindowLifecycle{
FluWindowLifecycle{
id:lifecycle
}
Rectangle{

View File

@ -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"

View File

@ -15,7 +15,7 @@ Item{
color: bgColor
anchors.fill: parent
}
QRCode{
FluQrCodeItem{
id:qrcode
size:control.size-margins
anchors.centerIn: parent

View File

@ -254,7 +254,7 @@ Window {
id:infoBar
root: window
}
WindowLifecycle{
FluWindowLifecycle{
id:lifecycle
}
Rectangle{

View File

@ -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);
}

View File

@ -3,6 +3,9 @@
#include <QQmlExtensionPlugin>
/**
* @brief The FluentUIPlugin class
*/
class FluentUIPlugin : public QQmlExtensionPlugin
{
Q_OBJECT

View File

@ -3,6 +3,9 @@
#include <QMutex>
/**
* @brief The Singleton class
*/
template <typename T>
class Singleton {
public: