调整界面流程

This commit is contained in:
yangjiaxuan 2022-12-22 10:48:06 +08:00
parent f2b38bc15f
commit 07dc440e67
9 changed files with 250 additions and 173 deletions

View File

@ -9,42 +9,42 @@
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="26"/>
<location filename="dialog_inputserialnum.ui" line="35"/>
<source>Input SN:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="49"/>
<location filename="dialog_inputserialnum.ui" line="75"/>
<source>Select devType:</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="63"/>
<location filename="dialog_inputserialnum.ui" line="89"/>
<source>G100</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="68"/>
<location filename="dialog_inputserialnum.ui" line="94"/>
<source>G200</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="73"/>
<location filename="dialog_inputserialnum.ui" line="99"/>
<source>G300</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="78"/>
<location filename="dialog_inputserialnum.ui" line="104"/>
<source>G400</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="92"/>
<location filename="dialog_inputserialnum.ui" line="142"/>
<source>OK</source>
<translation></translation>
</message>
<message>
<location filename="dialog_inputserialnum.ui" line="105"/>
<location filename="dialog_inputserialnum.ui" line="149"/>
<source>Cancel</source>
<translation></translation>
</message>
@ -253,12 +253,12 @@
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="80"/>
<location filename="dialog_login.cpp" line="87"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="dialog_login.cpp" line="80"/>
<location filename="dialog_login.cpp" line="87"/>
<source>Login failed: </source>
<translation> </translation>
</message>
@ -423,6 +423,16 @@
<source>Next Step</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="27"/>
<source>Device type:</source>
<translation></translation>
</message>
<message>
<location filename="form_maininterface.cpp" line="27"/>
<source> SerialNum:</source>
<translation> </translation>
</message>
</context>
<context>
<name>Form_textTips</name>
@ -485,7 +495,7 @@
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="276"/>
<location filename="mainwindow.cpp" line="285"/>
<source>Account login elsewhere</source>
<translation></translation>
</message>
@ -494,76 +504,76 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="279"/>
<location filename="mainwindow.cpp" line="288"/>
<source>You have been forced offline by the administrator account</source>
<translation>线</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="282"/>
<location filename="mainwindow.cpp" line="291"/>
<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"/>
<location filename="mainwindow.cpp" line="240"/>
<location filename="mainwindow.cpp" line="260"/>
<location filename="mainwindow.cpp" line="299"/>
<location filename="mainwindow.cpp" line="317"/>
<source>tips</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="235"/>
<location filename="mainwindow.cpp" line="241"/>
<source>Are you sure to connect the new device</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="237"/>
<location filename="mainwindow.cpp" line="243"/>
<source>yes</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="238"/>
<location filename="mainwindow.cpp" line="244"/>
<source>no</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="254"/>
<location filename="mainwindow.cpp" line="305"/>
<location filename="mainwindow.cpp" line="260"/>
<location filename="mainwindow.cpp" line="317"/>
<source>cannot create more table</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="325"/>
<location filename="mainwindow.cpp" line="337"/>
<source>save</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="325"/>
<location filename="mainwindow.cpp" line="337"/>
<source>xls(*.xls)</source>
<translation>xls表格(*.xls)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="349"/>
<location filename="mainwindow.cpp" line="361"/>
<source>Illegal user</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="353"/>
<location filename="mainwindow.cpp" line="365"/>
<source>Wrong password</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="357"/>
<location filename="mainwindow.cpp" line="369"/>
<source>Database error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="361"/>
<location filename="mainwindow.cpp" line="373"/>
<source>connect error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="365"/>
<location filename="mainwindow.cpp" line="377"/>
<source>Failed</source>
<translation></translation>
</message>

View File

@ -6,105 +6,160 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>225</height>
<width>413</width>
<height>175</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>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<property name="text">
<string>G100</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_sn">
<property name="text">
<string>Input SN:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_sn">
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<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>
<item>
<property name="text">
<string>G200</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_type">
<property name="text">
<string>Select devType:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbox_devType">
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</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>
</item>
<item>
<spacer name="horizontalSpacer_3">
<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>
<item>
<property name="text">
<string>G300</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbtn_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbtn_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</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>
</layout>
</widget>
<resources/>
<connections/>

View File

@ -3,10 +3,10 @@
#include <QMessageBox>
#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

View File

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

View File

@ -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<AnalysisJson::json_node> 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()

View File

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

View File

@ -1,6 +1,7 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QVBoxLayout>
#include <QTimer>
#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()

View File

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