70 lines
1.8 KiB
C
70 lines
1.8 KiB
C
|
|
#ifndef PARKINGSPACEGUIDEVIEW_MAINWINDOW_H
|
||
|
|
#define PARKINGSPACEGUIDEVIEW_MAINWINDOW_H
|
||
|
|
|
||
|
|
#include <QJsonObject>
|
||
|
|
#include <QMainWindow>
|
||
|
|
#include <QString>
|
||
|
|
|
||
|
|
class QLabel;
|
||
|
|
class QResizeEvent;
|
||
|
|
class RemoteGuideClient;
|
||
|
|
|
||
|
|
namespace Ui {
|
||
|
|
class MainWindow;
|
||
|
|
}
|
||
|
|
|
||
|
|
class MainWindow : public QMainWindow
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
explicit MainWindow(int discoveryPort = 5555,
|
||
|
|
QWidget* parent = nullptr);
|
||
|
|
~MainWindow() override;
|
||
|
|
|
||
|
|
protected:
|
||
|
|
void resizeEvent(QResizeEvent* event) override;
|
||
|
|
|
||
|
|
private:
|
||
|
|
struct GuidePresentation
|
||
|
|
{
|
||
|
|
QString name;
|
||
|
|
QString englishName;
|
||
|
|
QString displayText;
|
||
|
|
QString meaning;
|
||
|
|
QString action;
|
||
|
|
QString level;
|
||
|
|
};
|
||
|
|
|
||
|
|
void ApplyStatus(const QJsonObject& status);
|
||
|
|
void ApplyGuideState(int stateCode, const QString& guideText);
|
||
|
|
void UpdateControls();
|
||
|
|
void SetMetric(QLabel* label,
|
||
|
|
const QJsonObject& status,
|
||
|
|
const char* field,
|
||
|
|
const QString& unit,
|
||
|
|
int precision = 2,
|
||
|
|
double divisor = 1.0);
|
||
|
|
void HandleConnectionState(bool connected,
|
||
|
|
const QString& message,
|
||
|
|
const QString& deviceName,
|
||
|
|
const QString& address);
|
||
|
|
void HandleCommandFinished(const QString& command,
|
||
|
|
bool ok,
|
||
|
|
const QString& message,
|
||
|
|
const QJsonObject& response);
|
||
|
|
|
||
|
|
static const GuidePresentation& PresentationForState(int stateCode);
|
||
|
|
|
||
|
|
private:
|
||
|
|
Ui::MainWindow* ui = nullptr;
|
||
|
|
RemoteGuideClient* m_client = nullptr;
|
||
|
|
|
||
|
|
int m_currentStateCode = 12;
|
||
|
|
bool m_connected = false;
|
||
|
|
bool m_guidanceRunning = false;
|
||
|
|
bool m_commandPending = false;
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif // PARKINGSPACEGUIDEVIEW_MAINWINDOW_H
|