/**
 * @file TriggerBar.h
 * @brief Trigger configuration bar (hub-side trigger semantics).
 *
 * Edits the trigger config (signal/edge/threshold/window/pre%/mode), sends
 * setTrigger + arm/disarm/rearm/trigStop over the WS, and reflects hub
 * triggerState broadcasts in a status badge. Mirrors the ImGui TriggerPanel.
 */

#pragma once

#include <QWidget>

class QComboBox;
class QDoubleSpinBox;
class QSlider;
class QLabel;
class QPushButton;
class QRadioButton;

namespace shq {

class Hub;

class TriggerBar : public QWidget {
    Q_OBJECT
public:
    explicit TriggerBar(Hub* hub, QWidget* parent = nullptr);

public Q_SLOTS:
    /** Rebuild the signal combo from the model. */
    void refreshSignals();
    /** Reflect the latest hub trigger state (badge + buttons). */
    void onTriggerStateChanged();

private:
    void sendConfig();
    void pullFromUi();

    Hub*            hub_;
    QComboBox*      sigCombo_   = nullptr;
    QComboBox*      edgeCombo_  = nullptr;
    QDoubleSpinBox* thrSpin_    = nullptr;
    QComboBox*      winCombo_   = nullptr;
    QSlider*        preSlider_  = nullptr;
    QLabel*         preLbl_     = nullptr;
    QRadioButton*   normRadio_  = nullptr;
    QRadioButton*   singleRadio_= nullptr;
    QLabel*         badge_      = nullptr;
    QPushButton*    armBtn_     = nullptr;
    QPushButton*    disarmBtn_  = nullptr;
    QPushButton*    stopBtn_    = nullptr;
    QLabel*         trigTimeLbl_= nullptr;
    bool            updating_   = false;
};

} /* namespace shq */
