Increase Qt requirement to 5.12 and remove pre-5.12 workarounds

This commit is contained in:
Cameron Gutman 2025-10-11 11:03:33 -05:00
commit 2b3e0803de
7 changed files with 17 additions and 65 deletions

View file

@ -205,20 +205,10 @@ ApplicationWindow {
SdlGamepadKeyNavigation.notifyWindowFocus(visible && active)
}
// Workaround for lack of instanceof in Qt 5.9.
//
// Based on https://stackoverflow.com/questions/13923794/how-to-do-a-is-a-typeof-or-instanceof-in-qml
function qmltypeof(obj, className) { // QtObject, string -> bool
// className plus "(" is the class instance without modification
// className plus "_QML" is the class instance with user-defined properties
var str = obj.toString();
return str.startsWith(className + "(") || str.startsWith(className + "_QML");
}
function navigateTo(url, objectType)
{
var existingItem = stackView.find(function(item, index) {
return qmltypeof(item, objectType)
return item instanceof objectType
})
if (existingItem !== null) {
@ -285,7 +275,7 @@ ApplicationWindow {
Label {
id: versionLabel
visible: qmltypeof(stackView.currentItem, "SettingsView")
visible: stackView.currentItem instanceof SettingsView
text: qsTr("Version %1").arg(SystemProperties.versionString)
font.pointSize: 12
horizontalAlignment: Qt.AlignRight
@ -295,7 +285,7 @@ ApplicationWindow {
NavigableToolButton {
id: discordButton
visible: SystemProperties.hasBrowser &&
qmltypeof(stackView.currentItem, "SettingsView")
stackView.currentItem instanceof SettingsView
iconSource: "qrc:/res/discord.svg"
@ -314,7 +304,7 @@ ApplicationWindow {
NavigableToolButton {
id: addPcButton
visible: qmltypeof(stackView.currentItem, "PcView")
visible: stackView.currentItem instanceof PcView
iconSource: "qrc:/res/ic_add_to_queue_white_48px.svg"
@ -412,7 +402,7 @@ ApplicationWindow {
iconSource: "qrc:/res/ic_videogame_asset_white_48px.svg"
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", "GamepadMapper")
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", GamepadMapper)
Keys.onDownPressed: {
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
@ -424,7 +414,7 @@ ApplicationWindow {
iconSource: "qrc:/res/settings.svg"
onClicked: navigateTo("qrc:/gui/SettingsView.qml", "SettingsView")
onClicked: navigateTo("qrc:/gui/SettingsView.qml", SettingsView)
Keys.onDownPressed: {
stackView.currentItem.forceActiveFocus(Qt.TabFocus)