Prevent multiple instances of the same page on the StackView and stub out GamepadMapper

This commit is contained in:
Cameron Gutman
2018-07-08 22:37:29 -07:00
parent a47f59d1a4
commit 62cf95d55e
4 changed files with 45 additions and 12 deletions

View File

@@ -0,0 +1,5 @@
import QtQuick 2.0
Item {
objectName: "Gamepad Mapping"
}

View File

@@ -144,7 +144,7 @@ GridView {
var component = Qt.createComponent("AppView.qml")
var appView = component.createObject(stackView)
appView.computerIndex = index
appView.objectName = "Apps on " + model.name
appView.objectName = model.name
stackView.push(appView)
}
else {

View File

@@ -15,6 +15,22 @@ ApplicationWindow {
anchors.fill: parent
}
function navigateTo(url, objectName)
{
var existingItem = stackView.find(function(item, index) {
return item.objectName === objectName
})
if (existingItem !== null) {
// Pop to the existing item
stackView.pop(existingItem)
}
else {
// Create a new item
stackView.push(url)
}
}
header: ToolBar {
RowLayout {
@@ -45,17 +61,6 @@ ApplicationWindow {
Layout.fillWidth: true
}
ToolButton {
icon.source: "qrc:/res/settings.png"
onClicked: stackView.push("qrc:/gui/SettingsView.qml")
Menu {
id: optionsMenu
x: parent.width
transformOrigin: Menu.TopRight
}
}
ToolButton {
icon.source: "qrc:/res/question_mark.png"
@@ -68,6 +73,28 @@ ApplicationWindow {
transformOrigin: Menu.TopRight
}
}
ToolButton {
icon.source: "qrc:/res/ic_videogame_asset_white_48px.svg"
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", "Gamepad Mapping")
Menu {
id: gamepadMappingMenu
x: parent.width
transformOrigin: Menu.TopRight
}
}
ToolButton {
icon.source: "qrc:/res/settings.png"
onClicked: navigateTo("qrc:/gui/SettingsView.qml", "Settings")
Menu {
id: optionsMenu
x: parent.width
transformOrigin: Menu.TopRight
}
}
}
}
}

View File

@@ -8,5 +8,6 @@
<file>gui/AppView.qml</file>
<file>gui/SettingsView.qml</file>
<file>gui/StreamSegue.qml</file>
<file>gui/GamepadMapper.qml</file>
</qresource>
</RCC>