我正在使用 Qt 5.8 RC 以及 Universal 和 Material 主题中引入的新属性 System。
但是,在设计可定制的应用程序时,可以选择 Universal 或 Material 与 Dark、Light 或 System 的组合。我怎么知道 System 实际上不是字符串“System”,而是“Dark”或“Light”?
RadioButton {
text: qsTr("Light")
checked: appSettings.theme === "Light"
ButtonGroup.group: modeBG
onClicked: {
appSettings.theme = "Light"
appSettings.background = "white"
appSettings.menuPaneColor = "#eeeeee"
}
}
RadioButton {
text: qsTr("Dark")
checked: appSettings.theme === "Dark"
ButtonGroup.group: modeBG
onClicked: {
appSettings.theme = "Dark"
appSettings.background = "black"
appSettings.menuPaneColor = "#171717"
}
}
RadioButton {
text: qsTr("System theme")
ButtonGroup.group: modeBG
onClicked: {
appSettings.theme = "System"
//appSettings.background = "black"
//appSettings.menuPaneColor = "#171717"
}
}
显然,以下用于处理“硬”值的代码不再有效(main.qml):
ToolButton {
id: burgerMenu
checkable: appSettings.burgerMenuIsChecked
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "qrc:/images/" + appSettings.style + "/" + appSettings.theme + "/drawer.png"
}
...
}
任何想法?