#ifndef PROMPTDIALOG_H
#define PROMPTDIALOG_H

#include <QDialog>
#include <QDir>
#include <QFile>
#include <QTextCodec>
#include "wordsinputdialog.h"
#include "numerinputdialog.h"
#include "setcontrolstyle.h"
#include "sharedviews/passworddialog.h"

#define NOODLES 1
#define BOTTOM 2
#define TIMELIMITMAX 2147483647
#define TIMELIMITMIN 2147385345

namespace Ui {
class PromptDialog;
}

class PromptDialog : public QDialog
{
    Q_OBJECT

public:
    explicit PromptDialog(QWidget *parent = 0);
    ~PromptDialog();

    enum BTN_SHOW
    {
        BTN_OK_CANCEL, //ok和cancel按钮
        BTN_OK,        //ok按钮
        BTN_R_R_S,     //重命名、替换、跳过
        BTN_RESTART,   //重启按钮
        BTN_UCANCEL,   //升级取消按钮
        BTN_WARRANT,   //授权按钮
        BTN_M_C_C,     //手动换色
        BTN_BOTTOM,    //底线检测
        BTN_FACE,      //面线检测
        BTN_NONE,      //无按钮
        BTN_P_NONE,    //进度条模式下无按钮(文件导入导出)
        BTN_HEAD_EMB,  //隔头绣
        BTN_MOVE_FRAME,   //定量移框
        BTN_HMI_DECRYPT,   //界面解密
        BTN_CHANGE_PASSWORD,    //修改一级密码
        BTN_SPINDLE_ROTATE,  //主轴旋转
        BTN_MSPINDLE_ROTATE,  //M轴旋转
        BTN_NOSEHESD,  //平绣，毛巾，（冲孔，缝纫）两个按钮  ,用的一个frameNoseHead
        BTN_NOSEHESDTHREE,  //平绣，毛巾，缠绕   ，三个按钮
        BTN_TRIMDOWN,  //下剪线
        BTN_LIFTMOTORCONTROL,//毛巾提升电机控制
        BTN_ELASTICCONTROL,//毛巾松紧线控制
        BTN_HOOK_TEST,   //平绣勾刀检测
        BTN_FOOT_TEST,   //独立压脚测试
        BTN_LINE_OFFSET,   //线迹偏移
        BTN_WORK_AREA   //设置可工作区域
    };

private:
    Ui::PromptDialog *ui;

    QList<QPushButton*> m_buttonEmbNeedleList;
    QList<QPushButton*> m_buttonEmbHeadList;
    QList<QPushButton*> m_buttonChenilleHeadList;

    QPushButton *m_pEmbNeedleBtn;
    QPoint m_btnOkPoint;//ok按钮位置
    QPoint m_btnCancelPoint;//cancel按钮位置

    int m_selectNeedleIdx;//针杆索引
    int m_selectHeadleIdx;//机头索引
    int m_funType;//功能类型

    int m_curColorOrder;//当前色序数
    int m_totalColorOrder;//总色序数
    int m_totalHead;//总机头数
    QString m_filePath;
    u8 m_headBuf[HEADBUF];

    int m_moveX;//定量移框X值
    int m_moveY;//定量移框Y值
    int m_spindleAngle;//主轴旋转角度值
    int m_gearValue;//档位值

    int m_noseHead; //毛巾平绣（冲孔缝纫）的切换
    int m_headType;//底线面线检测区分平绣还是缠绕
    int m_elasticWirePos; //松紧线的位置
    int m_adcFlagValue;//电位器标志
    int m_area;//xy正负位置
    int m_camColorChange;//凸轮换色
    int m_stepDrive;//步进电机驱动
    QString m_newPassword;//获取新密码字符串
    QString m_confirmPassword;//获取确认新密码字符串

    QString m_buttonStyle1;
    QString m_buttonStyle2;

private:
    void initControl();//初始化窗体控件，包括位置、尺寸、样式
    void initResolution1910();//初始化窗体控件为1920x1080分辨率
    void initResolution1006();//初始化窗体控件为1920x1080分辨率
    void initControlStyle();//初始化窗体控件样式
    void initArabControlPos();//设置阿拉伯语时控件对齐方式
    void refreshColorOrderHead();//刷新绣花机当前色序的机头工作号

public:
    void initDialog(int sel = 0);//初始化窗体
    void setTitleStr(QString str);//设置标题
    void setStrColor(QString str);//设置底线面线断线机头显示字体的颜色
    void setContentStr(QString str);//设置显示内容
    void setContentProcessStr(QString str);//设置进度条显示内容
    void setContentInfoShow();//主板信息内容显示
    void setContentWarrantShow();//授权信息内容显示
    void setContentHMIDecryptShow(QString id);//界面解密网卡ID号显示
    void setContentChangePasswordShow();//修改一级用户密码内容显示
    void setValue(int progress);
    void setButtonUCancelStr(QString str);
    void setRange(int minimum, int maximum);
    void setNoseHeadValueStr(int noseHeadValue);//当前工作机头
    void setNoseHeadStrVisible(bool bl);//当前工作机头label是否可见
    void setPosValueStr(QString posValue);//电位器值
    void setGearValueStr(int gearValue);//档位值
    void setCurNeedleStr(int type = 1,QString idx = 0,QString posValue=0);//当前针杆
    void setCurNeedleStrVisible(bool bl);//当前针杆label是否可见
    void initNeedleBar(int val = PRODUCT_EMB);//初始化针杆
    void initSequinNeedleBar(int val);//初始化亮片针杆
    void setHeadType(int headType = 0);//用于区分底线面线检测是平绣还是缠绕
    inline int getNeedleSelectIdx(){return m_selectNeedleIdx;}//获取所选针杆的索引值
    inline int getMoveX(){return m_moveX;}//获取移框量X
    inline int getMoveY(){return m_moveY;}//获取移框量Y
    inline int getSpindleRotateAngle(){return m_spindleAngle;}//获取主轴旋转角度
    inline int getNoseHead(){return m_noseHead;}//获取毛巾和平绣（冲孔，缝纫）机头的切换
    inline int getArea(){return m_area;}
    //inline int getGearValue(){return m_gearValue;}//获取档位值
    inline QString getInputNewPassword(){return m_newPassword;}//获取新密码
    inline QString getInputConfirmPassword(){return m_confirmPassword;}//获取确认新密码

    void setHeadNum(int headNum);//机头个数
    void initEmbHead(int headNum,int colorOrderNum,QString path);//初始化平绣机头
    void initChenilleHead(int headNum);//初始毛巾化机头
    inline u8* getHeadBuf(){return m_headBuf;}

    QString getNetworkCardID();//获取网卡ID
    QString getInputPassword();//获取界面输入密码
    s16 getTraceOffsetType();//获取线迹偏移类型

signals:
    void siUpdataCancel();
    void siEmbSpindleAction(int action);//平绣主轴动作(正转、反转、停止)
    void siEmbSpindleRotate(int angle);//平绣主轴旋转角度
    void siElasticCtrlPos(int m_elasticWirePos);//松紧线位置值
    void siLiftMotorCtrl(int m_gearValue);//档位值

public slots:
    void slotMCInfoChange();

private slots:
    void slotEmbNeedleBtnClick();//针杆按钮被点击
    void slotEmbHeadBtnClick();//机头按钮被点击
    void slotChenilleHeadBtnClick();//提升电机控制界面，毛巾机头被点击
    //void slotTestADC(int m_adcFlag);//测试电位器的标志
private slots:
    void on_buttonOk_clicked();
    void on_buttonCancel_clicked();
    void on_buttonRename_clicked();
    void on_buttonReplace_clicked();
    void on_buttonSkip_clicked();
    void on_buttonRestart_clicked();
    void on_buttonUpdataCancel_clicked();
    void on_buttonWarrant_clicked();
    void on_buttonWarrantCancel_clicked();
    void on_buttonCurColorOrder_clicked();
    void on_buttonCurColorOrderUp_clicked();
    void on_buttonCurColorOrderDown_clicked();
    void on_buttonOddEmb_clicked();
    void on_buttonEvenEmb_clicked();
    void on_buttonHeadClear_clicked();
    void on_buttonDetectBegin_clicked();
    void on_buttonDetectEnd_clicked();
    void on_buttonDetectClose_clicked();
    void on_buttonMoveXValue_clicked();
    void on_buttonMoveYValue_clicked();
    void on_buttonHMIPassword_clicked();
    void on_buttonSpindleAngleValue_clicked();
    void on_buttonNewPassword_clicked();
    void on_buttonConfirmPassword_clicked();
    void on_buttonForward_pressed();
    void on_buttonForward_released();
    void on_buttonReverse_pressed();
    void on_buttonReverse_released();
    void on_buttonTraceOffset_clicked();
    void on_buttonTraceOffsetReset_clicked();
    void on_buttonCurTraceOffsetClear_clicked();
    void on_buttonGear_clicked();
    void on_buttonLocation1_clicked();
    void on_buttonLocation2_clicked();
    void on_buttonLocation3_clicked();
    void on_buttonLocation4_clicked();
    void on_buttonHead1_clicked();
    void on_buttonHead2_clicked();
    void on_buttonHead3_clicked();
    void on_buttonX1_pressed();
    void on_buttonX1_released();
    void on_buttonX2_pressed();
    void on_buttonX2_released();
    void on_buttonY1_pressed();
    void on_buttonY1_released();
    void on_buttonY2_pressed();
    void on_buttonY2_released();
    void on_button90_clicked();
    void on_button180_clicked();
    void on_button270_clicked();
    void on_button0_clicked();
};

#endif // PROMPTDIALOG_H
