增加烧录模式

This commit is contained in:
yangjiaxuan 2023-01-04 14:28:44 +08:00
parent d74ee4a2dd
commit 29753d6a79
18 changed files with 961 additions and 160 deletions

View File

@ -65,8 +65,10 @@ SOURCES += \
dialog_inputserialnum.cpp \
dialog_login.cpp \
dialog_rootfuntion.cpp \
dialog_setburnsn.cpp \
dialog_uploadcfgfile.cpp \
dialog_userinput.cpp \
form_burnmode.cpp \
form_maininterface.cpp \
form_texttips.cpp \
hgscanner.cpp \
@ -85,8 +87,10 @@ HEADERS += \
dialog_inputserialnum.h \
dialog_login.h \
dialog_rootfuntion.h \
dialog_setburnsn.h \
dialog_uploadcfgfile.h \
dialog_userinput.h \
form_burnmode.h \
form_maininterface.h \
form_texttips.h \
hgscanner.h \
@ -100,8 +104,10 @@ FORMS += \
dialog_inputserialnum.ui \
dialog_login.ui \
dialog_rootfuntion.ui \
dialog_setburnsn.ui \
dialog_uploadcfgfile.ui \
dialog_userinput.ui \
form_burnmode.ui \
form_maininterface.ui \
form_texttips.ui \
mainwindow.ui

View File

@ -101,6 +101,29 @@
<translation></translation>
</message>
</context>
<context>
<name>Dialog_SetBurnSn</name>
<message>
<location filename="dialog_setburnsn.ui" line="14"/>
<source>Dialog</source>
<translation></translation>
</message>
<message>
<location filename="dialog_setburnsn.ui" line="26"/>
<source>set sn:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_setburnsn.ui" line="49"/>
<source>OK</source>
<translation></translation>
</message>
<message>
<location filename="dialog_setburnsn.ui" line="62"/>
<source>Cancel</source>
<translation></translation>
</message>
</context>
<context>
<name>Dialog_UserInput</name>
<message>
@ -315,6 +338,26 @@
<source>ftpPort:</source>
<translation>FTP端口</translation>
</message>
<message>
<location filename="dialog_login.ui" line="341"/>
<source>Burn</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.ui" line="357"/>
<source>InitTest</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.ui" line="370"/>
<source>ImageTest</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.ui" line="383"/>
<source>PressureTest</source>
<translation></translation>
</message>
<message>
<source>host:</source>
<translation type="vanished">IP地址</translation>
@ -334,42 +377,42 @@
<translation>退</translation>
</message>
<message>
<location filename="dialog_login.cpp" line="23"/>
<location filename="dialog_login.cpp" line="24"/>
<source>Set host and port</source>
<translation>IP与端口</translation>
</message>
<message>
<location filename="dialog_login.cpp" line="24"/>
<location filename="dialog_login.cpp" line="25"/>
<source>Minimize</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="25"/>
<location filename="dialog_login.cpp" line="26"/>
<source>Close</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="26"/>
<location filename="dialog_login.cpp" line="27"/>
<source>LogIn</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="122"/>
<location filename="dialog_login.cpp" line="137"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="122"/>
<location filename="dialog_login.cpp" line="137"/>
<source>Login failed, sure to enter offline mode?</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="123"/>
<location filename="dialog_login.cpp" line="138"/>
<source>yes</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="124"/>
<location filename="dialog_login.cpp" line="139"/>
<source>no</source>
<translation></translation>
</message>
@ -505,6 +548,65 @@
<translation type="vanished"> </translation>
</message>
</context>
<context>
<name>Form_BurnMode</name>
<message>
<location filename="form_burnmode.ui" line="14"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.ui" line="25"/>
<source>Select All</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.ui" line="38"/>
<source>Burn</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.ui" line="51"/>
<source>Set sn</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.cpp" line="83"/>
<source>ID</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.cpp" line="83"/>
<source>selected</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.cpp" line="83"/>
<source>device</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.cpp" line="83"/>
<source>serialNum</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.cpp" line="147"/>
<location filename="form_burnmode.cpp" line="161"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.cpp" line="147"/>
<source>Please check single devices to set sn</source>
<translation></translation>
</message>
<message>
<location filename="form_burnmode.cpp" line="161"/>
<source>Please check a devices to set sn at least</source>
<translation></translation>
</message>
</context>
<context>
<name>Form_mainInterface</name>
<message>
@ -568,94 +670,94 @@
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="90"/>
<location filename="form_maininterface.cpp" line="47"/>
<source>Device has connected</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="92"/>
<location filename="form_maininterface.cpp" line="51"/>
<source>Device hasnot connected</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="93"/>
<location filename="form_maininterface.cpp" line="52"/>
<source>Device type:</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="93"/>
<location filename="form_maininterface.cpp" line="52"/>
<source> SerialNum:</source>
<translation> </translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="94"/>
<location filename="form_maininterface.cpp" line="158"/>
<location filename="form_maininterface.cpp" line="53"/>
<location filename="form_maininterface.cpp" line="115"/>
<source> connect status:</source>
<translation> </translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="103"/>
<location filename="form_maininterface.cpp" line="62"/>
<source>load last image which uploaded last time</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="157"/>
<location filename="form_maininterface.cpp" line="114"/>
<source>Device has disconnected</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="173"/>
<location filename="form_maininterface.cpp" line="597"/>
<location filename="form_maininterface.cpp" line="130"/>
<location filename="form_maininterface.cpp" line="500"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="200"/>
<location filename="form_maininterface.cpp" line="157"/>
<source>yes</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="201"/>
<location filename="form_maininterface.cpp" line="158"/>
<source>no</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="319"/>
<location filename="form_maininterface.cpp" line="277"/>
<source>ID</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="319"/>
<location filename="form_maininterface.cpp" line="277"/>
<source>Test items</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="319"/>
<location filename="form_maininterface.cpp" line="277"/>
<source>status</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="467"/>
<location filename="form_maininterface.cpp" line="355"/>
<source>not test</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="467"/>
<location filename="form_maininterface.cpp" line="355"/>
<source>not pass</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="467"/>
<location filename="form_maininterface.cpp" line="355"/>
<source>not support</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="467"/>
<location filename="form_maininterface.cpp" line="355"/>
<source>pass</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="597"/>
<location filename="form_maininterface.cpp" line="500"/>
<source>no image</source>
<translation></translation>
</message>
@ -721,7 +823,7 @@
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="427"/>
<location filename="mainwindow.cpp" line="476"/>
<source>Account login elsewhere</source>
<translation></translation>
</message>
@ -730,54 +832,54 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="430"/>
<location filename="mainwindow.cpp" line="479"/>
<source>You have been forced offline by the administrator account</source>
<translation>线</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="433"/>
<location filename="mainwindow.cpp" line="482"/>
<source>Data base error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="272"/>
<location filename="mainwindow.cpp" line="367"/>
<location filename="mainwindow.cpp" line="389"/>
<location filename="mainwindow.cpp" line="400"/>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="461"/>
<location filename="mainwindow.cpp" line="486"/>
<location filename="mainwindow.cpp" line="490"/>
<location filename="mainwindow.cpp" line="499"/>
<location filename="mainwindow.cpp" line="511"/>
<location filename="mainwindow.cpp" line="298"/>
<location filename="mainwindow.cpp" line="408"/>
<location filename="mainwindow.cpp" line="430"/>
<location filename="mainwindow.cpp" line="441"/>
<location filename="mainwindow.cpp" line="492"/>
<location filename="mainwindow.cpp" line="510"/>
<location filename="mainwindow.cpp" line="535"/>
<location filename="mainwindow.cpp" line="539"/>
<location filename="mainwindow.cpp" line="548"/>
<location filename="mainwindow.cpp" line="560"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="272"/>
<location filename="mainwindow.cpp" line="499"/>
<location filename="mainwindow.cpp" line="511"/>
<location filename="mainwindow.cpp" line="298"/>
<location filename="mainwindow.cpp" line="548"/>
<location filename="mainwindow.cpp" line="560"/>
<source>Is testing, do not close!</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="368"/>
<location filename="mainwindow.cpp" line="409"/>
<source>Are you sure to connect the new device</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="370"/>
<location filename="mainwindow.cpp" line="411"/>
<source>yes</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="371"/>
<location filename="mainwindow.cpp" line="412"/>
<source>no</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="389"/>
<location filename="mainwindow.cpp" line="461"/>
<location filename="mainwindow.cpp" line="430"/>
<location filename="mainwindow.cpp" line="510"/>
<source>cannot create more table</source>
<translation></translation>
</message>
@ -786,52 +888,52 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="400"/>
<location filename="mainwindow.cpp" line="441"/>
<source>Open device failed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="481"/>
<location filename="mainwindow.cpp" line="530"/>
<source>save</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="481"/>
<location filename="mainwindow.cpp" line="530"/>
<source>xls(*.xls)</source>
<translation>xls表格(*.xls)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="486"/>
<location filename="mainwindow.cpp" line="535"/>
<source>export succeed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="490"/>
<location filename="mainwindow.cpp" line="539"/>
<source>export failed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="523"/>
<location filename="mainwindow.cpp" line="572"/>
<source>Illegal user</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="527"/>
<location filename="mainwindow.cpp" line="576"/>
<source>Wrong password</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="531"/>
<location filename="mainwindow.cpp" line="580"/>
<source>Database error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="535"/>
<location filename="mainwindow.cpp" line="584"/>
<source>connect error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="539"/>
<location filename="mainwindow.cpp" line="588"/>
<source>Failed</source>
<translation></translation>
</message>

View File

@ -1,7 +1,8 @@
#include "dialog_login.h"
#include "ui_dialog_login.h"
#include <QMessageBox>
#include "mainwindow.h"
#include <QRegExpValidator>
#include <QMouseEvent>
#include "base/HGUtility.h"
#include "base/HGIni.h"
#include "HGUIGlobal.h"
@ -68,6 +69,11 @@ unsigned short Dialog_logIn::GetFtpPort()
return ui->lineEdit_ftpPort->text().toUShort();
}
Dialog_logIn::LogInType Dialog_logIn::GetLogInType()
{
return m_loginType;
}
void Dialog_logIn::mousePressEvent(QMouseEvent *event)
{
if(event->button()==Qt::LeftButton)
@ -109,6 +115,15 @@ void Dialog_logIn::on_pbtn_login_clicked()
saveCfgValue("login", "ftpHost", ftpHost);
saveCfgValue("login", "ftpPort", ftpPort);
if (ui->radioButton_burn->isChecked())
m_loginType = LogInType_Burn;
else if (ui->radioButton_initTest->isChecked())
m_loginType = LogInType_InitTest;
else if (ui->radioButton_imageTest->isChecked())
m_loginType = LogInType_ImageTest;
else if (ui->radioButton_pressureTest->isChecked())
m_loginType = LogInType_PressureTest;
HGPdtToolDbUserMgr pdtToolDbuserMgr = nullptr;
HGPdtToolDb_CreateUserMgr(dbHost.toStdString().c_str(), dbPort.toInt(), account.toStdString().c_str(), password.toStdString().c_str(),
&pdtToolDbuserMgr);

View File

@ -16,9 +16,18 @@ public:
explicit Dialog_logIn(QWidget *parent = nullptr);
~Dialog_logIn();
enum LogInType
{
LogInType_Burn = 0,
LogInType_InitTest = 1,
LogInType_ImageTest = 2,
LogInType_PressureTest = 3
};
HGPdtToolDbUserMgr GetUserMgr();
QString GetFtpHost();
unsigned short GetFtpPort();
LogInType GetLogInType();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
@ -45,6 +54,7 @@ private:
QPoint m_startPos;
QPoint m_endPos;
bool m_leftMousePressed;
LogInType m_loginType;
};
#endif // DIALOG_LOGIN_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>473</width>
<height>278</height>
<width>479</width>
<height>329</height>
</rect>
</property>
<property name="windowTitle">
@ -18,7 +18,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>451</width>
<width>481</width>
<height>30</height>
</rect>
</property>
@ -151,7 +151,7 @@ QPushButton#pbtn_close::hover
</rect>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<widget class="QLabel" name="label_user">
@ -172,7 +172,7 @@ QPushButton#pbtn_close::hover
<rect>
<x>140</x>
<y>30</y>
<width>151</width>
<width>161</width>
<height>22</height>
</rect>
</property>
@ -195,7 +195,7 @@ QPushButton#pbtn_close::hover
<rect>
<x>140</x>
<y>90</y>
<width>151</width>
<width>161</width>
<height>22</height>
</rect>
</property>
@ -299,8 +299,8 @@ QPushButton#pbtn_close::hover
<widget class="QPushButton" name="pushButton_exit">
<property name="geometry">
<rect>
<x>260</x>
<y>210</y>
<x>270</x>
<y>280</y>
<width>75</width>
<height>31</height>
</rect>
@ -313,7 +313,7 @@ QPushButton#pbtn_close::hover
<property name="geometry">
<rect>
<x>140</x>
<y>210</y>
<y>280</y>
<width>75</width>
<height>31</height>
</rect>
@ -328,6 +328,61 @@ QPushButton#pbtn_close::hover
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_burn">
<property name="geometry">
<rect>
<x>90</x>
<y>186</y>
<width>131</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Burn</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_initTest">
<property name="geometry">
<rect>
<x>270</x>
<y>185</y>
<width>141</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>InitTest</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_imageTest">
<property name="geometry">
<rect>
<x>90</x>
<y>230</y>
<width>151</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>ImageTest</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_pressureTest">
<property name="geometry">
<rect>
<x>270</x>
<y>230</y>
<width>151</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>PressureTest</string>
</property>
</widget>
</widget>
<resources/>
<connections/>

View File

@ -0,0 +1,39 @@
#include "dialog_setburnsn.h"
#include "ui_dialog_setburnsn.h"
#include <QRegExpValidator>
Dialog_SetBurnSn::Dialog_SetBurnSn(const QString &originSn, QWidget *parent) :
QDialog(parent),
m_originSn(originSn),
ui(new Ui::Dialog_SetBurnSn)
{
ui->setupUi(this);
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
if (!m_originSn.isEmpty())
{
ui->lineEdit->setText(m_originSn);
ui->lineEdit->selectAll();
}
}
Dialog_SetBurnSn::~Dialog_SetBurnSn()
{
delete ui;
}
QString Dialog_SetBurnSn::getSn()
{
return ui->lineEdit->text();
}
void Dialog_SetBurnSn::on_pbtn_ok_clicked()
{
accept();
}
void Dialog_SetBurnSn::on_pbtn_cancel_clicked()
{
reject();
}

View File

@ -0,0 +1,30 @@
#ifndef DIALOG_SETBURNSN_H
#define DIALOG_SETBURNSN_H
#include <QDialog>
namespace Ui {
class Dialog_SetBurnSn;
}
class Dialog_SetBurnSn : public QDialog
{
Q_OBJECT
public:
explicit Dialog_SetBurnSn(const QString &originSn, QWidget *parent = nullptr);
~Dialog_SetBurnSn();
QString getSn();
private slots:
void on_pbtn_ok_clicked();
void on_pbtn_cancel_clicked();
private:
Ui::Dialog_SetBurnSn *ui;
QString m_originSn;
};
#endif // DIALOG_SETBURNSN_H

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_SetBurnSn</class>
<widget class="QDialog" name="Dialog_SetBurnSn">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>415</width>
<height>190</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>set sn:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>130</x>
<y>40</y>
<width>231</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pbtn_ok">
<property name="geometry">
<rect>
<x>190</x>
<y>120</y>
<width>75</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
<widget class="QPushButton" name="pbtn_cancel">
<property name="geometry">
<rect>
<x>310</x>
<y>120</y>
<width>75</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,236 @@
#include "form_burnmode.h"
#include "ui_form_burnmode.h"
#include "dialog_setburnsn.h"
#include "hgscanner.h"
#include "mainwindow.h"
#include <QMessageBox>
#include <QLineEdit>
#include <QInputDialog>
Form_BurnMode::Form_BurnMode(class MainWindow *mainwnd, QWidget *parent) :
QWidget(parent),
m_curIndex(0),
m_mainwnd(mainwnd),
ui(new Ui::Form_BurnMode)
{
ui->setupUi(this);
connect(this, SIGNAL(testResult(QString)), this, SLOT(on_testResult(QString)), Qt::QueuedConnection);
initTableWidget();
}
Form_BurnMode::~Form_BurnMode()
{
delete ui;
}
void Form_BurnMode::addDevice(DeviceManager *devManager)
{
ui->tableWidget->setRowCount(m_curIndex + 1);
ui->tableWidget->setItem(m_curIndex, 0, new QTableWidgetItem(QString::number(m_curIndex + 1)));
ui->tableWidget->item(m_curIndex, 0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
QTableWidgetItem *check = new QTableWidgetItem();
check->setCheckState(Qt::Unchecked);
ui->tableWidget->setItem(m_curIndex, 1, check);
ui->tableWidget->item(m_curIndex, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->setItem(m_curIndex, 2, new QTableWidgetItem(devManager->getDevName()));
ui->tableWidget->item(m_curIndex, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->setItem(m_curIndex, 3, new QTableWidgetItem(devManager->getSn()));
ui->tableWidget->item(m_curIndex, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
QTableWidgetItem *item = ui->tableWidget->item(m_curIndex, 1);
QVariant var = QVariant::fromValue((void*)devManager);
item->setData(Qt::UserRole, var);
// for(int i = 0; i < ui->tableWidget->rowCount(); i++)
// {
// QTableWidgetItem *item = ui->tableWidget->item(i, 3);
// if (item != nullptr)
// item->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled);
// }
m_curIndex++;
}
void Form_BurnMode::deleteDevice(QString devName)
{
for(int i = 0; i < ui->tableWidget->columnCount(); i++)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 1);
QTableWidgetItem *item2 = ui->tableWidget->item(i, 2);
if (devName!= nullptr && item != nullptr)
{
if (devName == item2->text())
{
DeviceManager *devManager = (DeviceManager*)item->data(Qt::UserRole).value<void*>();
delete devManager;
ui->tableWidget->removeRow(i);
m_curIndex--;
break;
}
}
}
}
void Form_BurnMode::on_testResult(QString text)
{
if (!text.isEmpty())
QMessageBox::information(this, tr("tips"), text);
m_mainwnd->releaseTesting();
}
void Form_BurnMode::initTableWidget()
{
ui->tableWidget->resizeRowsToContents();
ui->tableWidget->setColumnCount(4);
ui->tableWidget->horizontalHeader()->setDefaultSectionSize(200);
// ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
QStringList header;
header<< tr("ID") << tr("selected") << tr("device") << tr("serialNum");
ui->tableWidget->setHorizontalHeaderLabels(header);
QFont font = ui->tableWidget->horizontalHeader()->font();
font.setBold(true);
ui->tableWidget->horizontalHeader()->setFont(font);
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->verticalHeader()->setDefaultSectionSize(10);
ui->tableWidget->setFrameShape(QFrame::NoFrame);
ui->tableWidget->setShowGrid(true);
ui->tableWidget->verticalHeader()->setVisible(false);
// ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableWidget->horizontalHeader()->setFixedHeight(30);
ui->tableWidget->clearContents();
}
void Form_BurnMode::on_cbox_selectAll_stateChanged(int arg1)
{
(void)arg1;
bool check = ui->cbox_selectAll->isChecked();
for(int i = 0; i < ui->tableWidget->columnCount(); i++)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 1);
if (item != nullptr)
{
if (check)
item->setCheckState(Qt::Checked);
else
item->setCheckState(Qt::Unchecked);
}
}
}
void Form_BurnMode::on_pbtn_burn_clicked()
{
ui->cbox_selectAll->setChecked(true);
for(int i = 0; i < ui->tableWidget->columnCount(); i++)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 1);
if (item != nullptr && Qt::Checked == item->checkState())
{
DeviceManager *devManager = (DeviceManager*)item->data(Qt::UserRole).value<void*>();
devManager->setBurnMode();
}
}
}
void Form_BurnMode::on_pbtn_setSn_clicked()
{
int select = 0;
for(int i = 0; i < ui->tableWidget->columnCount(); i++)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 1);
if (item != nullptr && Qt::Checked == item->checkState())
{
select++;
}
}
if (select == 0)
{
QMessageBox::information(this, tr("tips"), tr("Please check a devices to set sn at least"));
return;
}
else if (select > 1)
{
QMessageBox::information(this, tr("tips"), tr("Please check single devices to set sn"));
return;
}
else if (select == 1)
{
for(int i = 0; i < ui->tableWidget->columnCount(); i++)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 1);
QTableWidgetItem *item2 = ui->tableWidget->item(i, 3);
if (item != nullptr && Qt::Checked == item->checkState())
{
Dialog_SetBurnSn dlg(item2->text(), this);
if (dlg.exec())
{
DeviceManager *devManager = (DeviceManager*)item->data(Qt::UserRole).value<void*>();
devManager->setSn(dlg.getSn());
break;
}
}
}
}
}
DeviceManager::DeviceManager(class MainWindow *mainwnd, class Form_BurnMode *burnMode, SANE_Handle handle, const QString & devName, const QString & sn)
{
m_handle = handle;
m_devName = devName;
m_sn = sn;
m_mainwnd = mainwnd;
m_burnMode = burnMode;
m_hg = new hgscanner(nullptr, m_burnMode, m_handle);
}
DeviceManager::~DeviceManager()
{
delete m_hg;
m_hg = nullptr;
sane_close(m_handle);
}
QString DeviceManager::getDevName()
{
return m_devName;
}
QString DeviceManager::getSn()
{
return m_sn;
}
void DeviceManager::setBurnMode()
{
const wchar_t *p = L"1";
func_test_go(HGPDTTOOLDB_NAME_REBOOT_DEVICE, p, m_hg);
m_mainwnd->addTestingRef();
}
void DeviceManager::setSn(QString sn)
{
LPWRITECFG p = new WRITECFG;
p->cat = WRITE_CAT_SERIALNUM;
p->val = (void*)&sn;
func_test_go(WRITE_CFG_NAME, (const wchar_t*)p, m_hg);
m_mainwnd->addTestingRef();
delete p;
}

View File

@ -0,0 +1,68 @@
#ifndef FORM_BURNMODE_H
#define FORM_BURNMODE_H
#include <QWidget>
#include "sane/sane_ex.h"
#include "hgscanner.h"
namespace Ui {
class Form_BurnMode;
}
class DeviceManager
{
public:
DeviceManager(class MainWindow *mainwnd, class Form_BurnMode *burnMode, SANE_Handle handle, const QString &devName, const QString &sn);
~DeviceManager();
QString getDevName();
QString getSn();
void setBurnMode();
void setSn(QString sn);
SANE_Handle m_handle;
private:
QString m_devName;
QString m_sn;
class MainWindow *m_mainwnd;
class Form_BurnMode *m_burnMode;
hgscanner *m_hg;
};
class Form_BurnMode : public QWidget
{
Q_OBJECT
public:
explicit Form_BurnMode(class MainWindow *mainwnd, QWidget *parent = nullptr);
~Form_BurnMode();
void addDevice(DeviceManager *devManager);
void deleteDevice(QString devName);
signals:
void testResult(QString text);
private slots:
void on_testResult(QString text);
private slots:
void on_cbox_selectAll_stateChanged(int arg1);
void on_pbtn_burn_clicked();
void on_pbtn_setSn_clicked();
private:
void initTableWidget();
private:
Ui::Form_BurnMode *ui;
class MainWindow *m_mainwnd;
int m_curIndex;
};
#endif // FORM_BURNMODE_H

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form_BurnMode</class>
<widget class="QWidget" name="Form_BurnMode">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>527</width>
<height>333</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="cbox_selectAll">
<property name="text">
<string>Select All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbtn_burn">
<property name="minimumSize">
<size>
<width>91</width>
<height>31</height>
</size>
</property>
<property name="text">
<string>Burn</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbtn_setSn">
<property name="minimumSize">
<size>
<width>91</width>
<height>31</height>
</size>
</property>
<property name="text">
<string>Set sn</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="minimumSize">
<size>
<width>43</width>
<height>23</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -45,7 +45,7 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle ha
if (m_handle)
{
str = tr("Device has connected");
m_hg = new hgscanner(this, m_handle);
m_hg = new hgscanner(this, nullptr, m_handle);
}
else
str = tr("Device hasnot connected");
@ -401,21 +401,24 @@ void Form_mainInterface::setGlobalCfg(AnalysisJson analysisJson)
vidpid.VID = jsonGlobal.vid_to;
vidpid.PID = jsonGlobal.pid_to;
p->cat = WRITE_CAT_VID_PID;
p->val = (void *) & vidpid.Value;
int t = *(int*)p->val;
p->val = (void *) & vidpid.Value;
func_test_go(WRITE_CFG_NAME, (const wchar_t*)p, m_hg);
m_mainwnd->addTestingRef();
p->cat = WRITE_CAT_SPEED;
p->val = (void*)&jsonGlobal.speed_mode;
func_test_go(WRITE_CFG_NAME, (const wchar_t*)p, m_hg);
m_mainwnd->addTestingRef();
p->cat = WRITE_CAT_SLEEP;
p->val = (void*)&jsonGlobal.sleep_time;
func_test_go(WRITE_CFG_NAME, (const wchar_t*)p, m_hg);
m_mainwnd->addTestingRef();
p->cat = WRITE_CAT_SERIALNUM;
p->val = (void*)&m_serialNum;
func_test_go(WRITE_CFG_NAME, (const wchar_t*)p, m_hg);
m_mainwnd->addTestingRef();
delete p;
}

View File

@ -1,11 +1,13 @@
#include "hgscanner.h"
#include <QMessageBox>
#include "form_maininterface.h"
#include "form_burnmode.h"
#include "dialog_userinput.h"
#include <QDebug>
hgscanner::hgscanner(Form_mainInterface *form, SANE_Handle h)
hgscanner::hgscanner(Form_mainInterface *form, Form_BurnMode *burnMode, SANE_Handle h)
: m_interface(form)
, m_burnMode(burnMode)
, devHandle_(h)
{
cb_ = nullptr;
@ -38,7 +40,15 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si
else if (ev == TEST_EVENT_NOT_FIND_TEST)
{
QString info = QObject::tr("Not find test item");
emit m_interface->testResult(info);
if (m_interface != nullptr)
{
emit m_interface->testResult(info);
}
else if (m_burnMode != nullptr)
{
emit m_burnMode->testResult(info);
}
}
else if (ev == TEST_EVENT_IO_FAIL)
{
@ -47,7 +57,15 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si
{
info = QObject::tr("failed: ") + QString::fromStdWString((const wchar_t*)data);
}
emit m_interface->testResult(info);
if (m_interface != nullptr)
{
emit m_interface->testResult(info);
}
else if (m_burnMode != nullptr)
{
emit m_burnMode->testResult(info);
}
}
else if (ev == TEST_EVENT_MANUAL_CONFIRMATION)
{
@ -56,7 +74,15 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si
{
info = QString::fromStdWString((const wchar_t*)data);
}
emit m_interface->testResult(info);
if (m_interface != nullptr)
{
emit m_interface->testResult(info);
}
else if (m_burnMode != nullptr)
{
emit m_burnMode->testResult(info);
}
}
else if (ev == TEST_EVENT_RESULT)
{
@ -68,7 +94,14 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si
else
info = QObject::tr("failed: ") + QString::fromStdWString((const wchar_t*)data);
}
emit m_interface->testResult(info);
if (m_interface != nullptr)
{
emit m_interface->testResult(info);
}
else if (m_burnMode != nullptr)
{
emit m_burnMode->testResult(info);
}
}
else if (ev == TEST_EVENT_DISTORTION)
{

View File

@ -4,11 +4,12 @@
#include "test_base.h"
class Form_mainInterface;
class Form_BurnMode;
class hgscanner :public ui_helper
{
public:
hgscanner(Form_mainInterface *form, SANE_Handle h);
hgscanner(Form_mainInterface *form, Form_BurnMode *burnMode, SANE_Handle h);
~hgscanner();
virtual parameter* get_user_input(data_from from, value_type type, const wchar_t* title, const wchar_t* desc = NULL);
virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag);
@ -18,6 +19,7 @@ public:
sane_callback cb_;
private:
class Form_mainInterface *m_interface;
class Form_BurnMode *m_burnMode;
SANE_Handle devHandle_;
};

View File

@ -18,7 +18,7 @@ int main(int argc, char *argv[])
Dialog_logIn login;
if (login.exec())
{
MainWindow w(login.GetUserMgr(), login.GetFtpHost(), login.GetFtpPort());
MainWindow w(login.GetUserMgr(), login.GetLogInType(), login.GetFtpHost(), login.GetFtpPort());
a.exec();
if (w.isExitApp())
{

View File

@ -10,7 +10,7 @@
#include "dialog_uploadcfgfile.h"
#include "dialog_inputserialnum.h"
MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, const QString &ftpHost, unsigned short ftpPort, QWidget *parent)
MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, Dialog_logIn::LogInType loginType, const QString &ftpHost, unsigned short ftpPort, QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_pdtToolDbuserMgr(pdtToolDbuserMgr)
@ -18,6 +18,8 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, const QString &ftpHo
, m_ftpPort(ftpPort)
, m_lock(nullptr)
, m_testingRef(0)
, m_loginType(loginType)
, m_formBurnMode(nullptr)
, m_top_splitter(nullptr)
, m_bot_splitter(nullptr)
, m_isLogOut(false)
@ -35,19 +37,35 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, const QString &ftpHo
connect(this, SIGNAL(sane_dev_arrive(QString)), this, SLOT(on_sane_dev_arrive(QString)), Qt::QueuedConnection);
connect(this, SIGNAL(sane_dev_remove(QString)), this, SLOT(on_sane_dev_remove(QString)), Qt::QueuedConnection);
m_top_splitter = new QSplitter(Qt::Horizontal);
m_bot_splitter = new QSplitter(Qt::Horizontal);
m_top_splitter->setMinimumWidth(600);
m_bot_splitter->setMinimumWidth(600);
m_top_splitter->setChildrenCollapsible(false);
m_bot_splitter->setChildrenCollapsible(false);
if (m_loginType == Dialog_logIn::LogInType_Burn)
{
ui->act_newDevice->setVisible(false);
QVBoxLayout *vLayout = new QVBoxLayout;
vLayout->addWidget(m_top_splitter);
vLayout->addWidget(m_bot_splitter);
vLayout->setStretch(0, 0);
vLayout->setStretch(1, 0);
this->centralWidget()->setLayout(vLayout);
m_formBurnMode = new Form_BurnMode(this, this);
QVBoxLayout *vLayout = new QVBoxLayout;
vLayout->addWidget(m_formBurnMode);
this->centralWidget()->setLayout(vLayout);
show();
}
else
{
m_top_splitter = new QSplitter(Qt::Horizontal);
m_bot_splitter = new QSplitter(Qt::Horizontal);
m_top_splitter->setMinimumWidth(600);
m_bot_splitter->setMinimumWidth(600);
m_top_splitter->setChildrenCollapsible(false);
m_bot_splitter->setChildrenCollapsible(false);
QVBoxLayout *vLayout = new QVBoxLayout;
vLayout->addWidget(m_top_splitter);
vLayout->addWidget(m_bot_splitter);
vLayout->setStretch(0, 0);
vLayout->setStretch(1, 0);
this->centralWidget()->setLayout(vLayout);
showMaximized();
}
QTimer *timer = new QTimer(this);
timer->start(1000);
@ -65,8 +83,6 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, const QString &ftpHo
HGPdtToolDb_GetUserName(m_pdtToolDbuserMgr, userName, 128);
setWindowTitle(userName);
showMaximized();
SANE_Int v = 0;
sane_init_ex(&v, sane_ex_callback, this);
}
@ -74,17 +90,24 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, const QString &ftpHo
MainWindow::~MainWindow()
{
HGBase_EnterLock(m_lock);
while (0 != m_top_splitter->count())
if (m_top_splitter != nullptr)
{
Form_mainInterface *interface = (Form_mainInterface *)m_top_splitter->widget(0);
delete interface;
while (0 != m_top_splitter->count())
{
Form_mainInterface * mainInterface = (Form_mainInterface *)m_top_splitter->widget(0);
delete mainInterface;
}
}
while (0 != m_bot_splitter->count())
if (m_top_splitter != nullptr)
{
Form_mainInterface *interface = (Form_mainInterface *)m_bot_splitter->widget(0);
delete interface;
while (0 != m_bot_splitter->count())
{
Form_mainInterface * mainInterface = (Form_mainInterface *)m_bot_splitter->widget(0);
delete mainInterface;
}
}
HGBase_LeaveLock(m_lock);
sane_exit();
@ -92,6 +115,9 @@ MainWindow::~MainWindow()
HGPdtToolDb_DestroyUserMgr(m_pdtToolDbuserMgr);
m_pdtToolDbuserMgr = nullptr;
delete m_formBurnMode;
m_formBurnMode = nullptr;
HGBase_DestroyLock(m_lock);
m_lock = nullptr;
delete ui;
@ -130,19 +156,19 @@ 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())
Form_mainInterface * mainInterface = (Form_mainInterface *)m_top_splitter->widget(i);
if (sn == mainInterface->getSn())
{
return interface;
return mainInterface;
}
}
for (int i = 0; i < m_bot_splitter->count(); ++i)
{
Form_mainInterface *interface = (Form_mainInterface *)m_bot_splitter->widget(i);
if (sn == interface->getSn())
Form_mainInterface * mainInterface = (Form_mainInterface *)m_bot_splitter->widget(i);
if (sn == mainInterface->getSn())
{
return interface;
return mainInterface;
}
}
@ -153,19 +179,19 @@ Form_mainInterface *MainWindow::FindInterfaceByDevName(const QString &devName)
{
for (int i = 0; i < m_top_splitter->count(); ++i)
{
Form_mainInterface *interface = (Form_mainInterface *)m_top_splitter->widget(i);
if (devName == interface->getDevName())
Form_mainInterface * mainInterface = (Form_mainInterface *)m_top_splitter->widget(i);
if (devName == mainInterface->getDevName())
{
return interface;
return mainInterface;
}
}
for (int i = 0; i < m_bot_splitter->count(); ++i)
{
Form_mainInterface *interface = (Form_mainInterface *)m_bot_splitter->widget(i);
if (devName == interface->getDevName())
Form_mainInterface * mainInterface = (Form_mainInterface *)m_bot_splitter->widget(i);
if (devName == mainInterface->getDevName())
{
return interface;
return mainInterface;
}
}
@ -177,10 +203,10 @@ Form_mainInterface* MainWindow::FindInterface(SANE_Handle handle)
Form_mainInterface *form = nullptr;
for (int i = 0; i < m_top_splitter->count(); ++i)
{
Form_mainInterface *interface = (Form_mainInterface *)m_top_splitter->widget(i);
if (handle == interface->getDevHandle())
Form_mainInterface * mainInterface = (Form_mainInterface *)m_top_splitter->widget(i);
if (handle == mainInterface->getDevHandle())
{
form = interface;
form = mainInterface;
break;
}
}
@ -189,10 +215,10 @@ Form_mainInterface* MainWindow::FindInterface(SANE_Handle handle)
{
for (int i = 0; i < m_bot_splitter->count(); ++i)
{
Form_mainInterface *interface = (Form_mainInterface *)m_bot_splitter->widget(i);
if (handle == interface->getDevHandle())
Form_mainInterface * mainInterface = (Form_mainInterface *)m_bot_splitter->widget(i);
if (handle == mainInterface->getDevHandle())
{
form = interface;
form = mainInterface;
break;
}
}
@ -201,20 +227,20 @@ Form_mainInterface* MainWindow::FindInterface(SANE_Handle handle)
return form;
}
bool MainWindow::AddInterface(Form_mainInterface *interface)
bool MainWindow::AddInterface(Form_mainInterface * mainInterface)
{
assert(nullptr != interface);
assert(nullptr != mainInterface);
HGBase_EnterLock(m_lock);
bool ret = false;
if (m_top_splitter->count() < 2)
{
m_top_splitter->addWidget(interface);
m_top_splitter->addWidget(mainInterface);
ret = true;
}
else if (m_bot_splitter->count() < 2)
{
m_bot_splitter->addWidget(interface);
m_bot_splitter->addWidget(mainInterface);
ret = true;
}
HGBase_LeaveLock(m_lock);
@ -223,11 +249,11 @@ bool MainWindow::AddInterface(Form_mainInterface *interface)
return ret;
}
bool MainWindow::RemoveInterface(Form_mainInterface *interface)
bool MainWindow::RemoveInterface(Form_mainInterface * mainInterface)
{
assert(nullptr != interface);
assert(nullptr != mainInterface);
HGBase_EnterLock(m_lock);
delete interface;
delete mainInterface;
HGBase_LeaveLock(m_lock);
updateSplitter();
return true;
@ -292,11 +318,14 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne
if (code == SANE_EVENT_IMAGE_OK || code == SANE_EVENT_SCAN_FINISHED || code == SANE_EVENT_ERROR || code == SANE_EVENT_STATUS)
{
HGBase_EnterLock(p->m_lock);
Form_mainInterface* interface = p->FindInterface(hdev);
if (nullptr != interface)
if (p->m_loginType != Dialog_logIn::LogInType_Burn)
{
if (nullptr != interface->getScanner() && nullptr != interface->getScanner()->cb_)
interface->getScanner()->cb_(hdev, code, data, len, interface->getScanner());
Form_mainInterface* mainInterface = p->FindInterface(hdev);
if (nullptr != mainInterface)
{
if (nullptr != mainInterface->getScanner() && nullptr != mainInterface->getScanner()->cb_)
mainInterface->getScanner()->cb_(hdev, code, data, len, mainInterface->getScanner());
}
}
HGBase_LeaveLock(p->m_lock);
}
@ -364,53 +393,73 @@ QString MainWindow::getDevFwNum(SANE_Handle handle)
void MainWindow::on_sane_dev_arrive(QString devName)
{
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))
if (m_loginType == Dialog_logIn::LogInType_Burn)
{
SANE_Handle devHandle = nullptr;
sane_open(devName.toStdString().c_str(), &devHandle);
if (nullptr != devHandle)
{
Dialog_InputSerialNum dlg(this, getDevSn(devHandle), getDevType(devHandle));
if (dlg.exec())
DeviceManager *devManager = new DeviceManager(this, m_formBurnMode, devHandle, devName, getDevSn(devHandle));
m_formBurnMode->addDevice(devManager);
}
}
else
{
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);
if (nullptr != devHandle)
{
HGPdtToolDbDevice pdtToolDbDevice = nullptr;
HGPdtToolDb_OpenDevice(m_pdtToolDbuserMgr, dlg.GetSn().toStdString().c_str(), &pdtToolDbDevice);
Form_mainInterface *mainInterface = new Form_mainInterface(this, devHandle, m_pdtToolDbuserMgr, pdtToolDbDevice,
dlg.GetSn(), dlg.GetDevType(), devName, getDevFwNum(devHandle));
if (!AddInterface(mainInterface))
Dialog_InputSerialNum dlg(this, getDevSn(devHandle), getDevType(devHandle));
if (dlg.exec())
{
QMessageBox::information(this, tr("tips"), tr("cannot create more table"));
delete mainInterface;
HGPdtToolDbDevice pdtToolDbDevice = nullptr;
HGPdtToolDb_OpenDevice(m_pdtToolDbuserMgr, dlg.GetSn().toStdString().c_str(), &pdtToolDbDevice);
Form_mainInterface *mainInterface = new Form_mainInterface(this, devHandle, m_pdtToolDbuserMgr, pdtToolDbDevice,
dlg.GetSn(), dlg.GetDevType(), devName, getDevFwNum(devHandle));
if (!AddInterface(mainInterface))
{
QMessageBox::information(this, tr("tips"), tr("cannot create more table"));
delete mainInterface;
}
}
else
{
sane_close(devHandle);
}
}
else
{
sane_close(devHandle);
QMessageBox::information(this, tr("tips"), tr("Open device failed"));
}
}
else
{
QMessageBox::information(this, tr("tips"), tr("Open device failed"));
}
}
}
void MainWindow::on_sane_dev_remove(QString devName)
{
Form_mainInterface *interface = FindInterfaceByDevName(devName);
if (interface != nullptr)
if (m_loginType == Dialog_logIn::LogInType_Burn)
{
interface->setDevDisconnect();
if (!interface->isTesting())
m_formBurnMode->deleteDevice(devName);
}
else
{
Form_mainInterface * mainInterface = FindInterfaceByDevName(devName);
if (mainInterface != nullptr)
{
RemoveInterface(interface);
mainInterface->setDevDisconnect();
if (!mainInterface->isTesting())
{
RemoveInterface(mainInterface);
}
}
}
}

View File

@ -1,14 +1,16 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "form_maininterface.h"
#include "form_texttips.h"
#include "form_burnmode.h"
#include "form_maininterface.h"
#include <QtWidgets>
#include <QSplitter>
#include "HGPdtToolDb.h"
#include "sane/sane_ex.h"
#include "base/HGLock.h"
#include "hgscanner.h"
#include "dialog_login.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
@ -19,7 +21,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, const QString &ftpHost, unsigned short ftpPort, QWidget *parent = nullptr);
MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, Dialog_logIn::LogInType loginType, const QString &ftpHost, unsigned short ftpPort, QWidget *parent = nullptr);
~MainWindow();
static QString getLogInfo(HGResult ret);
bool isExitApp();
@ -28,8 +30,8 @@ public:
Form_mainInterface* FindInterface(const QString &sn);
Form_mainInterface* FindInterfaceByDevName(const QString &devName);
Form_mainInterface* FindInterface(SANE_Handle handle);
bool AddInterface(Form_mainInterface *interface);
bool RemoveInterface(Form_mainInterface *interface);
bool AddInterface(Form_mainInterface * mainInterface);
bool RemoveInterface(Form_mainInterface *mainInterface);
void addTestingRef();
void releaseTesting();
bool isTesting();
@ -79,6 +81,9 @@ private:
HGPdtToolDbUserMgr m_pdtToolDbuserMgr;
HGLock m_lock;
int m_testingRef;
Dialog_logIn::LogInType m_loginType;
Form_BurnMode *m_formBurnMode;
public:
QString m_ftpHost;