mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-23 16:39:02 +00:00
Start work on launching a stream from QML and rip out remaining QtWidgets
This commit is contained in:
@@ -7,6 +7,7 @@ import ComputerManager 1.0
|
||||
|
||||
GridView {
|
||||
property int computerIndex
|
||||
property AppModel appModel : createModel()
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 5
|
||||
@@ -33,7 +34,7 @@ GridView {
|
||||
return model
|
||||
}
|
||||
|
||||
model: createModel()
|
||||
model: appModel
|
||||
|
||||
delegate: Item {
|
||||
width: 200; height: 300;
|
||||
@@ -64,7 +65,8 @@ GridView {
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
parent.GridView.view.currentIndex = index
|
||||
var session = appModel.createSessionForGame(index);
|
||||
session.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,14 @@ void AppModel::initialize(ComputerManager* computerManager, int computerIndex)
|
||||
m_CurrentGameId = m_Computer->currentGameId;
|
||||
}
|
||||
|
||||
Session* AppModel::createSessionForApp(int appIndex)
|
||||
{
|
||||
Q_ASSERT(appIndex < m_Apps.count());
|
||||
NvApp app = m_Apps.at(appIndex);
|
||||
|
||||
return new Session(m_Computer, app);
|
||||
}
|
||||
|
||||
int AppModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
// For list models only the root node (an invalid parent) should return the list's size. For all
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "backend/boxartmanager.h"
|
||||
#include "backend/computermanager.h"
|
||||
#include "streaming/session.hpp"
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
@@ -22,6 +23,8 @@ public:
|
||||
// Must be called before any QAbstractListModel functions
|
||||
Q_INVOKABLE void initialize(ComputerManager* computerManager, int computerIndex);
|
||||
|
||||
Q_INVOKABLE Session* createSessionForApp(int appIndex);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
|
||||
@@ -78,6 +78,26 @@ QHash<int, QByteArray> ComputerModel::roleNames() const
|
||||
return names;
|
||||
}
|
||||
|
||||
Session* ComputerModel::createSessionForCurrentGame(int computerIndex)
|
||||
{
|
||||
Q_ASSERT(computerIndex < m_Computers.count());
|
||||
|
||||
NvComputer* computer = m_Computers[computerIndex];
|
||||
|
||||
// We must currently be streaming a game to use this function
|
||||
Q_ASSERT(computer->currentGameId != 0);
|
||||
|
||||
for (NvApp& app : computer->appList) {
|
||||
if (app.id == computer->currentGameId) {
|
||||
return new Session(computer, app);
|
||||
}
|
||||
}
|
||||
|
||||
// We have a current running app but it's not in our app list
|
||||
Q_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ComputerModel::deleteComputer(int computerIndex)
|
||||
{
|
||||
Q_ASSERT(computerIndex < m_Computers.count());
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "backend/computermanager.h"
|
||||
#include "streaming/session.hpp"
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
@@ -33,6 +34,8 @@ public:
|
||||
|
||||
Q_INVOKABLE bool wakeComputer(int computerIndex);
|
||||
|
||||
Q_INVOKABLE Session* createSessionForCurrentGame(int computerIndex);
|
||||
|
||||
signals:
|
||||
void pairingCompleted(QVariant error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user