#include "promptdialog.h"
#include "ui_promptdialog.h"

PromptDialog::PromptDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PromptDialog)
{
    ui->setupUi(this);

    setWindowFlags (Qt::Window | Qt::FramelessWindowHint);
    setWindowModality(Qt::ApplicationModal);

    setAttribute(Qt::WA_TranslucentBackground, true);
    connect(g_pMachine, SIGNAL(siMcInfoChange()), this, SLOT(slotMCInfoChange()));

    initDialog();
    initControl();
    initArabControlPos();
}

PromptDialog::~PromptDialog()
{
    delete ui;
}

//初始化窗体
void PromptDialog::initDialog(int sel)
{
    m_totalHead = 0;
    m_curColorOrder = 0;//当前色序数
    m_totalColorOrder = 0;//总色序数

    m_funType = sel;
    m_filePath.clear();
    memset(m_headBuf, 0, sizeof(m_headBuf));

    m_moveX = 0;//定量移框X值
    m_moveY = 0;//定量移框Y值
    m_spindleAngle = 0;//主轴旋转角度值
    m_gearValue =  1;//提升电机档位值
    m_adcFlagValue = -1;
    m_area = 0;
    m_headType =0;
    m_noseHead = FLATEMB;//初始化是平绣机头
    m_elasticWirePos = ELASTICWIRE_COLORCHANGE_POS;//初始化默认松紧线电机换色位
    m_camColorChange = 0;//凸轮换色
    m_camColorChange= g_pSettings->readFromInHMIiFile("HMI/camColorChange").toInt();

    m_stepDrive =0;//步进电机驱动
    m_stepDrive= g_pSettings->readFromInHMIiFile("HMI/stepDrive").toInt();

    setTitleStr("");
    setContentStr("");
    setContentProcessStr("");
    ui->frameProcess->hide();
    ui->labelContentInfo->setText("");
    ui->labeBreakHead->setText("");
    ui->labeBottomBreakHead->setText("");
    ui->labelCurNeedleValue->setText("0");
    ui->frameTwo->hide();
    ui->frameThree->hide();
    ui->frameProcessBtn->hide();

#if(0)
    //全部隐藏，否则新的弹窗显示时会先刷新成之前的再刷新成新的内容，尽管刷新速度很快但仍能看出来，所以先全部隐藏
    ui->frameChangePassword->hide();
    ui->frameElasticCtrl->hide();
    ui->frameHMIDecrypt->hide();
    ui->frameHeadEmb->hide();
    ui->frameLiftMControl->hide();
    ui->frameManualChangeColor->hide();
    ui->frameNoseHead->hide();
    ui->frameProcess->hide();
    ui->frameQuantityMoveFrame->hide();
    ui->frameSpindleRotate->hide();
    ui->frameTraceOffset->hide();
    ui->frameWarrantBtn->hide();
    ui->frameWorkArea->hide();
    ui->frameTwo->hide();
    ui->frameThree->hide();
    ui->frameProcessBtn->hide();
    ui->frameDetecBtn->hide();
    ui->labelContent->hide();
    ui->labeBreakHead->hide();
    ui->labeBottomBreakHead->hide();
    ui->labelContentWarrant->hide();
    ui->labelContentInfo->hide();
#endif

    m_selectNeedleIdx = 0;
    m_selectHeadleIdx = 0;

    ui->buttonOk->setEnabled(true);

    //蓝色
    m_buttonStyle1 = "QPushButton{outline: none;color:rgb(10,10,10);background-color:rgb(0,151,226);border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;}";
    //白色
    m_buttonStyle2 = "QPushButton{outline: none;color:rgb(10,10,10);background-color:rgb(250,250,250);border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;}";
    if (sel == BTN_OK_CANCEL)//确定、取消
    {
        ui->frameTwo->show();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameHeadEmb->hide();
        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if (sel == BTN_OK)//确定
    {
        ui->frameTwo->show();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameDetecBtn->hide();
        ui->frameHeadEmb->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->buttonOk->show();
        ui->buttonCancel->hide();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->move(m_btnCancelPoint);
    }
    else if (sel == BTN_R_R_S)//重命名、替换、跳过
    {
        ui->frameTwo->hide();
        ui->frameProcessBtn->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameWarrantBtn->hide();
        ui->frameDetecBtn->hide();
        ui->frameHeadEmb->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameThree->show();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();
    }
    else if (sel == BTN_LINE_OFFSET)//线迹偏移
    {
        ui->buttonTraceOffset->setCheckable(true);
        ui->buttonTraceOffset->setChecked(true);
        ui->buttonTraceOffsetReset->setChecked(false);
        ui->buttonCurTraceOffsetClear->setChecked(false);

        ui->labelTraceInfo->setText(tr("Click OK to change the work coordinates, please take carefully!"));//点击确定按钮后将改变工作坐标，请谨慎操作!
        ui->labelTraceType->setText(tr("Trace offset"));//线迹偏移

        ui->frameTwo->show();
        ui->frameTraceOffset->show();
        ui->frameProcessBtn->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameWarrantBtn->hide();
        ui->frameDetecBtn->hide();
        ui->frameHeadEmb->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameThree->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->show();
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if (sel == BTN_RESTART)//重启
    {
        ui->frameTwo->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcessBtn->show();
        ui->buttonRestart->show();
        ui->buttonUpdataCancel->hide();
        ui->buttonRestart->move(m_btnCancelPoint);
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();
    }
    else if (sel == BTN_UCANCEL)//升级取消
    {
        ui->frameTwo->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcessBtn->show();
        ui->buttonRestart->hide();
        ui->buttonUpdataCancel->show();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();
    }
    else if (sel == BTN_WARRANT)//授权按钮
    {
        ui->frameTwo->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameHeadEmb->hide();
        ui->frameDetecBtn->hide();
        ui->frameProcessBtn->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameWarrantBtn->show();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();
    }
    //手动换色
    else if(sel == BTN_M_C_C )
    {
        ui->frameManualChangeColor->show();//手动换色
        ui->frameTwo->show();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameProcess->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentProcess->hide();
        ui->labelContentWarrant->hide();
        ui->frameHeadEmb->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    // 底线检测，面线检测
    else if(sel == BTN_BOTTOM || sel == BTN_FACE)
    {
        ui->frameManualChangeColor->show();//手动换色，底线面线检测的时候，手动换色的窗体不能隐藏
        ui->frameDetecBtn->show();
        ui->frameHeadEmb->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameTwo->hide();
        ui->frameThree->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameProcess->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentProcess->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();
    }
    else if(sel == BTN_HOOK_TEST  || sel == BTN_FOOT_TEST )
    {
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameDetecBtn->show();
        ui->frameHeadEmb->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameTwo->hide();
        ui->frameThree->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameProcess->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentProcess->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();
    }
    else if(sel == BTN_MOVE_FRAME)//定量移框
    {
        ui->frameQuantityMoveFrame->show();
        if(m_stepDrive == 1)
        {
            ui->buttonMoveXValue->setText("0.0");
            ui->buttonMoveYValue->setText("0.0");
        }
        else if(m_stepDrive == 0)
        {
            ui->buttonMoveXValue->setText("0.00");
            ui->buttonMoveYValue->setText("0.00");
        }
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameTwo->show();
        ui->frameThree->hide();
        ui->frameDetecBtn->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameProcess->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentProcess->hide();
        ui->labelContentWarrant->hide();
        ui->frameHeadEmb->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_NONE)//无按钮
    {
        ui->frameTwo->hide();
        ui->frameThree->hide();
        ui->frameDetecBtn->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameProcess->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentProcess->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();
    }
    else if(sel == BTN_P_NONE)//无按钮
    {
        ui->frameTwo->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();
    }
    else if(sel == BTN_HEAD_EMB)
    {
        ui->frameHeadEmb->show();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameTwo->show();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameProcess->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentProcess->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameSpindleRotate->hide();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_HMI_DECRYPT)//界面解密
    {
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameSpindleRotate->hide();
        ui->frameHMIDecrypt->show();
        ui->frameChangePassword->hide();
        ui->frameTwo->show();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_CHANGE_PASSWORD)//修改一级密码
    {
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameSpindleRotate->hide();
        ui->frameHMIDecrypt->hide();//界面解密隐藏
        ui->frameChangePassword->show();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_SPINDLE_ROTATE)//主轴旋转角度
    {
        ui->frameSpindleRotate->show();
        ui->buttonSpindleAngleValue->setText("0.00");
        ui->button0->setText("0.00");
        ui->button90->setText("90.00");
        ui->button180->setText("180.00");
        ui->button270->setText("270.00");
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameTwo->show();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->show();//显示正转按钮
        ui->buttonReverse->show();//显示反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_NOSEHESD)//两个按钮选择
    {
        ui->buttonHead1->show();
        ui->buttonHead3->hide();//第三个按钮隐藏
        ui->frameNoseHead->show();
        int towel = g_pSettings->readFromInHMIiFile("HMI/towel").toInt();//是否有毛巾功能
        int coil = g_pSettings->readFromInHMIiFile("HMI/coil").toInt();//是否有缠绕功能
        if (g_emMacType == MACHINE_EMB && towel ==1 && coil ==1)//同时带毛巾和缠绕
        {
            ui->buttonHead1->setText(tr("Emb"));
            ui->buttonHead2->setText(tr("Cheniile"));
            ui->buttonHead3->setText(tr("Coil"));
            ui->buttonHead3->show();//第三个按钮显示
            ui->labelNoseHeadValue->setText(tr("Unknown"));
        }
        else if (g_emMacType == MACHINE_EMB && towel ==1)
        {
            ui->buttonHead1->setText(tr("Emb"));
            ui->buttonHead2->setText(tr("Cheniile"));
            ui->labelNoseHeadValue->setText(tr("Unknown"));
        }
        else if (g_emMacType == MACHINE_EMB && coil ==1)
        {
            ui->buttonHead1->setText(tr("Emb"));
            ui->buttonHead2->setText(tr("Coil"));
            ui->labelNoseHeadValue->setText(tr("Unknown"));
        }
        //初始化，一进来机头选择的窗体，就默认是平绣的被选中
        ui->buttonHead1->setStyleSheet(m_buttonStyle1);
        ui->buttonHead2->setStyleSheet(m_buttonStyle2);
        ui->buttonHead3->setStyleSheet(m_buttonStyle2);

        ui->frameSpindleRotate->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameTwo->show();
        ui->frameTraceOffset->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_TRIMDOWN)//下剪线
    {
        ui->buttonHead1->show();
        ui->buttonHead3->hide();//第三个按钮隐藏
        ui->frameNoseHead->show();
        int coil = g_pSettings->readFromInHMIiFile("HMI/coil").toInt();//是否有缠绕功能
        if (g_emMacType == MACHINE_EMB && coil ==1)//有缠绕
        {
            ui->buttonHead1->setText(tr("Emb"));
            ui->buttonHead2->setText(tr("Coil"));
            ui->labelNoseHeadValue->setText(tr("Unknown"));
        }

        //初始化，一进来机头选择的窗体，就默认是平绣的被选中
        ui->buttonHead1->setStyleSheet(m_buttonStyle1);
        ui->buttonHead2->setStyleSheet(m_buttonStyle2);
        ui->buttonHead3->setStyleSheet(m_buttonStyle2);

        ui->frameSpindleRotate->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameTwo->show();
        ui->frameTraceOffset->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_NOSEHESDTHREE || sel == BTN_MSPINDLE_ROTATE)//三个按钮选择
    {
        ui->buttonHead1->show();
        ui->buttonHead3->hide();//第三个按钮隐藏
        ui->frameNoseHead->show();
        int towel = g_pSettings->readFromInHMIiFile("HMI/towel").toInt();//是否有毛巾功能
         int coil = g_pSettings->readFromInHMIiFile("HMI/coil").toInt();//是否有缠绕功能
        if (g_emMacType == MACHINE_EMB && towel ==1 && coil ==1)//同时带毛巾和缠绕
        {
            ui->buttonHead1->setText(tr("Emb"));
            ui->buttonHead2->setText(tr("Cheniile"));
            ui->buttonHead3->setText(tr("Coil"));
            ui->buttonHead3->show();//第三个按钮显示
        }
        else if (g_emMacType == MACHINE_EMB && towel ==1)
        {
            ui->buttonHead1->setText(tr("Emb"));
            ui->buttonHead2->setText(tr("Cheniile"));
        }
        else if (g_emMacType == MACHINE_EMB && coil ==1)
        {
            ui->buttonHead1->setText(tr("Emb"));
            ui->buttonHead2->setText(tr("Coil"));
        }

        if(sel == BTN_MSPINDLE_ROTATE)
        {
            ui->buttonHead1->hide();
        }
        //初始化，一进来机头选择的窗体，就默认是平绣的被选中
        ui->labelNoseHead->hide();
        ui->labelNoseHeadValue->hide();
        ui->buttonHead1->setStyleSheet(m_buttonStyle1);
        ui->buttonHead2->setStyleSheet(m_buttonStyle2);
        ui->buttonHead3->setStyleSheet(m_buttonStyle2);

        ui->frameSpindleRotate->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameTwo->show();
        ui->frameTraceOffset->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_LIFTMOTORCONTROL)//毛巾提升电机控制
    {
        //xcy 0316  电位器
        QFont ft;
        if(g_emResolut == resolution1910)
        {
            ft.setPointSize(80);
        }
        else if(g_emResolut == resolution1006)
        {
            ft.setPointSize(38);
        }
        ui->labelPotenValue->setFont(ft);
        ui->labelPotenValue->setAlignment(Qt::AlignRight | Qt::AlignBottom);

        ui->frameLiftMControl->show();
        ui->labelPotenValue->setText("500.00");
        ui->buttonGear->setText("1");

        ui->frameSpindleRotate->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameTwo->show();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameElasticCtrl->hide();
        ui->frameWorkArea->hide();


        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_ELASTICCONTROL)//毛巾松紧线控制
    {
        ui->frameElasticCtrl->show();
        ui->labelPotenValue2->setText("0");
        ui->labelGearValue->setText("0");
        ui->labelLocationValue->setText(tr("Unknown location"));//松紧线电机位置显示,如果不在4个位置,就要显示未知位置
        ui->buttonLocation1->setText(tr("Color"));//换色位
        ui->buttonLocation2->setText(tr("Trim"));//剪线位
        ui->buttonLocation3->setText(tr("Chain"));//链式位
        ui->buttonLocation4->setText(tr("Chenille"));//毛巾位
        ui->buttonLocation1->setStyleSheet(m_buttonStyle1);//初始化默认都是白色，根据从主控上读上来的当前位置值，显示哪个是蓝色
        ui->buttonLocation2->setStyleSheet(m_buttonStyle2);
        ui->buttonLocation3->setStyleSheet(m_buttonStyle2);
        ui->buttonLocation4->setStyleSheet(m_buttonStyle2);

        ui->frameSpindleRotate->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameTwo->show();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameWorkArea->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮


        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_WORK_AREA)//设置可工作区域
    {
        ui->frameWorkArea->show();

        ui->buttonX1->setText(tr("X +"));
        ui->buttonX2->setText(tr("X  -"));
        ui->buttonY1->setText(tr("Y +"));
        ui->buttonY2->setText(tr("Y -"));

        ui->frameSpindleRotate->hide();
        ui->frameThree->hide();
        ui->frameQuantityMoveFrame->hide();
        ui->frameDetecBtn->hide();
        ui->frameManualChangeColor->hide();//手动换色
        ui->frameProcess->hide();
        ui->frameProcessBtn->hide();
        ui->frameWarrantBtn->hide();
        ui->frameHeadEmb->hide();
        ui->labelContentInfo->hide();
        ui->labeBreakHead->hide();
        ui->labeBottomBreakHead->hide();
        ui->labelContentWarrant->hide();
        ui->frameHMIDecrypt->hide();
        ui->frameChangePassword->hide();
        ui->frameTwo->show();
        ui->frameTraceOffset->hide();
        ui->frameNoseHead->hide();
        ui->frameLiftMControl->hide();
        ui->frameElasticCtrl->hide();

        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonForward->hide();//隐藏正转按钮
        ui->buttonReverse->hide();//隐藏反转按钮

        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
}

//初始化窗体控件，包括位置、尺寸、样式
void PromptDialog::initControl()
{
    m_buttonEmbNeedleList.clear();
    for(int i = 0; i < 32; i++)
    {
        QPushButton *buttonEmbNeedle = new QPushButton(ui->frameManualChangeColor);
        m_buttonEmbNeedleList.append(buttonEmbNeedle);
        connect(buttonEmbNeedle,
                SIGNAL(clicked()),
                this,
                SLOT(slotEmbNeedleBtnClick())
                );
    }

    //隔头绣界面显示的机头,暂定30个机头    -rq
    m_buttonEmbHeadList.clear();
    for(int i = 0; i < 30; i++)
    {
        QPushButton *buttonEmbHead = NULL;
        buttonEmbHead = new QPushButton(ui->frameHeadEmb);
        m_buttonEmbHeadList.append(buttonEmbHead);
        connect(buttonEmbHead,
                SIGNAL(clicked()),
                this,
                SLOT(slotEmbHeadBtnClick())
                );
    }

    //提升电机控制界面显示的毛巾机头   -rq
    m_buttonChenilleHeadList.clear();
    for(int i = 0; i < 32; i++)
    {
        QPushButton *m_buttonChenilleHead = new QPushButton(ui->frameLiftMControl);
        m_buttonChenilleHeadList.append(m_buttonChenilleHead);
        connect(m_buttonChenilleHead,
                SIGNAL(clicked()),
                this,
                SLOT(slotChenilleHeadBtnClick())
                );
    }
    //根据不同分辨率设置控件的位置和尺寸
    switch (g_emResolut)
    {
    case resolution1910:
        initResolution1910();
        break;
    case resolution1006:
        initResolution1006();
        break;
    default:
        initResolution1910();
        break;
    }
    initControlStyle();//初始化窗体控件样式
}

//初始化窗体控件为1920x1080分辨率
void PromptDialog::initResolution1910()
{
    //上状态栏
    this->resize(946,564);
    this->move((1920-this->width())/2,(1080-this->height())/2);

    ui->frameBack->setGeometry(0,0,946,564);
    ui->labelTitle->setGeometry(40,18,754,56);
    ui->labelContent->setGeometry(80,120,800,300);
    ui->labelContentInfo->setGeometry(80,120,800,300);
    ui->labeBreakHead->setGeometry(80,80,900,350);
    //ui->labeBottomBreakHead->setGeometry(80,260,900,170);
    ui->labelContentWarrant->setGeometry(96,134,800,260);
    ui->frameProcess->setGeometry(96,134,820,260);
    ui->labelContentProcess->setGeometry(0,20,800,100);
    ui->progressBar->setGeometry(0,160,754,36);

    ui->frameTwo->setGeometry(0,426,904,84);
    ui->buttonForward->setGeometry(148,0,174,70);
    ui->buttonReverse->setGeometry(340,0,174,70);
    ui->buttonOk->setGeometry(532,0,174,70);
    ui->buttonCancel->setGeometry(724,0,174,70);
    m_btnOkPoint.setX(532);//ok按钮位置
    m_btnOkPoint.setY(0);
    m_btnCancelPoint.setX(724);//cancel按钮位置
    m_btnCancelPoint.setY(0);

    ui->frameProcessBtn->setGeometry(0,430,904,84);//进度条
    ui->buttonRestart->setGeometry(532,0,174,70);
    ui->buttonUpdataCancel->setGeometry(724,0,174,70);

    ui->frameWarrantBtn->setGeometry(0,430,904,84);//授权
    ui->buttonWarrant->setGeometry(532,0,174,70);
    ui->buttonWarrantCancel->setGeometry(724,0,174,70);

    //手动换色
    ui->frameManualChangeColor->setGeometry(40,78,904,340);
    ui->labelCurNeedle->setGeometry(1,8,230,40);
    ui->labelCurNeedleValue->setGeometry(239,8,500,40);
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            m_buttonEmbNeedleList[i*8+j]->setGeometry(3+j*110,64+i*70,88,52);
            m_buttonEmbNeedleList[i*8+j]->setFont(fontNormal_1);
            m_buttonEmbNeedleList[i*8+j]->setText(QString::number(i*8+j+1));
        }
    }

    //隔头绣
    ui->frameHeadEmb->setGeometry(40,70,904,390);
    ui->labelCurColorOrder->setGeometry(1,18,200,40);
    ui->buttonCurColorOrder->setGeometry(209,14,160,58);
    ui->frameUpAndDown->setGeometry(380,10,140,64);
    ui->buttonCurColorOrderUp->setGeometry(6,0,64,64);
    ui->buttonCurColorOrderDown->setGeometry(76,0,64,64);
    ui->buttonOddEmb->setGeometry(10,278,90,90);
    ui->buttonEvenEmb->setGeometry(116,278,90,90);
    ui->buttonHeadClear->setGeometry(232,278,90,90);

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            m_buttonEmbHeadList[i*10+j]->setGeometry(6+j*86,76+i*68,78,62);
            m_buttonEmbHeadList[i*10+j]->setFont(fontNormal_1);
            m_buttonEmbHeadList[i*10+j]->setText(QString::number(i*10+j+1));
        }
    }

    //提升电机控制
    ui->frameLiftMControl->setGeometry(40,78,904,340);

    ui->labelPoten->setGeometry(1,200,185,40);//电位器
    ui->labelPotenValue->setGeometry(120,70,600,210);//电位器值
    ui->labelGear->setGeometry(440,286,200,40);
    ui->labelGearValue->setGeometry(500,286,200,40);//档位值

    ui->labelGearSwitch->setGeometry(12,280,180,58);//档位值切换
    ui->buttonGear->setGeometry(202,280,160,58);//档位切换按钮

    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            m_buttonChenilleHeadList[i*8+j]->setGeometry(3+j*110,8+i*70,88,52);
            m_buttonChenilleHeadList[i*8+j]->setFont(fontNormal_1);
            m_buttonChenilleHeadList[i*8+j]->setText(QString::number(i*8+j+1));
        }
    }
    //松紧线控制
    ui->frameElasticCtrl->setGeometry(40,78,904,340);
    ui->buttonLocation1->setGeometry(80,100,160,58);
    ui->buttonLocation2->setGeometry(80,200,160,58);
    ui->buttonLocation3->setGeometry(280,100,160,58);
    ui->buttonLocation4->setGeometry(280,200,160,58);

    ui->labelPoten2->setGeometry(1,8,185,40);//电位器
    ui->labelPotenValue2->setGeometry(185,8,120,40);//电位器值
    ui->labelLocation->setGeometry(390,8,230,40);
    ui->labelLocationValue->setGeometry(650,8,120,40);//档位值

    //设置可移动区域
    ui->frameWorkArea->setGeometry(40,78,904,340);
    ui->buttonX1->setGeometry(300,110,160,58);//x+
    ui->buttonX2->setGeometry(10,110,160,58);//x-
    ui->buttonY1->setGeometry(150,10,160,58);//y+
    ui->buttonY2->setGeometry(150,205,160,58);//y-

    //定量移框
    ui->frameQuantityMoveFrame->setGeometry(40,78,904,340);
    ui->labelMoveX->setGeometry(1,18,100,40);
    ui->buttonMoveXValue->setGeometry(109,14,300,58);
    ui->labelXUnit->setGeometry(414,18,100,40);
    ui->labelMoveY->setGeometry(1,104,100,40);
    ui->buttonMoveYValue->setGeometry(109,100,300,58);
    ui->labelYUnit->setGeometry(414,104,100,40);

    //主轴角度旋转
    ui->frameSpindleRotate->setGeometry(40,78,904,340);
    ui->labelSpindleAngle->setGeometry(1,28,180,40);
    ui->buttonSpindleAngleValue->setGeometry(190,24,300,58);
    ui->labelSpindleAngleUnit->setGeometry(496,28,100,40);
    ui->button0->setGeometry(2,210,180,68);
    ui->button90->setGeometry(220,210,180,68);
    ui->button180->setGeometry(440,210,180,68);
    ui->button270->setGeometry(660,210,180,68);

    //平绣毛巾缠绕
    ui->frameNoseHead->setGeometry(40,78,904,340);
    ui->buttonHead1->setGeometry(0,24,200,68);
    ui->buttonHead2->setGeometry(240,24,200,68);
    ui->buttonHead3->setGeometry(480,24,200,68);
//    ui->buttonHead2->setGeometry(480,24,200,68);
//    ui->buttonHead3->setGeometry(240,24,200,68);
    ui->labelNoseHead->setGeometry(1,8,200,40);
    ui->labelNoseHeadValue->setGeometry(209,8,60,40);

    //界面解密
    ui->frameHMIDecrypt->setGeometry(40,78,904,340);
    ui->labelNetworkCardID->setGeometry(1,18,200,40);
    ui->labelNetworkCardIDValue->setGeometry(209,18,300,40);
    ui->labelHMIPassword->setGeometry(1,104,200,40);
    ui->buttonHMIPassword->setGeometry(209,100,300,58);
    ui->labelDecryptInfo->setGeometry(1,190,200,40);
    ui->labelDecryptInfoValue->setGeometry(209,190,300,40);

    //修改一级密码
    ui->frameChangePassword->setGeometry(40,78,904,340);
    ui->labelNewPassword->setGeometry(10,90,420,60);
    ui->buttonNewPassword->setGeometry(440,90,300,60);
    ui->labelConfirmPassword->setGeometry(10,190,420,60);
    ui->buttonConfirmPassword->setGeometry(440,190,300,60);

    //线迹偏移
    ui->frameTraceOffset->setGeometry(40,68,904,320);
    ui->labelTraceInfo->setGeometry(20,40,500,80);
    ui->labelTraceType->setGeometry(20,160,500,80);
    ui->buttonTraceOffset->setGeometry(640,40,200,64);
    ui->buttonTraceOffsetReset->setGeometry(640,140,200,64);
    ui->buttonCurTraceOffsetClear->setGeometry(640,240,200,64);

    ui->frameThree->setGeometry(0,430,904,84);
    ui->buttonRename->setGeometry(340,0,174,70);
    ui->buttonReplace->setGeometry(532,0,174,70);
    ui->buttonSkip->setGeometry(724,0,174,70);

    ui->frameDetecBtn->setGeometry(0,430,904,84);
    ui->buttonDetectBegin->setGeometry(340,0,174,70);
    ui->buttonDetectEnd->setGeometry(532,0,174,70);
    ui->buttonDetectClose->setGeometry(724,0,174,70);
}

//初始化窗体控件为1024x600分辨率
void PromptDialog::initResolution1006()
{
    //上状态栏
    this->resize(508,304);
    this->move((1024-this->width())/2+g_mainWidgetPos.x(),(600-this->height())/2+g_mainWidgetPos.y());

    ui->frameBack->setGeometry(0,0,508,304);
    ui->labelTitle->setGeometry(20,-4,400,56);
    ui->labelContent->setGeometry(46,40,400,180);
    ui->labelContentInfo->setGeometry(46,40,400,180);
    ui->labeBreakHead->setGeometry(40,40,450,180);
    //ui->labeBottomBreakHead->setGeometry(40,65,400,145);
    ui->labelContentWarrant->setGeometry(46,40,300,225);
    ui->frameProcess->setGeometry(20,70,480,130);
    ui->labelContentProcess->setGeometry(10,10,398,40);
    ui->progressBar->setGeometry(10,50,446,26);

    ui->frameTwo->setGeometry(-4,225,500,51);
    ui->buttonForward->setGeometry(72,0,96,40);
    ui->buttonReverse->setGeometry(178,0,96,40);
    ui->buttonOk->setGeometry(284,0,96,40);
    ui->buttonCancel->setGeometry(390,-1,96,40);
    m_btnOkPoint.setX(284);//ok按钮位置
    m_btnOkPoint.setY(0);
    m_btnCancelPoint.setX(390);//cancel按钮位置
    m_btnCancelPoint.setY(1);

    ui->frameProcessBtn->setGeometry(0,228,500,51);//进度条
    ui->buttonRestart->setGeometry(284,0,96,40);
    ui->buttonUpdataCancel->setGeometry(390,1,96,40);

    ui->frameWarrantBtn->setGeometry(0,235,500,51);//授权
    ui->buttonWarrant->setGeometry(284,0,96,40);
    ui->buttonWarrantCancel->setGeometry(390,1,96,40);

    //手动换色
    ui->frameManualChangeColor->setGeometry(40,48,440,165);
    ui->labelCurNeedle->setGeometry(0,-10,100,40);
    ui->labelCurNeedleValue->setGeometry(100,-10,335,40);
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 5; j++)
        {
            m_buttonEmbNeedleList[i*5+j]->setGeometry(3+j*88,34+i*46,66,34);//15个针杆会显示不全   -rq
            m_buttonEmbNeedleList[i*5+j]->setFont(fontNormal_1);
            m_buttonEmbNeedleList[i*5+j]->setText(QString::number(i*5+j+1));
        }
    }

    //隔头绣
    ui->frameHeadEmb->setGeometry(14,44,500,184);
    ui->labelCurColorOrder->setGeometry(1,5,100,40);
    ui->buttonCurColorOrder->setGeometry(110,5,70,38);

    ui->frameUpAndDown->setGeometry(190,0,130,60);
    ui->buttonCurColorOrderUp->setGeometry(6,0,50,50);
    ui->buttonCurColorOrderDown->setGeometry(62,0,50,50);
    ui->buttonOddEmb->setGeometry(5,125,58,58);//20220419-rq，机头个数显示不全，变成两行
    ui->buttonEvenEmb->setGeometry(78,125,58,58);
    ui->buttonHeadClear->setGeometry(150,125,58,58);

    for(int i = 0; i < 2; i++)
    {
        for(int j = 0; j < 15; j++)//一行显示6个
        {
            m_buttonEmbHeadList[i*15+j]->setGeometry(0+j*32,54+i*35,30,32);
            m_buttonEmbHeadList[i*15+j]->setFont(fontNormal_1);
            m_buttonEmbHeadList[i*15+j]->setText(QString::number(i*15+j+1));
        }
    }

    //提升电机控制
    ui->frameLiftMControl->setGeometry(20,50,500,172);
    ui->labelPoten->setGeometry(16,70,100,40);
    ui->labelPotenValue->setGeometry(100,70,200,50);//电位器值
    ui->labelGear->setGeometry(220,120,100,40);
    ui->labelGearValue->setGeometry(260,120,95,40);//档位值
    ui->buttonGear->setGeometry(100,125,70,38);
    ui->labelGearSwitch->setGeometry(4,125,90,40);//档位值切换

    //    for(int i = 0; i < 3; i++)
    //    {
    //        for(int j = 0; j < 5; j++)
    //        {
    //            m_buttonChenilleHeadList[i*5+j]->setGeometry(3+j*88,34+i*46,66,34);//15个针杆会显示不全   -rq
    //            m_buttonChenilleHeadList[i*5+j]->setFont(fontNormal_1);
    //            m_buttonChenilleHeadList[i*5+j]->setText(QString::number(i*5+j+1));
    //        }
    //    }

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            m_buttonChenilleHeadList[i*8+j]->setGeometry(0+j*58,0+i*36,52,30);//15个针杆会显示不全   -rq
            m_buttonChenilleHeadList[i*8+j]->setFont(fontNormal_1);
            m_buttonChenilleHeadList[i*8+j]->setText(QString::number(i*6+j+1));
        }
    }

    //松紧线控制
    ui->frameElasticCtrl->setGeometry(40,58,440,161);
    ui->buttonLocation1->setGeometry(10,40,70,38);
    ui->buttonLocation2->setGeometry(10,98,70,38);
    ui->buttonLocation3->setGeometry(110,40,70,38);
    ui->buttonLocation4->setGeometry(110,98,70,38);

    ui->labelLocation->setGeometry(190,-10,110,40);
    ui->labelLocationValue->setGeometry(290,-10,95,40);//档位值
    ui->labelPoten2->setGeometry(0,-10,100,40);
    ui->labelPotenValue2->setGeometry(70,-10,95,40);//电位器值

    //
    ui->frameWorkArea->setGeometry(40,58,440,161);
    ui->buttonX1->setGeometry(170,60,70,38);
    ui->buttonX2->setGeometry(10,60,70,38);
    ui->buttonY1->setGeometry(90,10,70,38);//y+
    ui->buttonY2->setGeometry(90,120,70,38);

    //定量移框
    ui->frameQuantityMoveFrame->setGeometry(40,78,440,161);
    ui->labelMoveX->setGeometry(20,12,91,40);
    ui->buttonMoveXValue->setGeometry(120,10,78,40);
    ui->labelXUnit->setGeometry(214,12,91,40);
    ui->labelMoveY->setGeometry(20,70,91,40);
    ui->buttonMoveYValue->setGeometry(120,68,78,40);
    ui->labelYUnit->setGeometry(214,70,91,40);

    //主轴角度旋转
    ui->frameSpindleRotate->setGeometry(30,78,440,161);
    ui->labelSpindleAngle->setGeometry(0,12,120,40);
    ui->buttonSpindleAngleValue->setGeometry(125,10,78,40);
    ui->button0->setGeometry(8,80,78,40);
    ui->button90->setGeometry(100,80,78,40);
    ui->button180->setGeometry(200,80,78,40);
    ui->button270->setGeometry(300,80,78,40);
    ui->labelSpindleAngleUnit->setGeometry(214,12,91,40);

    //平绣毛巾缠绕
    ui->frameNoseHead->setGeometry(40,48,440,165);
    ui->buttonHead1->setGeometry(0,24,91,40);
    ui->buttonHead2->setGeometry(101,24,91,40);
    ui->buttonHead3->setGeometry(202,24,91,40);
//    ui->buttonHead2->setGeometry(202,24,91,40);
//    ui->buttonHead3->setGeometry(101,24,91,40);
    ui->labelNoseHead->setGeometry(0,-10,100,40);
    ui->labelNoseHeadValue->setGeometry(120,-10,95,40);

    //界面解密
    ui->frameHMIDecrypt->setGeometry(40,78,440,161);
    ui->labelNetworkCardID->setGeometry(10,12,110,40);
    ui->labelNetworkCardIDValue->setGeometry(130,12,200,40);
    ui->labelHMIPassword->setGeometry(10,52,110,40);
    ui->buttonHMIPassword->setGeometry(130,50,200,40);
    ui->labelDecryptInfo->setGeometry(10,92,110,40);
    ui->labelDecryptInfoValue->setGeometry(130,92,200,40);

    //修改一级密码
    ui->frameChangePassword->setGeometry(0,78,440,161);
    ui->labelNewPassword->setGeometry(0,0,240,40);
    ui->buttonNewPassword->setGeometry(280,0,200,40);
    ui->labelConfirmPassword->setGeometry(0,52,240,40);
    ui->buttonConfirmPassword->setGeometry(280,52,200,40);

    //线迹偏移
    ui->frameTraceOffset->setGeometry(0,40,500,161);
    ui->labelTraceInfo->setGeometry(40,20,300,60);
    ui->labelTraceType->setGeometry(40,80,300,60);
    ui->buttonTraceOffset->setGeometry(376,20,106,40);
    ui->buttonTraceOffsetReset->setGeometry(376,70,106,40);
    ui->buttonCurTraceOffsetClear->setGeometry(376,120,106,40);

    ui->frameThree->setGeometry(0,225,500,51);
    ui->buttonRename->setGeometry(187,0,96,40);
    ui->buttonReplace->setGeometry(289,0,96,40);
    ui->buttonSkip->setGeometry(390,1,96,40);

    ui->frameDetecBtn->setGeometry(0,225,500,51);
    ui->buttonDetectBegin->setGeometry(187,0,96,40);
    ui->buttonDetectEnd->setGeometry(289,0,96,40);
    ui->buttonDetectClose->setGeometry(390,1,96,40);
}

//初始化窗体控件样式
void PromptDialog::initControlStyle()
{
    SetControlStyle setControlStyle;
    setControlStyle.setUiName(this->objectName());

    //设置控件图标
    //背景图
    this->setStyleSheet(LABELWHITESTYLE);
    ui->frameBack->setStyleSheet(TRANSPARENTSTYLE);
    ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName()));
    ui->labelTitle->setStyleSheet(LABELWHITESTYLE);
    ui->labelTitle->setFont(fontNormal_1);
    ui->labelTitle->setAlignment(Qt::AlignLeft);
    ui->labelTitle->setAlignment(Qt::AlignVCenter);

    ui->frameProcess->setStyleSheet(TRANSPARENTSTYLE);
    ui->progressBar->setFont(fontNormal_1);

    ui->labelContent->setStyleSheet(LABELGREYSTYLE);
    ui->labelContent->setFont(fontNormal_1);
    ui->labelContent->setAlignment(Qt::AlignLeft);
    ui->labelContent->setAlignment(Qt::AlignVCenter);

    ui->labeBreakHead->setStyleSheet(LABELREDSTYLE);  // 断线机头  红色  字体加大  -rq
    ui->labeBreakHead->setFont(fontNormal_9);
    //    ui->labeBreakHead->setAlignment(Qt::AlignHCenter);
    //    ui->labeBreakHead->setAlignment(Qt::AlignVCenter);
    ui->labeBottomBreakHead->setAlignment(Qt::AlignCenter);//文字水平垂直居中

    //ui->labeBottomBreakHead->setStyleSheet(LABELREDSTYLEGREEN);  // 底线断线机头  绿色  字体加大  -rq
    ui->labeBottomBreakHead->setFont(fontNormal_9);
    ui->labeBottomBreakHead->setAlignment(Qt::AlignCenter);
    ui->labeBottomBreakHead->setAlignment(Qt::AlignVCenter);

    ui->labelContentInfo->setStyleSheet(LABELGREYSTYLE);
    ui->labelContentInfo->setFont(fontNormal_1);
    ui->labelContentInfo->setAlignment(Qt::AlignLeft);
    ui->labelContentInfo->setAlignment(Qt::AlignVCenter);

    ui->labelContentProcess->setStyleSheet(LABELGREYSTYLE);
    ui->labelContentProcess->setFont(fontNormal_1);
    ui->labelContentProcess->setAlignment(Qt::AlignLeft);
    ui->labelContentProcess->setAlignment(Qt::AlignVCenter);

    ui->labelContentWarrant->setStyleSheet(LABELGREYSTYLE);
    ui->labelContentWarrant->setFont(fontNormal_1);
    ui->labelContentWarrant->setAlignment(Qt::AlignLeft);
    ui->labelContentWarrant->setAlignment(Qt::AlignVCenter);

    ui->frameTwo->setStyleSheet(TRANSPARENTSTYLE);
    ui->buttonOk->setWhiteBlueBottomStyle();
    ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1"),12);
    ui->buttonCancel->setWhiteBlueBottomStyle();
    ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"),12);
    ui->buttonForward->setWhiteBlueBottomStyle();
    ui->buttonForward->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonForward->objectName()),12);
    ui->buttonReverse->setWhiteBlueBottomStyle();
    ui->buttonReverse->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonReverse->objectName()),12);

    ui->frameThree->setStyleSheet(TRANSPARENTSTYLE);
    ui->buttonRename->setWhiteBlueBottomStyle();
    ui->buttonReplace->setWhiteBlueBottomStyle();
    ui->buttonSkip->setWhiteBlueBottomStyle();
    ui->buttonRename->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonRename->objectName()),12);
    ui->buttonReplace->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonReplace->objectName()),12);
    ui->buttonSkip->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonSkip->objectName()),12);

    ui->frameDetecBtn->setStyleSheet(TRANSPARENTSTYLE);
    ui->buttonDetectBegin->setWhiteBlueBottomStyle();
    ui->buttonDetectBegin->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonDetectBegin->objectName()),12);
    ui->buttonDetectEnd->setWhiteBlueBottomStyle();
    ui->buttonDetectEnd->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonDetectEnd->objectName()),12);
    ui->buttonDetectClose->setWhiteBlueBottomStyle();
    ui->buttonDetectClose->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"),12);

    ui->frameProcessBtn->setStyleSheet(TRANSPARENTSTYLE);
    ui->buttonRestart->setWhiteBlueBottomStyle();
    ui->buttonRestart->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonRestart->objectName()),12);
    ui->buttonUpdataCancel->setWhiteBlueBottomStyle();
    ui->buttonUpdataCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"),12);

    ui->frameManualChangeColor->setStyleSheet(TRANSPARENTSTYLE);
    ui->labelCurNeedle->setStyleSheet(LABELGREYSTYLE);
    ui->labelCurNeedle->setFont(fontNormal_1);
    ui->labelCurNeedleValue->setStyleSheet(LABELGREYSTYLE);
    ui->labelCurNeedleValue->setFont(fontNormal_1);

    //提升电机控制
    ui->frameLiftMControl->setStyleSheet(TRANSPARENTSTYLE);
    ui->labelPotenValue->setStyleSheet(LABELGREYSTYLE);
    ui->labelPotenValue->setFont(fontNormal_1);
    ui->labelPoten->setStyleSheet(LABELGREYSTYLE);
    ui->labelPoten->setFont(fontNormal_1);
    ui->buttonGear->setFont(fontNormal_1);
    ui->labelGearSwitch->setStyleSheet(LABELGREYSTYLE);
    ui->labelGearSwitch->setFont(fontNormal_1);
    ui->labelGear->setFont(fontNormal_1);
    ui->labelGear->setStyleSheet(LABELGREYSTYLE);
    ui->labelGearValue->setFont(fontNormal_1);
    ui->labelGearValue->setStyleSheet(LABELGREYSTYLE);

    //松紧线界面
    ui->frameElasticCtrl->setStyleSheet(TRANSPARENTSTYLE);
    ui->buttonLocation1->setFont(fontNormal_1);
    ui->buttonLocation2->setFont(fontNormal_1);
    ui->buttonLocation3->setFont(fontNormal_1);
    ui->buttonLocation4->setFont(fontNormal_1);
    ui->labelPotenValue2->setStyleSheet(LABELGREYSTYLE);
    ui->labelPotenValue2->setFont(fontNormal_1);
    ui->labelPoten2->setStyleSheet(LABELGREYSTYLE);
    ui->labelPoten2->setFont(fontNormal_1);
    ui->labelLocation->setFont(fontNormal_1);
    ui->labelLocation->setStyleSheet(LABELGREYSTYLE);
    ui->labelLocationValue->setFont(fontNormal_1);
    ui->labelLocationValue->setStyleSheet(LABELGREYSTYLE);

    //设置可工作区域
    ui->frameWorkArea->setStyleSheet(TRANSPARENTSTYLE);
    ui->buttonX1->setFont(fontNormal_1);
    ui->buttonX2->setFont(fontNormal_1);
    ui->buttonY1->setFont(fontNormal_1);
    ui->buttonY2->setFont(fontNormal_1);

    //定量移框
    ui->frameQuantityMoveFrame->setStyleSheet(TRANSPARENTSTYLE);
    ui->labelMoveX->setStyleSheet(LABELGREYSTYLE);
    ui->labelMoveX->setFont(fontNormal_1);
    ui->labelMoveY->setStyleSheet(LABELGREYSTYLE);
    ui->labelMoveY->setFont(fontNormal_1);
    ui->labelXUnit->setStyleSheet(LABELGREYSTYLE);
    ui->labelXUnit->setFont(fontNormal_1);
    ui->labelYUnit->setStyleSheet(LABELGREYSTYLE);
    ui->labelYUnit->setFont(fontNormal_1);
    ui->buttonMoveXValue->setFont(fontNormal_1);
    ui->buttonMoveYValue->setFont(fontNormal_1);

    //主轴角度旋转
    ui->frameSpindleRotate->setStyleSheet(TRANSPARENTSTYLE);
    ui->labelSpindleAngle->setStyleSheet(LABELGREYSTYLE);
    ui->labelSpindleAngle->setFont(fontNormal_1);
    ui->labelSpindleAngleUnit->setStyleSheet(LABELGREYSTYLE);
    ui->labelSpindleAngleUnit->setFont(fontNormal_1);
    ui->buttonSpindleAngleValue->setFont(fontNormal_1);
    ui->button0->setFont(fontNormal_1);
    ui->button90->setFont(fontNormal_1);
    ui->button180->setFont(fontNormal_1);
    ui->button270->setFont(fontNormal_1);

    //机头切换（毛巾，平绣，缠绕，M轴）
    ui->frameNoseHead->setStyleSheet(TRANSPARENTSTYLE);
    ui->buttonHead1->setFont(fontNormal_1);
    ui->buttonHead2->setFont(fontNormal_1);
    ui->buttonHead3->setFont(fontNormal_1);
    ui->labelNoseHead->setStyleSheet(LABELGREYSTYLE);
    ui->labelNoseHead->setFont(fontNormal_1);
    ui->labelNoseHeadValue->setStyleSheet(LABELGREYSTYLE);
    ui->labelNoseHeadValue->setFont(fontNormal_1);

    //界面解密
    ui->frameHMIDecrypt->setStyleSheet(TRANSPARENTSTYLE);
    ui->labelNetworkCardID->setStyleSheet(LABELGREYSTYLE);
    ui->labelNetworkCardID->setFont(fontNormal_1);
    ui->labelNetworkCardIDValue->setStyleSheet(LABELGREYSTYLE);
    ui->labelNetworkCardIDValue->setFont(fontNormal_1);
    ui->labelHMIPassword->setStyleSheet(LABELGREYSTYLE);
    ui->labelHMIPassword->setFont(fontNormal_1);
    ui->buttonHMIPassword->setFont(fontNormal_1);
    ui->labelDecryptInfo->setStyleSheet(LABELGREYSTYLE);
    ui->labelDecryptInfo->setFont(fontNormal_1);
    ui->labelDecryptInfoValue->setStyleSheet(LABELGREYSTYLE);
    ui->labelDecryptInfoValue->setFont(fontNormal_1);

    //修改一级密码
    ui->frameChangePassword->setStyleSheet(TRANSPARENTSTYLE);
    ui->labelNewPassword->setStyleSheet(LABELGREYSTYLE);
    ui->labelNewPassword->setFont(fontNormal_1);
    ui->labelConfirmPassword->setStyleSheet(LABELGREYSTYLE);
    ui->labelConfirmPassword->setFont(fontNormal_1);
    ui->buttonNewPassword->setFont(fontNormal_1);
    ui->buttonConfirmPassword->setFont(fontNormal_1);

    //线迹偏移
    ui->frameTraceOffset->setStyleSheet(TRANSPARENTSTYLE);
    ui->labelTraceInfo->setStyleSheet(LABELGREYSTYLE);
    ui->labelTraceInfo->setFont(fontNormal_1);
    ui->labelTraceType->setStyleSheet(LABELGREYSTYLE);
    ui->labelTraceType->setFont(fontNormal_1);
    ui->buttonTraceOffset->setWhiteBlueBottomStyle();
    ui->buttonTraceOffsetReset->setWhiteBlueBottomStyle();
    ui->buttonCurTraceOffsetClear->setWhiteBlueBottomStyle();
    ui->buttonTraceOffset->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonTraceOffset->objectName()),12);
    ui->buttonTraceOffsetReset->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonTraceOffsetReset->objectName()),12);
    ui->buttonCurTraceOffsetClear->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonCurTraceOffsetClear->objectName()),12);

    //隔头绣
    ui->frameHeadEmb->setStyleSheet(TRANSPARENTSTYLE);
    ui->frameUpAndDown->setStyleSheet(TRANSPARENTSTYLE);
    ui->labelCurColorOrder->setStyleSheet(LABELGREYSTYLE);
    ui->labelCurColorOrder->setFont(fontNormal_1);
    ui->buttonCurColorOrder->setFont(fontNormal_1);
    ui->buttonCurColorOrderUp->setGreenGradientBottomStyle(BORDER_RADIUS1);
    ui->buttonCurColorOrderUp->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonCurColorOrderUp->objectName()));
    ui->buttonCurColorOrderDown->setGreenGradientBottomStyle(BORDER_RADIUS1);
    ui->buttonCurColorOrderDown->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonCurColorOrderDown->objectName()));
    ui->buttonOddEmb->setOrangeGradientBottomStyle(BORDER_RADIUS1);
    ui->buttonOddEmb->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonOddEmb->objectName()));
    ui->buttonEvenEmb->setOrangeGradientBottomStyle(BORDER_RADIUS1);
    ui->buttonEvenEmb->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonEvenEmb->objectName()));
    ui->buttonHeadClear->setOrangeGradientBottomStyle(BORDER_RADIUS1);
    ui->buttonHeadClear->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonHeadClear->objectName()));

    ui->frameWarrantBtn->setStyleSheet(TRANSPARENTSTYLE);
    ui->buttonWarrant->setWhiteBlueBottomStyle();
    ui->buttonWarrant->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1"),12);
    ui->buttonWarrantCancel->setWhiteBlueBottomStyle();
    ui->buttonWarrantCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"),12);
}

void PromptDialog::initArabControlPos()
{
    int language = g_pSettings->readFromInHMIiFile("HMI/language").toInt();
    if(language != arabic)
    {
        return;
    }

    ui->labelTitle->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    ui->labelContent->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    ui->labelContentInfo->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    //ui->labelContentWarrant->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    ui->labelContentProcess->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    //手动换色
    ui->labelCurNeedle->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    ui->labelCurNeedleValue->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    //隔头绣
    ui->labelCurColorOrder->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);

    //提升电机控制
    ui->labelPoten->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
    ui->labelPotenValue->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
    ui->labelGear->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
    ui->labelGearValue->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
    ui->labelGearSwitch->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);

    //松紧线控制
    ui->labelLocation->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
    ui->labelLocationValue->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
    ui->labelPoten2->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
    ui->labelPotenValue2->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);

    //定量移框
    //ui->labelMoveX->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    ui->labelXUnit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    ui->labelMoveY->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    ui->labelYUnit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    //主轴角度旋转
    ui->labelSpindleAngle->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
    ui->labelSpindleAngleUnit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    //平绣毛巾缠绕
    ui->labelNoseHead->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    ui->labelNoseHeadValue->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    //界面解密
    ui->labelNetworkCardID->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    ui->labelHMIPassword->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    ui->labelDecryptInfo->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);

    //修改一级密码
    ui->labelNewPassword->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    ui->labelConfirmPassword->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);

    //线迹偏移
    ui->labelTraceInfo->setAlignment(Qt::AlignRight| Qt::AlignVCenter);
    ui->labelTraceType->setAlignment(Qt::AlignLeft| Qt::AlignVCenter);
}

//刷新当前色序的机头工作号
void PromptDialog::refreshColorOrderHead()
{
    if(sizeof(m_headBuf) < HEADBUF)
    {
        return;
    }

    //复制当前色序的全部工作机头缓存 128个机头
    u8 curHeadBuf[16];
    memcpy(curHeadBuf,m_headBuf+(m_curColorOrder-1)*sizeof(curHeadBuf),sizeof(curHeadBuf));

    for(u32 i = 0; i < sizeof(curHeadBuf); i++)
    {
        s8 eachBuf = curHeadBuf[i];

        for(int j = 0; j < 8; j++)
        {
            int idx = i*8+j;

            if(((eachBuf >> j) & 1) == 1)
            {
                if(idx < m_buttonEmbHeadList.size())
                {
                    m_buttonEmbHeadList.at(idx)->setStyleSheet(m_buttonStyle2);
                }
            }
            else
            {
                if(idx < m_buttonEmbHeadList.size())
                {
                    m_buttonEmbHeadList.at(idx)->setStyleSheet(m_buttonStyle1);
                }
            }
        }
    }

    ui->buttonCurColorOrder->setText(QString::number(m_curColorOrder));
}

//设置标题
void PromptDialog::setTitleStr(QString str)
{
    ui->labelTitle->setText(str);
}

//设置断线机头字体颜色    -rq
void PromptDialog::setStrColor(QString str)
{
    ui->frameProcess->hide();
    ui->labelContentInfo->setText("");
    ui->labelContentInfo->hide();
    ui->labelContentWarrant->setText("");
    ui->labelContentWarrant->hide();
    ui->labelContent->setText("");
    ui->labelContent->hide();
    ui->labeBreakHead->setText(str);
    ui->labeBreakHead->show();
    //    ui->labeBottomBreakHead->setText(str2);
    //    ui->labeBottomBreakHead->show();
}
//设置显示内容
void PromptDialog::setContentStr(QString str)
{
    ui->frameProcess->hide();
    ui->labelContentInfo->setText("");
    ui->labelContentInfo->hide();
    ui->labeBreakHead->setText("");//断线机头显示
    ui->labeBreakHead->hide();
    ui->labeBottomBreakHead->setText("");//底线断线机头显示
    ui->labeBottomBreakHead->hide();
    ui->labelContentWarrant->setText("");
    ui->labelContentWarrant->hide();
    ui->labelContent->setText(str);
    ui->labelContent->show();
}

void PromptDialog::setContentProcessStr(QString str)
{
    ui->frameProcess->show();
    ui->labelContentInfo->setText("");
    ui->labelContentInfo->hide();
    ui->labeBreakHead->setText("");//断线机头显示
    ui->labeBreakHead->hide();
    ui->labeBottomBreakHead->setText("");//底线断线机头显示
    ui->labeBottomBreakHead->hide();
    ui->labelContent->setText("");
    ui->labelContent->hide();
    ui->labelContentWarrant->setText("");
    ui->labelContentWarrant->hide();
    ui->labelContentProcess->show();
    ui->labelContentProcess->setText(str);
}

void PromptDialog::setContentInfoShow()
{
    ui->labelContent->hide();
    ui->labeBreakHead->hide();
    ui->labeBottomBreakHead->hide();
    ui->frameProcess->hide();
    ui->labelContentWarrant->hide();
    ui->labelContentInfo->show();
}

void PromptDialog::setContentWarrantShow()
{
    ui->labelContent->hide();
    ui->labeBreakHead->hide();
    ui->labeBottomBreakHead->hide();
    ui->frameProcess->hide();
    ui->labelContentInfo->hide();
    ui->labelContentWarrant->show();
}

void PromptDialog::setContentHMIDecryptShow(QString id)
{
    //将id中的冒号去掉
    QStringList strlist = id.split(":", QString::SkipEmptyParts);
    QString nId;
    nId.clear();
    for(int i = 0; i < strlist.size(); i++)
    {
        nId += strlist[i];
    }
    ui->labelNetworkCardIDValue->setText(nId);
    ui->buttonHMIPassword->setText("");

    QDir apppath(qApp->applicationDirPath());
    QString HMIDecryptConfigfile;
    HMIDecryptConfigfile = apppath.path() + apppath.separator() + "HMIDecryptConfig.ini";
    QSettings iniSetting(HMIDecryptConfigfile, QSettings::IniFormat);
    int decryptFlag = iniSetting.value("HMIDecrypt/ifdecrypt").toInt();
    QFile iniFile(HMIDecryptConfigfile);
    if(decryptFlag != 0 || !iniFile.exists())//等于1或者配置文件不存在
    {
        ui->labelDecryptInfoValue->setText("HMI decrypted");//界面已解密
    }
    else
    {
        ui->labelDecryptInfoValue->setText("HMI unresolved");//界面未解密
    }

    ui->buttonOk->setEnabled(false);
}
void PromptDialog::setContentChangePasswordShow()//修改一级用户密码内容显示
{
    ui->buttonNewPassword->setText("");
    ui->buttonConfirmPassword->setText("");
    ui->buttonOk->setEnabled(false);
}

void PromptDialog::setValue(int progress)
{
    ui->progressBar->setValue(progress);
}

void PromptDialog::setButtonUCancelStr(QString str)
{
    ui->buttonUpdataCancel->setText(str);
}

void PromptDialog::setRange(int minimum, int maximum)
{
    ui->progressBar->setRange(minimum,maximum);
}

//当前机头
void PromptDialog::setNoseHeadValueStr(int noseHeadValue)
{
    if(noseHeadValue == 1)  //平绣机头
    {
        ui->labelNoseHeadValue->setText(tr("Emb shead"));
    }
    else if(noseHeadValue == 2) // 毛巾机头
    {
        ui->labelNoseHeadValue->setText(tr("Chenille head"));
    }
    else if(noseHeadValue == 3) // 缠绕机头
    {
        ui->labelNoseHeadValue->setText(tr("Coil head"));
    }
    else
    {
        ui->labelNoseHeadValue->setText(tr("Unknown"));
    }
}

//当前工作label是否可见
void PromptDialog::setNoseHeadStrVisible(bool bl)
{
    ui->labelNoseHead->setVisible(bl);
    ui->labelNoseHeadValue->setVisible(bl);
}

//电位器值
void PromptDialog::setPosValueStr(QString posValue)
{
    ui->labelPotenValue->setText(posValue);//提升电机界面
    ui->labelPotenValue2->setText(posValue);//松紧线控制界面
}
//档位值
void PromptDialog::setGearValueStr(int  gearValue)
{
    ui->labelGearValue->setText(QString::number(gearValue));//提升电机控制界面显示当前档位值
    if(gearValue == 1)  // 松紧线电机换色位
    {
        ui->labelLocationValue->setText(tr("Color"));
    }
    else if(gearValue == 2) // 松紧线电机剪线位
    {
        ui->labelLocationValue->setText(tr("Trim"));
    }
    else if(gearValue == 3) // 松紧线电机链式位
    {
        ui->labelLocationValue->setText(tr("Chain"));
    }
    else if(gearValue == 4)   // 松紧线电机毛巾位
    {
        ui->labelLocationValue->setText(tr("Chenille"));
    }
    else
    {
        ui->labelLocationValue->setText(tr("Unknown location"));
    }
}

//当前针杆
void PromptDialog::setCurNeedleStr(int type,QString idx,QString posValue)
{
    QString potvalStr;
    potvalStr.clear();
    if(m_camColorChange == 1)//有凸轮换色功能
    {
        potvalStr =tr("Potentiometer value:")+posValue;//电位器值
    }
    else
    {
        potvalStr="";
    }

    if(type == 1)  //平绣机头//默认显示  （平绣针杆：0）
    {
        ui->labelCurNeedleValue->setText(tr("EmbNeedle: ")+idx+potvalStr);
    }
    else if(type == 2) // 毛巾机头
    {
        ui->labelCurNeedleValue->setText(tr("ChenilleNeedle: ")+idx+potvalStr);
    }
    else
    {
        ui->labelCurNeedleValue->setText(idx+potvalStr);
    }
}

//当前针杆label是否可见
void PromptDialog::setCurNeedleStrVisible(bool bl)
{
    ui->labelCurNeedle->setVisible(bl);
    ui->labelCurNeedleValue->setVisible(bl);
}

//初始化针杆
void PromptDialog::initNeedleBar(int val)
{
    //读入配置
    QDir apppath(qApp->applicationDirPath());

    //配置文件路径
    QString configFile = apppath.path() + apppath.separator() + "config.ini";
    QFile iniFile(configFile);

    QRgb * pColorBuf = (QRgb *)(g_pSettings->getColorRgbArray().data());
    QString buttonStyle3 = "QPushButton{outline: none;border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;";
    QString buttonStyle4 = "QPushButton:checked{outline: none;border:3px groove rgb(80,80,80);}";

    int num,idx;
    num = idx = 0;
    if(!iniFile.exists())
    {
        num = 1;
        idx = 0;

        QRgb rgb = pColorBuf[(idx % EMB_BF_SW_ND)];
        rgb |= 0xff000000;
        QColor bkcolor(rgb);
        QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
        QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
                + " color:" + tcolor.name() + ";";

        for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
        {
            if(i < num)
            {
                m_buttonEmbNeedleList.at(i)->setStyleSheet(buttonStyle3 + cstyle + "}" + buttonStyle4);
                m_buttonEmbNeedleList.at(i)->show();
            }
            else
            {
                m_buttonEmbNeedleList.at(i)->hide();
            }
        }
    }
    else
    {
        QRgb rgb = qRgb(0,255,0);
        if(val == PRODUCT_EMB)
        {
            num = g_pSettings->readFromIniFile("EmbNeedle/number").toInt();
        }
        else if ( val == RODUCT_SEQUIN)
        {
            num = g_pSettings->readFromIniFile("SequinColor/number").toInt();
        }
        else if (val == PRODUCT_TOWEL)
        {
            //从配置文件里读有几个针杆,显示几个按钮
            num = g_pSettings->readFromIniFile("TowelNeedle/number").toInt();
        }
        else if (val == PRODUCT_COIL)
        {
            //缠绕就一个针杆所以不显示
            num = 0;
        }
        for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)//针杆按钮
        {
            QString idxStr;
            if(val == PRODUCT_EMB)
            {
                idxStr = "EmbNeedle/"+QString::number(i+1)+"_coloridx";
            }
            else if(val == RODUCT_SEQUIN)
            {
                idxStr = "SequinColor/"+QString::number(i+1)+"_coloridx";
            }
            else if(val == PRODUCT_TOWEL)
            {
                idxStr = "TowelNeedle/"+QString::number(i+1)+"_coloridx";
            }
            else if(val == PRODUCT_COIL)
            {
                idxStr = "CoilNeedle/"+QString::number(i+1)+"_coloridx";
            }

            if(g_pSettings->ifKeyExists(idxStr) == true)//判断配置文件中是否有这个key(TowelNeedle/1_coloridx)
            {
                idx = g_pSettings->readFromIniFile(idxStr).toInt();//从配置文件里读的第几个针杆的颜色
                rgb = pColorBuf[(idx % EMB_BF_SW_ND)];
            }
            else
            {
                rgb = pColorBuf[(i % EMB_MC_SW_ND)];
            }
            rgb |= 0xff000000;
            QColor bkcolor(rgb);
            QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
            QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
                    + " color:" + tcolor.name() + ";";
            if(i < num)//从配置文件里读有几个针杆，然后换色弹窗就显示几个
            {
                m_buttonEmbNeedleList.at(i)->setStyleSheet(buttonStyle3 + cstyle + "}" + buttonStyle4);
                m_buttonEmbNeedleList.at(i)->show();
            }
            else
            {
                m_buttonEmbNeedleList.at(i)->hide();
            }
        }
    }

    for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
    {
        m_buttonEmbNeedleList.at(i)->setChecked(false);
        m_buttonEmbNeedleList.at(i)->setCheckable(false);
    }

    ui->buttonOk->setEnabled(false);
    //    if(needle > 0)
    //    {
    //        //        m_buttonEmbNeedleList.at(val-1)->setChecked(true);
    //        //        m_buttonEmbNeedleList.at(val-1)->setCheckable(true);
    //        //        ui->buttonOk->setEnabled(true);
    //    }
}
void PromptDialog::setHeadType(int headType)
{
    m_headType = headType;
}

void PromptDialog::setHeadNum(int headNum)
{
    m_totalHead = headNum;
}

//初始化亮片针杆
void PromptDialog::initSequinNeedleBar(int val)
{
    QString buttonStyle3 = "QPushButton{outline: none;border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;";
    QString buttonStyle4 = "QPushButton:checked{outline: none;border:3px groove rgb(80,80,80);}";

    QColor bkcolor(255,255,255);
    QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
    QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
            + " color:" + tcolor.name() + ";";

    for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
    {
        if(i < val)//8
        {
            m_buttonEmbNeedleList.at(i)->setStyleSheet(buttonStyle3 + cstyle + "}" + buttonStyle4);
            m_buttonEmbNeedleList.at(i)->show();
        }
        else
        {
            m_buttonEmbNeedleList.at(i)->hide();
        }
    }

    for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
    {
        m_buttonEmbNeedleList.at(i)->setChecked(false);
        m_buttonEmbNeedleList.at(i)->setCheckable(false);
    }

    ui->buttonOk->setEnabled(false);
}

//初始化平绣机头
void PromptDialog::initEmbHead(int headNum,int colorOrderNum,QString path)
{
    m_totalColorOrder = colorOrderNum;
    m_filePath = path + ".fcg";

    for(int i = 0; i < m_buttonEmbHeadList.size(); i++)
    {
        if(i < headNum)
        {
            //m_buttonEmbHeadList.at(i)->setStyleSheet(buttonStyle1);
            m_buttonEmbHeadList.at(i)->show();
        }
        else
        {
            m_buttonEmbHeadList.at(i)->hide();
        }
    }

    if(headNum <= 0)
    {
        ui->buttonOddEmb->setEnabled(false);
        ui->buttonEvenEmb->setEnabled(false);
        ui->buttonOk->setEnabled(false);
    }
    else
    {
        ui->buttonOddEmb->setEnabled(true);
        ui->buttonEvenEmb->setEnabled(true);
        ui->buttonOk->setEnabled(true);
    }

    QFile file(m_filePath);
    if(file.exists())//存在fcg文件
    {
        if(file.open(QIODevice::ReadOnly))
        {
            QByteArray ary = file.readAll();
            if((u32)ary.size() >= sizeof(DataFileHead)+sizeof(m_headBuf))
            {
                memcpy(m_headBuf,ary.data()+sizeof(DataFileHead),sizeof(m_headBuf));
            }
        }
        file.close();
    }

    m_curColorOrder = 1;
    refreshColorOrderHead();
}

//初始化毛巾机头
void PromptDialog::initChenilleHead(int headNum)
{
    QString buttonStyle3 = "QPushButton{outline: none;border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;";
    QString buttonStyle4 = "QPushButton:checked{outline: none;border:3px groove rgb(80,80,80);}";

    QColor bkcolor(255,255,255);
    QColor tcolor = QColor(255-bkcolor.red(), 255-bkcolor.green(), 255-bkcolor.blue()).lighter(168);
    QString cstyle = "outline: none;background-color:" + bkcolor.name() + ";"
            + " color:" + tcolor.name() + ";";

    for(int i = 0; i < m_buttonChenilleHeadList.size(); i++)
    {
        if(i < headNum)
        {
            m_buttonChenilleHeadList.at(i)->setStyleSheet(buttonStyle3 + cstyle + "}" + buttonStyle4);
            m_buttonChenilleHeadList.at(i)->show();
        }
        else
        {
            m_buttonChenilleHeadList.at(i)->hide();
        }
    }
    for(int i = 0; i < m_buttonChenilleHeadList.size(); i++)
    {
        m_buttonChenilleHeadList.at(i)->setChecked(false);
        m_buttonChenilleHeadList.at(i)->setCheckable(false);
    }
    ui->buttonOk->setEnabled(true);
}

QString PromptDialog::getNetworkCardID()
{
    return ui->labelNetworkCardIDValue->text();
}

QString PromptDialog::getInputPassword()
{
    return ui->buttonHMIPassword->text();
}

//获取线迹偏移类型
s16 PromptDialog::getTraceOffsetType()
{
    s16 val = 0;
    if(ui->buttonTraceOffset->isChecked())
    {
        val = 1;
    }
    else if(ui->buttonTraceOffsetReset->isChecked())
    {
        val = 2;
    }
    else if(ui->buttonCurTraceOffsetClear->isChecked())
    {
        val = 3;
    }
    return val;
}

void PromptDialog::slotMCInfoChange()
{
    QString strInfo;
    MCInfo info;//机器信息
    char softwareVerStr[32+1];//软件版本
    char mBoardVerStr[16+1];//主板（n1）板卡版本
    char exBoardVerStr[16+1];//主板（n1-1）板卡版本
    char buildInfoStr[32+1];//编译日期信息

    info = g_pMachine->getMcInfo();
    memcpy(softwareVerStr, info.softwareVerStr, 32);
    memcpy(mBoardVerStr, info.mBoardVerStr, 16);
    memcpy(exBoardVerStr, info.exBoardVerStr, 16);
    memcpy(buildInfoStr, info.buildInfoStr, 32);

    softwareVerStr[32] = 0;
    mBoardVerStr[16]= 0;
    exBoardVerStr[16]= 0;
    buildInfoStr[32]=0;

    QString strBoardVer;
    strBoardVer.sprintf("%s", softwareVerStr);

    QString strMBoardVer;
    strMBoardVer.sprintf("%s", mBoardVerStr);

    QString strExBoardVer;
    strExBoardVer.sprintf("%s", exBoardVerStr);

    QString strBuildInfo;
    strBuildInfo.sprintf("%s", buildInfoStr);

    if(strBoardVer.length() > 0 )
    {
        strBoardVer.remove(" ");//清除空格
    }
    strInfo += tr("Board:") + " " +  strBoardVer + "\n"+
            strBuildInfo+ "\n" +
            strMBoardVer + "\n" +
            strExBoardVer + "\n" ;

    QString verInfo = "\n" + strInfo;
    ui->labelContentInfo->setText(verInfo);

    //连接多块主板也是从g_pMachine(第一块)获取软件授权信息
    MCStatus mcStatus;
    mcStatus = g_pMachine->getMcStatus();   //读的一个主板的可工作时间计数器（分钟）

    MCInfo infoID;//机器信息
    infoID = g_pMachine->getMcInfo();

    QString IDStr(infoID.boardId);
    if(IDStr.indexOf(":") != -1)
    {
        QStringList list = IDStr.split(":");
        IDStr = list.at(1);
    }

    QString passwordStr(infoID.installment);
    if(passwordStr.indexOf(":") != -1)
    {
        QStringList list = passwordStr.split(":");
        passwordStr = list.at(1);
    }

    int time = mcStatus.workableTimer;//只在上电的时候读取
    QString timeStr;
    if( time > TIMELIMITMIN && time < TIMELIMITMAX)
    {
        timeStr = (tr("Unlimited time"));   // 无时间限制
    }
    if(time <= 0)
    {
        timeStr = (tr("Time has run out")); // 时间已用完
    }
    if(time > 0 && time < TIMELIMITMIN)
    {
        QString strDay;
        QString strHour;
        QString strSec;

        strDay  = QString::number(time/(60 *24) , 10);
        strHour = QString::number((time%(60 *24))/60 , 10) ;
        strSec  = QString::number(time%60 , 10);

        timeStr = strDay + " " + tr("Day") + " " + strHour + " " + tr("Hour")  + " " +  strSec  + " " + tr("Minutes") ;  // 天   小时   分钟
    }

    QString strBoardInfo;
    strBoardInfo = QString(tr("ID: %1\n")).arg(IDStr);
    strBoardInfo += QString(tr("Password: %1\n")).arg(passwordStr);
    strBoardInfo += QString(tr("Time: %1")).arg(timeStr);
    ui->labelContentWarrant->setText(strBoardInfo);
}

//针杆按钮被点击
void PromptDialog::slotEmbNeedleBtnClick()
{
    m_pEmbNeedleBtn = (QPushButton*) this->sender();

    if(m_pEmbNeedleBtn == NULL)
    {
        return;
    }

    for(int i = 0; i < m_buttonEmbNeedleList.size(); i++)
    {
        if(m_pEmbNeedleBtn == m_buttonEmbNeedleList.at(i))
        {
            m_selectNeedleIdx = i+1;
        }
        m_buttonEmbNeedleList.at(i)->setChecked(false);
        m_buttonEmbNeedleList.at(i)->setCheckable(false);
    }
    m_pEmbNeedleBtn->setCheckable(true);
    m_pEmbNeedleBtn->setChecked(true);

    ui->buttonOk->setEnabled(true);
}

//机头按钮被点击
void PromptDialog::slotEmbHeadBtnClick()
{
    if(sizeof(m_headBuf) < HEADBUF)
    {
        return;
    }

    QPushButton *headNeedleBtn = (QPushButton*) this->sender();

    if(headNeedleBtn == NULL)
    {
        return;
    }

    int size = 16;//每个色序对应的机头数 16x8=128
    u16 idx = 0;
    u16 oft = 0;
    for(int i = 0; i < m_buttonEmbHeadList.size(); i++)
    {
        if(headNeedleBtn == m_buttonEmbHeadList.at(i))
        {
            idx = i/8;
            oft = i%8;

            s8 eachBuf = m_headBuf[idx+(m_curColorOrder-1)*size];

            if(((eachBuf >> oft) & 1) == 1)
            {
                m_headBuf[idx+(m_curColorOrder-1)*size] = ~((~(m_headBuf[idx+(m_curColorOrder-1)*size])) | (1 << oft));
            }
            else
            {
                m_headBuf[idx+(m_curColorOrder-1)*size] = m_headBuf[idx+(m_curColorOrder-1)*size] | (1 << oft);//0000 0001
            }

            break;
        }
    }

    refreshColorOrderHead();
}

//毛巾机头被点击
void PromptDialog::slotChenilleHeadBtnClick()
{
    //按钮被点击时，设置是否可按
    QPushButton * m_pChenilleNeedleBtn = (QPushButton*) this->sender();

    if(m_pChenilleNeedleBtn == NULL)
    {
        return;
    }
    for(int i = 0; i < m_buttonChenilleHeadList.size(); i++)
    {
        if(m_pChenilleNeedleBtn == m_buttonChenilleHeadList.at(i))
        {
            m_selectHeadleIdx = i+1;
        }
        m_buttonChenilleHeadList.at(i)->setChecked(false);
        m_buttonChenilleHeadList.at(i)->setCheckable(false);
    }
    m_pChenilleNeedleBtn->setCheckable(true);
    m_pChenilleNeedleBtn->setChecked(true);
    //发送测试电位器
    if(g_pMachine != NULL)
    {
        g_pMachine->testADC(3,m_selectHeadleIdx);//para2=3，para3=所选的机头
        m_adcFlagValue = 1;
    }
}
//发送了测试电位器的命令（para = 2）
//void PromptDialog::slotTestADC(int m_adcFlag)
//{
//    m_adcFlagValue = m_adcFlag;
//}

void PromptDialog::on_buttonOk_clicked()
{
    if(m_funType == BTN_SPINDLE_ROTATE)
    {
        emit siEmbSpindleRotate(m_spindleAngle);
    }
    else if(m_funType == BTN_LIFTMOTORCONTROL)//点击确认按钮发命令，但是不会关闭弹窗
    {
        emit siLiftMotorCtrl(m_gearValue);//档位值
    }
    else if(m_funType == BTN_ELASTICCONTROL)//点击确认按钮发命令，但是不会关闭弹窗
    {
        emit siElasticCtrlPos(m_elasticWirePos);
    }
    else
    {
        if(m_adcFlagValue == 1)//发送了测试电位器的命令
        {
            if(g_pMachine != NULL)
            {
                g_pMachine->testADC(0);//退出测试电位器
                m_adcFlagValue =-1;
            }
        }
        done(1);
    }
}

void PromptDialog::on_buttonCancel_clicked()
{
    done(0);
}

void PromptDialog::on_buttonRename_clicked()
{
    done(1);
}

void PromptDialog::on_buttonReplace_clicked()
{
    done(2);
}

void PromptDialog::on_buttonSkip_clicked()
{
    done(0);
}

//重启
void PromptDialog::on_buttonRestart_clicked()
{
#ifdef Q_OS_WIN
    qApp->exit();
#endif

#ifdef Q_OS_LINUX
    system("reboot");
#endif
}

//升级中断
void PromptDialog::on_buttonUpdataCancel_clicked()
{
    emit(siUpdataCancel());
    done(0);
}

void PromptDialog::on_buttonWarrant_clicked()
{
    //输入框
    WordsInputDialog wordInputDlg;
    wordInputDlg.clean();
    wordInputDlg.setTitleStr(tr("Warrant"));
    wordInputDlg.setOldWordsStr("");
    if(wordInputDlg.exec() == 1)
    {
        QString textStr = wordInputDlg.getInputStr();
        g_pMachine->setMacKey(( unsigned char * ) textStr.toLatin1().data() ,textStr.toLatin1().size());
        done(1);
    }
}

void PromptDialog::on_buttonWarrantCancel_clicked()
{
    done(0);
}

//机头显示
void PromptDialog::on_buttonCurColorOrder_clicked()
{
    int rslt;
    NumerInputDialog ndlg(this);
    ndlg.setTitleStr(tr("Color order num"));//色序号
    ndlg.setUnitStr("");
    ndlg.setValueAndRange(m_curColorOrder, 1, m_totalColorOrder, 0);
    rslt = ndlg.exec();

    if (rslt == 1)
    {
        s32 val = ndlg.getValue();
        m_curColorOrder = val;
        refreshColorOrderHead();
    }
}

//上一个色序
void PromptDialog::on_buttonCurColorOrderUp_clicked()
{
    m_curColorOrder--;
    if(m_curColorOrder <= 0)
    {
        m_curColorOrder = 1;
    }
    refreshColorOrderHead();
}

//下一个色序
void PromptDialog::on_buttonCurColorOrderDown_clicked()
{
    m_curColorOrder++;
    if(m_curColorOrder > m_totalColorOrder)
    {
        m_curColorOrder = m_totalColorOrder;
    }
    refreshColorOrderHead();
}

//奇数隔头
void PromptDialog::on_buttonOddEmb_clicked()
{
    int size = 16;//每个色序对应的机头数 16x8=128
    int preIdx = -1;
    int idx = 0;
    s8 oddVal = -86;//奇 1010 1010

    for(int i = 0; i < m_buttonEmbHeadList.size(); i++)
    {
        idx = i/8;
        if(preIdx != idx)
        {
            m_headBuf[idx+(m_curColorOrder-1)*size] = oddVal;
        }
        preIdx = idx;
    }
    refreshColorOrderHead();
}

//偶数隔头
void PromptDialog::on_buttonEvenEmb_clicked()
{
    int size = 16;//每个色序对应的机头数 16x8=128
    int preIdx = -1;
    int idx = 0;
    s8 evenVal = 85;//偶 0101 0101

    for(int i = 0; i < m_buttonEmbHeadList.size(); i++)
    {
        idx = i/8;
        if(preIdx != idx)
        {
            m_headBuf[idx+(m_curColorOrder-1)*size] = evenVal;
        }
        preIdx = idx;
    }
    refreshColorOrderHead();
}

//清除隔头
void PromptDialog::on_buttonHeadClear_clicked()
{
    memset(m_headBuf,0,sizeof(m_headBuf));
    refreshColorOrderHead();
}

//开始检测
void PromptDialog::on_buttonDetectBegin_clicked()
{
    if(m_funType == BTN_BOTTOM)//等于底线检测
    {
        //底线检测开始，绣花机才有，所以是g_pMachine(第一块)
        if(g_pMachine != NULL)
        {
            if(m_headType == FLATEMB)
            {
                g_pMachine->testThreadBK(BOTTOM,m_selectNeedleIdx,FLATEMB);
            }
            else if(m_headType == COIL)
            {
                g_pMachine->testThreadBK(BOTTOM,1,COIL);
            }
        }
        return;
    }
    if(m_funType == BTN_FACE)//等于面线检测
    {
        //面线检测开始，绣花机才有，所以是g_pMachine(第一块)
        if(g_pMachine != NULL)
        {
            if(m_headType == FLATEMB)
            {
                g_pMachine->testThreadBK(NOODLES,m_selectNeedleIdx,FLATEMB);
            }
            else if(m_headType == COIL)
            {
                g_pMachine->testThreadBK(NOODLES,1,COIL);//缠绕就一个针杆
            }
        }
        return;
    }

    if(m_funType == BTN_HOOK_TEST)//等于勾刀检测
    {
        //勾刀检测开始，绣花机才有，所以是g_pMachine(第一块)
        if(g_pMachine != NULL)
        {
            g_pMachine->outputCtrl(OT_TEST_HOOK,UP_OPEN_ON, 0);//1启动，0停止
        }
        return;
    }

    if(m_funType == BTN_FOOT_TEST)//等于独立压脚
    {
        //独立压脚测试开始，绣花机才有，所以是g_pMachine(第一块)
        if(g_pMachine != NULL)
        {
            g_pMachine->footTest();
        }
        return;
    }
}

//停止检测
void PromptDialog::on_buttonDetectEnd_clicked()
{
    //绣花机才有，所以是g_pMachine(第一块)
    if(m_funType == BTN_HOOK_TEST)//等于勾刀检测
    {
        if(g_pMachine != NULL)
        {
            g_pMachine->outputCtrl(OT_TEST_HOOK,OT_STOP, 0);
        }
    }
    else if(m_funType == BTN_FOOT_TEST)//等于独立压脚
    {
        //独立压脚测试开始，绣花机才有，所以是g_pMachine(第一块)
        if(g_pMachine != NULL)
        {
            g_pMachine->manualAction(TEST_EMB_FOOT,OT_STOP,1);
        }
    }
    else//停止面线、底线检测
    {
        if(g_pMachine != NULL)
        {
            g_pMachine->exitDetectTest();
        }
    }
}

//关闭检测窗体
void PromptDialog::on_buttonDetectClose_clicked()
{
    //退出弹窗的时候也发一个  停止检测  的命令  -rq
    if(m_funType == BTN_BOTTOM  || m_funType == BTN_FACE)//等于面线、底线检测
    {
        if(g_pMachine != NULL)
        {
            g_pMachine->exitDetectTest();
        }
    }
    else if(m_funType == BTN_FOOT_TEST)//等于独立压脚
    {
        //独立压脚测试开始，绣花机才有，所以是g_pMachine(第一块)
        if(g_pMachine != NULL)
        {
            g_pMachine->manualAction(TEST_EMB_FOOT,OT_STOP,1);
        }
    }
    done(0);
}

//定量移框X输入
void PromptDialog::on_buttonMoveXValue_clicked()
{
    int rslt;
    NumerInputDialog ndlg(this);
    ndlg.setTitleStr(tr("X mobile quantity"));//X移动量
    ndlg.setUnitStr("mm");

    int val = 2;
    if(m_stepDrive == 1)//有步进电机驱动
    {
        val = 1;
    }
    ndlg.setValueAndRange(ui->buttonMoveXValue->text().toInt()*100, S32_MIN, S32_MAX,val);
    rslt = ndlg.exec();

    if (rslt == 1)
    {
        QString xStr;
        s32 val = ndlg.getValue();
        m_moveX = val;//定量移框X值
        if(m_stepDrive == 1)
        {
            float x = m_moveX*0.1;
            xStr.sprintf("%.1f",x);
        }
        else if(m_stepDrive == 0)
        {
            float x = m_moveX*0.01;
            xStr.sprintf("%.2f",x);
        }
        ui->buttonMoveXValue->setText(xStr);
    }
}

//定量移框Y输入
void PromptDialog::on_buttonMoveYValue_clicked()
{
    int rslt;
    NumerInputDialog ndlg(this);
    ndlg.setTitleStr(tr("Y mobile quantity"));//Y移动量
    ndlg.setUnitStr("mm");
    int val = 2;
    if(m_stepDrive == 1)//有步进电机驱动
    {
        val = 1;
    }
    ndlg.setValueAndRange(ui->buttonMoveYValue->text().toInt()*100, S32_MIN, S32_MAX, val);
    rslt = ndlg.exec();

    if (rslt == 1)
    {
        QString yStr;
        s32 val = ndlg.getValue();
        m_moveY = val;//定量移框Y值
        if(m_stepDrive == 1)
        {
            float y = m_moveY*0.1;
            yStr.sprintf("%.1f",y);
        }
        else if(m_stepDrive == 0)
        {
            float y = m_moveY*0.01;
            yStr.sprintf("%.2f",y);
        }
        ui->buttonMoveYValue->setText(yStr);
    }
}

//界面解密ID号输入按钮
void PromptDialog::on_buttonHMIPassword_clicked()
{
    //输入框
    WordsInputDialog wordInputDlg;
    wordInputDlg.clean();
    wordInputDlg.setTitleStr(tr("HMI decrypt"));
    wordInputDlg.setOldWordsStr("");
    if(wordInputDlg.exec() == 1)
    {
        QString textStr = wordInputDlg.getInputStr();
        ui->buttonHMIPassword->setText(textStr);
        if(textStr.length() > 0)
        {
            ui->buttonOk->setEnabled(true);
        }
    }
}

void PromptDialog::on_buttonSpindleAngleValue_clicked()
{
    QTextCodec *cod = QTextCodec::codecForLocale();
    int rslt;
    NumerInputDialog ndlg(this);
    ndlg.setTitleStr(tr("Spindle angle rotation"));//主轴角度旋转
    ndlg.setUnitStr(cod->toUnicode("°"));
    ndlg.setValueAndRange(ui->buttonSpindleAngleValue->text().toInt()*100, 0, 36000, 2);
    rslt = ndlg.exec();

    if (rslt == 1)//输入弹窗点击了确认
    {
        s32 val = ndlg.getValue();
        m_spindleAngle = val;
        float angle = m_spindleAngle*0.01;
        QString angleStr;
        angleStr.sprintf("%.2f",angle);
        ui->buttonSpindleAngleValue->setText(angleStr);
    }
}

//修改一级密码:新密码输入按钮
void PromptDialog::on_buttonNewPassword_clicked()
{
    //密码输入框
    PassWordDialog passWordDlg;
    passWordDlg.setTitleStr(tr("New Password input"));//设置新密码输入的标题
    if(passWordDlg.exec() == 1)//确认
    {
        m_newPassword = passWordDlg.getInputStr();//获取输入框里的密码
        QString showStr("");
        for (int var = 0; var < m_newPassword.size(); var++)
        {
            showStr = showStr + "*";
        }
        ui->buttonNewPassword->setText(showStr);//新密码框里显示获取的密码
    }
}
//修改一级密码:确认新密码输入按钮
void PromptDialog::on_buttonConfirmPassword_clicked()
{
    //密码输入框
    PassWordDialog passWordDlg;
    passWordDlg.setTitleStr(tr("Confirm Password input"));//设置确认密码输入的标题
    if(passWordDlg.exec() == 1)//确认
    {
        m_confirmPassword = passWordDlg.getInputStr();//获取输入框里的密码
        QString showStr("");
        for (int var = 0; var < m_confirmPassword.size(); var++)
        {
            showStr = showStr + "*";
        }
        ui->buttonConfirmPassword->setText(showStr);//确认密码框里显示获取的密码
        if(m_confirmPassword.length() > 0 )
        {
            ui->buttonOk->setEnabled(true);
        }
    }

}

//平绣主轴正转
void PromptDialog::on_buttonForward_pressed()
{
    emit siEmbSpindleAction(MT_MOVE_DIR_POSI);
}

//平绣主轴正转停止
void PromptDialog::on_buttonForward_released()
{
    emit siEmbSpindleAction(MT_MOVE_DIR_STOP);
}

//平绣主轴反转
void PromptDialog::on_buttonReverse_pressed()
{
    emit siEmbSpindleAction(MT_MOVE_DIR_NEGA);
}

//平绣主轴反转停止
void PromptDialog::on_buttonReverse_released()
{
    emit siEmbSpindleAction(MT_MOVE_DIR_STOP);
}

//线迹偏移
void PromptDialog::on_buttonTraceOffset_clicked()
{
    ui->labelTraceType->setText(tr("Trace offset"));//线迹偏移
    ui->buttonTraceOffset->setCheckable(true);
    ui->buttonTraceOffset->setChecked(true);

    ui->buttonTraceOffsetReset->setChecked(false);
    ui->buttonCurTraceOffsetClear->setChecked(false);
}

//所有线迹偏移复位
void PromptDialog::on_buttonTraceOffsetReset_clicked()
{
    ui->labelTraceType->setText(tr("Trace offset data reset"));//线迹偏移数据复位
    ui->buttonTraceOffsetReset->setCheckable(true);
    ui->buttonTraceOffsetReset->setChecked(true);

    ui->buttonTraceOffset->setChecked(false);
    ui->buttonCurTraceOffsetClear->setChecked(false);
}

//清除当前线迹偏移
void PromptDialog::on_buttonCurTraceOffsetClear_clicked()
{
    ui->labelTraceType->setText(tr("Clear the trace offset data of the current index"));//清除当前索引的线迹偏移数据
    ui->buttonCurTraceOffsetClear->setCheckable(true);
    ui->buttonCurTraceOffsetClear->setChecked(true);

    ui->buttonTraceOffset->setChecked(false);
    ui->buttonTraceOffsetReset->setChecked(false);
}
//平绣
void PromptDialog::on_buttonHead1_clicked()
{
    ui->buttonHead2->setStyleSheet(m_buttonStyle2);
    ui->buttonHead1->setStyleSheet(m_buttonStyle1);
    ui->buttonHead3->setStyleSheet(m_buttonStyle2);
    if(g_emMacType == MACHINE_EMB||
            g_emMacType == QUIMACHINE_EMB)
    {
        m_noseHead = FLATEMB;
    }
}

//毛巾
void PromptDialog::on_buttonHead2_clicked()
{
    ui->buttonHead2->setStyleSheet(m_buttonStyle1);
    ui->buttonHead1->setStyleSheet(m_buttonStyle2);
    ui->buttonHead3->setStyleSheet(m_buttonStyle2);
    if(g_emMacType == MACHINE_EMB ||
            g_emMacType == QUIMACHINE_EMB)
    {
        if(m_funType == BTN_TRIMDOWN)//下剪线
        {
            m_noseHead = COIL;
        }
        else if(m_funType == BTN_MSPINDLE_ROTATE)
        {
            m_noseHead = TOWELM;
        }
        else
        {
            int towel = g_pSettings->readFromInHMIiFile("HMI/towel").toInt();//是否有毛巾功能
            int coil = g_pSettings->readFromInHMIiFile("HMI/coil").toInt();//是否有缠绕功能
            if(towel == 1 && coil != 1)
            {
                m_noseHead = TOWEL;
            }
            else if(coil == 1 && towel != 1)
            {
                m_noseHead = COIL;
            }
            else if(coil == 1 && towel == 1)
            {
                m_noseHead = TOWEL;
            }
        }
    }
}

void PromptDialog::on_buttonHead3_clicked()
{
    ui->buttonHead2->setStyleSheet(m_buttonStyle2);
    ui->buttonHead1->setStyleSheet(m_buttonStyle2);
    ui->buttonHead3->setStyleSheet(m_buttonStyle1);
    if(g_emMacType == MACHINE_EMB||
            g_emMacType == QUIMACHINE_EMB)
    {
        if(m_funType == BTN_MSPINDLE_ROTATE)
        {
            m_noseHead = COILM;
        }
        else
        {
            m_noseHead = COIL;
        }
    }
}

//提升电机控制界面，档位切换按钮
void PromptDialog::on_buttonGear_clicked()
{
    int rslt;
    NumerInputDialog ndlg(this);
    ndlg.setTitleStr(tr("Gear switch"));//档位切换
    ndlg.setUnitStr("");
    ndlg.setValueAndRange(ui->buttonGear->text().toInt(), 1, 11, 0);
    rslt = ndlg.exec();

    if (rslt == 1)
    {
        s32 val = ndlg.getValue();
        m_gearValue = val;//档位值
        ui->buttonGear->setText(QString("%1").arg(m_gearValue)); //int转成QString
    }
}

// 松紧线电机换色位
void PromptDialog::on_buttonLocation1_clicked()
{
    ui->buttonLocation1->setStyleSheet(m_buttonStyle1);
    ui->buttonLocation2->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation3->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation4->setStyleSheet(m_buttonStyle2);
    m_elasticWirePos = ELASTICWIRE_COLORCHANGE_POS;
}

// 松紧线电机剪线位
void PromptDialog::on_buttonLocation2_clicked()
{
    ui->buttonLocation1->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation2->setStyleSheet(m_buttonStyle1);
    ui->buttonLocation3->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation4->setStyleSheet(m_buttonStyle2);
    m_elasticWirePos = ELASTICWIRE_TRIMMING_POS;
}

// 松紧线电机链式位
void PromptDialog::on_buttonLocation3_clicked()
{
    ui->buttonLocation1->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation2->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation3->setStyleSheet(m_buttonStyle1);
    ui->buttonLocation4->setStyleSheet(m_buttonStyle2);
    m_elasticWirePos = ELASTICWIRE_CHAIN_POS;
}
// 松紧线电机毛巾位
void PromptDialog::on_buttonLocation4_clicked()
{
    ui->buttonLocation1->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation2->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation3->setStyleSheet(m_buttonStyle2);
    ui->buttonLocation4->setStyleSheet(m_buttonStyle1);
    m_elasticWirePos = ELASTICWIRE_CHENILLE_POS;
}

void PromptDialog::on_buttonX1_pressed()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(XY_MOVE_RIGHT, 2);//速度等级默认是2
    }
}

void PromptDialog::on_buttonX1_released()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->motoMove(XY_MOVE_RIGHT, MT_MOVE_DIR_STOP, 0);
    }
    m_area = 2;
}

void PromptDialog::on_buttonX2_pressed()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(XY_MOVE_LEFT, 2);
    }
}

void PromptDialog::on_buttonX2_released()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->motoMove(XY_MOVE_LEFT, MT_MOVE_DIR_STOP, 0);
    }
    m_area = 1;
}

void PromptDialog::on_buttonY1_pressed()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(XY_MOVE_FRONT, 2);
    }
}
//Y+
void PromptDialog::on_buttonY1_released()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->motoMove(XY_MOVE_FRONT, MT_MOVE_DIR_STOP, 0);
    }
    m_area = 4;
}

void PromptDialog::on_buttonY2_pressed()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(XY_MOVE_BACK, 2);
    }
}
//Y-
void PromptDialog::on_buttonY2_released()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->motoMove(XY_MOVE_BACK, MT_MOVE_DIR_STOP, 0);
    }
    m_area = 3;
}

//主轴旋转角度 90度
void PromptDialog::on_button90_clicked()
{
    m_spindleAngle = 9000;
    float angle = m_spindleAngle*0.01;
    QString angleStr;
    angleStr.sprintf("%.2f",angle);
    ui->buttonSpindleAngleValue->setText(angleStr);
}

void PromptDialog::on_button180_clicked()
{
    m_spindleAngle = 18000;
    float angle = m_spindleAngle*0.01;
    QString angleStr;
    angleStr.sprintf("%.2f",angle);
    ui->buttonSpindleAngleValue->setText(angleStr);
}

void PromptDialog::on_button270_clicked()
{
    m_spindleAngle = 27000;
    float angle = m_spindleAngle*0.01;
    QString angleStr;
    angleStr.sprintf("%.2f",angle);
    ui->buttonSpindleAngleValue->setText(angleStr);
}

void PromptDialog::on_button0_clicked()
{
    m_spindleAngle = 0;
    float angle = m_spindleAngle*0.01;
    QString angleStr;
    angleStr.sprintf("%.2f",angle);
    ui->buttonSpindleAngleValue->setText(angleStr);
}
