调整热拔插流程,json读取
This commit is contained in:
parent
dbb5398156
commit
fae6326c7e
|
@ -25,6 +25,7 @@ win32 {
|
|||
contains(QT_ARCH, i386) {
|
||||
LIBS += -L../../../sdk/lib/win/x86/Release -lHGBase -lHGImgFmt -lHGImgProc
|
||||
LIBS += -L../../../sdk/lib/win/x86/OEM/huagao -lsane
|
||||
LIBS += -L../../code/base/Debug/ -ltest
|
||||
CONFIG(release, debug|release) {
|
||||
LIBS += -L../../db/Release -lHGPdtToolDb
|
||||
DESTDIR = ../../../release/win/x86/Release
|
||||
|
@ -36,7 +37,6 @@ win32 {
|
|||
contains(QT_ARCH, x86_64){
|
||||
LIBS += -L../../../sdk/lib/win/x64/Release -lHGBase -lHGImgFmt -lHGImgProc
|
||||
LIBS += -L../../../sdk/lib/win/x64/OEM/huagao -lsane
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
LIBS += -L../../db/x64/Release -lHGPdtToolDb
|
||||
DESTDIR = ../../../release/win/x64/Release
|
||||
|
@ -62,8 +62,10 @@ SOURCES += \
|
|||
dialog_uploadcfgfile.cpp \
|
||||
form_maininterface.cpp \
|
||||
form_texttips.cpp \
|
||||
hgscanner.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
mainwindow.cpp \
|
||||
ui_helper.cpp
|
||||
|
||||
HEADERS += \
|
||||
HGImgView.h \
|
||||
|
@ -76,7 +78,9 @@ HEADERS += \
|
|||
dialog_uploadcfgfile.h \
|
||||
form_maininterface.h \
|
||||
form_texttips.h \
|
||||
mainwindow.h
|
||||
hgscanner.h \
|
||||
mainwindow.h \
|
||||
ui_helper.h
|
||||
|
||||
FORMS += \
|
||||
dialog_accountmanage.ui \
|
||||
|
|
Binary file not shown.
|
@ -257,7 +257,7 @@
|
|||
<message>
|
||||
<location filename="dialog_uploadcfgfile.ui" line="32"/>
|
||||
<source>select file</source>
|
||||
<translation>选择目录</translation>
|
||||
<translation type="unfinished">选择文件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_uploadcfgfile.ui" line="43"/>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QJsonArray>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
|
||||
AnalysisJson::AnalysisJson(QString path)
|
||||
{
|
||||
|
@ -23,7 +24,13 @@ std::vector<AnalysisJson::json_node> AnalysisJson::GetNode()
|
|||
if(!m_json.isObject())
|
||||
return nodes;
|
||||
auto obj = m_json.object();
|
||||
for(auto key : obj.keys())
|
||||
|
||||
auto keys = obj.keys().toVector();
|
||||
std::sort(keys.begin(),keys.end(),[](QString x,QString y){
|
||||
return x.toInt()<y.toInt();
|
||||
});
|
||||
|
||||
for(auto key : keys)
|
||||
{
|
||||
if(key != "global")
|
||||
nodes.push_back(json_node{obj[key].toObject()["title"].toString(),
|
||||
|
|
|
@ -12,6 +12,7 @@ Dialog_uploadCfgFile::Dialog_uploadCfgFile(HGPdtToolDbUserMgr pdtToolDbuserMgr,
|
|||
ui(new Ui::Dialog_uploadCfgFile)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
}
|
||||
|
||||
Dialog_uploadCfgFile::~Dialog_uploadCfgFile()
|
||||
|
|
|
@ -17,11 +17,18 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr userMgr, QWidget *parent)
|
|||
, m_top_splitter(nullptr)
|
||||
, m_bot_splitter(nullptr)
|
||||
, m_splitterCount(1)
|
||||
, m_handle(nullptr)
|
||||
, m_isLogOut(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowIcon(QIcon(":image/image_rsc/logo/logo.ico"));
|
||||
|
||||
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);
|
||||
|
||||
SANE_Int v = 0;
|
||||
sane_init_ex(&v, sane_ex_callback, this);
|
||||
|
||||
HGUInt userType = 0;
|
||||
HGPdtToolDb_GetUserType(m_pdtToolDbuserMgr, &userType);
|
||||
if (userType == HGPDTTOOLDB_USERTYPE_NORMAL)
|
||||
|
@ -42,7 +49,6 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr userMgr, QWidget *parent)
|
|||
vLayout->setStretch(0, 1);
|
||||
vLayout->setStretch(1, 0);
|
||||
this->centralWidget()->setLayout(vLayout);
|
||||
test();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -58,7 +64,31 @@ bool MainWindow::isExitApp()
|
|||
return !m_isLogOut;
|
||||
}
|
||||
|
||||
std::vector<std::string> MainWindow::get_devices()
|
||||
int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int *len, void *param)
|
||||
{
|
||||
(void)hdev;
|
||||
(void)len;
|
||||
MainWindow *p = (MainWindow *)param;
|
||||
switch (code)
|
||||
{
|
||||
case SANE_EVENT_DEVICE_ARRIVED:
|
||||
{
|
||||
SANE_Device_Ex* sane_dev = (SANE_Device_Ex*)data;
|
||||
emit p->sane_dev_arrive(sane_dev->name);
|
||||
}
|
||||
break;
|
||||
case SANE_EVENT_DEVICE_LEFT:
|
||||
{
|
||||
SANE_Device* sane_dev = (SANE_Device*)data;
|
||||
emit p->sane_dev_remove(sane_dev->name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> MainWindow::getDevices()
|
||||
{
|
||||
std::vector<std::string> name;
|
||||
const SANE_Device** devs_list;
|
||||
|
@ -77,59 +107,21 @@ std::vector<std::string> MainWindow::get_devices()
|
|||
return name;
|
||||
}
|
||||
|
||||
|
||||
int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param)
|
||||
void MainWindow::on_sane_dev_arrive(QString devName)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case SANE_EVENT_DEVICE_ARRIVED:
|
||||
(SANE_Device*)data;
|
||||
break;
|
||||
case SANE_EVENT_DEVICE_LEFT:
|
||||
(SANE_Device*)data;
|
||||
break;
|
||||
case SANE_EVENT_WORKING:
|
||||
(char*)data;
|
||||
break;
|
||||
case SANE_EVENT_SCAN_FINISHED:
|
||||
(char*)data;
|
||||
break;
|
||||
case SANE_EVENT_STATUS:
|
||||
(char*)data;
|
||||
break;
|
||||
case SANE_EVENT_ERROR:
|
||||
(char*)data;
|
||||
break;
|
||||
case SANE_EVENT_IMAGE_OK:
|
||||
SANE_Image* sane_img = (SANE_Image*)data;
|
||||
break;
|
||||
}
|
||||
// sane_ex_callback1(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param);
|
||||
SANE_Status ret = sane_open(devName.toStdString().c_str(), &m_handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
void MainWindow::test()
|
||||
{
|
||||
SANE_Handle devHandle;
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
SANE_Int version_code = 0;
|
||||
status = sane_init_ex(&version_code, sane_ex_callback, NULL);
|
||||
Sleep(2000);
|
||||
const SANE_Device** device_list;
|
||||
//status = sane_get_devices(&device_list, SANE_TRUE);
|
||||
std::vector<std::string> name = get_devices();
|
||||
|
||||
// SANE_String_Const n = name[0].c_str();
|
||||
int len = name[0].size();
|
||||
char* buf = new char[len];
|
||||
strcpy(buf, name[0].c_str());
|
||||
sane_open(buf, &devHandle);
|
||||
ui_helper* helper;
|
||||
hgscanner* hg = new hgscanner(devHandle);
|
||||
hgscanner* hg = new hgscanner(m_handle);
|
||||
helper = dynamic_cast<hgscanner*>(hg);
|
||||
// sane_ex_callback1();
|
||||
func_test_go(L"test-35", L"null", helper);
|
||||
func_test_go(L"test-31", L"null", helper);
|
||||
}
|
||||
|
||||
void MainWindow::on_sane_dev_remove(QString devName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_act_newDevice_triggered()
|
||||
{
|
||||
m_splitterCount++;
|
||||
|
|
|
@ -20,11 +20,21 @@ public:
|
|||
~MainWindow();
|
||||
|
||||
static QString getLogInfo(HGResult ret);
|
||||
|
||||
bool isExitApp();
|
||||
void test();
|
||||
|
||||
|
||||
private:
|
||||
static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param);
|
||||
std::vector<std::string> get_devices();
|
||||
|
||||
std::vector<std::string> getDevices();
|
||||
|
||||
signals:
|
||||
void sane_dev_arrive(QString devName);
|
||||
void sane_dev_remove(QString devName);
|
||||
|
||||
private slots:
|
||||
void on_sane_dev_arrive(QString devName);
|
||||
void on_sane_dev_remove(QString devName);
|
||||
|
||||
private slots:
|
||||
void on_act_newDevice_triggered();
|
||||
|
@ -44,6 +54,7 @@ private slots:
|
|||
private:
|
||||
QSplitter *m_top_splitter;
|
||||
QSplitter *m_bot_splitter;
|
||||
SANE_Handle m_handle;
|
||||
|
||||
int m_splitterCount;
|
||||
bool m_isLogOut;
|
||||
|
|
Loading…
Reference in New Issue