#ifndef PARKINGSPACEGUIDEVIEW_MAINWINDOW_H #define PARKINGSPACEGUIDEVIEW_MAINWINDOW_H #include #include #include #include class QComboBox; class QLabel; class QLineEdit; class QPushButton; class QResizeEvent; class QTimer; 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); void ApplyPanelConfig(const QJsonObject& panel); void ApplySessionList(const QJsonArray& sessions); void StartReplay(const QJsonArray& samples); void StopReplay(); void PlayNextReplaySample(); void RebuildModelCombo(const QJsonArray& models); void AddStatusRow(const QString& caption, QLabel*& valueLabel); QString PromptControlPassword(const QString& title); void RecordChockWithPassword(bool chockOn); bool IsPasswordSessionValid() const; void BeginPasswordSession(); void ExpirePasswordSession(); 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; bool m_loggedIn = false; bool m_requireLogin = true; bool m_maintenanceMode = false; int m_passwordValidSeconds = 120; qint64 m_passwordValidUntilMs = 0; bool m_replaying = false; QLineEdit* m_passwordEdit = nullptr; QPushButton* m_loginButton = nullptr; QPushButton* m_maintenanceButton = nullptr; QPushButton* m_chockOnButton = nullptr; QPushButton* m_chockOffButton = nullptr; QComboBox* m_sessionCombo = nullptr; QPushButton* m_replayButton = nullptr; QLabel* m_activatedLabel = nullptr; QLabel* m_selfCheckLabel = nullptr; QLabel* m_workModeLabel = nullptr; QLabel* m_personChockLabel = nullptr; QLabel* m_chockOnLabel = nullptr; QLabel* m_chockOffLabel = nullptr; QTimer* m_replayTimer = nullptr; QTimer* m_passwordExpireTimer = nullptr; QJsonArray m_replaySamples; int m_replayIndex = 0; }; #endif // PARKINGSPACEGUIDEVIEW_MAINWINDOW_H