mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +00:00
Switch to ItemDelegate for PCs and Apps for proper hover and click behavior
This commit is contained in:
+12
-13
@@ -16,8 +16,7 @@ GridView {
|
|||||||
anchors.topMargin: 20
|
anchors.topMargin: 20
|
||||||
anchors.rightMargin: 5
|
anchors.rightMargin: 5
|
||||||
anchors.bottomMargin: 5
|
anchors.bottomMargin: 5
|
||||||
cellWidth: 225; cellHeight: 350;
|
cellWidth: 225; cellHeight: 385;
|
||||||
focus: true
|
|
||||||
|
|
||||||
// Cache delegates for 1000px in both directions to improve
|
// Cache delegates for 1000px in both directions to improve
|
||||||
// scrolling and resizing performance
|
// scrolling and resizing performance
|
||||||
@@ -52,12 +51,13 @@ GridView {
|
|||||||
|
|
||||||
model: appModel
|
model: appModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: ItemDelegate {
|
||||||
width: 200; height: 300;
|
width: 200; height: 335;
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: appIcon
|
id: appIcon
|
||||||
anchors.horizontalCenter: parent.horizontalCenter;
|
anchors.horizontalCenter: parent.horizontalCenter;
|
||||||
|
y: 20
|
||||||
source: model.boxart
|
source: model.boxart
|
||||||
sourceSize {
|
sourceSize {
|
||||||
width: 150
|
width: 150
|
||||||
@@ -132,18 +132,17 @@ GridView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
// Nothing is running or this app is running
|
||||||
|
launchOrResumeSelectedApp()
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mouse.button === Qt.LeftButton) {
|
// Right click
|
||||||
// Nothing is running or this app is running
|
appContextMenu.open()
|
||||||
launchOrResumeSelectedApp()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Right click
|
|
||||||
appContextMenu.open()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+38
-40
@@ -19,7 +19,6 @@ GridView {
|
|||||||
anchors.rightMargin: 5
|
anchors.rightMargin: 5
|
||||||
anchors.bottomMargin: 5
|
anchors.bottomMargin: 5
|
||||||
cellWidth: 350; cellHeight: 350;
|
cellWidth: 350; cellHeight: 350;
|
||||||
focus: true
|
|
||||||
objectName: "Computers"
|
objectName: "Computers"
|
||||||
|
|
||||||
// The StackView will trigger a visibility change when
|
// The StackView will trigger a visibility change when
|
||||||
@@ -73,7 +72,7 @@ GridView {
|
|||||||
|
|
||||||
model: computerModel
|
model: computerModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: ItemDelegate {
|
||||||
width: 300; height: 300;
|
width: 300; height: 300;
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
@@ -142,47 +141,46 @@ GridView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (model.addPc) {
|
||||||
|
addPcDialog.open()
|
||||||
|
}
|
||||||
|
else if (model.online) {
|
||||||
|
if (model.paired) {
|
||||||
|
// go to game view
|
||||||
|
var component = Qt.createComponent("AppView.qml")
|
||||||
|
var appView = component.createObject(stackView, {"computerIndex": index, "objectName": model.name})
|
||||||
|
stackView.push(appView)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!model.busy) {
|
||||||
|
var pin = ("0000" + Math.floor(Math.random() * 10000)).slice(-4)
|
||||||
|
|
||||||
|
// Kick off pairing in the background
|
||||||
|
computerModel.pairComputer(index, pin)
|
||||||
|
|
||||||
|
// Display the pairing dialog
|
||||||
|
pairDialog.pin = pin
|
||||||
|
pairDialog.open()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// cannot pair while something is streaming or attempting to pair
|
||||||
|
errorDialog.text = "This PC is currently busy. Make sure to quit any running games and try again."
|
||||||
|
errorDialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (!model.online) {
|
||||||
|
pcContextMenu.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton;
|
acceptedButtons: Qt.RightButton;
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(mouse.button === Qt.LeftButton) {
|
// right click
|
||||||
if (model.addPc) {
|
if (!model.addPc) { // but only for actual PCs, not the add-pc option
|
||||||
addPcDialog.open()
|
pcContextMenu.open()
|
||||||
}
|
|
||||||
else if (model.online) {
|
|
||||||
if (model.paired) {
|
|
||||||
// go to game view
|
|
||||||
var component = Qt.createComponent("AppView.qml")
|
|
||||||
var appView = component.createObject(stackView, {"computerIndex": index, "objectName": model.name})
|
|
||||||
stackView.push(appView)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!model.busy) {
|
|
||||||
var pin = ("0000" + Math.floor(Math.random() * 10000)).slice(-4)
|
|
||||||
|
|
||||||
// Kick off pairing in the background
|
|
||||||
computerModel.pairComputer(index, pin)
|
|
||||||
|
|
||||||
// Display the pairing dialog
|
|
||||||
pairDialog.pin = pin
|
|
||||||
pairDialog.open()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// cannot pair while something is streaming or attempting to pair
|
|
||||||
errorDialog.text = "This PC is currently busy. Make sure to quit any running games and try again."
|
|
||||||
errorDialog.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(!model.online) {
|
|
||||||
pcContextMenu.open()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else { // right click
|
|
||||||
if(!model.addPc) { // but only for actual PCs, not the add-pc option
|
|
||||||
pcContextMenu.open()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user