FluentUI/example/qml-Qt6/page/T_Settings.qml

220 lines
5.9 KiB
QML
Raw Normal View History

2023-08-24 15:50:37 +08:00
import QtQuick
import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Controls
import FluentUI
import "qrc:///example/qml/global"
import "qrc:///example/qml/component"
2023-09-12 18:45:15 +08:00
import "qrc:///example/qml/viewmodel"
2023-08-24 15:50:37 +08:00
FluScrollablePage{
title:"Settings"
2023-09-12 18:45:15 +08:00
SettingsViewModel{
id:viewmodel_settings
}
2023-09-11 18:10:50 +08:00
FluEvent{
id:event_checkupdate_finish
name: "checkUpdateFinish"
onTriggered: {
btn_checkupdate.loading = false
}
}
Component.onCompleted: {
FluEventBus.registerEvent(event_checkupdate_finish)
}
Component.onDestruction: {
FluEventBus.unRegisterEvent(event_checkupdate_finish)
}
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 60
paddings: 10
Row{
spacing: 20
anchors.verticalCenter: parent.verticalCenter
FluText{
2023-09-17 20:36:33 +08:00
text:"当前版本 v%1".arg(AppInfo.version)
2023-09-11 18:10:50 +08:00
font: FluTextStyle.Body
anchors.verticalCenter: parent.verticalCenter
}
FluLoadingButton{
id:btn_checkupdate
text:"检查更新"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
loading = true
FluEventBus.post("checkUpdate")
}
}
}
}
2023-10-15 17:24:33 +08:00
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 50
paddings: 10
FluCheckBox{
text:"V-Sync"
checked: FluApp.vsync
anchors.verticalCenter: parent.verticalCenter
onClicked: {
FluApp.vsync = !FluApp.vsync
dialog_restart.open()
}
}
}
2023-11-23 19:58:54 +08:00
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 50
paddings: 10
FluCheckBox{
text:"Use System AppBar"
checked: FluApp.useSystemAppBar
anchors.verticalCenter: parent.verticalCenter
onClicked: {
FluApp.useSystemAppBar = !FluApp.useSystemAppBar
dialog_restart.open()
}
}
}
2023-10-15 17:24:33 +08:00
2023-09-17 20:36:33 +08:00
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 50
paddings: 10
FluCheckBox{
text:"Software Render"
2023-10-10 18:31:22 +08:00
checked: SettingsHelper.getRender() === "software"
2023-09-17 20:36:33 +08:00
anchors.verticalCenter: parent.verticalCenter
onClicked: {
2023-10-10 18:31:22 +08:00
if(SettingsHelper.getRender() === "software"){
2023-09-17 20:36:33 +08:00
SettingsHelper.saveRender("")
}else{
SettingsHelper.saveRender("software")
}
2023-10-15 17:24:33 +08:00
dialog_restart.open()
2023-09-17 20:36:33 +08:00
}
}
}
FluContentDialog{
2023-10-15 17:24:33 +08:00
id:dialog_restart
2023-09-17 20:36:33 +08:00
title:"友情提示"
message:"此操作需要重启才能生效,是否重新启动?"
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
negativeText: "取消"
positiveText:"确定"
onPositiveClicked:{
2023-09-27 15:18:10 +08:00
FluApp.exit(931)
2023-09-17 20:36:33 +08:00
}
}
2023-09-11 18:10:50 +08:00
2023-08-24 15:50:37 +08:00
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 128
paddings: 10
ColumnLayout{
spacing: 5
anchors{
top: parent.top
left: parent.left
}
FluText{
2023-10-10 15:06:44 +08:00
text:Lang.dark_mode
2023-08-24 15:50:37 +08:00
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
Repeater{
model: [{title:"System",mode:FluThemeType.System},{title:"Light",mode:FluThemeType.Light},{title:"Dark",mode:FluThemeType.Dark}]
delegate: FluRadioButton{
checked : FluTheme.darkMode === modelData.mode
text:modelData.title
clickListener:function(){
FluTheme.darkMode = modelData.mode
}
}
}
}
}
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 160
paddings: 10
ColumnLayout{
spacing: 5
anchors{
top: parent.top
left: parent.left
}
FluText{
2023-10-10 15:06:44 +08:00
text:Lang.navigation_view_display_mode
2023-08-24 15:50:37 +08:00
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
Repeater{
model: [{title:"Open",mode:FluNavigationViewType.Open},{title:"Compact",mode:FluNavigationViewType.Compact},{title:"Minimal",mode:FluNavigationViewType.Minimal},{title:"Auto",mode:FluNavigationViewType.Auto}]
delegate: FluRadioButton{
2023-09-12 18:45:15 +08:00
checked : viewmodel_settings.displayMode===modelData.mode
2023-08-24 15:50:37 +08:00
text:modelData.title
clickListener:function(){
2023-09-12 18:45:15 +08:00
viewmodel_settings.displayMode = modelData.mode
2023-08-24 15:50:37 +08:00
}
}
}
}
}
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 80
paddings: 10
ColumnLayout{
spacing: 10
anchors{
top: parent.top
left: parent.left
}
FluText{
2023-10-10 15:06:44 +08:00
text:Lang.locale
2023-08-24 15:50:37 +08:00
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
Flow{
spacing: 5
Repeater{
2023-10-10 15:06:44 +08:00
model: Lang.__localeList
2023-08-24 15:50:37 +08:00
delegate: FluRadioButton{
2023-10-10 15:06:44 +08:00
checked: Lang.__locale === modelData
2023-08-24 15:50:37 +08:00
text:modelData
clickListener:function(){
2023-10-10 15:06:44 +08:00
Lang.__locale = modelData
2023-08-24 15:50:37 +08:00
}
}
}
}
}
}
}