From 07dc440e67ce96233a55ed04596e95e2d367e310 Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Thu, 22 Dec 2022 10:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=95=8C=E9=9D=A2=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/HGProductionTool/ProductionTool_zh_CN.qm | Bin 6631 -> 6771 bytes app/HGProductionTool/ProductionTool_zh_CN.ts | 68 +++--- app/HGProductionTool/dialog_inputserialnum.ui | 231 +++++++++++------- app/HGProductionTool/dialog_login.cpp | 17 +- app/HGProductionTool/dialog_login.h | 6 +- app/HGProductionTool/form_maininterface.cpp | 8 +- app/HGProductionTool/main.cpp | 6 +- app/HGProductionTool/mainwindow.cpp | 75 +++--- app/HGProductionTool/mainwindow.h | 12 +- 9 files changed, 250 insertions(+), 173 deletions(-) diff --git a/app/HGProductionTool/ProductionTool_zh_CN.qm b/app/HGProductionTool/ProductionTool_zh_CN.qm index c153507b25b92b5d6e5600931bfe9834b88ea6ed..0060dc4690347bef1ca9f0a67f414a6646a16c8a 100644 GIT binary patch delta 504 zcmaEE{MlrJ2xG)VQ8gtobq0o@K^ZK8Mg^wXF1t==ZevHG5 zfq_wt{kUlf0|P%Fhkbu5&{;bs$1=$Yi5PJ;-7jEZVDaZ#e6*B-L5N{;FOz!xEbfqN zTNoHPE4hzWeE>S>KliECK&zSWa-Z4@6c_H}VOwnqwB#iZ=aof3OJ?!}{s8iMKl1d* zbulooU*$DB`~+yK5N}j;5zy3R-o&{oK>h;Wv=cyi{v*6SuULR|EARhCSD^kNJ|@do zKu1pHO9knltj(+_I*WgjQVq}zJNZwG1_8~Ooyou;J~^IGZgV~JYJMdi1_cI%xc(sV z;P3yXI2eF{4TyOZ6oONWG81$BN^>V0h{!5%b?=L05AQ}*}6o6Kg__u`W!-w#ZQb?W8yzD zu~kor|1$&2wO$4WK`{naw`QQ)5C+yx2O#~NfqlkN1_sd!6R(;viGH8V%V;MgbeHk@ zhYdi3EE%8w3t?aoZkim+sLol>e7iWEfk9}?~c<>9=t2 z8n%G9=M@VB1Ai;;|3+7!vTKudnf1lw_$MjV01e&Ae_AvM=t=oZ1_rU#$pw6}oBNqp L^KafJyq66C)^lj= diff --git a/app/HGProductionTool/ProductionTool_zh_CN.ts b/app/HGProductionTool/ProductionTool_zh_CN.ts index 24e287f..339cfda 100644 --- a/app/HGProductionTool/ProductionTool_zh_CN.ts +++ b/app/HGProductionTool/ProductionTool_zh_CN.ts @@ -9,42 +9,42 @@ 输入序列号 - + Input SN: 输入序列号: - + Select devType: 设备型号: - + G100 - + G200 - + G300 - + G400 - + OK 确定 - + Cancel 取消 @@ -253,12 +253,12 @@ 登录 - + tips 提示 - + Login failed: 登录失败: @@ -423,6 +423,16 @@ Next Step 下一步 + + + Device type: + 设备型号: + + + + SerialNum: + 序列号: + Form_textTips @@ -485,7 +495,7 @@ 上传配置文件 - + Account login elsewhere 账户在其他地方登录 @@ -494,76 +504,76 @@ 网络连接断开 - + 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.ui b/app/HGProductionTool/dialog_inputserialnum.ui index 2d4b7c5..eb84de9 100644 --- a/app/HGProductionTool/dialog_inputserialnum.ui +++ b/app/HGProductionTool/dialog_inputserialnum.ui @@ -6,105 +6,160 @@ 0 0 - 400 - 225 + 413 + 175 Dialog - - - - 50 - 50 - 54 - 12 - - - - Input SN: - - - - - - 120 - 50 - 171 - 20 - - - - - - - 30 - 110 - 81 - 16 - - - - Select devType: - - - - - - 120 - 110 - 171 - 22 - - + - - G100 - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Input SN: + + + + + + + + 130 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - G200 - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Select devType: + + + + + + + + 130 + 0 + + + + + G100 + + + + + G200 + + + + + G300 + + + + + G400 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - G300 - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + - - - G400 - - - - - - - 197 - 181 - 75 - 23 - - - - OK - - - - - - 278 - 181 - 75 - 23 - - - - Cancel - - + diff --git a/app/HGProductionTool/dialog_login.cpp b/app/HGProductionTool/dialog_login.cpp index f4b807a..99b173c 100644 --- a/app/HGProductionTool/dialog_login.cpp +++ b/app/HGProductionTool/dialog_login.cpp @@ -3,10 +3,10 @@ #include #include "mainwindow.h" -Dialog_logIn::Dialog_logIn(class MainWindow *mainwindow) : - QDialog(nullptr), +Dialog_logIn::Dialog_logIn(QWidget *parent) : + QDialog(parent), ui(new Ui::Dialog_logIn) - , m_mainwindow(mainwindow) + , m_pdtToolDbuserMgr(nullptr) { ui->setupUi(this); @@ -36,6 +36,11 @@ Dialog_logIn::~Dialog_logIn() delete ui; } +HGPdtToolDbUserMgr Dialog_logIn::GetUserMgr() +{ + return m_pdtToolDbuserMgr; +} + void Dialog_logIn::mousePressEvent(QMouseEvent *event) { if(event->button()==Qt::LeftButton) @@ -69,10 +74,12 @@ void Dialog_logIn::on_pbtn_login_clicked() QString host = ui->lineEdit_host->text(); QString port = ui->lineEdit_port->text(); + HGPdtToolDbUserMgr pdtToolDbuserMgr = nullptr; HGResult ret = HGPdtToolDb_CreateUserMgr(host.toStdString().c_str(), port.toInt(), account.toStdString().c_str(), password.toStdString().c_str(), - MainWindow::PdtToolDbUserEventFunc, m_mainwindow, &m_mainwindow->m_pdtToolDbuserMgr); - if (NULL != m_mainwindow->m_pdtToolDbuserMgr) + &pdtToolDbuserMgr); + if (NULL != pdtToolDbuserMgr) { + m_pdtToolDbuserMgr = pdtToolDbuserMgr; accept(); } else diff --git a/app/HGProductionTool/dialog_login.h b/app/HGProductionTool/dialog_login.h index 923d8f1..84cddb2 100644 --- a/app/HGProductionTool/dialog_login.h +++ b/app/HGProductionTool/dialog_login.h @@ -13,9 +13,11 @@ class Dialog_logIn : public QDialog Q_OBJECT public: - explicit Dialog_logIn(class MainWindow *mainwindow); + explicit Dialog_logIn(QWidget *parent = nullptr); ~Dialog_logIn(); + HGPdtToolDbUserMgr GetUserMgr(); + void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); @@ -33,8 +35,8 @@ private slots: private: Ui::Dialog_logIn *ui; - class MainWindow *m_mainwindow; + HGPdtToolDbUserMgr m_pdtToolDbuserMgr; QPoint m_startPos; QPoint m_endPos; bool m_leftMousePressed; diff --git a/app/HGProductionTool/form_maininterface.cpp b/app/HGProductionTool/form_maininterface.cpp index a209302..cf529ad 100644 --- a/app/HGProductionTool/form_maininterface.cpp +++ b/app/HGProductionTool/form_maininterface.cpp @@ -24,7 +24,7 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle ha { ui->setupUi(this); - ui->label_sn->setText(serialNum); + ui->label_sn->setText(tr("Device type:") + m_devType + tr(" SerialNum:") + m_serialNum); this->setMinimumWidth(400); m_textTips = new Form_textTips(); m_view = new HGImgView(); @@ -116,8 +116,8 @@ void Form_mainInterface::downloadCfgFile() strcat(cfgPath, ".json"); HGResult ret = HGPdtToolDb_DownloadFile(m_pdtToolDbuserMgr, m_devType.toStdString().c_str(), cfgPath); -// if(ret == HGBASE_ERR_OK) -// { + if(ret == HGBASE_ERR_OK) + { AnalysisJson analysisJson(QString::fromStdString(cfgPath)); std::vector list_jsonNode = analysisJson.GetNode(); @@ -127,7 +127,7 @@ void Form_mainInterface::downloadCfgFile() ui->listWidget->addItem(node.title); m_map_title_name.insert(node.title, node); } -// } + } } void Form_mainInterface::on_pbtn_stop_clicked() diff --git a/app/HGProductionTool/main.cpp b/app/HGProductionTool/main.cpp index 51c5138..69716f1 100644 --- a/app/HGProductionTool/main.cpp +++ b/app/HGProductionTool/main.cpp @@ -15,15 +15,13 @@ int main(int argc, char *argv[]) while (1) { - MainWindow w; - - Dialog_logIn login(&w); + Dialog_logIn login; if (login.exec()) { + MainWindow w(login.GetUserMgr()); w.showMaximized(); w.Init(); a.exec(); - w.Deinit(); if (w.isExitApp()) { break; diff --git a/app/HGProductionTool/mainwindow.cpp b/app/HGProductionTool/mainwindow.cpp index 894912b..71167f6 100644 --- a/app/HGProductionTool/mainwindow.cpp +++ b/app/HGProductionTool/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" #include +#include #include "base/HGBase.h" #include "HGUIGlobal.h" #include "dialog_login.h" @@ -9,10 +10,10 @@ #include "dialog_uploadcfgfile.h" #include "dialog_inputserialnum.h" -MainWindow::MainWindow(QWidget *parent) +MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) - , m_pdtToolDbuserMgr(nullptr) + , m_pdtToolDbuserMgr(pdtToolDbuserMgr) , m_top_splitter(nullptr) , m_bot_splitter(nullptr) , m_isLogOut(false) @@ -33,16 +34,11 @@ MainWindow::MainWindow(QWidget *parent) vLayout->setStretch(0, 0); vLayout->setStretch(1, 0); this->centralWidget()->setLayout(vLayout); -} -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::Init() -{ - assert(nullptr != m_pdtToolDbuserMgr); + // todo 创建定时器 + QTimer *timer = new QTimer(this); + timer->start(1000); + connect(timer, SIGNAL(timeout()), this, SLOT(on_update_userStatus())); HGUInt userType = 0; HGPdtToolDb_GetUserType(m_pdtToolDbuserMgr, &userType); @@ -55,17 +51,34 @@ void MainWindow::Init() HGChar userName[128]; HGPdtToolDb_GetUserName(m_pdtToolDbuserMgr, userName, 128); setWindowTitle(userName); - - SANE_Int v = 0; - sane_init_ex(&v, sane_ex_callback, this); } -void MainWindow::Deinit() +MainWindow::~MainWindow() { + for (int i = 0; i < m_top_splitter->count(); ++i) + { + Form_mainInterface *interface = (Form_mainInterface *)m_top_splitter->widget(i); + delete interface; + } + + for (int i = 0; i < m_bot_splitter->count(); ++i) + { + Form_mainInterface *interface = (Form_mainInterface *)m_bot_splitter->widget(i); + delete interface; + } + //sane_exit(); HGPdtToolDb_DestroyUserMgr(m_pdtToolDbuserMgr); m_pdtToolDbuserMgr = NULL; + + delete ui; +} + +void MainWindow::Init() +{ + SANE_Int v = 0; + sane_init_ex(&v, sane_ex_callback, this); } bool MainWindow::isExitApp() @@ -148,16 +161,6 @@ bool MainWindow::RemoveInterface(Form_mainInterface *interface) return true; } -void HGAPI MainWindow::PdtToolDbUserEventFunc(HGPdtToolDbUserMgr userMgr, HGUInt event, HGPointer param) -{ - MainWindow *p = (MainWindow *)param; - - if (0 != event) - { - emit p->user_event(event); - } -} - int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int *len, void *param) { (void)hdev; @@ -270,28 +273,34 @@ void MainWindow::on_sane_dev_remove(QString devName) } -void MainWindow::on_user_event(int event) +void MainWindow::on_update_userStatus() { QString tips; - switch (event) + HGUInt userStatus; + HGPdtToolDb_GetUserStatus(m_pdtToolDbuserMgr, &userStatus); + + switch (userStatus) { - case HGPDTTOOLDB_USEREVENT_CONFLICT: + case HGPDTTOOLDB_USERSTATUS_CONFLICT: tips = tr("Account login elsewhere"); break; - case HGPDTTOOLDB_USEREVENT_REFUSE: + case HGPDTTOOLDB_USERSTATUS_REFUSE: tips = tr("You have been forced offline by the administrator account"); break; - case HGPDTTOOLDB_USEREVENT_DBERROR: + case HGPDTTOOLDB_USERSTATUS_DBERROR: tips = tr("Data base error"); break; default: break; } - QMessageBox::information(this, (tr("tips")), tips); + if (!tips.isEmpty()) + { + QMessageBox::information(this, (tr("tips")), tips); + m_isLogOut = true; + close(); + } - m_isLogOut = true; - close(); } void MainWindow::on_act_newDevice_triggered() diff --git a/app/HGProductionTool/mainwindow.h b/app/HGProductionTool/mainwindow.h index 345f952..967e0c1 100644 --- a/app/HGProductionTool/mainwindow.h +++ b/app/HGProductionTool/mainwindow.h @@ -14,17 +14,13 @@ namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow -{ - friend class Dialog_logIn; - +{ Q_OBJECT public: - MainWindow(QWidget *parent = nullptr); + MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, QWidget *parent = nullptr); ~MainWindow(); - hgscanner* hg; void Init(); - void Deinit(); static QString getLogInfo(HGResult ret); bool isExitApp(); @@ -34,7 +30,6 @@ public: 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(); @@ -49,7 +44,7 @@ signals: private slots: void on_sane_dev_arrive(QString devName); void on_sane_dev_remove(QString devName); - void on_user_event(int event); + void on_update_userStatus(); private slots: void on_act_newDevice_triggered(); @@ -75,5 +70,6 @@ private: private: Ui::MainWindow *ui; HGPdtToolDbUserMgr m_pdtToolDbuserMgr; + hgscanner* hg; }; #endif // MAINWINDOW_H