Tab based websocket comms looking like trad RM
This commit is contained in:
52
WebSocketController.h
Normal file
52
WebSocketController.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QWebSocket>
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QTextEdit;
|
||||
class GamesPanel;
|
||||
class SettingsTree;
|
||||
class VersionsPanel;
|
||||
|
||||
class WebSocketController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WebSocketController(QLineEdit *urlEdit,
|
||||
QLabel *statusLabel,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
QWebSocket *socket();
|
||||
void addLogView(QTextEdit *log);
|
||||
void setSettingsTree(SettingsTree *tree);
|
||||
void setGamesPanel(GamesPanel *panel);
|
||||
void setVersionsPanel(VersionsPanel *panel);
|
||||
bool isConnected() const;
|
||||
|
||||
public slots:
|
||||
void startConnection();
|
||||
void closeConnection();
|
||||
void sendCommand(const QString &cmd);
|
||||
|
||||
void onConnected();
|
||||
void onDisconnected();
|
||||
void onTextMessageReceived(const QString &msg);
|
||||
void onErrorOccurred(QAbstractSocket::SocketError error);
|
||||
void onValueEdited(const QString &key, const QString &newValue);
|
||||
|
||||
private:
|
||||
void handleProtocol(const QString &msg);
|
||||
void broadcast(const QString &line);
|
||||
|
||||
QLineEdit *m_urlEdit = nullptr;
|
||||
QLabel *m_statusLabel = nullptr;
|
||||
QWebSocket m_socket;
|
||||
QList<QTextEdit *> m_logs;
|
||||
SettingsTree *m_settingsTree = nullptr;
|
||||
GamesPanel *m_gamesPanel = nullptr;
|
||||
VersionsPanel *m_versionsPanel = nullptr;
|
||||
QStringList m_settingsKeys;
|
||||
int m_rnpCount = -1;
|
||||
};
|
||||
Reference in New Issue
Block a user