Tab based websocket comms looking like trad RM

This commit is contained in:
Jon ESA
2026-04-01 19:38:05 +01:00
parent 21a3c35876
commit e10e7127b7
7 changed files with 435 additions and 0 deletions

52
WebSocketController.h Normal file
View 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;
};