diff --git a/app/scanner/dialog_device_scan.cpp b/app/scanner/dialog_device_scan.cpp deleted file mode 100644 index 64b50c3c..00000000 --- a/app/scanner/dialog_device_scan.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "dialog_device_scan.h" -#include "ui_dialog_device_scan.h" - -Dialog_Device_Scan::Dialog_Device_Scan(HGSaneDevice dev, QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog_Device_Scan) -{ - ui->setupUi(this); - m_saneDev = dev; - - connect(this, SIGNAL(eventFunc(unsigned int, QString)), this, SLOT(on_eventFunc(unsigned int, QString)), Qt::QueuedConnection); - - ui->pushButton_Continue->setEnabled(false); - ui->pushButton_Cancel->setEnabled(false); - ui->pushButton_Complete->setEnabled(false); - - on_pushButton_Continue_clicked(); -} - -Dialog_Device_Scan::~Dialog_Device_Scan() -{ - delete ui; -} - -void HGAPI Dialog_Device_Scan::DeviceEventFunc(HGSaneDevice dev, HGUInt error, const HGChar *errInfo, HGPointer param) -{ - Dialog_Device_Scan *p = (Dialog_Device_Scan*)param; - emit p->eventFunc(error, tr(errInfo)); -} - -void HGAPI Dialog_Device_Scan::DeviceImageFunc(HGSaneDevice dev, HGImage image, HGPointer param) -{ - Dialog_Device_Scan *p = (Dialog_Device_Scan*)param; - HGImage image2 = nullptr; - HGBase_CloneImage(image, 0, 0, &image2); - if (nullptr != image2) - { - emit p->newImage(image2); - } -} - -void Dialog_Device_Scan::on_eventFunc(HGUInt error, QString errInfo) -{ - if (HGBASE_ERR_OK == error) - ui->label->setText("扫描完成"); - else - ui->label->setText(errInfo); - - HGSane_StopDevice(m_saneDev); - - ui->pushButton_Continue->setEnabled(true); - ui->pushButton_Cancel->setEnabled(false); - ui->pushButton_Complete->setEnabled(true); -} - -void Dialog_Device_Scan::on_pushButton_Cancel_clicked() -{ - HGSane_StopDevice(m_saneDev); - - ui->pushButton_Continue->setEnabled(true); - ui->pushButton_Cancel->setEnabled(false); - ui->pushButton_Complete->setEnabled(true); -} - -void Dialog_Device_Scan::on_pushButton_Complete_clicked() -{ - accept(); -} - -void Dialog_Device_Scan::on_pushButton_Continue_clicked() -{ - HGChar errInfo[256]; - HGResult ret = HGSane_StartDevice(m_saneDev, DeviceEventFunc, this, DeviceImageFunc, this, errInfo, 256); - if (HGBASE_ERR_OK != ret) - { - ui->pushButton_Continue->setEnabled(true); - ui->pushButton_Cancel->setEnabled(false); - ui->pushButton_Complete->setEnabled(true); - - ui->label->setText(tr(errInfo)); - } - else - { - ui->pushButton_Continue->setEnabled(false); - ui->pushButton_Cancel->setEnabled(true); - ui->pushButton_Complete->setEnabled(false); - - ui->label->setText("扫描中..."); - } -} diff --git a/app/scanner/dialog_device_select.cpp b/app/scanner/dialog_device_select.cpp deleted file mode 100644 index 3b7fcdad..00000000 --- a/app/scanner/dialog_device_select.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "dialog_device_select.h" -#include "ui_dialog_device_select.h" -#include - -Dialog_Device_Select::Dialog_Device_Select(HGSaneManager saneMgr, QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog_Device_Select) -{ - ui->setupUi(this); - m_saneMgr = saneMgr; - m_saneDev = nullptr; - - HGUInt count = 0; - HGSane_GetDeviceCount(m_saneMgr, &count); - for (HGUInt i = 0; i < count; ++i) - { - HGChar name[256]; - HGSane_GetDeviceName(m_saneMgr, i, name, 256); - ui->listWidget->addItem(name); - } -} - -Dialog_Device_Select::~Dialog_Device_Select() -{ - delete ui; -} - -HGSaneDevice Dialog_Device_Select::getSaneDevice() -{ - return m_saneDev; -} - -void Dialog_Device_Select::on_buttonBox_accepted() -{ - int index = ui->listWidget->currentRow(); - if (index >= 0) - { - HGSaneDevice dev = nullptr; - HGChar errInfo[256]; - HGSane_OpenDevice(m_saneMgr, index, &dev, errInfo, 256); - if (nullptr == dev) - { - QMessageBox msg(QMessageBox::Information, tr("tips"), tr(errInfo), QMessageBox::Ok, this); - msg.exec(); - return; - } - - m_saneDev = dev; - accept(); - } -} diff --git a/build-qt/HGSolution/HGSaneUI/HGSaneUI.pro b/build-qt/HGSolution/HGSaneUI/HGSaneUI.pro new file mode 100644 index 00000000..ae400e0e --- /dev/null +++ b/build-qt/HGSolution/HGSaneUI/HGSaneUI.pro @@ -0,0 +1,259 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TEMPLATE = lib + +CONFIG += c++11 +QMAKE_CXXFLAGS += -std=c++0x +# The following define makes your compiler emit warnings if you use +# any Qt feature that has been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS +DEFINES += QT_NO_VERSION_TAGGING + +# OEM definition +DEFINES += OEM_HUAGAO + +# You can also make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +if (contains(DEFINES, OEM_HANWANG) || contains(DEFINES, OEM_LISICHENG) || contains(DEFINES, OEM_CANGTIAN) || contains(DEFINES, OEM_ZHONGJING) || contains(DEFINES, OEM_ZIGUANG)) { + contains(DEFINES, OEM_HANWANG) { + TARGET = HWSaneUI + } + contains(DEFINES, OEM_LISICHENG) { + TARGET = LSCSaneUI + } + contains(DEFINES, OEM_CANGTIAN) { + TARGET = CTSSaneUI + } + contains(DEFINES, OEM_ZHONGJING) { + TARGET = ZJSaneUI + } + contains(DEFINES, OEM_ZIGUANG) { + TARGET = ZGSaneUI + } +} else { + TARGET = HGSaneUI +} + +win32 { + DEFINES += _CRT_SECURE_NO_WARNINGS + LIBS += -ladvapi32 + + if (contains(DEFINES, OEM_HANWANG) || contains(DEFINES, OEM_LISICHENG) || contains(DEFINES, OEM_CANGTIAN) || contains(DEFINES, OEM_ZHONGJING) || contains(DEFINES, OEM_ZIGUANG)) { + contains(DEFINES, OEM_HANWANG) { + LIBS += -lHWBase -lHWImgFmt -lHWImgProc + contains(QT_ARCH, i386) { + LIBS += -L../../../../sdk/lib/win/x86/OEM/hanvon -lsane -llang + } + contains(QT_ARCH, x86_64){ + LIBS += -L../../../../sdk/lib/win/x64/OEM/hanvon -lsane -llang + } + } + contains(DEFINES, OEM_LISICHENG) { + LIBS += -lLSCBase -lLSCImgFmt -lLSCImgProc + contains(QT_ARCH, i386) { + LIBS += -L../../../../sdk/lib/win/x86/OEM/lanxum -lsane -llang + } + contains(QT_ARCH, x86_64){ + LIBS += -L../../../../sdk/lib/win/x64/OEM/lanxum -lsane -llang + } + } + contains(DEFINES, OEM_CANGTIAN) { + LIBS += -lCTSBase -lCTSImgFmt -lCTSImgProc + contains(QT_ARCH, i386) { + LIBS += -L../../../../sdk/lib/win/x86/OEM/cumtenn -lsane -llang + } + contains(QT_ARCH, x86_64){ + LIBS += -L../../../../sdk/lib/win/x64/OEM/cumtenn -lsane -llang + } + } + contains(DEFINES, OEM_ZHONGJING) { + LIBS += -lZJBase -lZJImgFmt -lZJImgProc + contains(QT_ARCH, i386) { + LIBS += -L../../../../sdk/lib/win/x86/OEM/microtek -lsane -llang + } + contains(QT_ARCH, x86_64){ + LIBS += -L../../../../sdk/lib/win/x64/OEM/microtek -lsane -llang + } + } + contains(DEFINES, OEM_ZIGUANG) { + LIBS += -lZGBase -lZGImgFmt -lZGImgProc + contains(QT_ARCH, i386) { + LIBS += -L../../../../sdk/lib/win/x86/OEM/unis -lsane -llang + } + contains(QT_ARCH, x86_64){ + LIBS += -L../../../../sdk/lib/win/x64/OEM/unis -lsane -llang + } + } + } else { + LIBS += -lHGBase -lHGImgFmt -lHGImgProc + contains(QT_ARCH, i386) { + LIBS += -L../../../../sdk/lib/win/x86/OEM/huagao -lsane -llang + } + contains(QT_ARCH, x86_64){ + LIBS += -L../../../../sdk/lib/win/x64/OEM/huagao -lsane -llang + } + } + + contains(QT_ARCH, i386) { + LIBS += -L../../../../sdk/lib/win/x86/Release + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/win/x86/Release/ + } + CONFIG(debug, debug|release) { + } + } + contains(QT_ARCH, x86_64){ + LIBS += -L../../../../sdk/lib/win/x64/Release + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/win/x64/Release/ + } + CONFIG(debug, debug|release) { + } + } +} + +unix { + LIBS += -llang + QMAKE_LFLAGS += -static-libstdc++ -static-libgcc + DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1) + message($$DISTRIBUTION) + ARCH = $$system(arch) + message($$ARCH) + QMAKE_LFLAGS += -Wl,-rpath=\'\$\$ORIGIN\' + + if (contains(DEFINES, OEM_HANWANG) || contains(DEFINES, OEM_LISICHENG) || contains(DEFINES, OEM_CANGTIAN) || contains(DEFINES, OEM_ZHONGJING) || contains(DEFINES, OEM_ZIGUANG)) { + contains(DEFINES, OEM_HANWANG){ + LIBS += -lHwBase -lHwImgFmt -lHwImgProc -lsane-hwsane -lhwdriver + } + contains(DEFINES, OEM_LISICHENG){ + LIBS += -lLscBase -lLscImgFmt -lLscImgProc -lsane-lscsane -llscdriver + } + contains(DEFINES, OEM_CANGTIAN){ + LIBS += -lCtsBase -lCtsImgFmt -lCtsImgProc -lsane-ctssane -lctsdriver + } + contains(DEFINES, OEM_ZHONGJING){ + LIBS += -lZjBase -lZjImgFmt -lZjImgProc -lsane-zjsane -lzjdriver + } + contains(DEFINES, OEM_ZIGUANG){ + LIBS += -lZgBase -lZgImgFmt -lZgImgProc -lsane-zgsane -lzgdriver + } + } else { + LIBS += -lHGBase -lHGImgFmt -lHGImgProc -lsane-hgsane -lhgdriver + } + + contains(DISTRIBUTION, UnionTech){ + message('UOS') + + contains(ARCH, x86_64){ + DEFINES += x86_64 + LIBS += -L../../../../release/uos/x86_64 + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/uos/x86_64/ + } + CONFIG(debug, debug|release) { + + } + } + contains(ARCH, aarch64){ + DEFINES += aarch64 + LIBS += -L../../../../release/uos/aarch64 + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/uos/aarch64/ + } + CONFIG(debug, debug|release) { + + } + } + contains(ARCH, mips64){ + DEFINES += mips64 + LIBS += -L../../../../release/uos/mips64 + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/uos/mips64/ + } + CONFIG(debug, debug|release) { + + } + } + contains(ARCH, loongarch64){ + DEFINES += loongarch64 + LIBS += -L../../../../release/uos/loongarch64 + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/uos/loongarch64/ + } + CONFIG(debug, debug|release) { + + } + } + } else { + message('KYLIN') + + contains(ARCH, x86_64){ + DEFINES += x86_64 + LIBS += -L../../../../release/kylin/x86_64 + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/kylin/x86_64/ + } + CONFIG(debug, debug|release) { + + } + } + contains(ARCH, aarch64){ + DEFINES += aarch64 + LIBS += -L../../../../release/kylin/aarch64 + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/kylin/aarch64/ + } + CONFIG(debug, debug|release) { + + } + } + contains(ARCH, mips64){ + DEFINES += mips64 + LIBS += -L../../../../release/kylin/mips64 + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/kylin/mips64/ + } + CONFIG(debug, debug|release) { + + } + } + contains(ARCH, loongarch64){ + DEFINES += loongarch64 + LIBS += -L../../../../release/kylin/loongarch64 + CONFIG(release, debug|release) { + DESTDIR = ../../../../release/kylin/loongarch64/ + } + CONFIG(debug, debug|release) { + + } + } + } +} + +INCLUDEPATH += $$PWD/../../../modules/saneui/ +INCLUDEPATH += $$PWD/../../../utility/ +INCLUDEPATH += $$PWD/../../../modules/ +INCLUDEPATH += $$PWD/../../../../sdk/include/ + +FORMS += \ + ../../../modules/saneui/dialog_device_scan.ui \ + ../../../modules/saneui/dialog_device_select.ui + +HEADERS += \ + ../../../modules/saneui/HGSaneUI.h \ + ../../../modules/saneui/dialog_device_scan.h \ + ../../../modules/saneui/dialog_device_select.h + +SOURCES += \ + ../../../modules/saneui/HGSaneUI.cpp \ + ../../../modules/saneui/dialog_device_scan.cpp \ + ../../../modules/saneui/dialog_device_select.cpp + + diff --git a/build/windows/HGSaneUser/HGSaneUser.vcxproj b/build/windows/HGSaneUser/HGSaneUser.vcxproj index cfbc515b..0a522233 100644 --- a/build/windows/HGSaneUser/HGSaneUser.vcxproj +++ b/build/windows/HGSaneUser/HGSaneUser.vcxproj @@ -283,7 +283,7 @@ NotUsing pch.h MultiThreadedDebug - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -305,7 +305,7 @@ NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -336,7 +336,7 @@ copy $(OutDir)HGSaneUser.dll $(SolutionDir)..\..\..\release\win\x86\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -367,7 +367,7 @@ copy $(OutDir)HWSaneUser.dll $(SolutionDir)..\..\..\release\win\x86\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -398,7 +398,7 @@ copy $(OutDir)ZGSaneUser.dll $(SolutionDir)..\..\..\release\win\x86\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -429,7 +429,7 @@ copy $(OutDir)ZJSaneUser.dll $(SolutionDir)..\..\..\release\win\x86\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -460,7 +460,7 @@ copy $(OutDir)LSCSaneUser.dll $(SolutionDir)..\..\..\release\win\x86\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -489,7 +489,7 @@ copy $(OutDir)CTSSaneUser.dll $(SolutionDir)..\..\..\release\win\x86\Release\NotUsing pch.h MultiThreadedDebug - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -511,7 +511,7 @@ copy $(OutDir)CTSSaneUser.dll $(SolutionDir)..\..\..\release\win\x86\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -542,7 +542,7 @@ copy $(OutDir)HGSaneUser.dll $(SolutionDir)..\..\..\release\win\x64\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -573,7 +573,7 @@ copy $(OutDir)HWSaneUser.dll $(SolutionDir)..\..\..\release\win\x64\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -604,7 +604,7 @@ copy $(OutDir)ZGSaneUser.dll $(SolutionDir)..\..\..\release\win\x64\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -635,7 +635,7 @@ copy $(OutDir)ZJSaneUser.dll $(SolutionDir)..\..\..\release\win\x64\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true @@ -666,7 +666,7 @@ copy $(OutDir)LSCSaneUser.dll $(SolutionDir)..\..\..\release\win\x64\Release\NotUsing pch.h MultiThreaded - ../../../third_party/sane/;%(AdditionalIncludeDirectories) + ../../../../sdk/include/;%(AdditionalIncludeDirectories) true diff --git a/modules/sane_user/HGSaneImpl.cpp b/modules/sane_user/HGSaneImpl.cpp index 31398f0b..ab52be41 100644 --- a/modules/sane_user/HGSaneImpl.cpp +++ b/modules/sane_user/HGSaneImpl.cpp @@ -18,6 +18,7 @@ HGSaneManagerImpl::HGSaneManagerImpl() m_f_sane_get_parameters = NULL; m_f_sane_get_option_descriptor = NULL; m_f_sane_control_option = NULL; + memset(&m_saneApi, 0, sizeof(SANEAPI)); m_saneDlgDll = NULL; m_f_show_devlist_ui = NULL; @@ -48,7 +49,7 @@ HGResult HGSaneManagerImpl::Create(const HGChar* sanePath) return ret; } - HGBase_CreateDll("HGSaneDlg.dll", &m_saneDlgDll); + HGBase_CreateDll("HGSaneUI.dll", &m_saneDlgDll); if (NULL != m_saneDlgDll) { HGBase_GetDllProcAddress(m_saneDlgDll, "show_devlist_ui", (HGPointer*)&m_f_show_devlist_ui); @@ -182,23 +183,7 @@ HGResult HGSaneManagerImpl::OpenSelectedDevice(HGWindow parent, class HGSaneDevi return HGBASE_ERR_FAIL; } - const SANE_Device** device_list; - if (SANE_STATUS_GOOD != m_f_sane_get_devices(&device_list, SANE_TRUE)) - { - return HGSANE_ERR_FAIL; - } - - HGUInt count = 0; - const SANE_Device** p; - for (p = device_list; *p != NULL; ++p) - ++count; - - const char** devNameList = new const char*[count + 1]; - for (HGUInt i = 0; i < count; ++i) - devNameList[i] = device_list[i]->name; - devNameList[count] = 0; - SANE_Handle handle = m_f_show_devlist_ui(devNameList, parent); - delete []devNameList; + SANE_Handle handle = m_f_show_devlist_ui(&m_saneApi, parent); if (NULL == handle) { return HGSANE_ERR_FAIL; @@ -277,6 +262,17 @@ HGResult HGSaneManagerImpl::FindFunctions() } while (0); + m_saneApi.sane_get_devices_api = m_f_sane_get_devices; + m_saneApi.sane_open_api = m_f_sane_open; + m_saneApi.sane_close_api = m_f_sane_close; + m_saneApi.sane_start_api = m_f_sane_start; + m_saneApi.sane_read_api = m_f_sane_read; + m_saneApi.sane_cancel_api = m_f_sane_cancel; + m_saneApi.sane_set_io_mode_api = m_f_sane_set_io_mode; + m_saneApi.sane_strstatus_api = m_f_sane_strstatus; + m_saneApi.sane_get_parameters_api = m_f_sane_get_parameters; + m_saneApi.sane_get_option_descriptor_api = m_f_sane_get_option_descriptor; + m_saneApi.sane_control_option_api = m_f_sane_control_option; return ret; } @@ -377,7 +373,7 @@ HGResult HGSaneDeviceImpl::ShowSettingDlg(HGWindow parent) return HGBASE_ERR_FAIL; } - m_mgrImpl->m_f_show_setting_ui(m_devHandle, parent); + m_mgrImpl->m_f_show_setting_ui(&m_mgrImpl->m_saneApi, m_devHandle, parent); return HGBASE_ERR_OK; } @@ -480,7 +476,7 @@ HGResult HGSaneDeviceImpl::StartWithUI(HGWindow parent, HGSane_DeviceImageFunc i m_dpi = GetDpi(); m_imageFunc = imageFunc; m_imageParam = imageParam; - m_mgrImpl->m_f_show_scan_ui(m_devHandle, parent, ShowScanImageCallback, this); + m_mgrImpl->m_f_show_scan_ui(&m_mgrImpl->m_saneApi, m_devHandle, parent, ShowScanImageCallback, this); return HGBASE_ERR_OK; } @@ -499,7 +495,7 @@ HGUInt HGSaneDeviceImpl::GetDpi() { SANE_Int value = 0; m_mgrImpl->m_f_sane_control_option(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, NULL); - if (0 == strcmp(desp->name, SANE_NAME_SCAN_RESOLUTION)) + if (0 == strcmp(desp->name, "resolution")) { dpi = (HGUInt)value; break; diff --git a/modules/sane_user/HGSaneImpl.hpp b/modules/sane_user/HGSaneImpl.hpp index 8c2b5374..aa6b88d1 100644 --- a/modules/sane_user/HGSaneImpl.hpp +++ b/modules/sane_user/HGSaneImpl.hpp @@ -6,8 +6,7 @@ #include "../base/HGDll.h" #include "../base/HGThread.h" #include "../base/HGLock.h" -#include "sane.h" -#include "saneopts.h" +#include "sane/sane_ex.h" #include #include @@ -22,13 +21,13 @@ typedef void (*f_sane_cancel)(SANE_Handle handle); typedef SANE_Status (*f_sane_set_io_mode)(SANE_Handle handle, SANE_Bool non_blocking); typedef SANE_String_Const (*f_sane_strstatus)(SANE_Status status); typedef SANE_Status (*f_sane_get_parameters)(SANE_Handle handle, SANE_Parameters* params); -typedef SANE_Option_Descriptor* (*f_sane_get_option_descriptor)(SANE_Handle handle, SANE_Int option); +typedef const SANE_Option_Descriptor* (*f_sane_get_option_descriptor)(SANE_Handle handle, SANE_Int option); typedef SANE_Status (*f_sane_control_option)(SANE_Handle handle, SANE_Int option, SANE_Action action, void* value, SANE_Int* info); -typedef SANE_Handle (*f_show_devlist_ui)(const char **devNameList, HGWindow parent); -typedef void (*f_show_setting_ui)(SANE_Handle handle, HGWindow parent); +typedef SANE_Handle (*f_show_devlist_ui)(SANEAPI* saneApi, HGWindow parent); +typedef void (*f_show_setting_ui)(SANEAPI* saneApi, SANE_Handle handle, HGWindow parent); typedef void (*f_show_scan_ui_image_callback)(const SANE_Parameters *imageFormat, const SANE_Byte *imageData, void * callbackParam); -typedef void (*f_show_scan_ui)(SANE_Handle handle, HGWindow parent, f_show_scan_ui_image_callback callback, void *callbackParam); +typedef void (*f_show_scan_ui)(SANEAPI* saneApi, SANE_Handle handle, HGWindow parent, f_show_scan_ui_image_callback callback, void *callbackParam); class HGSaneManagerImpl { @@ -63,6 +62,7 @@ private: f_sane_get_parameters m_f_sane_get_parameters; f_sane_get_option_descriptor m_f_sane_get_option_descriptor; f_sane_control_option m_f_sane_control_option; + SANEAPI m_saneApi; HGDll m_saneDlgDll; f_show_devlist_ui m_f_show_devlist_ui; diff --git a/modules/saneui/HGSaneUI.cpp b/modules/saneui/HGSaneUI.cpp new file mode 100644 index 00000000..bd8b7336 --- /dev/null +++ b/modules/saneui/HGSaneUI.cpp @@ -0,0 +1,16 @@ +#include "HGSaneUI.h" + +SANE_Handle show_devlist_ui(SANEAPI* saneApi, HGWindow parent) +{ + return nullptr; +} + +void show_setting_ui(SANEAPI* saneApi, SANE_Handle handle, HGWindow parent) +{ + +} + +void show_scan_ui(SANEAPI* saneApi, SANE_Handle handle, HGWindow parent, show_scan_ui_image_callback callback, void *callbackParam) +{ + +} diff --git a/modules/saneui/HGSaneUI.h b/modules/saneui/HGSaneUI.h new file mode 100644 index 00000000..b312eb12 --- /dev/null +++ b/modules/saneui/HGSaneUI.h @@ -0,0 +1,13 @@ +#ifndef SANE_UI_H +#define SANE_UI_H + +#include "base/HGDef.h" +#include "sane/sane_ex.h" + +typedef void (*show_scan_ui_image_callback)(const SANE_Parameters *imageFormat, const SANE_Byte *imageData, void * callbackParam); + +HGEXPORT SANE_Handle show_devlist_ui(SANEAPI* saneApi, HGWindow parent); +HGEXPORT void show_setting_ui(SANEAPI* saneApi, SANE_Handle handle, HGWindow parent); +HGEXPORT void show_scan_ui(SANEAPI* saneApi, SANE_Handle handle, HGWindow parent, show_scan_ui_image_callback callback, void *callbackParam); + +#endif diff --git a/modules/saneui/dialog_device_scan.cpp b/modules/saneui/dialog_device_scan.cpp new file mode 100644 index 00000000..8cd5c04f --- /dev/null +++ b/modules/saneui/dialog_device_scan.cpp @@ -0,0 +1,43 @@ +#include "dialog_device_scan.h" +#include "ui_dialog_device_scan.h" + +Dialog_Device_Scan::Dialog_Device_Scan(SANE_Handle dev, QWidget *parent) : + QDialog(parent), + ui(new Ui::Dialog_Device_Scan) +{ + ui->setupUi(this); + m_saneDev = dev; + + connect(this, SIGNAL(eventFunc(unsigned int, QString)), this, SLOT(on_eventFunc(unsigned int, QString)), Qt::QueuedConnection); + + ui->pushButton_Continue->setEnabled(false); + ui->pushButton_Cancel->setEnabled(false); + ui->pushButton_Complete->setEnabled(false); + + on_pushButton_Continue_clicked(); +} + +Dialog_Device_Scan::~Dialog_Device_Scan() +{ + delete ui; +} + +void Dialog_Device_Scan::on_eventFunc(HGUInt error, QString errInfo) +{ + +} + +void Dialog_Device_Scan::on_pushButton_Cancel_clicked() +{ + +} + +void Dialog_Device_Scan::on_pushButton_Complete_clicked() +{ + accept(); +} + +void Dialog_Device_Scan::on_pushButton_Continue_clicked() +{ + +} diff --git a/app/scanner/dialog_device_scan.h b/modules/saneui/dialog_device_scan.h similarity index 63% rename from app/scanner/dialog_device_scan.h rename to modules/saneui/dialog_device_scan.h index 98575e5a..f0b5d33c 100644 --- a/app/scanner/dialog_device_scan.h +++ b/modules/saneui/dialog_device_scan.h @@ -2,7 +2,7 @@ #define DIALOG_DEVICE_SCAN_H #include "base/HGDef.h" -#include "sane_user/HGSane.h" +#include "sane.h" #include namespace Ui { @@ -14,7 +14,7 @@ class Dialog_Device_Scan : public QDialog Q_OBJECT public: - explicit Dialog_Device_Scan(HGSaneDevice dev, QWidget *parent = nullptr); + explicit Dialog_Device_Scan(SANE_Handle dev, QWidget *parent = nullptr); ~Dialog_Device_Scan(); signals: @@ -30,13 +30,9 @@ private slots: void on_pushButton_Continue_clicked(); -private: - static void HGAPI DeviceEventFunc(HGSaneDevice dev, HGUInt error, const HGChar *errInfo, HGPointer param); - static void HGAPI DeviceImageFunc(HGSaneDevice dev, HGImage image, HGPointer param); - private: Ui::Dialog_Device_Scan *ui; - HGSaneDevice m_saneDev; + SANE_Handle m_saneDev; }; #endif // DIALOG_DEVICE_SCAN_H diff --git a/app/scanner/dialog_device_scan.ui b/modules/saneui/dialog_device_scan.ui similarity index 100% rename from app/scanner/dialog_device_scan.ui rename to modules/saneui/dialog_device_scan.ui diff --git a/modules/saneui/dialog_device_select.cpp b/modules/saneui/dialog_device_select.cpp new file mode 100644 index 00000000..e3adad23 --- /dev/null +++ b/modules/saneui/dialog_device_select.cpp @@ -0,0 +1,20 @@ +#include "dialog_device_select.h" +#include "ui_dialog_device_select.h" +#include + +Dialog_Device_Select::Dialog_Device_Select(QWidget *parent) : + QDialog(parent), + ui(new Ui::Dialog_Device_Select) +{ + ui->setupUi(this); +} + +Dialog_Device_Select::~Dialog_Device_Select() +{ + delete ui; +} + +void Dialog_Device_Select::on_buttonBox_accepted() +{ + +} diff --git a/app/scanner/dialog_device_select.h b/modules/saneui/dialog_device_select.h similarity index 65% rename from app/scanner/dialog_device_select.h rename to modules/saneui/dialog_device_select.h index 7516d9ea..776afd90 100644 --- a/app/scanner/dialog_device_select.h +++ b/modules/saneui/dialog_device_select.h @@ -2,7 +2,7 @@ #define DIALOG_DEVICE_SELECT_H #include "base/HGDef.h" -#include "sane_user/HGSane.h" +#include "sane.h" #include namespace Ui { @@ -14,18 +14,14 @@ class Dialog_Device_Select : public QDialog Q_OBJECT public: - Dialog_Device_Select(HGSaneManager saneMgr, QWidget *parent = nullptr); + Dialog_Device_Select(QWidget *parent = nullptr); ~Dialog_Device_Select(); - HGSaneDevice getSaneDevice(); - private slots: void on_buttonBox_accepted(); private: Ui::Dialog_Device_Select *ui; - HGSaneManager m_saneMgr; - HGSaneDevice m_saneDev; }; #endif // DIALOG_DEVICE_SELECT_H diff --git a/app/scanner/dialog_device_select.ui b/modules/saneui/dialog_device_select.ui similarity index 100% rename from app/scanner/dialog_device_select.ui rename to modules/saneui/dialog_device_select.ui