From ed5956d8244cfc56d4de1d8a71203354abe3c015 Mon Sep 17 00:00:00 2001 From: zhuzichu Date: Wed, 6 Sep 2023 14:05:29 +0800 Subject: [PATCH] update --- example/qml-Qt6/page/T_Http.qml | 70 ++++++++- example/qml/page/T_Http.qml | 71 ++++++++- example/src/main.cpp | 2 +- src/FluHttp.cpp | 123 ++++++++------- src/FluHttp.h | 4 +- src/FluTools.cpp | 22 +++ src/FluTools.h | 13 ++ src/Qt5/imports/FluentUI/plugins.qmltypes | 178 +++++++++++++++------- 8 files changed, 375 insertions(+), 108 deletions(-) diff --git a/example/qml-Qt6/page/T_Http.qml b/example/qml-Qt6/page/T_Http.qml index 1ca46ff0..6360fc75 100644 --- a/example/qml-Qt6/page/T_Http.qml +++ b/example/qml-Qt6/page/T_Http.qml @@ -17,6 +17,12 @@ FluContentPage{ cacheDir:cacheDirPath } + FluHttp{ + id:http_breakpoint_download + cacheDir:cacheDirPath + breakPointDownload: true + } + FluHttp{ id:http_cache_ifnonecacherequest cacheMode:FluHttpType.IfNoneCacheRequest @@ -125,6 +131,45 @@ FluContentPage{ folder_dialog.open() } } + FluProgressButton{ + property string saveFilePath: FluTools.getApplicationDirPath()+ "/download/big_buck_bunny.mp4" + property string resourcePath: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" + id:btn_breakpoint_download + implicitWidth: parent.width + implicitHeight: 36 + text: progress === 1 ? "打开文件" : "断点下载文件" + Component.onCompleted: { + progress = http_breakpoint_download.breakPointDownloadProgress(resourcePath,saveFilePath) + } + onClicked: { + if(progress === 1){ + FluTools.showFileInFolder(saveFilePath) + }else{ + http_breakpoint_download.download(resourcePath,callable_breakpoint_download,saveFilePath) + } + } + FluMenu{ + id:menu_breakpoint_download + width: 120 + FluMenuItem{ + text: "删除文件" + onClicked: { + if(FluTools.removeFile(btn_breakpoint_download.saveFilePath)){ + btn_breakpoint_download.progress = 0 + } + } + } + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + onClicked: { + if(btn_breakpoint_download.progress === 1){ + menu_breakpoint_download.popup() + } + } + } + } FluProgressButton{ id:btn_upload implicitWidth: parent.width @@ -230,6 +275,30 @@ FluContentPage{ } } + HttpCallable{ + id:callable_breakpoint_download + onStart: { + btn_breakpoint_download.disabled = true + } + onFinish: { + btn_breakpoint_download.disabled = false + } + onError: + (status,errorString,result)=>{ + btn_breakpoint_download.progress = 0 + showError(errorString) + console.debug(status+";"+errorString+";"+result) + } + onSuccess: + (result)=>{ + showSuccess(result) + } + onDownloadProgress: + (recv,total)=>{ + btn_breakpoint_download.progress = recv/total + } + } + HttpCallable{ id:callable_download onStart: { @@ -289,5 +358,4 @@ FluContentPage{ } } } - } diff --git a/example/qml/page/T_Http.qml b/example/qml/page/T_Http.qml index 95d5ae21..6a98a4da 100644 --- a/example/qml/page/T_Http.qml +++ b/example/qml/page/T_Http.qml @@ -8,7 +8,6 @@ import FluentUI 1.0 import "qrc:///example/qml/component" import "../component" - FluContentPage{ title:"Http" @@ -19,6 +18,12 @@ FluContentPage{ cacheDir:cacheDirPath } + FluHttp{ + id:http_breakpoint_download + cacheDir:cacheDirPath + breakPointDownload: true + } + FluHttp{ id:http_cache_ifnonecacherequest cacheMode:FluHttpType.IfNoneCacheRequest @@ -127,6 +132,45 @@ FluContentPage{ folder_dialog.open() } } + FluProgressButton{ + property string saveFilePath: FluTools.getApplicationDirPath()+ "/download/big_buck_bunny.mp4" + property string resourcePath: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" + id:btn_breakpoint_download + implicitWidth: parent.width + implicitHeight: 36 + text: progress === 1 ? "打开文件" : "断点下载文件" + Component.onCompleted: { + progress = http_breakpoint_download.breakPointDownloadProgress(resourcePath,saveFilePath) + } + onClicked: { + if(progress === 1){ + FluTools.showFileInFolder(saveFilePath) + }else{ + http_breakpoint_download.download(resourcePath,callable_breakpoint_download,saveFilePath) + } + } + FluMenu{ + id:menu_breakpoint_download + width: 120 + FluMenuItem{ + text: "删除文件" + onClicked: { + if(FluTools.removeFile(btn_breakpoint_download.saveFilePath)){ + btn_breakpoint_download.progress = 0 + } + } + } + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + onClicked: { + if(btn_breakpoint_download.progress === 1){ + menu_breakpoint_download.popup() + } + } + } + } FluProgressButton{ id:btn_upload implicitWidth: parent.width @@ -232,6 +276,30 @@ FluContentPage{ } } + HttpCallable{ + id:callable_breakpoint_download + onStart: { + btn_breakpoint_download.disabled = true + } + onFinish: { + btn_breakpoint_download.disabled = false + } + onError: + (status,errorString,result)=>{ + btn_breakpoint_download.progress = 0 + showError(errorString) + console.debug(status+";"+errorString+";"+result) + } + onSuccess: + (result)=>{ + showSuccess(result) + } + onDownloadProgress: + (recv,total)=>{ + btn_breakpoint_download.progress = recv/total + } + } + HttpCallable{ id:callable_download onStart: { @@ -291,5 +359,4 @@ FluContentPage{ } } } - } diff --git a/example/src/main.cpp b/example/src/main.cpp index 2dcb2d96..1cbe1648 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); #ifdef Q_OS_WIN // 此设置仅在Windows下生效 FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder); - FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,true); + FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false); #endif #ifdef Q_OS_MACOS FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false); diff --git a/src/FluHttp.cpp b/src/FluHttp.cpp index 60f830ca..9bd9ff80 100644 --- a/src/FluHttp.cpp +++ b/src/FluHttp.cpp @@ -25,7 +25,7 @@ FluHttp::FluHttp(QObject *parent) timeout(15000); cacheMode(FluHttpType::CacheMode::NoCache); cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)+"/httpcache"); - breakPointDownload(true); + breakPointDownload(false); } FluHttp::~FluHttp(){ @@ -40,21 +40,18 @@ void FluHttp::cancel(){ } } -void FluHttp::handleReply(QNetworkReply* reply){ - _cacheReply.append(reply); -} - void FluHttp::post(QString url,HttpCallable* callable,QMap params,QMap headers){ QThreadPool::globalInstance()->start([=](){ - QMap data = invokeIntercept(toRequest(url,params,headers,"post")).toMap(); + auto requestMap = toRequest(url,params,headers,"post"); + QMap data = invokeIntercept(requestMap).toMap(); Q_EMIT callable->start(); - if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); Q_EMIT callable->finish(); return; } - if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); } for (int i = 0; i < retry(); ++i) { QNetworkAccessManager manager; @@ -84,17 +81,16 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap pa int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); QString errorString = reply->errorString(); bool isSuccess = reply->error() == QNetworkReply::NoError; - _cacheReply.removeOne(reply); reply->deleteLater(); reply = nullptr; if (isSuccess) { - handleCache(data,result); + handleCache(requestMap,result); Q_EMIT callable->success(result); break; }else{ if(i == retry()-1){ - if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); } Q_EMIT callable->error(status,errorString,result); } @@ -106,15 +102,16 @@ void FluHttp::post(QString url,HttpCallable* callable,QMap pa void FluHttp::postString(QString url,HttpCallable* callable,QString params,QMap headers){ QThreadPool::globalInstance()->start([=](){ - QMap data = invokeIntercept(toRequest(url,params,headers,"postString")).toMap(); + auto requestMap = toRequest(url,params,headers,"postString"); + QMap data = invokeIntercept(requestMap).toMap(); Q_EMIT callable->start(); - if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); Q_EMIT callable->finish(); return; } - if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); } for (int i = 0; i < retry(); ++i) { QNetworkAccessManager manager; @@ -135,17 +132,16 @@ void FluHttp::postString(QString url,HttpCallable* callable,QString params,QMap< int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); QString errorString = reply->errorString(); bool isSuccess = reply->error() == QNetworkReply::NoError; - _cacheReply.removeOne(reply); reply->deleteLater(); reply = nullptr; if (isSuccess) { - handleCache(data,result); + handleCache(requestMap,result); Q_EMIT callable->success(result); break; }else{ if(i == retry()-1){ - if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); } Q_EMIT callable->error(status,errorString,result); } @@ -157,15 +153,16 @@ void FluHttp::postString(QString url,HttpCallable* callable,QString params,QMap< void FluHttp::postJson(QString url,HttpCallable* callable,QMap params,QMap headers){ QThreadPool::globalInstance()->start([=](){ - QMap data = invokeIntercept(toRequest(url,params,headers,"postJson")).toMap(); + auto requestMap = toRequest(url,params,headers,"postJson"); + QMap data = invokeIntercept(requestMap).toMap(); Q_EMIT callable->start(); - if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); Q_EMIT callable->finish(); return; } - if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); } for (int i = 0; i < retry(); ++i) { QNetworkAccessManager manager; @@ -186,17 +183,16 @@ void FluHttp::postJson(QString url,HttpCallable* callable,QMapattribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); QString errorString = reply->errorString(); bool isSuccess = reply->error() == QNetworkReply::NoError; - _cacheReply.removeOne(reply); reply->deleteLater(); reply = nullptr; if (isSuccess) { - handleCache(data,result); + handleCache(requestMap,result); Q_EMIT callable->success(result); break; }else{ if(i == retry()-1){ - if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); } Q_EMIT callable->error(status,errorString,result); } @@ -208,13 +204,14 @@ void FluHttp::postJson(QString url,HttpCallable* callable,QMap params,QMap headers){ QThreadPool::globalInstance()->start([=](){ - QMap data = invokeIntercept(toRequest(url,params,headers,"get")).toMap(); + auto requestMap = toRequest(url,params,headers,"get"); + QMap data = invokeIntercept(requestMap).toMap(); Q_EMIT callable->start(); - if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::FirstCacheThenRequest && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); } - if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::IfNoneCacheRequest && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); Q_EMIT callable->finish(); return; } @@ -236,17 +233,16 @@ void FluHttp::get(QString url,HttpCallable* callable,QMap par int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); QString errorString = reply->errorString(); bool isSuccess = reply->error() == QNetworkReply::NoError; - _cacheReply.removeOne(reply); reply->deleteLater(); reply = nullptr; if (isSuccess) { - handleCache(data,result); + handleCache(requestMap,result); Q_EMIT callable->success(result); break; }else{ if(i == retry()-1){ - if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(data)){ - Q_EMIT callable->cache(readCache(data)); + if(_cacheMode == FluHttpType::CacheMode::RequestFailedReadCache && cacheExists(requestMap)){ + Q_EMIT callable->cache(readCache(requestMap)); } Q_EMIT callable->error(status,errorString,result); } @@ -268,17 +264,21 @@ void FluHttp::download(QString url,HttpCallable* callable,QString savePath,QMap< QNetworkRequest request(_url); addHeaders(&request,data["headers"].toMap()); QSharedPointer file(new QFile(savePath)); + QDir dir = QFileInfo(savePath).path(); + if (!dir.exists(dir.path())){ + dir.mkpath(dir.path()); + } QEventLoop loop; connect(&manager,&QNetworkAccessManager::finished,&manager,[&loop](QNetworkReply *reply){ loop.quit(); }); - auto filePath = getCacheFilePath(data); qint64 seek = 0; + auto filePath = getCacheFilePath(requestMap); QSharedPointer fileCache(new QFile(filePath)); if(fileCache->exists() && file->exists() && _breakPointDownload){ - QJsonObject cacheInfo = QJsonDocument::fromJson(readCache(data).toUtf8()).object(); - auto fileSize = cacheInfo.value("fileSize").toInteger(); - auto contentLength = cacheInfo.value("contentLength").toInteger(); + QJsonObject cacheInfo = QJsonDocument::fromJson(readCache(requestMap).toUtf8()).object(); + qint64 fileSize = cacheInfo.value("fileSize").toDouble(); + qint64 contentLength = cacheInfo.value("contentLength").toDouble(); if(fileSize == contentLength && file->size() == contentLength){ Q_EMIT callable->downloadProgress(fileSize,contentLength); Q_EMIT callable->success(savePath); @@ -301,12 +301,12 @@ void FluHttp::download(QString url,HttpCallable* callable,QString savePath,QMap< { qDebug()<<"FileCache Error"; } - connect(reply,&QNetworkReply::readyRead,reply,[reply,file,fileCache,data,callable,seek]{ + connect(reply,&QNetworkReply::readyRead,reply,[reply,file,fileCache,requestMap,callable,seek]{ if (!reply || !file || reply->error() != QNetworkReply::NoError) { return; } - QMap downMap = data; + QMap downMap = requestMap; qint64 contentLength = reply->header(QNetworkRequest::ContentLengthHeader).toLongLong()+seek; downMap.insert("contentLength",contentLength); QString eTag = reply->header(QNetworkRequest::ETagHeader).toString(); @@ -325,7 +325,6 @@ void FluHttp::download(QString url,HttpCallable* callable,QString savePath,QMap< }else{ Q_EMIT callable->error(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(),reply->errorString(),""); } - _cacheReply.removeOne(reply); reply->deleteLater(); reply = nullptr; Q_EMIT callable->finish(); @@ -371,7 +370,6 @@ void FluHttp::upload(QString url,HttpCallable* callable,QMap int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); QString errorString = reply->errorString(); bool isSuccess = reply->error() == QNetworkReply::NoError; - _cacheReply.removeOne(reply); reply->deleteLater(); reply = nullptr; if (isSuccess) { @@ -393,12 +391,12 @@ QMap FluHttp::toRequest(const QString& url,const QVariant& pa return request; } -QVariant FluHttp::invokeIntercept(QMap request){ +QVariant FluHttp::invokeIntercept(QMap request,Qt::ConnectionType type){ if(!FluApp::getInstance()->httpInterceptor()){ return request; } QVariant target; - QMetaObject::invokeMethod(FluApp::getInstance()->httpInterceptor(), "onIntercept",Qt::BlockingQueuedConnection,Q_RETURN_ARG(QVariant,target),Q_ARG(QVariant, request)); + QMetaObject::invokeMethod(FluApp::getInstance()->httpInterceptor(), "onIntercept",type,Q_RETURN_ARG(QVariant,target),Q_ARG(QVariant, request)); return target; } @@ -463,3 +461,26 @@ void FluHttp::handleCache(QMap request,const QString& result) } file->write(FluTools::getInstance()->toBase64(result).toUtf8()); } + +qreal FluHttp::breakPointDownloadProgress(QString url,QString savePath,QMap params,QMap headers){ + auto requestMap = toRequest(url,params,headers,"download"); + requestMap.insert("savePath",savePath); + QSharedPointer file(new QFile(savePath)); + auto filePath = getCacheFilePath(requestMap); + QSharedPointer fileCache(new QFile(filePath)); + if(fileCache->exists() && file->exists() && _breakPointDownload){ + QJsonObject cacheInfo = QJsonDocument::fromJson(readCache(requestMap).toUtf8()).object(); + double fileSize = cacheInfo.value("fileSize").toDouble(); + double contentLength = cacheInfo.value("contentLength").toDouble(); + if(fileSize == contentLength && file->size() == contentLength){ + return 1; + } + if(fileSize==file->size()){ + return fileSize/contentLength; + }else{ + return 0; + } + }else{ + return 0; + } +} diff --git a/src/FluHttp.h b/src/FluHttp.h index f071d360..6f75ca9f 100644 --- a/src/FluHttp.h +++ b/src/FluHttp.h @@ -32,9 +32,8 @@ class FluHttp : public QObject Q_PROPERTY_AUTO(bool,breakPointDownload); QML_NAMED_ELEMENT(FluHttp) private: - QVariant invokeIntercept(QMap request); + QVariant invokeIntercept(QMap request,Qt::ConnectionType type = Qt::BlockingQueuedConnection); QMap toRequest(const QString& url,const QVariant& params,const QVariant& headers,const QString& method); - void handleReply(QNetworkReply* reply); void addQueryParam(QUrl* url,const QMap& params); void addHeaders(QNetworkRequest* request,const QMap& params); void handleCache(QMap request, const QString& result); @@ -51,6 +50,7 @@ public: Q_INVOKABLE void postJson(QString url,HttpCallable* callable,QMap params = {},QMap headers = {}); Q_INVOKABLE void download(QString url,HttpCallable* callable,QString savePath,QMap params = {},QMap headers = {}); Q_INVOKABLE void upload(QString url,HttpCallable* callable,QMap params = {},QMap headers = {}); + Q_INVOKABLE qreal breakPointDownloadProgress(QString url,QString savePath,QMap params = {},QMap headers = {}); Q_INVOKABLE void cancel(); private: QList> _cacheReply; diff --git a/src/FluTools.cpp b/src/FluTools.cpp index 1ca3e1ee..15f0f4d6 100644 --- a/src/FluTools.cpp +++ b/src/FluTools.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -151,6 +152,27 @@ bool FluTools::removeDir(QString dirPath){ return qDir.removeRecursively(); } +bool FluTools::removeFile(QString filePath){ + QFile file(filePath); + return file.remove(); +} + QString FluTools::sha256(QString text){ return QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Sha256).toHex(); } + +void FluTools::showFileInFolder(QString path){ +#if defined(Q_OS_WIN) + QProcess::startDetached("explorer.exe", {"/select,", QDir::toNativeSeparators(path)}); +#endif +#if defined(Q_OS_LINUX) + QFileInfo fileInfo(path); + auto process = "xdg-open"; + auto arguments = { fileInfo.absoluteDir().absolutePath() }; + QProcess::startDetached(process, arguments); +#endif +#if defined(Q_OS_MACOS) + QProcess::execute("/usr/bin/osascript", {"-e", "tell application \"Finder\" to reveal POSIX file \"" + path + "\""}); + QProcess::execute("/usr/bin/osascript", {"-e", "tell application \"Finder\" to activate"}); +#endif +} diff --git a/src/FluTools.h b/src/FluTools.h index 272eadd5..fcaac58d 100644 --- a/src/FluTools.h +++ b/src/FluTools.h @@ -180,6 +180,19 @@ public: */ Q_INVOKABLE bool removeDir(QString dirPath); + /** + * @brief removeFile + * @param filePath + * @return + */ + Q_INVOKABLE bool removeFile(QString filePath); + + /** + * @brief showFileInFolder + * @param path + */ + Q_INVOKABLE void showFileInFolder(QString path); + }; #endif // FLUTOOLS_H diff --git a/src/Qt5/imports/FluentUI/plugins.qmltypes b/src/Qt5/imports/FluentUI/plugins.qmltypes index b6f83d0e..82a4c78d 100644 --- a/src/Qt5/imports/FluentUI/plugins.qmltypes +++ b/src/Qt5/imports/FluentUI/plugins.qmltypes @@ -8,21 +8,6 @@ import QtQuick.tooling 1.2 Module { dependencies: ["QtQuick 2.0"] - Component { - name: "FluHttpType" - exports: ["FluentUI/FluHttpType 1.0"] - isCreatable: false - exportMetaObjectRevisions: [0] - Enum { - name: "CacheMode" - values: { - "NoCache": 0, - "RequestFailedReadCache": 1, - "IfNoneCacheRequest": 2, - "FirstCacheThenRequest": 4 - } - } - } Component { name: "FluCalendarViewType" exports: ["FluentUI/FluCalendarViewType 1.0"] @@ -85,116 +70,140 @@ Module { exportMetaObjectRevisions: [0] Property { name: "retry"; type: "int" } Property { name: "timeout"; type: "int" } + Property { name: "cacheMode"; type: "int" } + Property { name: "cacheDir"; type: "string" } + Property { name: "breakPointDownload"; type: "bool" } Method { name: "get" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "QVariantMap" } Parameter { name: "headers"; type: "QVariantMap" } } Method { name: "get" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "QVariantMap" } } Method { name: "get" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } } Method { name: "post" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "QVariantMap" } Parameter { name: "headers"; type: "QVariantMap" } } Method { name: "post" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "QVariantMap" } } Method { name: "post" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } } Method { name: "postString" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "string" } Parameter { name: "headers"; type: "QVariantMap" } } Method { name: "postString" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "string" } } Method { name: "postString" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } } Method { name: "postJson" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "QVariantMap" } Parameter { name: "headers"; type: "QVariantMap" } } Method { name: "postJson" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "QVariantMap" } } Method { name: "postJson" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } } Method { name: "download" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } - Parameter { name: "filePath"; type: "string" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } + Parameter { name: "savePath"; type: "string" } Parameter { name: "params"; type: "QVariantMap" } Parameter { name: "headers"; type: "QVariantMap" } } Method { name: "download" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } - Parameter { name: "filePath"; type: "string" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } + Parameter { name: "savePath"; type: "string" } Parameter { name: "params"; type: "QVariantMap" } } Method { name: "download" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } - Parameter { name: "filePath"; type: "string" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } + Parameter { name: "savePath"; type: "string" } } Method { name: "upload" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "QVariantMap" } Parameter { name: "headers"; type: "QVariantMap" } } Method { name: "upload" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } Parameter { name: "params"; type: "QVariantMap" } } Method { name: "upload" Parameter { name: "url"; type: "string" } - Parameter { name: "callable"; type: "QJSValue" } + Parameter { name: "callable"; type: "HttpCallable"; isPointer: true } + } + Method { + name: "breakPointDownloadProgress" + type: "double" + Parameter { name: "url"; type: "string" } + Parameter { name: "savePath"; type: "string" } + Parameter { name: "params"; type: "QVariantMap" } + Parameter { name: "headers"; type: "QVariantMap" } + } + Method { + name: "breakPointDownloadProgress" + type: "double" + Parameter { name: "url"; type: "string" } + Parameter { name: "savePath"; type: "string" } + Parameter { name: "params"; type: "QVariantMap" } + } + Method { + name: "breakPointDownloadProgress" + type: "double" + Parameter { name: "url"; type: "string" } + Parameter { name: "savePath"; type: "string" } } Method { name: "cancel" } } @@ -204,6 +213,21 @@ Module { exports: ["FluentUI/FluHttpInterceptor 1.0"] exportMetaObjectRevisions: [0] } + Component { + name: "FluHttpType" + exports: ["FluentUI/FluHttpType 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "CacheMode" + values: { + "NoCache": 0, + "RequestFailedReadCache": 1, + "IfNoneCacheRequest": 2, + "FirstCacheThenRequest": 4 + } + } + } Component { name: "FluNavigationViewType" exports: ["FluentUI/FluNavigationViewType 1.0"] @@ -241,7 +265,7 @@ Module { } } } - Component { + Component { name: "FluScreenshotType" exports: ["FluentUI/FluScreenshotType 1.0"] isCreatable: false @@ -253,20 +277,6 @@ Module { "File": 1 } } - } - Component { - name: "FluTimelineType" - exports: ["FluentUI/FluTimelineType 1.0"] - isCreatable: false - exportMetaObjectRevisions: [0] - Enum { - name: "Mode" - values: { - "Left": 0, - "Right": 1, - "Alternate": 2 - } - } } Component { name: "FluStatusViewType" @@ -332,6 +342,20 @@ Module { } } } + Component { + name: "FluTimelineType" + exports: ["FluentUI/FluTimelineType 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "Mode" + values: { + "Left": 0, + "Right": 1, + "Alternate": 2 + } + } + } Component { name: "FluTreeViewType" exports: ["FluentUI/FluTreeViewType 1.0"] @@ -1787,6 +1811,38 @@ Module { } } } + Component { + name: "HttpCallable" + prototype: "QObject" + exports: ["FluentUI/HttpCallable 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: "downloadProgress" + Parameter { name: "recv"; type: "qlonglong" } + Parameter { name: "total"; type: "qlonglong" } + } + Signal { + name: "uploadProgress" + Parameter { name: "recv"; type: "qlonglong" } + Parameter { name: "total"; type: "qlonglong" } + } + } Component { name: "QRCode" defaultProperty: "data" @@ -1816,6 +1872,7 @@ Module { exportMetaObjectRevisions: [0] Property { name: "saveFolder"; type: "string" } Property { name: "captureMode"; type: "int" } + Property { name: "hitDrawData"; type: "DrawData"; isPointer: true } Signal { name: "captrueToPixmapCompleted" Parameter { name: "captrue"; type: "QPixmap" } @@ -1829,6 +1886,25 @@ Module { Parameter { name: "start"; type: "QPoint" } Parameter { name: "end"; type: "QPoint" } } + Method { + name: "appendDrawData" + type: "DrawData*" + Parameter { name: "drawType"; type: "int" } + Parameter { name: "start"; type: "QPoint" } + Parameter { name: "end"; type: "QPoint" } + } + Method { + name: "updateDrawData" + Parameter { name: "data"; type: "DrawData"; isPointer: true } + Parameter { name: "start"; type: "QPoint" } + Parameter { name: "end"; type: "QPoint" } + } + Method { name: "clear" } + Method { + name: "hit" + type: "DrawData*" + Parameter { name: "point"; type: "QPoint" } + } } Component { name: "WindowHelper"