This commit is contained in:
zhuzichu
2023-09-06 14:05:29 +08:00
parent ddee70cdca
commit ed5956d824
8 changed files with 375 additions and 108 deletions

View File

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

View File

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

View File

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