From e2879f564cccf976bc037ba04ec592a9200c15d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Sun, 27 Aug 2023 09:11:44 +0800 Subject: [PATCH] check update --- .cmake/Version.h.in | 3 +- example/qml-Qt6/window/MainWindow.qml | 43 +++++++++++++++++++ example/qml/window/MainWindow.qml | 43 +++++++++++++++++++ .../FluentUI/Controls/FluContentDialog.qml | 36 +++++++++++----- .../FluentUI/Controls/FluContentDialog.qml | 35 ++++++++++----- 5 files changed, 137 insertions(+), 23 deletions(-) diff --git a/.cmake/Version.h.in b/.cmake/Version.h.in index 30d87aaa..939b2a8b 100644 --- a/.cmake/Version.h.in +++ b/.cmake/Version.h.in @@ -5,8 +5,9 @@ #include -#define APPLICATION_VERSION "${GIT_SEMVER}.${GIT_COMMIT_COUNT}" +#define APPLICATION_FULL_VERSION "${GIT_SEMVER}.${GIT_COMMIT_COUNT}" #define VERSION_COUNTER ${GIT_COMMIT_COUNT} #define COMMIT_HASH "${GIT_DESCRIBE}" +#define APPLICATION_VERSION "${GIT_SEMVER}" #endif // VERSION_H diff --git a/example/qml-Qt6/window/MainWindow.qml b/example/qml-Qt6/window/MainWindow.qml index be1553d6..2512bee9 100644 --- a/example/qml-Qt6/window/MainWindow.qml +++ b/example/qml-Qt6/window/MainWindow.qml @@ -28,6 +28,7 @@ CustomWindow { Component.onCompleted: { FluTools.setQuitOnLastWindowClosed(false) tour.open() + checkUpdate() } SystemTrayIcon { @@ -277,4 +278,46 @@ CustomWindow { ] } + FluHttp{ + id:http + } + + FluContentDialog{ + property string newVerson + property string body + id:dialog_update + title:"升级提示" + message:"FluentUI目前最新版本 "+ newVerson +" -- 当前应用版本 "+appInfo.version+" \n现在是否去下载新版本?\n\n更新内容:\n"+body + buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton + negativeText: "取消" + positiveText:"确定" + onPositiveClicked:{ + Qt.openUrlExternally("https://github.com/zhuzichu520/FluentUI/releases/latest") + } + } + + function checkUpdate(){ + var callable = {} + callable.onStart = function(){ + console.debug("satrt check update...") + } + callable.onFinish = function(){ + console.debug("check update finish") + } + callable.onSuccess = function(result){ + var data = JSON.parse(result) + console.debug("current version "+appInfo.version) + console.debug("new version "+data.tag_name) + if(data.tag_name !== appInfo.version){ + dialog_update.newVerson = data.tag_name + dialog_update.body = data.body + dialog_update.open() + } + } + callable.onError = function(status,errorString){ + console.debug(status+";"+errorString) + } + http.get("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest",callable) + } + } diff --git a/example/qml/window/MainWindow.qml b/example/qml/window/MainWindow.qml index 229cfad2..f0f8367a 100644 --- a/example/qml/window/MainWindow.qml +++ b/example/qml/window/MainWindow.qml @@ -29,6 +29,7 @@ CustomWindow { Component.onCompleted: { FluTools.setQuitOnLastWindowClosed(false) tour.open() + checkUpdate() } SystemTrayIcon { @@ -278,4 +279,46 @@ CustomWindow { ] } + FluHttp{ + id:http + } + + FluContentDialog{ + property string newVerson + property string body + id:dialog_update + title:"升级提示" + message:"FluentUI目前最新版本 "+ newVerson +" -- 当前应用版本 "+appInfo.version+" \n现在是否去下载新版本?\n\n更新内容:\n"+body + buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton + negativeText: "取消" + positiveText:"确定" + onPositiveClicked:{ + Qt.openUrlExternally("https://github.com/zhuzichu520/FluentUI/releases/latest") + } + } + + function checkUpdate(){ + var callable = {} + callable.onStart = function(){ + console.debug("satrt check update...") + } + callable.onFinish = function(){ + console.debug("check update finish") + } + callable.onSuccess = function(result){ + var data = JSON.parse(result) + console.debug("current version "+appInfo.version) + console.debug("new version "+data.tag_name) + if(data.tag_name !== appInfo.version){ + dialog_update.newVerson = data.tag_name + dialog_update.body = data.body + dialog_update.open() + } + } + callable.onError = function(status,errorString){ + console.debug(status+";"+errorString) + } + http.get("https://api.github.com/repos/zhuzichu520/FluentUI/releases/latest",callable) + } + } diff --git a/src/Qt5/imports/FluentUI/Controls/FluContentDialog.qml b/src/Qt5/imports/FluentUI/Controls/FluContentDialog.qml index 44ab05ed..5c177337 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluContentDialog.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluContentDialog.qml @@ -18,7 +18,7 @@ FluPopup { property int buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton focus: true implicitWidth: 400 - implicitHeight: text_title.height + text_message.height + layout_actions.height + implicitHeight: text_title.height + sroll_message.height + layout_actions.height Rectangle { id:layout_content anchors.fill: parent @@ -38,28 +38,41 @@ FluPopup { right: parent.right } } - FluText{ - id:text_message - font: FluTextStyle.Body - wrapMode: Text.WrapAnywhere - text:message - topPadding: 14 - leftPadding: 20 - rightPadding: 20 - bottomPadding: 14 + + Flickable{ + id:sroll_message + contentWidth: width anchors{ top:text_title.bottom left: parent.left right: parent.right } + contentHeight: text_message.height + clip: true + height: Math.min(text_message.height,300) + ScrollBar.vertical: FluScrollBar {} + + FluText{ + id:text_message + font: FluTextStyle.Body + wrapMode: Text.WrapAnywhere + text:message + width: parent.width + topPadding: 14 + leftPadding: 20 + rightPadding: 20 + bottomPadding: 14 + } + } + Rectangle{ id:layout_actions height: 68 radius: 5 color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1) anchors{ - top:text_message.bottom + top:sroll_message.bottom left: parent.left right: parent.right } @@ -127,3 +140,4 @@ FluPopup { } } } + diff --git a/src/Qt6/imports/FluentUI/Controls/FluContentDialog.qml b/src/Qt6/imports/FluentUI/Controls/FluContentDialog.qml index dd325092..20344527 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluContentDialog.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluContentDialog.qml @@ -18,7 +18,7 @@ FluPopup { property int buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton focus: true implicitWidth: 400 - implicitHeight: text_title.height + text_message.height + layout_actions.height + implicitHeight: text_title.height + sroll_message.height + layout_actions.height Rectangle { id:layout_content anchors.fill: parent @@ -38,28 +38,41 @@ FluPopup { right: parent.right } } - FluText{ - id:text_message - font: FluTextStyle.Body - wrapMode: Text.WrapAnywhere - text:message - topPadding: 14 - leftPadding: 20 - rightPadding: 20 - bottomPadding: 14 + + Flickable{ + id:sroll_message + contentWidth: width anchors{ top:text_title.bottom left: parent.left right: parent.right } + contentHeight: text_message.height + clip: true + height: Math.min(text_message.height,300) + ScrollBar.vertical: FluScrollBar {} + + FluText{ + id:text_message + font: FluTextStyle.Body + wrapMode: Text.WrapAnywhere + text:message + width: parent.width + topPadding: 14 + leftPadding: 20 + rightPadding: 20 + bottomPadding: 14 + } + } + Rectangle{ id:layout_actions height: 68 radius: 5 color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1) anchors{ - top:text_message.bottom + top:sroll_message.bottom left: parent.left right: parent.right }