Add support for hiding games

Fixes #255
This commit is contained in:
Cameron Gutman
2020-08-01 21:06:01 -07:00
parent 9385d62c89
commit 539bf0cb30
10 changed files with 239 additions and 47 deletions
+34 -3
View File
@@ -9,6 +9,7 @@ CenteredGridView {
property int computerIndex
property AppModel appModel : createModel()
property bool activated
property bool showHiddenGames
id: appGrid
focus: true
@@ -48,7 +49,7 @@ CenteredGridView {
function createModel()
{
var model = Qt.createQmlObject('import AppModel 1.0; AppModel {}', parent, '')
model.initialize(ComputerManager, computerIndex)
model.initialize(ComputerManager, computerIndex, showHiddenGames)
return model
}
@@ -58,6 +59,9 @@ CenteredGridView {
width: 220; height: 287;
grid: appGrid
// Dim the app if it's hidden
opacity: model.hidden ? 0.4 : 1.0
Image {
property bool isPlaceholder: false
@@ -165,8 +169,8 @@ CenteredGridView {
function launchOrResumeSelectedApp()
{
var runningIndex = appModel.getRunningAppIndex()
if (runningIndex >= 0 && runningIndex !== index) {
var runningId = appModel.getRunningAppId()
if (runningId !== 0 && runningId !== model.appid) {
quitAppDialog.appName = appModel.getRunningAppName()
quitAppDialog.segueToStream = true
quitAppDialog.nextAppName = model.name
@@ -190,6 +194,25 @@ CenteredGridView {
}
}
onPressAndHold: {
// popup() ensures the menu appears under the mouse cursor
if (appContextMenu.popup) {
appContextMenu.popup()
}
else {
// Qt 5.9 doesn't have popup()
appContextMenu.open()
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton;
onClicked: {
parent.onPressAndHold()
}
}
Keys.onReturnPressed: {
// Open the app context menu if activated via the gamepad or keyboard
// for running games. If the game isn't running, the above onClicked
@@ -228,6 +251,14 @@ CenteredGridView {
onTriggered: doQuitGame()
visible: model.running
}
NavigableMenuItem {
parentMenu: appContextMenu
checkable: true
checked: model.hidden
text: "Hide Game"
onTriggered: appModel.setAppHidden(model.index, !model.hidden)
visible: !model.running || model.hidden
}
}
}