#ifndef CONTROLNETCONFIGWIDGET_H
#define CONTROLNETCONFIGWIDGET_H

#include <wDevicesManager/ledcard.h>
#include <communication/hpptclient.h>
#include <base/loemptydialog.h>
#include "base/qiplineedit.h"
#include "base/switchcontrol.h"
#include <QButtonGroup>
#include <QJsonObject>
#include <QRadioButton>
#include <QGroupBox>
#include <QCheckBox>

typedef struct wifiInfo{
    QString ssid;
    int signal;
    QString encryptionMethod;

}ST_WIFiINFO;
typedef struct ApnInfo{
    QString apn;
    QString carrier;
    QString mcc;
    QString mmsc;
    QString mmsport;
    QString mmsproxy;
    QString mnc;
    QString password;
    QString port;
    QString proxy;
    QString server;
    QString type;
    QString user;
}ST_APNINFO;
class ControlNetConfigWidget : public QWidget {
    Q_OBJECT
public:
    explicit ControlNetConfigWidget(QWidget *parent = nullptr,QList<LedCard *> *m_pLedlist=nullptr);
    ~ControlNetConfigWidget();
protected slots:
    void changeEvent(QEvent *) override;
    void transUi();

    void onSetWiFiModel();
    void onReadbackWiFiModel();
    void onSetAp();
    void OnDhcpOrSpecifyIp(int iIndex);
    void OnScanWifi();
    void onSet4GInfo();
    void onReadback4G();
    void onReadbackFlightModel();
    void onGetMcc();
    void onGet4GStatus();
    void SetMcc(QString strMcc);
    void onFightModelChecked(bool b);
signals:
    void sigSend(QJsonObject &,QString);
    void sigGetDhcpOrSpecifyIp(int);
protected slots:
    void DeletePostingDlg();
    void OnProHttpResponse(QString url, QString postMD5, QByteArray data);
    void OnProHttpResponseAll(QString url, QString postMD5, QByteArray data);
    void onSelectedDeviceList(QList<LedCard*> *);
    void onReadbackAllThisPage();
    void OnControlTypeSwitchIndexChanged(int index);
    void OnComboMccChanged(int);
    void OnComboCarrierChanged(int index);
    void OnCustom4G(bool b);
    void OnOpne4G(bool b);

private:
    QList<LedCard *> *m_pLedlist=nullptr;
    LedCard   *m_pLedCard = nullptr;
    LedCard   *m_oldLedlist = nullptr;
    HpptClient *pHpptClient = nullptr;
    HpptClient *pHpptClientAll = nullptr;
    QString m_strUrl="";
    LoEmptyDialog * m_PostingDlg=nullptr;
    QTimer *m_pGetAskTimer=nullptr;
    bool m_bSelected=false;
    QList<QJsonObject> m_ApnInfoiList;
    QList<QJsonObject> m_MccCarrierInfoiList;
    QJsonObject m_4gObj;
    QString mcc;
    QString apn;
    bool iEnableFlag=true;
    int m_buttonFlagClick=0;


    QButtonGroup *m_buttonGroup;
    QLabel *lbLanCfg;
    QRadioButton *fdDhcp;
    QRadioButton *fdSpecifyIp;
    QVBoxLayout *vBoxSpecifyIp;
    QGroupBox *gBoxSpecifyIp;
    QLabel *labelIpAddress;
    QIPLineEdit *fdIP;
    QLabel *labelMaskAddress;
    QIPLineEdit *fdGateWay;
    QLabel *labelGateway;
    QIPLineEdit *fdMask;
    QLabel *labelDnsAddress;
    QIPLineEdit *fdDns;
    QPushButton *btnLanSet;
    QPushButton *btnLanGet;
    QLabel *label_5;
    QHBoxLayout *horizontalLayout_2;
    QVBoxLayout *verticalLayout_6;
    QGroupBox *groupBox_3;
    QVBoxLayout *verticalLayout_7;
    QHBoxLayout *horizontalLayout_9;
    QVBoxLayout *verticalLayout_11;
    QLabel *labelWifiName;
    QLabel *labelWifiPassword;
    QVBoxLayout *verticalLayout_12;
    QComboBox *comboBox;
    QLineEdit *lineEditWifiPassword;
    QVBoxLayout *verticalLayout_13;
    QPushButton *pushButtonScan;
    QSpacerItem *horizontalSpacer_10;
    QPushButton *pushButtonWiFiModel;
    QPushButton *pushButtonReadbackWiFiModel;
    QVBoxLayout *verticalLayout_4;
    QGroupBox *groupBox_4;
    QVBoxLayout *verticalLayout_8;
    QHBoxLayout *horizontalLayout_12;
    QVBoxLayout *verticalLayout_14;
    QLabel *labelApName;
    QLabel *labelApPassword;
    QVBoxLayout *verticalLayout_15;
    QLineEdit *lineEditHotspotName;
    QLineEdit *lineEditApPassword;
    QPushButton *pushButtonApSet;
    QSpacerItem *horizontalSpacer_2;
    QFrame *line_3;
    QLabel *label;
    QCheckBox *checkBox4g;
    QHBoxLayout *horizontalLayout_13;
    QPushButton *pushButtonReadback4G;
    QLabel *label_ApnInfo;
    QLineEdit *lineEditApnInfo;
    QPushButton *pushButtonRead4GStatus;
    QSpacerItem *horizontalSpacer_6;
    QSpacerItem *verticalSpacer_2;
    QGroupBox *groupBox_5;
    QVBoxLayout *verticalLayout_16;
    QLabel *label_8;
    QCheckBox *checkBoxCustom;
    QHBoxLayout *horizontalLayout_10;
    QPushButton *pushButtonGetMcc;
    QLabel *label_9;
    QLabel *label_2;
    QComboBox *comboBoxCountryID;
    QLabel *label_11;
    QLabel *label_3;
    QComboBox *comboBoxCarrierName;
    QLabel *label_12;
    QLabel *label_4;
    QLineEdit *lineEditAPN;
    QSpacerItem *horizontalSpacer_3;
    QHBoxLayout *horizontalLayout_11;
    QLabel *label_6;
    QLineEdit *lineEditUser;
    QLabel *label_7;
    QLineEdit *lineEditPassword;
    QSpacerItem *horizontalSpacer_7;
    QHBoxLayout *horizontalLayout_8;
    QSpacerItem *horizontalSpacer_5;
    QPushButton *pushButtonSet4GInfo;
    QPushButton *pushButtonSetYuanHengApn;
    QSpacerItem *horizontalSpacer_4;
    QSpacerItem *verticalSpacer_4;
    QHBoxLayout *horizontalLayout_15;
    QLabel *label_10;
    SwitchControl *widgetFightModel;
    QPushButton *pushButtonReadbackFlightModel;
    QSpacerItem *horizontalSpacer_8;
    QSpacerItem *verticalSpacer;
};

#endif // CONTROLNETCONFIGWIDGET_H
