2018-07-06 03:07:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "backend/boxartmanager.h"
|
|
|
|
#include "backend/computermanager.h"
|
2018-07-07 23:30:26 +00:00
|
|
|
#include "streaming/session.hpp"
|
2018-07-06 03:07:05 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
|
|
|
class AppModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
enum Roles
|
|
|
|
{
|
|
|
|
NameRole = Qt::UserRole,
|
|
|
|
RunningRole,
|
|
|
|
BoxArtRole
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AppModel(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
// Must be called before any QAbstractListModel functions
|
2018-07-06 05:08:55 +00:00
|
|
|
Q_INVOKABLE void initialize(ComputerManager* computerManager, int computerIndex);
|
2018-07-06 03:07:05 +00:00
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
Q_INVOKABLE Session* createSessionForApp(int appIndex);
|
|
|
|
|
2018-08-01 05:21:39 +00:00
|
|
|
Q_INVOKABLE int getRunningAppIndex();
|
|
|
|
|
|
|
|
Q_INVOKABLE QString getRunningAppName();
|
|
|
|
|
|
|
|
Q_INVOKABLE void quitRunningApp();
|
|
|
|
|
2018-07-06 03:07:05 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
|
|
|
|
virtual QHash<int, QByteArray> roleNames() const override;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleComputerStateChanged(NvComputer* computer);
|
|
|
|
|
|
|
|
void handleBoxArtLoaded(NvComputer* computer, NvApp app, QUrl image);
|
|
|
|
|
2018-08-10 01:48:40 +00:00
|
|
|
signals:
|
|
|
|
void computerLost();
|
|
|
|
|
2018-07-06 03:07:05 +00:00
|
|
|
private:
|
|
|
|
NvComputer* m_Computer;
|
|
|
|
BoxArtManager m_BoxArtManager;
|
2018-07-06 05:08:55 +00:00
|
|
|
ComputerManager* m_ComputerManager;
|
2018-07-06 03:07:05 +00:00
|
|
|
QVector<NvApp> m_Apps;
|
|
|
|
int m_CurrentGameId;
|
|
|
|
};
|