#ifndef Q_VIDEO_WIDGET_H
#define Q_VIDEO_WIDGET_H

#include <QWidget>
#include <QTimer>
#include <QPixmap>
#include "ui_qvideopanel.h"
#include "q_border_label.h"
#include "QVideoPanelLabel.h"
#include "nsst_define.h"

class QVideoWidget : public QWidget
{
    Q_OBJECT

public:
    QVideoWidget(QWidget *parent, const NsstChannel& nsst_channel);
    ~QVideoWidget();

    QVideoPanelLabel*  video_panel_label_;
    Ui_form_video video_form_;
    QBorderLabel* border_;

    QPixmap pixmap_alarm_on_;
    QPixmap pixmap_alarm_off_;

    void SetPanelActive();
    void SetPanelNoActive();

    void SetRecordIcon(bool recording);

    void OnAlarm(int type,int status);

    void StopRecord();

    void PlayVideo();
    void CloseVideo();

    void StartDrawText(int index,POINT* start,const QString& text);
    void StopDrawText(int index);

    void ShowAlarmGrid();
    void StopDrawAlarmGrid();
    void SetAllAlarmGrid(int* area);
    void ClearDrawAlarmGrid();

    void ResetDeviceId(DEVICE_ID id);

    void ShowFps();
    void CloseFps();

protected slots:
    void OnVideoBorderResize(QBorderLabel* border);

    void OnRecordClick();

    void OnCaptureClick();

    void OnTimerAlarmStatus();

    void OnTimerCheckRecord();

Q_SIGNALS:
    void keypress(int key);

    void wheel(int channel,int delta);
private:
    NsstChannel nsst_channel_;

    DWORD alarmtick[NS_ALARM_TYPE_COUNT];

    bool recording_;

    QString record_path_;

    QTimer* timer_alarm_status_;

    QTimer* timer_check_record_;

    virtual void keyPressEvent(QKeyEvent *ev);

    virtual void wheelEvent(QWheelEvent *);

    bool GetAppDataPath(QString* path);

    void StartRecord();

    //virtual void windowActivationChange(bool);
};

#endif // Q_VIDEO_WIDGET_H
