2023-03-28 10:38:35 +00:00
|
|
|
|
#include "HGSaneUI.h"
|
2023-03-29 08:16:19 +00:00
|
|
|
|
#include "dialog_device_select.h"
|
|
|
|
|
#include "dialog_device_scan.h"
|
2023-03-29 14:46:41 +00:00
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
|
|
#ifdef HG_CMP_MSC
|
|
|
|
|
#include "qwinwidget.h"
|
|
|
|
|
extern HINSTANCE g_hInst;
|
|
|
|
|
extern bool g_ownApplication;
|
|
|
|
|
#endif
|
2023-03-28 10:38:35 +00:00
|
|
|
|
|
2023-03-29 08:16:19 +00:00
|
|
|
|
int show_devlist_ui(SANEAPI* saneApi, HGWindow parent, SANE_Handle *handle, char *devName, unsigned int maxLen)
|
2023-03-28 10:38:35 +00:00
|
|
|
|
{
|
2023-03-29 08:16:19 +00:00
|
|
|
|
if (nullptr == saneApi || nullptr == handle)
|
|
|
|
|
return -1;
|
2023-03-29 10:04:59 +00:00
|
|
|
|
|
2023-03-29 08:16:19 +00:00
|
|
|
|
QWidget *qParent = nullptr;
|
|
|
|
|
#ifdef HG_CMP_MSC
|
2023-03-29 14:46:41 +00:00
|
|
|
|
if (!g_ownApplication)
|
|
|
|
|
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
|
|
|
|
|
QWinWidget win(parent);
|
|
|
|
|
win.showCentered();
|
|
|
|
|
qParent = &win;
|
2023-03-29 08:16:19 +00:00
|
|
|
|
#else
|
|
|
|
|
qParent = parent;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
*handle = nullptr;
|
|
|
|
|
Dialog_Device_Select dlg(saneApi, qParent);
|
|
|
|
|
if (dlg.exec())
|
|
|
|
|
{
|
|
|
|
|
if (nullptr != devName)
|
|
|
|
|
{
|
|
|
|
|
std::string strDevName = dlg.GetDevName();
|
|
|
|
|
if (maxLen >= strDevName.size() + 1)
|
|
|
|
|
strcpy(devName, strDevName.c_str());
|
|
|
|
|
}
|
2023-03-28 10:38:35 +00:00
|
|
|
|
|
2023-03-29 08:16:19 +00:00
|
|
|
|
*handle = dlg.GetDevHandle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2023-03-28 10:38:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 08:16:19 +00:00
|
|
|
|
int show_setting_ui(SANEAPI* saneApi, SANE_Handle handle, HGWindow parent)
|
2023-03-28 10:38:35 +00:00
|
|
|
|
{
|
2023-03-29 08:16:19 +00:00
|
|
|
|
if (nullptr == saneApi || nullptr == handle)
|
|
|
|
|
return -1;
|
2023-03-29 10:04:59 +00:00
|
|
|
|
|
2023-03-29 08:16:19 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2023-03-28 10:38:35 +00:00
|
|
|
|
|
2023-03-29 08:16:19 +00:00
|
|
|
|
int show_scan_ui(SANEAPI* saneApi, SANE_Handle handle, HGWindow parent, show_scan_ui_image_callback callback, void *callbackParam)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr == saneApi || nullptr == handle)
|
|
|
|
|
return -1;
|
2023-03-29 10:04:59 +00:00
|
|
|
|
|
|
|
|
|
QWidget *qParent = nullptr;
|
|
|
|
|
#ifdef HG_CMP_MSC
|
2023-03-29 14:46:41 +00:00
|
|
|
|
if (!g_ownApplication)
|
|
|
|
|
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
|
|
|
|
|
QWinWidget win(parent);
|
|
|
|
|
win.showCentered();
|
|
|
|
|
qParent = &win;
|
2023-03-29 10:04:59 +00:00
|
|
|
|
#else
|
|
|
|
|
qParent = parent;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
Dialog_Device_Scan dlg(saneApi, handle, callback, callbackParam, qParent);
|
|
|
|
|
dlg.exec();
|
2023-03-29 08:16:19 +00:00
|
|
|
|
return 0;
|
2023-03-28 10:38:35 +00:00
|
|
|
|
}
|