mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-16 08:17:58 +00:00
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#include "backend/computermanager.h"
|
|
#include "streaming/session.h"
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
class ComputerModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
enum Roles
|
|
{
|
|
NameRole = Qt::UserRole,
|
|
OnlineRole,
|
|
PairedRole,
|
|
BusyRole,
|
|
WakeableRole,
|
|
StatusUnknownRole
|
|
};
|
|
|
|
public:
|
|
explicit ComputerModel(QObject* object = nullptr);
|
|
|
|
// Must be called before any QAbstractListModel functions
|
|
Q_INVOKABLE void initialize(ComputerManager* computerManager);
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
virtual QHash<int, QByteArray> roleNames() const override;
|
|
|
|
Q_INVOKABLE void deleteComputer(int computerIndex);
|
|
|
|
Q_INVOKABLE QString generatePinString();
|
|
|
|
Q_INVOKABLE void pairComputer(int computerIndex, QString pin);
|
|
|
|
Q_INVOKABLE void testConnectionForComputer(int computerIndex);
|
|
|
|
Q_INVOKABLE void wakeComputer(int computerIndex);
|
|
|
|
Q_INVOKABLE void renameComputer(int computerIndex, QString name);
|
|
|
|
Q_INVOKABLE Session* createSessionForCurrentGame(int computerIndex);
|
|
|
|
signals:
|
|
void pairingCompleted(QVariant error);
|
|
void connectionTestCompleted(int result, QString blockedPorts);
|
|
|
|
private slots:
|
|
void handleComputerStateChanged(NvComputer* computer);
|
|
|
|
void handlePairingCompleted(NvComputer* computer, QString error);
|
|
|
|
private:
|
|
QVector<NvComputer*> m_Computers;
|
|
ComputerManager* m_ComputerManager;
|
|
};
|