mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-18 18:42:40 +00:00
Now with WoL and PC deletion from QML. Deletion needs bugfix, possibly not committed to storage?
This commit is contained in:
parent
277594139b
commit
9e744ce169
@ -142,44 +142,66 @@ GridView {
|
|||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Menu {
|
||||||
|
id: pcContextMenu
|
||||||
|
MenuItem {
|
||||||
|
text: "Wake PC"
|
||||||
|
onTriggered: computerModel.wakeComputer(index)
|
||||||
|
}
|
||||||
|
MenuItem {
|
||||||
|
text: "Delete PC"
|
||||||
|
onTriggered: {
|
||||||
|
deletePcDialog.pcIndex = index
|
||||||
|
// get confirmation first, actual closing is called from the dialog
|
||||||
|
deletePcDialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton;
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (model.addPc) {
|
if(mouse.button === Qt.LeftButton) {
|
||||||
addPcDialog.open()
|
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)
|
|
||||||
appView.computerIndex = index
|
|
||||||
appView.objectName = model.name
|
|
||||||
stackView.push(appView)
|
|
||||||
}
|
}
|
||||||
else {
|
else if (model.online) {
|
||||||
if (!model.busy) {
|
if (model.paired) {
|
||||||
var pin = ("0000" + Math.floor(Math.random() * 10000)).slice(-4)
|
// go to game view
|
||||||
|
var component = Qt.createComponent("AppView.qml")
|
||||||
// Stop polling, since pairing may make GFE unresponsive
|
var appView = component.createObject(stackView)
|
||||||
ComputerManager.stopPollingAsync()
|
appView.computerIndex = index
|
||||||
|
appView.objectName = model.name
|
||||||
// Kick off pairing in the background
|
stackView.push(appView)
|
||||||
computerModel.pairComputer(index, pin)
|
|
||||||
|
|
||||||
// Display the pairing dialog
|
|
||||||
pairDialog.pin = pin
|
|
||||||
pairDialog.open()
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// cannot pair while something is streaming or attempting to pair
|
if (!model.busy) {
|
||||||
errorDialog.text = "This PC is currently busy. Make sure to quit any running games and try again."
|
var pin = ("0000" + Math.floor(Math.random() * 10000)).slice(-4)
|
||||||
errorDialog.open()
|
|
||||||
|
// Stop polling, since pairing may make GFE unresponsive
|
||||||
|
ComputerManager.stopPollingAsync()
|
||||||
|
|
||||||
|
// 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 {
|
else { // right click
|
||||||
// TODO: Wake on LAN and delete PC options
|
if(!model.addPc) { // but only for actual PCs, not the add-pc option
|
||||||
|
pcContextMenu.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,6 +240,22 @@ GridView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageDialog {
|
||||||
|
id: deletePcDialog
|
||||||
|
// don't allow edits to the rest of the window while open
|
||||||
|
modality:Qt.WindowModal
|
||||||
|
property int pcIndex : -1;
|
||||||
|
text:"Are you sure you want to unpair from this PC?"
|
||||||
|
standardButtons: StandardButton.Yes |StandardButton.No
|
||||||
|
onYes: {
|
||||||
|
console.log("deleting PC pairing for PC at index: " + pcIndex)
|
||||||
|
computerModel.deleteComputer(pcIndex);
|
||||||
|
// hack to remove the child from the gridview
|
||||||
|
model = createModel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: addPcDialog
|
id: addPcDialog
|
||||||
property string label: "Enter the IP address of your GameStream PC"
|
property string label: "Enter the IP address of your GameStream PC"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user