调整app界面与流程

This commit is contained in:
yangjiaxuan 2022-12-16 19:01:30 +08:00
parent 86e4b458b4
commit 253892e9e3
13 changed files with 604 additions and 124 deletions

View File

@ -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 \

View File

@ -1,6 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>Dialog_InputSerialNum</name>
<message>
<location filename="dialog_inputserialnum.ui" line="14"/>
<source>Dialog</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="26"/>
<source>Input SN:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="49"/>
<source>Select devType:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="63"/>
<source>G100</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="68"/>
<source>G200</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="73"/>
<source>G300</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="78"/>
<source>G400</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="92"/>
<source>OK</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="105"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.cpp" line="43"/>
<location filename="dialog_inputserialnum.cpp" line="49"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.cpp" line="43"/>
<source>Serial num is empty</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.cpp" line="49"/>
<source>The device is testing</source>
<translation></translation>
</message>
</context>
<context>
<name>Dialog_accountManage</name>
<message>
@ -262,10 +326,30 @@
<message>
<location filename="dialog_uploadcfgfile.ui" line="43"/>
<source>tag:</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.ui" line="83"/>
<location filename="dialog_uploadcfgfile.ui" line="51"/>
<source>G100</source>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.ui" line="56"/>
<source>G200</source>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.ui" line="61"/>
<source>G300</source>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.ui" line="66"/>
<source>G400</source>
<translation></translation>
</message>
<message>
<location filename="dialog_uploadcfgfile.ui" line="104"/>
<source>upload</source>
<translation></translation>
</message>
@ -339,16 +423,6 @@
<source>Next Step</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="77"/>
<source>HGPDTTOOLDB_TITLE_DIAL_SWITCH</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="82"/>
<source>HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Form_textTips</name>
@ -411,53 +485,85 @@
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="157"/>
<location filename="mainwindow.cpp" line="276"/>
<source>Account login elsewhere</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="160"/>
<source>Network connection lost</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="163"/>
<location filename="mainwindow.cpp" line="279"/>
<source>You have been forced offline by the administrator account</source>
<translation>线</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="169"/>
<location filename="mainwindow.cpp" line="204"/>
<location filename="mainwindow.cpp" line="282"/>
<source>Data base error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="234"/>
<location filename="mainwindow.cpp" line="254"/>
<location filename="mainwindow.cpp" line="288"/>
<location filename="mainwindow.cpp" line="305"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="204"/>
<location filename="mainwindow.cpp" line="235"/>
<source>Are you sure to connect the new device</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="237"/>
<source>yes</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="238"/>
<source>no</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="254"/>
<location filename="mainwindow.cpp" line="305"/>
<source>cannot create more table</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="250"/>
<location filename="mainwindow.cpp" line="325"/>
<source>save</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="325"/>
<source>xls(*.xls)</source>
<translation>xls表格(*.xls)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="349"/>
<source>Illegal user</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="254"/>
<location filename="mainwindow.cpp" line="353"/>
<source>Wrong password</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="258"/>
<location filename="mainwindow.cpp" line="357"/>
<source>Database error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="262"/>
<location filename="mainwindow.cpp" line="361"/>
<source>connect error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="266"/>
<location filename="mainwindow.cpp" line="365"/>
<source>Failed</source>
<translation></translation>
</message>

View File

@ -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();
}

View File

@ -0,0 +1,34 @@
#ifndef DIALOG_INPUTSERIALNUM_H
#define DIALOG_INPUTSERIALNUM_H
#include <QDialog>
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

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_InputSerialNum</class>
<widget class="QDialog" name="Dialog_InputSerialNum">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>225</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label_sn">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>Input SN:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_sn">
<property name="geometry">
<rect>
<x>120</x>
<y>50</y>
<width>171</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_type">
<property name="geometry">
<rect>
<x>30</x>
<y>110</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Select devType:</string>
</property>
</widget>
<widget class="QComboBox" name="cbox_devType">
<property name="geometry">
<rect>
<x>120</x>
<y>110</y>
<width>171</width>
<height>22</height>
</rect>
</property>
<item>
<property name="text">
<string>G100</string>
</property>
</item>
<item>
<property name="text">
<string>G200</string>
</property>
</item>
<item>
<property name="text">
<string>G300</string>
</property>
</item>
<item>
<property name="text">
<string>G400</string>
</property>
</item>
</widget>
<widget class="QPushButton" name="pbtn_ok">
<property name="geometry">
<rect>
<x>197</x>
<y>181</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
<widget class="QPushButton" name="pbtn_cancel">
<property name="geometry">
<rect>
<x>278</x>
<y>181</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -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)

View File

@ -45,7 +45,28 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_tag"/>
<widget class="QComboBox" name="comboBox_tag">
<item>
<property name="text">
<string>G100</string>
</property>
</item>
<item>
<property name="text">
<string>G200</string>
</property>
</item>
<item>
<property name="text">
<string>G300</string>
</property>
</item>
<item>
<property name="text">
<string>G400</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">

View File

@ -1,43 +1,57 @@
#include "form_maininterface.h"
#include "ui_form_maininterface.h"
#include <QPainter>
#include <QMessageBox>
#include <QInputDialog>
#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<AnalysisJson::json_node> 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 &currentText)
{
(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<hgscanner*>(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<AnalysisJson::json_node> 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);
}

View File

@ -2,9 +2,12 @@
#define FORM_MAININTERFACE_H
#include <QWidget>
#include <QMap>
#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 &currentText);
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<QString, AnalysisJson::json_node> m_map_title_name;
};
#endif // FORM_MAININTERFACE_H

View File

@ -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())

View File

@ -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<QVBoxLayout*>(this->centralWidget()->layout())->setStretch(0, 1);
reinterpret_cast<QVBoxLayout*>(this->centralWidget()->layout())->setStretch(1, 0);
}
else if (0 == m_top_splitter->count() && 0 != m_bot_splitter->count())
{
reinterpret_cast<QVBoxLayout*>(this->centralWidget()->layout())->setStretch(0, 0);
reinterpret_cast<QVBoxLayout*>(this->centralWidget()->layout())->setStretch(1, 1);
}
else if (0 != m_top_splitter->count() && 0 != m_bot_splitter->count())
{
reinterpret_cast<QVBoxLayout*>(this->centralWidget()->layout())->setStretch(0, 1);
reinterpret_cast<QVBoxLayout*>(this->centralWidget()->layout())->setStretch(1, 1);
}
else
{
reinterpret_cast<QVBoxLayout*>(this->centralWidget()->layout())->setStretch(0, 0);
reinterpret_cast<QVBoxLayout*>(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<std::string> 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<hgscanner*>(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<QVBoxLayout*>(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();
}

View File

@ -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<std::string> 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