diff --git a/app/HGProductionTool/HGProductionTool.pro b/app/HGProductionTool/HGProductionTool.pro index 9355e0b..a03b84c 100644 --- a/app/HGProductionTool/HGProductionTool.pro +++ b/app/HGProductionTool/HGProductionTool.pro @@ -62,6 +62,7 @@ SOURCES += \ dialog_accountmanage.cpp \ dialog_changepwd.cpp \ dialog_excepdesc.cpp \ + dialog_hgmessagebox.cpp \ dialog_inputserialnum.cpp \ dialog_login.cpp \ dialog_rootfuntion.cpp \ @@ -84,6 +85,7 @@ HEADERS += \ dialog_accountmanage.h \ dialog_changepwd.h \ dialog_excepdesc.h \ + dialog_hgmessagebox.h \ dialog_inputserialnum.h \ dialog_login.h \ dialog_rootfuntion.h \ @@ -101,6 +103,7 @@ FORMS += \ dialog_accountmanage.ui \ dialog_changepwd.ui \ dialog_excepdesc.ui \ + dialog_hgmessagebox.ui \ dialog_inputserialnum.ui \ dialog_login.ui \ dialog_rootfuntion.ui \ diff --git a/app/HGProductionTool/ProductionTool_zh_CN.qm b/app/HGProductionTool/ProductionTool_zh_CN.qm index 7c33111..595235a 100644 Binary files a/app/HGProductionTool/ProductionTool_zh_CN.qm and b/app/HGProductionTool/ProductionTool_zh_CN.qm differ diff --git a/app/HGProductionTool/ProductionTool_zh_CN.ts b/app/HGProductionTool/ProductionTool_zh_CN.ts index 154911b..20b35d4 100644 --- a/app/HGProductionTool/ProductionTool_zh_CN.ts +++ b/app/HGProductionTool/ProductionTool_zh_CN.ts @@ -29,6 +29,29 @@ 请输入异常说明: + + Dialog_HGMessageBox + + + Dialog + 警告 + + + + TextLabel + 警告 + + + + OK + 确定 + + + + Cancel + 取消 + + Dialog_InputSerialNum @@ -939,7 +962,7 @@ 刷新设备列表 - + Account login elsewhere 账户在其他地方登录 @@ -948,63 +971,62 @@ 网络连接断开 - + You have been forced offline by the administrator account 你已被管理员账户强制下线 - + Data base error 数据库错误 - - - - - - - - - - + + + + + + + + + + tips 提示 - + production tool-burn station 华高生产工具-烧录工位 - + production tool-init test station 华高生产工具-初检工位 - + production tool-image test station 华高生产工具-图像测试工位 - + production tool-pressure test station 华高生产工具-压力测试工位 - - - + + + Is testing, do not close! 测试中,请勿关闭! - warning - 警告 + 警告 - + Confirm whether the device is reset Are you sure to connect the new device 检测到设备,请先确认是否已经复位,否则有可能导致获取序列号失败! @@ -1014,14 +1036,13 @@ 确定 - no - 取消 + 取消 - - - + + + cannot create more table 不能创建更多项目 @@ -1030,57 +1051,56 @@ 设备已断开连接 - confirm - 已复位 + 已复位 - + Open device failed 打开设备失败 - + save 保存 - + xls(*.xls) xls表格(*.xls) - + export succeed 导出成功 - + export failed 导出失败 - + Illegal user 非法的用户 - + Wrong password 密码错误 - + Database error 数据库错误 - + connect error 连接错误 - + Failed 错误 diff --git a/app/HGProductionTool/dialog_hgmessagebox.cpp b/app/HGProductionTool/dialog_hgmessagebox.cpp new file mode 100644 index 0000000..4ff5046 --- /dev/null +++ b/app/HGProductionTool/dialog_hgmessagebox.cpp @@ -0,0 +1,34 @@ +#include "dialog_hgmessagebox.h" +#include "ui_dialog_hgmessagebox.h" + +Dialog_HGMessageBox::Dialog_HGMessageBox(const QString &text, QWidget *parent) : + QDialog(parent), + ui(new Ui::Dialog_HGMessageBox) +{ + ui->setupUi(this); + + setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); + + QFont ft; + ft.setPointSize(15); + ft.setBold(true); + ui->label->setFont(ft); + + ui->label->setText(text); + ui->label->setStyleSheet("color:red;"); +} + +Dialog_HGMessageBox::~Dialog_HGMessageBox() +{ + delete ui; +} + +void Dialog_HGMessageBox::on_pbtn_ok_clicked() +{ + accept(); +} + +void Dialog_HGMessageBox::on_pbtn_cancel_clicked() +{ + reject(); +} diff --git a/app/HGProductionTool/dialog_hgmessagebox.h b/app/HGProductionTool/dialog_hgmessagebox.h new file mode 100644 index 0000000..997a586 --- /dev/null +++ b/app/HGProductionTool/dialog_hgmessagebox.h @@ -0,0 +1,27 @@ +#ifndef DIALOG_HGMESSAGEBOX_H +#define DIALOG_HGMESSAGEBOX_H + +#include + +namespace Ui { +class Dialog_HGMessageBox; +} + +class Dialog_HGMessageBox : public QDialog +{ + Q_OBJECT + +public: + explicit Dialog_HGMessageBox(const QString &text, QWidget *parent = nullptr); + ~Dialog_HGMessageBox(); + +private slots: + void on_pbtn_ok_clicked(); + + void on_pbtn_cancel_clicked(); + +private: + Ui::Dialog_HGMessageBox *ui; +}; + +#endif // DIALOG_HGMESSAGEBOX_H diff --git a/app/HGProductionTool/dialog_hgmessagebox.ui b/app/HGProductionTool/dialog_hgmessagebox.ui new file mode 100644 index 0000000..0c99200 --- /dev/null +++ b/app/HGProductionTool/dialog_hgmessagebox.ui @@ -0,0 +1,127 @@ + + + Dialog_HGMessageBox + + + + 0 + 0 + 462 + 168 + + + + Dialog + + + + + + Qt::Vertical + + + + 20 + 52 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + TextLabel + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 51 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 30 + + + + OK + + + + + + + + 0 + 30 + + + + Cancel + + + + + + + + + + diff --git a/app/HGProductionTool/mainwindow.cpp b/app/HGProductionTool/mainwindow.cpp index 525ac9e..60faf07 100644 --- a/app/HGProductionTool/mainwindow.cpp +++ b/app/HGProductionTool/mainwindow.cpp @@ -9,6 +9,7 @@ #include "dialog_accountmanage.h" #include "dialog_uploadcfgfile.h" #include "dialog_inputserialnum.h" +#include "dialog_hgmessagebox.h" MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, Dialog_logIn::LogInType loginType, const QString &ftpHost, unsigned short ftpPort, QWidget *parent) : QMainWindow(parent) @@ -319,7 +320,6 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne { SANE_Device_Ex* sane_dev = (SANE_Device_Ex*)data; - Sleep(5000); emit p->sane_dev_arrive(sane_dev->name); } else if (SANE_EVENT_DEVICE_LEFT == code) @@ -406,6 +406,14 @@ QString MainWindow::getDevFwNum(SANE_Handle handle) void MainWindow::on_sane_dev_arrive(QString devName) { + ui->act_refreshDevice->setEnabled(false); + QTime curTimer = QTime::currentTime().addMSecs(5000); + while (QTime::currentTime() < curTimer) + { + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); + } + ui->act_refreshDevice->setEnabled(true); + if (m_loginType == Dialog_logIn::LogInType_Burn) { SANE_Handle devHandle = nullptr; @@ -415,48 +423,48 @@ void MainWindow::on_sane_dev_arrive(QString devName) DeviceManager *devManager = new DeviceManager(this, m_formBurnMode, devHandle, devName); m_formBurnMode->addDevice(devManager); } + + return; } - else + + QString str = tr("Confirm whether the device is reset"); + Dialog_HGMessageBox dlg(str, this); + if (!dlg.exec()) { - QMessageBox msg(QMessageBox::Warning, tr("warning"), - tr("Confirm whether the device is reset"), - QMessageBox::Yes | QMessageBox::No, this); - msg.setButtonText(QMessageBox::Yes, tr("confirm")); - msg.setButtonText(QMessageBox::No, tr("no")); - msg.exec(); - if (msg.clickedButton() == msg.button(QMessageBox::Yes)) - { - SANE_Handle devHandle = nullptr; - sane_open(devName.toStdString().c_str(), &devHandle); - if (nullptr != devHandle) - { - m_inputSnDlg = new Dialog_InputSerialNum(this, devName, m_pdtToolDbuserMgr, devHandle, getDevSn(devHandle), getDevType(devHandle)); - if (m_inputSnDlg->exec()) - { - HGPdtToolDbDevice pdtToolDbDevice = nullptr; - HGPdtToolDb_OpenDevice(m_pdtToolDbuserMgr, m_inputSnDlg->GetSn().toStdString().c_str(), &pdtToolDbDevice); + return; + } - Form_mainInterface *mainInterface = new Form_mainInterface(this, m_loginType, devHandle, m_pdtToolDbuserMgr, pdtToolDbDevice, - m_inputSnDlg->GetSn(), m_inputSnDlg->GetDevType(), devName, getDevFwNum(devHandle)); - if (!AddInterface(mainInterface)) - { - QMessageBox::information(this, tr("tips"), tr("cannot create more table")); - delete mainInterface; - } - } - else - { - sane_close(devHandle); - } + SANE_Handle devHandle = nullptr; + sane_open(devName.toStdString().c_str(), &devHandle); - delete m_inputSnDlg; - m_inputSnDlg = nullptr; - } - else - { - QMessageBox::information(this, tr("tips"), tr("Open device failed")); - } - } + if (nullptr == devHandle) + { + QMessageBox::information(this, tr("tips"), tr("Open device failed")); + return; + } + + m_inputSnDlg = new Dialog_InputSerialNum(this, devName, m_pdtToolDbuserMgr, devHandle, getDevSn(devHandle), getDevType(devHandle)); + if (!m_inputSnDlg->exec()) + { + sane_close(devHandle); + return ; + } + + HGPdtToolDbDevice pdtToolDbDevice = nullptr; + HGPdtToolDb_OpenDevice(m_pdtToolDbuserMgr, m_inputSnDlg->GetSn().toStdString().c_str(), &pdtToolDbDevice); + + Form_mainInterface *mainInterface = new Form_mainInterface(this, m_loginType, devHandle, m_pdtToolDbuserMgr, pdtToolDbDevice, + m_inputSnDlg->GetSn(), m_inputSnDlg->GetDevType(), devName, getDevFwNum(devHandle)); + if (!AddInterface(mainInterface)) + { + QMessageBox::information(this, tr("tips"), tr("cannot create more table")); + delete mainInterface; + } + + if (m_inputSnDlg != nullptr) + { + delete m_inputSnDlg; + m_inputSnDlg = nullptr; } }