Change Style.theme type to string

This commit is contained in:
Stefano Moretti 2023-06-06 18:40:23 +02:00
parent 287d439eec
commit 768bb75de4
3 changed files with 9 additions and 11 deletions

View File

@ -294,22 +294,17 @@ UI.App {
id: themeDialog
title: "Choose theme style"
model: [
{ name: "Dark", style: Material.Dark },
{ name: "Light", style: Material.Light },
{ name: "System", style: Material.System }
]
model: [ "Dark", "Light", "System" ]
delegate: RowLayout {
spacing: 0
RadioButton {
checked: modelData.name === root.themeStyle
text: modelData.name
checked: modelData === root.themeStyle
text: modelData
Layout.leftMargin: 4
onClicked: {
themeDialog.close()
root.themeStyle = modelData.name
UI.Style.theme = modelData.style
root.themeStyle = modelData
root.theme = root.Material.theme === Material.Dark
}
}
@ -395,5 +390,6 @@ UI.App {
UI.Style.primaryColor = Qt.binding(function() { return root.primary })
UI.Style.accentColor = Qt.binding(function() { return root.accent })
UI.Style.isDarkTheme = Qt.binding(function() { return root.theme })
UI.Style.theme = Qt.binding(function() { return root.themeStyle })
}
}

View File

@ -23,5 +23,7 @@ ApplicationWindow {
Material.primary: Style.primaryColor
Material.accent: Style.accentColor
Material.theme: Style.theme
Material.theme: Style.theme == "System"
? Material.System
: (Style.theme == "Dark" ? Material.Dark : Material.Light)
}

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
QtObject {
property bool isDarkTheme: false
property int theme: Material.System
property string theme: "System"
property bool toolBarPrimary: true
property color primaryColor: Material.color(Material.BlueGrey)