diff --git a/app/HGProductionTool/HGProductionTool.pro b/app/HGProductionTool/HGProductionTool.pro index 1d90fc2..22569d0 100644 --- a/app/HGProductionTool/HGProductionTool.pro +++ b/app/HGProductionTool/HGProductionTool.pro @@ -57,6 +57,7 @@ SOURCES += \ analysisjson.cpp \ dialog_accountmanage.cpp \ dialog_changepwd.cpp \ + dialog_inputserialnum.cpp \ dialog_login.cpp \ dialog_rootfuntion.cpp \ dialog_uploadcfgfile.cpp \ @@ -73,6 +74,7 @@ HEADERS += \ analysisjson.h \ dialog_accountmanage.h \ dialog_changepwd.h \ + dialog_inputserialnum.h \ dialog_login.h \ dialog_rootfuntion.h \ dialog_uploadcfgfile.h \ @@ -85,6 +87,7 @@ HEADERS += \ FORMS += \ dialog_accountmanage.ui \ dialog_changepwd.ui \ + dialog_inputserialnum.ui \ dialog_login.ui \ dialog_rootfuntion.ui \ dialog_uploadcfgfile.ui \ diff --git a/app/HGProductionTool/ProductionTool_zh_CN.qm b/app/HGProductionTool/ProductionTool_zh_CN.qm index 810ad31..c153507 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 b565de6..24e287f 100644 --- a/app/HGProductionTool/ProductionTool_zh_CN.ts +++ b/app/HGProductionTool/ProductionTool_zh_CN.ts @@ -1,6 +1,70 @@ + + Dialog_InputSerialNum + + + Dialog + 输入序列号 + + + + Input SN: + 输入序列号: + + + + Select devType: + 设备型号: + + + + G100 + + + + + G200 + + + + + G300 + + + + + G400 + + + + + OK + 确定 + + + + Cancel + 取消 + + + + + tips + 提示 + + + + Serial num is empty + 序列号为空 + + + + The device is testing + 该设备正在进行测试 + + Dialog_accountManage @@ -262,10 +326,30 @@ tag: - 标识符: + 设备型号: - + + G100 + + + + + G200 + + + + + G300 + + + + + G400 + + + + upload 上传 @@ -339,16 +423,6 @@ Next Step 下一步 - - - HGPDTTOOLDB_TITLE_DIAL_SWITCH - - - - - HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE - - Form_textTips @@ -411,53 +485,85 @@ 上传配置文件 - + Account login elsewhere 账户在其他地方登录 - Network connection lost - 网络连接断开 + 网络连接断开 - + You have been forced offline by the administrator account 你已被管理员账户强制下线 - - + + Data base error + 数据库错误 + + + + + + tips 提示 - + + Are you sure to connect the new device + 检测到设备连接,是否启动测试? + + + + yes + 确定 + + + + no + 取消 + + + + cannot create more table 不能创建更多项目 - + + save + 保存 + + + + xls(*.xls) + xls表格(*.xls) + + + Illegal user 非法的用户 - + Wrong password 密码错误 - + Database error 数据库错误 - + connect error 连接错误 - + Failed 错误 diff --git a/app/HGProductionTool/dialog_inputserialnum.cpp b/app/HGProductionTool/dialog_inputserialnum.cpp new file mode 100644 index 0000000..8c30ce3 --- /dev/null +++ b/app/HGProductionTool/dialog_inputserialnum.cpp @@ -0,0 +1,58 @@ +#include "dialog_inputserialnum.h" +#include "ui_dialog_inputserialnum.h" +#include "mainwindow.h" + +Dialog_InputSerialNum::Dialog_InputSerialNum(class MainWindow *mainWnd, const QString &serialNum, const QString &devType) : + QDialog(mainWnd), + ui(new Ui::Dialog_InputSerialNum), + m_mainWnd(mainWnd), + m_serialNum(serialNum), + m_devType(devType) +{ + ui->setupUi(this); + + setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); + + ui->lineEdit_sn->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$"))); + ui->lineEdit_sn->setText(serialNum); + if (devType.isEmpty()) + ui->cbox_devType->setCurrentIndex(0); + else + ui->cbox_devType->setCurrentText(devType); +} + +Dialog_InputSerialNum::~Dialog_InputSerialNum() +{ + delete ui; +} + +QString Dialog_InputSerialNum::GetSn() +{ + return ui->lineEdit_sn->text(); +} + +QString Dialog_InputSerialNum::GetDevType() +{ + return ui->cbox_devType->currentText(); +} + +void Dialog_InputSerialNum::on_pbtn_ok_clicked() +{ + if (ui->lineEdit_sn->text().isEmpty()) + { + QMessageBox::information(this, tr("tips"), tr("Serial num is empty")); + return; + } + + if (m_mainWnd->FindInterface(ui->lineEdit_sn->text()) != nullptr) + { + QMessageBox::information(this, tr("tips"), tr("The device is testing")); + return; + } + accept(); +} + +void Dialog_InputSerialNum::on_pbtn_cancel_clicked() +{ + reject(); +} diff --git a/app/HGProductionTool/dialog_inputserialnum.h b/app/HGProductionTool/dialog_inputserialnum.h new file mode 100644 index 0000000..bc8f5a7 --- /dev/null +++ b/app/HGProductionTool/dialog_inputserialnum.h @@ -0,0 +1,34 @@ +#ifndef DIALOG_INPUTSERIALNUM_H +#define DIALOG_INPUTSERIALNUM_H + +#include + +namespace Ui { +class Dialog_InputSerialNum; +} + +class Dialog_InputSerialNum : public QDialog +{ + Q_OBJECT + +public: + explicit Dialog_InputSerialNum(class MainWindow *mainWnd, const QString &serialNum, const QString &devType); + ~Dialog_InputSerialNum(); + + QString GetSn(); + QString GetDevType(); + +private slots: + void on_pbtn_ok_clicked(); + + void on_pbtn_cancel_clicked(); + +private: + Ui::Dialog_InputSerialNum *ui; + + class MainWindow *m_mainWnd; + QString m_serialNum; + QString m_devType; +}; + +#endif // DIALOG_INPUTSERIALNUM_H diff --git a/app/HGProductionTool/dialog_inputserialnum.ui b/app/HGProductionTool/dialog_inputserialnum.ui new file mode 100644 index 0000000..2d4b7c5 --- /dev/null +++ b/app/HGProductionTool/dialog_inputserialnum.ui @@ -0,0 +1,111 @@ + + + Dialog_InputSerialNum + + + + 0 + 0 + 400 + 225 + + + + Dialog + + + + + 50 + 50 + 54 + 12 + + + + Input SN: + + + + + + 120 + 50 + 171 + 20 + + + + + + + 30 + 110 + 81 + 16 + + + + Select devType: + + + + + + 120 + 110 + 171 + 22 + + + + + G100 + + + + + G200 + + + + + G300 + + + + + G400 + + + + + + + 197 + 181 + 75 + 23 + + + + OK + + + + + + 278 + 181 + 75 + 23 + + + + Cancel + + + + + + diff --git a/app/HGProductionTool/dialog_uploadcfgfile.cpp b/app/HGProductionTool/dialog_uploadcfgfile.cpp index 03af995..8d88a59 100644 --- a/app/HGProductionTool/dialog_uploadcfgfile.cpp +++ b/app/HGProductionTool/dialog_uploadcfgfile.cpp @@ -26,7 +26,7 @@ void Dialog_uploadCfgFile::on_pbtn_select_clicked() if (!info.absoluteFilePath().isEmpty()) { ui->lineEdit_filename->setText(info.absoluteFilePath()); - ui->lineEdit_tag->setText(info.completeBaseName()); + ui->comboBox_tag->setCurrentText(info.completeBaseName()); } } @@ -38,7 +38,7 @@ void Dialog_uploadCfgFile::on_pbtn_upload_clicked() return; } - QString tag = ui->lineEdit_tag->text(); + QString tag = ui->comboBox_tag->currentText(); QString filename = ui->lineEdit_filename->text(); HGResult ret = HGPdtToolDb_UploadFile(m_pdtToolDbuserMgr, tag.toStdString().c_str(), getStdString(filename).c_str()); if(ret == HGBASE_ERR_OK) diff --git a/app/HGProductionTool/dialog_uploadcfgfile.ui b/app/HGProductionTool/dialog_uploadcfgfile.ui index da7cbc8..02225d1 100644 --- a/app/HGProductionTool/dialog_uploadcfgfile.ui +++ b/app/HGProductionTool/dialog_uploadcfgfile.ui @@ -45,7 +45,28 @@ - + + + + G100 + + + + + G200 + + + + + G300 + + + + + G400 + + + diff --git a/app/HGProductionTool/form_maininterface.cpp b/app/HGProductionTool/form_maininterface.cpp index 368cc7c..5ed46b6 100644 --- a/app/HGProductionTool/form_maininterface.cpp +++ b/app/HGProductionTool/form_maininterface.cpp @@ -1,43 +1,57 @@ #include "form_maininterface.h" #include "ui_form_maininterface.h" #include +#include +#include +#include "base/HGBase.h" #include "imgfmt/HGImgFmt.h" #include "HGUIGlobal.h" #include "form_texttips.h" #include "test_base.h" +#include "hgscanner.h" +#include "mainwindow.h" -Form_mainInterface::Form_mainInterface(QWidget *parent) - : QWidget(parent) +Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle handle, HGPdtToolDbDevice pdtToolDbDevice, + const QString &serialNum, const QString &devType) + : QWidget(mainwnd) , ui(new Ui::Form_mainInterface) + , m_mainwnd(mainwnd) + , m_handle(handle) + , m_pdtToolDbDevice(pdtToolDbDevice) + , m_serialNum(serialNum) + , m_devType(devType) { ui->setupUi(this); + ui->label_sn->setText(serialNum); + this->setMinimumWidth(400); m_textTips = new Form_textTips(); m_view = new HGImgView(); ui->stackedWidget->addWidget(m_textTips); ui->stackedWidget->addWidget(m_view); - QString path("../../doc/config.json"); - AnalysisJson analysisJson(path); + getTestItem(); - std::vector list_jsonNode = analysisJson.GetNode(); - for(int i = 0; i < list_jsonNode.size(); ++i) - { - AnalysisJson::json_node node = list_jsonNode[i]; - ui->listWidget->addItem(node.title); - } - - this->setMinimumWidth(400); ui->listWidget->setMinimumWidth(200); ui->listWidget->setCurrentRow(0); ui->pbtn_preStep->setEnabled(false); + + // TODO download file } Form_mainInterface::~Form_mainInterface() { + //sane_close(m_handle); + HGPdtToolDb_CloseDevice(m_pdtToolDbDevice); + delete ui; } +QString Form_mainInterface::getSn() +{ + return m_serialNum; +} + void Form_mainInterface::paintEvent(QPaintEvent *event) { (void)event; @@ -46,30 +60,31 @@ void Form_mainInterface::paintEvent(QPaintEvent *event) p.drawRect(0, 0, width() -1, height() -1); } -void Form_mainInterface::on_listWidget_currentRowChanged(int currentRow) +void Form_mainInterface::on_listWidget_currentTextChanged(const QString ¤tText) { - (void)currentRow; ui->pbtn_preStep->setEnabled(ui->listWidget->currentRow() != 0); ui->pbtn_nextStep->setEnabled(ui->listWidget->currentRow() != ui->listWidget->count() - 1); - - QString curItemContent = ui->listWidget->currentItem()->text(); - - if (curItemContent == HGPDTTOOLDB_TITLE_DIAL_SWITCH) + QString testName; + if (currentText == HGPDTTOOLDB_TITLE_DIAL_SWITCH) { - m_textTips->setViewContent(tr("HGPDTTOOLDB_TITLE_DIAL_SWITCH")); + m_textTips->setViewContent(m_map_title_name.value(currentText).desc); + testName = m_map_title_name.value(currentText).name; ui->stackedWidget->setCurrentWidget(m_textTips); } - else if (curItemContent == HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE) - { - m_textTips->setViewContent(tr("HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE")); - ui->stackedWidget->setCurrentWidget(m_textTips); - } - else if (curItemContent == HGPDTTOOLDB_TITLE_IMAGE_QUALITY) + else if (currentText == HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_1) { //addImg + testName = m_map_title_name.value(currentText).name; ui->stackedWidget->setCurrentWidget(m_view); } + + ui_helper* helper; + hgscanner* hg = new hgscanner(m_handle); + helper = dynamic_cast(hg); + + QString s("test-31"); +// func_test_go(s.toStdWString().c_str(), L"null", helper); } void Form_mainInterface::on_pbtn_preStep_clicked() @@ -93,3 +108,21 @@ void Form_mainInterface::on_pbtn_pass_clicked() on_pbtn_nextStep_clicked(); } +void Form_mainInterface::getTestItem() +{ + QString path("../../doc/config.json"); + AnalysisJson analysisJson(path); + + std::vector list_jsonNode = analysisJson.GetNode(); + for(int i = 0; i < list_jsonNode.size(); ++i) + { + AnalysisJson::json_node node = list_jsonNode[i]; + ui->listWidget->addItem(node.title); + m_map_title_name.insert(node.title, node); + } +} + +void Form_mainInterface::on_pbtn_stop_clicked() +{ + m_mainwnd->RemoveInterface(this); +} diff --git a/app/HGProductionTool/form_maininterface.h b/app/HGProductionTool/form_maininterface.h index 9a36546..54c2acb 100644 --- a/app/HGProductionTool/form_maininterface.h +++ b/app/HGProductionTool/form_maininterface.h @@ -2,9 +2,12 @@ #define FORM_MAININTERFACE_H #include +#include #include "HGImgView.h" #include "form_texttips.h" #include "analysisjson.h" +#include "sane/sane_ex.h" +#include "HGPdtToolDb.h" namespace Ui { class Form_mainInterface; @@ -15,14 +18,17 @@ class Form_mainInterface : public QWidget Q_OBJECT public: - explicit Form_mainInterface(QWidget *parent = nullptr); + explicit Form_mainInterface(class MainWindow *mainwnd, SANE_Handle handle, HGPdtToolDbDevice pdtToolDbDevice, + const QString &serialNum, const QString &devType); ~Form_mainInterface(); + QString getSn(); + protected: void paintEvent(QPaintEvent *event) override; private slots: - void on_listWidget_currentRowChanged(int currentRow); + void on_listWidget_currentTextChanged(const QString ¤tText); void on_pbtn_preStep_clicked(); @@ -32,12 +38,25 @@ private slots: void on_pbtn_pass_clicked(); + void on_pbtn_stop_clicked(); + +private: + void getTestItem(); + private: Ui::Form_mainInterface *ui; AnalysisJson *m_analysisJson; Form_textTips *m_textTips; HGImgView *m_view; + + class MainWindow *m_mainwnd; + SANE_Handle m_handle; + HGPdtToolDbDevice m_pdtToolDbDevice; + QString m_serialNum; + QString m_devType; + + QMap m_map_title_name; }; #endif // FORM_MAININTERFACE_H diff --git a/app/HGProductionTool/main.cpp b/app/HGProductionTool/main.cpp index f97d1a2..51c5138 100644 --- a/app/HGProductionTool/main.cpp +++ b/app/HGProductionTool/main.cpp @@ -20,8 +20,8 @@ int main(int argc, char *argv[]) Dialog_logIn login(&w); if (login.exec()) { - w.Init(); w.showMaximized(); + w.Init(); a.exec(); w.Deinit(); if (w.isExitApp()) diff --git a/app/HGProductionTool/mainwindow.cpp b/app/HGProductionTool/mainwindow.cpp index dbf9f3f..850eb91 100644 --- a/app/HGProductionTool/mainwindow.cpp +++ b/app/HGProductionTool/mainwindow.cpp @@ -7,16 +7,14 @@ #include "dialog_changepwd.h" #include "dialog_accountmanage.h" #include "dialog_uploadcfgfile.h" +#include "dialog_inputserialnum.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_pdtToolDbuserMgr(nullptr) - , m_form_mainInterface(nullptr) , m_top_splitter(nullptr) , m_bot_splitter(nullptr) - , m_splitterCount(1) - , m_handle(nullptr) , m_isLogOut(false) { ui->setupUi(this); @@ -28,13 +26,11 @@ MainWindow::MainWindow(QWidget *parent) m_top_splitter = new QSplitter(Qt::Horizontal); m_bot_splitter = new QSplitter(Qt::Horizontal); - m_form_mainInterface = new Form_mainInterface(); - m_top_splitter->addWidget(m_form_mainInterface); QVBoxLayout *vLayout = new QVBoxLayout; vLayout->addWidget(m_top_splitter); vLayout->addWidget(m_bot_splitter); - vLayout->setStretch(0, 1); + vLayout->setStretch(0, 0); vLayout->setStretch(1, 0); this->centralWidget()->setLayout(vLayout); } @@ -59,17 +55,11 @@ void MainWindow::Init() SANE_Int v = 0; sane_init_ex(&v, sane_ex_callback, this); - Sleep(500); } void MainWindow::Deinit() { -// if (nullptr != m_handle) -// { -// sane_close(m_handle); -// m_handle = nullptr; -// } -// sane_exit(); + //sane_exit(); HGPdtToolDb_DestroyUserMgr(m_pdtToolDbuserMgr); m_pdtToolDbuserMgr = NULL; @@ -80,6 +70,81 @@ bool MainWindow::isExitApp() return !m_isLogOut; } +void MainWindow::updateSplitter() +{ + if (0 != m_top_splitter->count() && 0 == m_bot_splitter->count()) + { + reinterpret_cast(this->centralWidget()->layout())->setStretch(0, 1); + reinterpret_cast(this->centralWidget()->layout())->setStretch(1, 0); + } + else if (0 == m_top_splitter->count() && 0 != m_bot_splitter->count()) + { + reinterpret_cast(this->centralWidget()->layout())->setStretch(0, 0); + reinterpret_cast(this->centralWidget()->layout())->setStretch(1, 1); + } + else if (0 != m_top_splitter->count() && 0 != m_bot_splitter->count()) + { + reinterpret_cast(this->centralWidget()->layout())->setStretch(0, 1); + reinterpret_cast(this->centralWidget()->layout())->setStretch(1, 1); + } + else + { + reinterpret_cast(this->centralWidget()->layout())->setStretch(0, 0); + reinterpret_cast(this->centralWidget()->layout())->setStretch(1, 0); + } +} + +Form_mainInterface* MainWindow::FindInterface(const QString &sn) +{ + for (int i = 0; i < m_top_splitter->count(); ++i) + { + Form_mainInterface *interface = (Form_mainInterface *)m_top_splitter->widget(i); + if (sn == interface->getSn()) + { + return interface; + } + } + + for (int i = 0; i < m_bot_splitter->count(); ++i) + { + Form_mainInterface *interface = (Form_mainInterface *)m_bot_splitter->widget(i); + if (sn == interface->getSn()) + { + return interface; + } + } + + return nullptr; +} + +bool MainWindow::AddInterface(Form_mainInterface *interface) +{ + assert(nullptr != interface); + + bool ret = false; + if (m_top_splitter->count() < 2) + { + m_top_splitter->addWidget(interface); + ret = true; + } + else if (m_bot_splitter->count() < 2) + { + m_bot_splitter->addWidget(interface); + ret = true; + } + + updateSplitter(); + return ret; +} + +bool MainWindow::RemoveInterface(Form_mainInterface *interface) +{ + assert(nullptr != interface); + delete interface; + updateSplitter(); + return true; +} + void HGAPI MainWindow::PdtToolDbUserEventFunc(HGPdtToolDbUserMgr userMgr, HGUInt event, HGPointer param) { MainWindow *p = (MainWindow *)param; @@ -138,14 +203,63 @@ std::vector MainWindow::getDevices() return name; } +QString MainWindow::getDevSn(SANE_Handle handle) +{ + std::string serialNum; + unsigned int serialNumLen = 0; + if(SANE_STATUS_NO_MEM == sane_io_control(handle, IO_CTRL_CODE_GET_SERIAL, nullptr, &serialNumLen) && serialNumLen) + { + serialNum.resize(serialNumLen); + sane_io_control(handle, IO_CTRL_CODE_GET_SERIAL, &serialNum[0], &serialNumLen); + } + return QString::fromStdString(serialNum.c_str()); +} + +QString MainWindow::getDevType(SANE_Handle handle) +{ + std::string firmWareNum; + unsigned int firmWareNumLen = 0; + if(SANE_STATUS_NO_MEM == sane_io_control(handle, IO_CTRL_CODE_GET_HARDWARE_VERSION, nullptr, &firmWareNumLen) && firmWareNumLen) + { + firmWareNum.resize(firmWareNumLen); + sane_io_control(handle, IO_CTRL_CODE_GET_HARDWARE_VERSION, &firmWareNum[0], &firmWareNumLen); + } + + QString str = QString::fromStdString(firmWareNum.c_str()); + return str.left(2) + "00"; +} + void MainWindow::on_sane_dev_arrive(QString devName) { - SANE_Status ret = sane_open(devName.toStdString().c_str(), &m_handle); + QMessageBox msg(QMessageBox::Question, tr("tips"), + tr("Are you sure to connect the new device"), + QMessageBox::Yes | QMessageBox::No, this); + msg.setButtonText(QMessageBox::Yes, tr("yes")); + 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); - ui_helper* helper; - this->hg = new hgscanner(m_handle); - helper = dynamic_cast(this->hg); - func_test_go(L"test-31", L"null", helper); + Dialog_InputSerialNum dlg(this, getDevSn(devHandle), getDevType(devHandle)); + if (dlg.exec()) + { + HGPdtToolDbDevice pdtToolDbDevice = nullptr; + HGPdtToolDb_OpenDevice(m_pdtToolDbuserMgr, dlg.GetSn().toStdString().c_str(), &pdtToolDbDevice); + + Form_mainInterface *mainInterface = new Form_mainInterface(this, devHandle, pdtToolDbDevice, dlg.GetSn(), dlg.GetDevType()); + if (!AddInterface(mainInterface)) + { + QMessageBox::information(this, tr("tips"), tr("cannot create more table")); + delete mainInterface; + } + } + else + { +// sane_close(devHandle); + } + } } void MainWindow::on_sane_dev_remove(QString devName) @@ -158,15 +272,15 @@ void MainWindow::on_user_event(int event) QString tips; switch (event) { - case 1: + case HGPDTTOOLDB_USEREVENT_CONFLICT: tips = tr("Account login elsewhere"); break; - case 2: - tips = tr("Network connection lost"); - break; - case 3: + case HGPDTTOOLDB_USEREVENT_REFUSE: tips = tr("You have been forced offline by the administrator account"); break; + case HGPDTTOOLDB_USEREVENT_DBERROR: + tips = tr("Data base error"); + break; default: break; } @@ -179,39 +293,18 @@ void MainWindow::on_user_event(int event) void MainWindow::on_act_newDevice_triggered() { - m_splitterCount++; - switch (m_splitterCount) + Dialog_InputSerialNum dlg(this, "", ""); + if (dlg.exec()) { - case 2: - { - Form_mainInterface *form_mainInterface = new Form_mainInterface(); - m_top_splitter->addWidget(form_mainInterface); + HGPdtToolDbDevice pdtToolDbDevice = nullptr; + HGPdtToolDb_OpenDevice(m_pdtToolDbuserMgr, dlg.GetSn().toStdString().c_str(), &pdtToolDbDevice); - break; - } - - case 3: - { - Form_mainInterface *form_mainInterface = new Form_mainInterface(); - m_bot_splitter->addWidget(form_mainInterface); - reinterpret_cast(this->centralWidget()->layout())->setStretch(1, 1); - break; - } - - case 4: - { - Form_mainInterface *form_mainInterface = new Form_mainInterface(); - m_bot_splitter->addWidget(form_mainInterface); - break; - } - - case 5: - QMessageBox::information(this, tr("tips"), tr("cannot create more table")); - return; - break; - - default: - break; + Form_mainInterface *mainInterface = new Form_mainInterface(this, nullptr, pdtToolDbDevice, dlg.GetSn(), dlg.GetDevType()); + if (!AddInterface(mainInterface)) + { + QMessageBox::information(this, tr("tips"), tr("cannot create more table")); + delete mainInterface; + } } } @@ -229,10 +322,11 @@ void MainWindow::on_act_changePwd_triggered() void MainWindow::on_act_export_triggered() { - HGChar cfgPath[256]= {0}; - HGBase_GetConfigPath(cfgPath, 256); - strcat(cfgPath, "1.xls"); - HGPdtToolDb_Export(m_pdtToolDbuserMgr, getStdString(cfgPath).c_str()); + QString filename = QFileDialog::getSaveFileName(this, tr("save"), "test.xls", tr("xls(*.xls)")); + if (!filename.isEmpty()) + { + HGPdtToolDb_Export(m_pdtToolDbuserMgr, getStdString(filename).c_str()); + } } void MainWindow::on_act_logOut_triggered() @@ -274,8 +368,8 @@ QString MainWindow::getLogInfo(HGResult ret) return str; } -//void MainWindow::on_act_upload_triggered() -//{ -// Dialog_uploadCfgFile dlg(m_pdtToolDbuserMgr, this); -// dlg.exec(); -//} +void MainWindow::on_act_upload_triggered() +{ + Dialog_uploadCfgFile dlg(m_pdtToolDbuserMgr, this); + dlg.exec(); +} diff --git a/app/HGProductionTool/mainwindow.h b/app/HGProductionTool/mainwindow.h index 4388fb5..345f952 100644 --- a/app/HGProductionTool/mainwindow.h +++ b/app/HGProductionTool/mainwindow.h @@ -28,12 +28,18 @@ public: static QString getLogInfo(HGResult ret); bool isExitApp(); + void updateSplitter(); + Form_mainInterface* FindInterface(const QString &sn); + bool AddInterface(Form_mainInterface *interface); + bool RemoveInterface(Form_mainInterface *interface); private: static void HGAPI PdtToolDbUserEventFunc(HGPdtToolDbUserMgr userMgr, HGUInt event, HGPointer param); static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param); std::vector getDevices(); + QString getDevSn(SANE_Handle handle); + QString getDevType(SANE_Handle handle); signals: void sane_dev_arrive(QString devName); @@ -58,21 +64,16 @@ private slots: void on_act_close_triggered(); - /* void on_act_upload_triggered();*/ + void on_act_upload_triggered(); private: QSplitter *m_top_splitter; QSplitter *m_bot_splitter; - SANE_Handle m_handle; - int m_splitterCount; bool m_isLogOut; private: Ui::MainWindow *ui; HGPdtToolDbUserMgr m_pdtToolDbuserMgr; - - Form_mainInterface *m_form_mainInterface; - }; #endif // MAINWINDOW_H