#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QImage>
#include <QMutex>
#include <QTimer>
#include "ui_mainwindow.h"

#include "joystick.h"
#include "qnode.hpp"
#include "dashboard.h"
#include <sensor_msgs/BatteryState.h>
#include "atr.h"

using namespace cv;
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(int argc, char **argv, QWidget *parent = 0);
    ~MainWindow();
    enum {
        upleft = 0,
        up,
        upright,
        left,
        stop,
        right,
        downleft,
        down,
        downright
      };



public slots:
    void slot_keyboard_control();
    //void slot_command_control(int linear, int angular);
    void slot_rockKeyChange(int);
    void slot_speed_x(double x);
    void slot_speed_th(double th);
    void slot_batteryState(sensor_msgs::BatteryState);
    void Slider_raw_valueChanged(int v);
    void Slider_linear_valueChanged(int v);
    void importFrame();//read video
    void slot_show_image(const QImage& image);//added
    void slot_show_solvedImage(const QImage& solvedImage);
    void slot_get_slovedImage();

private slots:
    void on_Stop_receive_clicked();

private slots:
    void on_Open_receive_clicked();

    void on_ConnectTello_clicked();

private:
    Ui::MainWindow *ui;
    QNode qnode;
    ATR atr;
    JoyStick *rock_widget;
    DashBoard *m_DashBoard_x;
    DashBoard *m_DashBoard_th;

    VideoCapture capture;
    QTimer *timer;
    Mat frame;
    bool isCamerea = 0;

    void initUis();
    void setBtnStyles();
    void connections();

    QImage qimage_;//added
    mutable QMutex qimage_mutex_;//added


};

#endif // MAINWINDOW_H
