FluentUI/example/Installer.qml

173 lines
3.9 KiB
QML
Raw Normal View History

2023-03-01 22:06:48 +08:00
import QtQuick 2.15
import QtQuick.Layouts 1.15
2023-03-02 18:21:43 +08:00
import QtQuick.Dialogs 1.3 as Dialogs
import Qt.labs.platform 1.1
2023-03-01 22:06:48 +08:00
import FluentUI 1.0
FluWindow {
id:window
2023-03-02 00:35:58 +08:00
width: 800
height: 400
2023-03-02 18:21:43 +08:00
minimumWidth:800
maximumWidth:800
minimumHeight:400
maximumHeight:400
2023-03-01 22:06:48 +08:00
title:"安装向导"
2023-03-02 18:21:43 +08:00
property string installPath: "C:\\Program Files"
property string installName: "FluentUI"
2023-03-01 22:06:48 +08:00
FluAppBar{
id:appbar
title: "安装向导"
}
2023-03-02 18:21:43 +08:00
Item{
id:data
Dialogs.FileDialog {
id: fileDialog
selectFolder: true
folder: "file:///"+installPath
onAccepted: {
installPath = String(fileDialog.fileUrls[0]).replace("file:///","").replace(RegExp("/",'g'),"\\")
}
}
2023-03-05 23:39:13 +08:00
Connections{
target: installHelper
function onErrorInfoChanged(){
showError(installHelper.errorInfo)
}
}
2023-03-02 18:21:43 +08:00
}
2023-03-01 22:06:48 +08:00
ColumnLayout{
width: parent.width
anchors{
top: appbar.bottom
bottom: parent.bottom
topMargin: 20
}
RowLayout{
width: parent.width
FluText{
text:"安装路径:"
Layout.leftMargin: 30
}
2023-03-02 12:20:16 +08:00
FluTextBox{
2023-03-02 18:21:43 +08:00
id:textbox_path
2023-03-02 12:20:16 +08:00
Layout.preferredHeight: 40
2023-03-01 22:06:48 +08:00
Layout.fillWidth: true
2023-03-02 18:21:43 +08:00
text:installPath+ "\\" +installName
2023-03-02 12:20:16 +08:00
readOnly:true
2023-03-01 22:06:48 +08:00
}
FluButton{
text:"更改路径"
Layout.rightMargin: 30
2023-03-02 18:21:43 +08:00
onClicked: {
2023-03-05 23:39:13 +08:00
fileDialog.open()
2023-03-02 18:21:43 +08:00
}
2023-03-01 22:06:48 +08:00
}
}
2023-03-02 18:21:43 +08:00
FluCheckBox{
id:checkbox_startmenu
Layout.topMargin: 20
Layout.leftMargin: 30
checked: true
text:"创建启动菜单快捷方式"
}
FluCheckBox{
id:checkbox_home
Layout.leftMargin: 30
Layout.topMargin: 5
checked: true
text:"创建桌面图标"
}
2023-03-01 22:06:48 +08:00
Item{
width: 1
Layout.fillHeight: true
}
Rectangle{
Layout.fillWidth: true
border.width: 1
border.color: FluApp.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1)
height: 60
color: FluApp.isDark ? "#323232" : "#FFFFFF"
RowLayout{
anchors{
right: parent.right
rightMargin: 30
verticalCenter: parent.verticalCenter
}
spacing: 14
FluButton{
text:"取消"
onClicked: {
window.close()
}
}
FluFilledButton{
text:"同意并安装"
2023-03-02 18:21:43 +08:00
onClicked: {
2023-03-03 18:19:48 +08:00
installHelper.install(textbox_path.text,checkbox_home.checked,checkbox_startmenu.checked)
2023-03-02 18:21:43 +08:00
}
2023-03-01 22:06:48 +08:00
}
FluButton{
text:"不安装直接运行"
onClicked: {
FluApp.navigate("/")
window.close()
}
}
}
}
}
2023-03-02 18:21:43 +08:00
Rectangle{
anchors.fill: parent
2023-03-03 18:19:48 +08:00
visible: installHelper.installing
2023-03-02 18:21:43 +08:00
color: "#80000000"
MouseArea{
anchors.fill: parent
hoverEnabled: true
}
FluProgressBar{
id:progress
anchors.centerIn: parent
}
FluText{
text:"正在安装..."
color:"#FFFFFF"
font.pixelSize: 20
anchors{
horizontalCenter: progress.horizontalCenter
bottom: progress.top
bottomMargin: 10
}
}
}
2023-03-01 22:06:48 +08:00
}