2018-07-06 03:07:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "backend/boxartmanager.h"
|
|
|
|
#include "backend/computermanager.h"
|
2018-09-29 23:18:46 +00:00
|
|
|
#include "streaming/session.h"
|
2018-07-06 03:07:05 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
|
|
|
class AppModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
enum Roles
|
|
|
|
{
|
|
|
|
NameRole = Qt::UserRole,
|
|
|
|
RunningRole,
|
2020-08-02 04:06:01 +00:00
|
|
|
BoxArtRole,
|
|
|
|
HiddenRole,
|
|
|
|
AppIdRole,
|
2018-07-06 03:07:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AppModel(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
// Must be called before any QAbstractListModel functions
|
2020-08-02 04:06:01 +00:00
|
|
|
Q_INVOKABLE void initialize(ComputerManager* computerManager, int computerIndex, bool showHiddenGames);
|
2018-07-06 03:07:05 +00:00
|
|
|
|
2018-07-07 23:30:26 +00:00
|
|
|
Q_INVOKABLE Session* createSessionForApp(int appIndex);
|
|
|
|
|
2020-08-02 04:06:01 +00:00
|
|
|
Q_INVOKABLE int getRunningAppId();
|
2018-08-01 05:21:39 +00:00
|
|
|
|
|
|
|
Q_INVOKABLE QString getRunningAppName();
|
|
|
|
|
|
|
|
Q_INVOKABLE void quitRunningApp();
|
|
|
|
|
2020-08-02 04:06:01 +00:00
|
|
|
Q_INVOKABLE void setAppHidden(int appIndex, bool hidden);
|
|
|
|
|
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:
|
2020-08-02 04:06:01 +00:00
|
|
|
void updateAppList(QVector<NvApp> newList);
|
|
|
|
|
|
|
|
QVector<NvApp> getVisibleApps(const QVector<NvApp>& appList);
|
|
|
|
|
2018-07-06 03:07:05 +00:00
|
|
|
NvComputer* m_Computer;
|
|
|
|
BoxArtManager m_BoxArtManager;
|
2018-07-06 05:08:55 +00:00
|
|
|
ComputerManager* m_ComputerManager;
|
2020-08-02 04:06:01 +00:00
|
|
|
QVector<NvApp> m_VisibleApps, m_AllApps;
|
2018-07-06 03:07:05 +00:00
|
|
|
int m_CurrentGameId;
|
2020-08-02 04:06:01 +00:00
|
|
|
bool m_ShowHiddenGames;
|
2018-07-06 03:07:05 +00:00
|
|
|
};
|