2018-07-06 03:07:05 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
|
|
|
|
import AppModel 1.0
|
|
|
|
|
2018-07-06 05:08:55 +00:00
|
|
|
import ComputerManager 1.0
|
|
|
|
|
2018-07-06 03:07:05 +00:00
|
|
|
GridView {
|
|
|
|
property int computerIndex
|
2018-07-07 23:30:26 +00:00
|
|
|
property AppModel appModel : createModel()
|
2018-07-06 03:07:05 +00:00
|
|
|
|
|
|
|
anchors.fill: parent
|
2018-07-08 15:28:28 +00:00
|
|
|
anchors.leftMargin: (parent.width % (cellWidth + anchors.rightMargin)) / 2
|
2018-07-06 03:07:05 +00:00
|
|
|
anchors.topMargin: 5
|
|
|
|
anchors.rightMargin: 5
|
|
|
|
anchors.bottomMargin: 5
|
|
|
|
cellWidth: 225; cellHeight: 350;
|
|
|
|
focus: true
|
|
|
|
|
2018-07-09 05:07:20 +00:00
|
|
|
// The StackView will trigger a visibility change when
|
|
|
|
// we're pushed onto it, causing our onVisibleChanged
|
|
|
|
// routine to run, but only if we start as invisible
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
|
|
|
// Start polling when this view is shown
|
|
|
|
ComputerManager.startPolling()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Stop polling when this view is not on top
|
|
|
|
ComputerManager.stopPollingAsync()
|
|
|
|
}
|
2018-07-06 07:34:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-06 03:07:05 +00:00
|
|
|
function createModel()
|
|
|
|
{
|
2018-07-06 05:08:55 +00:00
|
|
|
var model = Qt.createQmlObject('import AppModel 1.0; AppModel {}', parent, '')
|
|
|
|
model.initialize(ComputerManager, computerIndex)
|
2018-07-06 03:07:05 +00:00
|
|
|
return model
|
|
|
|
}
|
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
model: appModel
|
2018-07-06 03:07:05 +00:00
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
width: 200; height: 300;
|
|
|
|
|
2018-07-08 15:44:09 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
if (model.running) {
|
|
|
|
appNameText.text = "<font color=\"green\">Running</font><font color=\"white\"> - </font>" + appNameText.text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-06 03:07:05 +00:00
|
|
|
Image {
|
|
|
|
id: appIcon
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter;
|
|
|
|
source: model.boxart
|
|
|
|
sourceSize {
|
|
|
|
width: 150
|
|
|
|
height: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: appNameText
|
|
|
|
text: model.name
|
|
|
|
color: "white"
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
height: 100
|
|
|
|
anchors.top: appIcon.bottom
|
|
|
|
font.pointSize: 26
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2018-07-07 23:47:39 +00:00
|
|
|
// TODO: Check if a different game is running
|
2018-07-08 04:52:20 +00:00
|
|
|
|
2018-07-09 05:06:52 +00:00
|
|
|
var component = Qt.createComponent("StreamSegue.qml")
|
|
|
|
var segue = component.createObject(stackView)
|
|
|
|
segue.appname = model.name
|
|
|
|
segue.session = appModel.createSessionForApp(index)
|
|
|
|
stackView.push(segue)
|
2018-07-06 03:07:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|