FluentUI/example/qml/page/T_Settings.qml

191 lines
5.2 KiB
QML
Raw Normal View History

2023-08-24 15:50:37 +08:00
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
2023-06-12 16:46:02 +08:00
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-26 17:20:30 +08:00
import "../component"
2023-09-12 18:45:15 +08:00
import "../viewmodel"
import "../global"
2023-04-10 18:17:22 +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-09-17 20:36:33 +08:00
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 50
paddings: 10
FluCheckBox{
text:"Software Render"
checked: SettingsHelper.getReander() === "software"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
if(SettingsHelper.getReander() === "software"){
SettingsHelper.saveRender("")
}else{
SettingsHelper.saveRender("software")
}
dialog_render.open()
}
}
}
FluContentDialog{
id:dialog_render
title:"友情提示"
message:"此操作需要重启才能生效,是否重新启动?"
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
negativeText: "取消"
positiveText:"确定"
onPositiveClicked:{
window.deleteWindow()
AppInfo.restart()
}
}
2023-09-11 18:10:50 +08:00
2023-04-10 18:17:22 +08:00
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
2023-06-20 18:02:15 +08:00
height: 128
2023-04-10 18:17:22 +08:00
paddings: 10
ColumnLayout{
2023-06-20 18:02:15 +08:00
spacing: 5
2023-04-10 18:17:22 +08:00
anchors{
2023-04-14 17:07:54 +08:00
top: parent.top
2023-04-10 18:17:22 +08:00
left: parent.left
}
FluText{
2023-04-19 23:53:00 +08:00
text:lang.dark_mode
2023-05-10 00:27:53 +08:00
font: FluTextStyle.BodyStrong
2023-04-10 18:17:22 +08:00
Layout.bottomMargin: 4
}
Repeater{
2023-07-18 18:24:06 +08:00
model: [{title:"System",mode:FluThemeType.System},{title:"Light",mode:FluThemeType.Light},{title:"Dark",mode:FluThemeType.Dark}]
2023-04-10 18:17:22 +08:00
delegate: FluRadioButton{
2023-05-31 15:39:59 +08:00
checked : FluTheme.darkMode === modelData.mode
2023-04-10 18:17:22 +08:00
text:modelData.title
2023-05-31 15:39:59 +08:00
clickListener:function(){
2023-04-19 23:53:00 +08:00
FluTheme.darkMode = modelData.mode
2023-04-10 18:17:22 +08:00
}
}
}
}
}
2023-04-14 17:07:54 +08:00
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
2023-06-20 18:02:15 +08:00
height: 160
2023-04-14 17:07:54 +08:00
paddings: 10
ColumnLayout{
2023-06-20 18:02:15 +08:00
spacing: 5
2023-04-14 17:07:54 +08:00
anchors{
top: parent.top
left: parent.left
}
FluText{
2023-04-19 23:53:00 +08:00
text:lang.navigation_view_display_mode
2023-05-10 00:27:53 +08:00
font: FluTextStyle.BodyStrong
2023-04-14 17:07:54 +08:00
Layout.bottomMargin: 4
}
2023-04-19 23:53:00 +08:00
Repeater{
2023-07-18 18:24:06 +08:00
model: [{title:"Open",mode:FluNavigationViewType.Open},{title:"Compact",mode:FluNavigationViewType.Compact},{title:"Minimal",mode:FluNavigationViewType.Minimal},{title:"Auto",mode:FluNavigationViewType.Auto}]
2023-05-31 15:39:59 +08:00
delegate: FluRadioButton{
2023-09-12 18:45:15 +08:00
checked : viewmodel_settings.displayMode===modelData.mode
2023-04-19 23:53:00 +08:00
text:modelData.title
2023-05-31 15:39:59 +08:00
clickListener:function(){
2023-09-12 18:45:15 +08:00
viewmodel_settings.displayMode = modelData.mode
2023-04-14 17:07:54 +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-04-19 23:53:00 +08:00
text:lang.locale
2023-05-10 00:27:53 +08:00
font: FluTextStyle.BodyStrong
Layout.bottomMargin: 4
}
Flow{
spacing: 5
2023-04-19 23:53:00 +08:00
Repeater{
model: ["Zh","En"]
2023-05-31 15:39:59 +08:00
delegate: FluRadioButton{
2023-09-17 20:36:33 +08:00
checked: AppInfo.lang.objectName === modelData
2023-04-19 23:53:00 +08:00
text:modelData
2023-05-31 15:39:59 +08:00
clickListener:function(){
2023-09-17 20:36:33 +08:00
AppInfo.changeLang(modelData)
2023-04-19 23:53:00 +08:00
}
}
}
}
}
}
2023-04-10 18:17:22 +08:00
}