我正在使用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"
}
...
}
有什么想法吗?
答案 0 :(得分:1)
silverstripe-translatable docs说:
将主题设置为“系统”可选择浅色或深色主题 基于系统主题颜色。但是,在阅读时的价值 主题属性,值永远不是系统,而是实际主题。
因此,如果您检查Material.theme
和Universal.theme
的值,则两者都应返回其有效值,而不是您设置的值。