mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-16 00:07:58 +00:00
70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "backend/boxartmanager.h"
|
|
#include "backend/computermanager.h"
|
|
#include "streaming/session.h"
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
class AppModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
enum Roles
|
|
{
|
|
NameRole = Qt::UserRole,
|
|
RunningRole,
|
|
BoxArtRole,
|
|
HiddenRole,
|
|
AppIdRole,
|
|
DirectLaunchRole
|
|
};
|
|
|
|
public:
|
|
explicit AppModel(QObject *parent = nullptr);
|
|
|
|
// Must be called before any QAbstractListModel functions
|
|
Q_INVOKABLE void initialize(ComputerManager* computerManager, int computerIndex, bool showHiddenGames);
|
|
|
|
Q_INVOKABLE Session* createSessionForApp(int appIndex);
|
|
|
|
Q_INVOKABLE int getDirectLaunchAppIndex();
|
|
|
|
Q_INVOKABLE int getRunningAppId();
|
|
|
|
Q_INVOKABLE QString getRunningAppName();
|
|
|
|
Q_INVOKABLE void quitRunningApp();
|
|
|
|
Q_INVOKABLE void setAppHidden(int appIndex, bool hidden);
|
|
|
|
Q_INVOKABLE void setAppDirectLaunch(int appIndex, bool directLaunch);
|
|
|
|
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);
|
|
|
|
signals:
|
|
void computerLost();
|
|
|
|
private:
|
|
void updateAppList(QVector<NvApp> newList);
|
|
|
|
QVector<NvApp> getVisibleApps(const QVector<NvApp>& appList);
|
|
|
|
bool isAppCurrentlyVisible(const NvApp& app);
|
|
|
|
NvComputer* m_Computer;
|
|
BoxArtManager m_BoxArtManager;
|
|
ComputerManager* m_ComputerManager;
|
|
QVector<NvApp> m_VisibleApps, m_AllApps;
|
|
int m_CurrentGameId;
|
|
bool m_ShowHiddenGames;
|
|
};
|