diff --git a/example/main.qml b/example/main.qml index a2b7385..a761e95 100644 --- a/example/main.qml +++ b/example/main.qml @@ -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 }) } } diff --git a/qml/App.qml b/qml/App.qml index dd25434..4ac9af4 100644 --- a/qml/App.qml +++ b/qml/App.qml @@ -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) } diff --git a/qml/Style.qml b/qml/Style.qml index da7b39f..d3603f5 100644 --- a/qml/Style.qml +++ b/qml/Style.qml @@ -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)