调整app调用sane功能
This commit is contained in:
parent
1974ba5dbf
commit
b742818db6
|
@ -200,6 +200,47 @@ class DeviceUser* DeviceUserMgr::OpenDeviceUser()
|
|||
return new DeviceUser(m_wnd, source, dev, m_password);
|
||||
}
|
||||
|
||||
DeviceUser *DeviceUserMgr::OpenDefaultDeviceUser()
|
||||
{
|
||||
HGSaneSource source = nullptr;
|
||||
HGSane_OpenDefaultSource(m_saneMgr, &source);
|
||||
if (nullptr == source)
|
||||
return nullptr;
|
||||
|
||||
HGUInt devCount = 0;
|
||||
HGSane_GetDeviceCount(source, &devCount);
|
||||
if (0 == devCount)
|
||||
{
|
||||
HGSane_CloseSource(source);
|
||||
QMessageBox::information(m_wnd, tr("tips"), tr("no device"));
|
||||
return nullptr;
|
||||
}
|
||||
else if (1 == devCount)
|
||||
{
|
||||
HGChar errInfo[256];
|
||||
HGSaneDevice dev = nullptr;
|
||||
HGSane_OpenDevice(source, 0, &dev, errInfo, 256);
|
||||
if (nullptr == dev)
|
||||
{
|
||||
HGSane_CloseSource(source);
|
||||
QMessageBox::information(m_wnd, tr("tips"), QString::fromUtf8(errInfo));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new DeviceUser(m_wnd, source, dev, m_password);
|
||||
}
|
||||
|
||||
HGSaneDevice dev = nullptr;
|
||||
HGSane_OpenSelectedDevice(source, m_wnd, &dev);
|
||||
if (nullptr == dev)
|
||||
{
|
||||
HGSane_CloseSource(source);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new DeviceUser(m_wnd, source, dev, m_password);
|
||||
}
|
||||
|
||||
DeviceUser::DeviceUser(QWidget *wnd, HGSaneSource source, HGSaneDevice dev, QString password)
|
||||
{
|
||||
m_wnd = wnd;
|
||||
|
@ -290,7 +331,15 @@ HGResult DeviceUser::ClearDeviceLog()
|
|||
|
||||
void HGAPI DeviceUser::DeviceEventFunc(HGSaneDevice dev, HGUInt event, HGPointer param)
|
||||
{
|
||||
|
||||
DeviceUser* p = (DeviceUser*)param;
|
||||
if (HGSANE_EVENT_TYPE_SCANFINISHED == event)
|
||||
{
|
||||
emit p->scanFinishEvent();
|
||||
}
|
||||
else if (HGSANE_EVENT_TYPE_WORKING == event)
|
||||
{
|
||||
emit p->scanWorkingEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void HGAPI DeviceUser::DeviceImageFunc(HGSaneDevice dev, HGImage image, HGPointer param)
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
|
||||
// 弹出设备选择对话框,选择设备
|
||||
class DeviceUser* OpenDeviceUser();
|
||||
class DeviceUser* OpenDefaultDeviceUser();
|
||||
|
||||
private:
|
||||
QWidget *m_wnd;
|
||||
|
@ -116,7 +117,8 @@ private:
|
|||
|
||||
signals:
|
||||
void newImage(void *image);
|
||||
void scanEvent(HGUInt event);
|
||||
void scanFinishEvent();
|
||||
void scanWorkingEvent();
|
||||
|
||||
private:
|
||||
QWidget *m_wnd;
|
||||
|
|
|
@ -79,6 +79,25 @@ HGResult HGAPI HGSane_OpenSource(HGSaneManager manager, HGUInt index, HGSaneSour
|
|||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGAPI HGSane_OpenDefaultSource(HGSaneManager manager, HGSaneSource* source)
|
||||
{
|
||||
if (NULL == manager)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
HGSaneManagerImpl *managerImpl = (HGSaneManagerImpl*)manager;
|
||||
HGSaneSourceImpl *sourceImpl = NULL;
|
||||
HGResult ret = managerImpl->OpenDefaultSource(&sourceImpl);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
*source = (HGSaneSource)sourceImpl;
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGAPI HGSane_OpenSelectedSource(HGSaneManager manager, HGWindow parent, HGSaneSource* source)
|
||||
{
|
||||
if (NULL == manager)
|
||||
|
|
|
@ -54,6 +54,8 @@ HGEXPORT HGResult HGAPI HGSane_GetSourceNameWithIndex(HGSaneManager manager, HGU
|
|||
|
||||
HGEXPORT HGResult HGAPI HGSane_OpenSource(HGSaneManager manager, HGUInt index, HGSaneSource* source);
|
||||
|
||||
HGEXPORT HGResult HGAPI HGSane_OpenDefaultSource(HGSaneManager manager, HGSaneSource* source);
|
||||
|
||||
HGEXPORT HGResult HGAPI HGSane_OpenSelectedSource(HGSaneManager manager, HGWindow parent, HGSaneSource* source);
|
||||
|
||||
HGEXPORT HGResult HGAPI HGSane_CloseSource(HGSaneSource source);
|
||||
|
|
|
@ -96,7 +96,8 @@ HGResult HGSaneManagerImpl::Create()
|
|||
sprintf(sanePath, "/usr/lib/%s-linux-gnu/sane/libsane-%s.so.1", archName.c_str(), manuName.c_str());
|
||||
pr.second = sanePath;
|
||||
|
||||
m_vSource.push_back(pr);
|
||||
if(!filterDeviceSource(pr.first.c_str()))
|
||||
m_vSource.push_back(pr);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
@ -159,6 +160,21 @@ HGResult HGSaneManagerImpl::OpenSource(HGUInt index, class HGSaneSourceImpl **so
|
|||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGSaneManagerImpl::OpenDefaultSource(HGSaneSourceImpl **sourceImpl)
|
||||
{
|
||||
HGSaneSourceImpl *newSourceImpl = new HGSaneSourceImpl(this);
|
||||
HGResult ret = newSourceImpl->Open(m_vSource[0].first.c_str(), m_vSource[0].second.c_str());
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
delete newSourceImpl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
m_listSourceImpl.push_back(newSourceImpl);
|
||||
*sourceImpl = newSourceImpl;
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGSaneManagerImpl::OpenSelectedSource(HGWindow parent, class HGSaneSourceImpl **sourceImpl)
|
||||
{
|
||||
if (NULL == sourceImpl)
|
||||
|
@ -222,6 +238,30 @@ void HGSaneManagerImpl::RemoveSource(class HGSaneSourceImpl* sourceImpl)
|
|||
}
|
||||
}
|
||||
|
||||
bool HGSaneManagerImpl::filterDeviceSource(const char *sourceName)
|
||||
{
|
||||
#if !defined(OEM_HANWANG) && !defined(OEM_LISICHENG) && !defined(OEM_CANGTIAN) && !defined(OEM_ZHONGJING) && !defined(OEM_ZIGUANG) && !defined(OEM_NEUTRAL)
|
||||
std::string oemIden = "hgsane";
|
||||
#elif defined(OEM_HANWANG)
|
||||
std::string oemIden = "hwsane";
|
||||
#elif defined(OEM_LISICHENG)
|
||||
std::string oemIden = "lscsane";
|
||||
#elif defined(OEM_CANGTIAN)
|
||||
std::string oemIden = "ctssane";
|
||||
#elif defined(OEM_ZHONGJING)
|
||||
std::string oemIden = "zjsane";
|
||||
#elif defined(OEM_ZIGUANG)
|
||||
std::string oemIden = "zgsane";
|
||||
#endif
|
||||
|
||||
if (sourceName != strstr(sourceName, oemIden.c_str()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
HGSaneSourceImpl::HGSaneSourceImpl(HGSaneManagerImpl *managerImpl)
|
||||
{
|
||||
|
@ -540,10 +580,9 @@ void HGSaneSourceImpl::RemoveDevice(class HGSaneDeviceImpl* deviceImpl)
|
|||
delete deviceImpl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HGSaneDeviceImpl::HGSaneDeviceImpl(HGSaneSourceImpl* sourceImpl)
|
||||
{
|
||||
m_sourceImpl = sourceImpl;
|
||||
|
@ -738,7 +777,7 @@ HGResult HGSaneDeviceImpl::ShowSettingDlg(HGWindow parent)
|
|||
HGResult HGSaneDeviceImpl::Start(HGWindow parent, HGSane_DeviceEventFunc eventFunc, HGPointer eventParam,
|
||||
HGSane_DeviceImageFunc imageFunc, HGPointer imageParam)
|
||||
{
|
||||
HGResult ret = GetValueInt32(0x8818, &m_dpi);
|
||||
HGResult ret = GetDpi(&m_dpi);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
|
@ -763,20 +802,20 @@ HGResult HGSaneDeviceImpl::StartWithSingleScan(HGWindow parent, HGSane_DeviceEve
|
|||
HGSane_DeviceImageFunc imageFunc, HGPointer imageParam)
|
||||
{
|
||||
HGChar scanMode[256] = {0};
|
||||
HGResult ret = GetValueStr256(0x882E, scanMode, 256);
|
||||
HGResult ret = GetScanMode(scanMode, 256);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGInt scanCount = 0;
|
||||
ret = GetValueInt32(0x882F, &scanCount);
|
||||
ret = GetScanCount(&scanCount);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = GetValueInt32(0x8818, &m_dpi);
|
||||
ret = GetDpi(&m_dpi);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
|
@ -784,8 +823,8 @@ HGResult HGSaneDeviceImpl::StartWithSingleScan(HGWindow parent, HGSane_DeviceEve
|
|||
|
||||
HGChar newScanMode[256] = {0};
|
||||
strcpy(newScanMode, OPTION_VALUE_SMZS_SMZDZS);
|
||||
SetValueStr256(0x882E, newScanMode);
|
||||
SetValueInt32(0x882F, 1);
|
||||
SetScanMode(newScanMode);
|
||||
SetScanCount(1);
|
||||
|
||||
m_eventFunc = eventFunc;
|
||||
m_eventParam = eventParam;
|
||||
|
@ -795,14 +834,14 @@ HGResult HGSaneDeviceImpl::StartWithSingleScan(HGWindow parent, HGSane_DeviceEve
|
|||
if (-2 == show_scan_ui(&m_sourceImpl->m_saneApi, m_devHandle, m_devName.c_str(), parent,
|
||||
show_scan_ui_event_func, this, show_scan_ui_image_func, this))
|
||||
{
|
||||
SetValueStr256(0x882E, scanMode);
|
||||
SetValueInt32(0x882F, scanCount);
|
||||
SetScanMode(scanMode);
|
||||
SetScanCount(scanCount);
|
||||
m_dpi = 0;
|
||||
return HGBASE_ERR_NOTSUPPORT;
|
||||
}
|
||||
|
||||
SetValueStr256(0x882E, scanMode);
|
||||
SetValueInt32(0x882F, scanCount);
|
||||
SetScanMode(scanMode);
|
||||
SetScanCount(scanCount);
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -861,6 +900,125 @@ HGResult HGSaneDeviceImpl::GetValueStr256(HGUInt optionId, HGChar *value, HGUInt
|
|||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGSaneDeviceImpl::GetDpi(HGInt *dpi)
|
||||
{
|
||||
SANE_Int dev_options = 0;
|
||||
SANE_Int method = 0;
|
||||
m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
||||
for (int i = 1; i < dev_options; ++i)
|
||||
{
|
||||
const SANE_Option_Descriptor* opt = m_sourceImpl->m_saneApi.sane_get_option_descriptor_api(m_devHandle, i);
|
||||
if (strcmp(opt->name, SANE_STD_OPT_NAME_RESOLUTION) == 0)
|
||||
{
|
||||
SANE_Int value = 0;
|
||||
SANE_Status ret = m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, &method);
|
||||
if (ret == SANE_STATUS_GOOD)
|
||||
{
|
||||
*dpi = (HGInt)value;
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
HGResult HGSaneDeviceImpl::GetScanMode(HGChar *scanMode, HGUInt maxLen)
|
||||
{
|
||||
if (NULL == scanMode || 0 == maxLen)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
SANE_Int dev_options = 0;
|
||||
SANE_Int method = 0;
|
||||
m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
||||
for (int i = 1; i < dev_options; ++i)
|
||||
{
|
||||
const SANE_Option_Descriptor* opt = m_sourceImpl->m_saneApi.sane_get_option_descriptor_api(m_devHandle, i);
|
||||
HGChar *value = (char*)malloc(opt->size * 2 + 4);
|
||||
if (strcmp(opt->name, SANE_STD_OPT_NAME_SCAN_MODE) == 0)
|
||||
{
|
||||
SANE_Status ret = m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, &method);
|
||||
if (ret == SANE_STATUS_GOOD)
|
||||
{
|
||||
strcpy(scanMode, value);
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
HGResult HGSaneDeviceImpl::GetScanCount(HGInt *scanCount)
|
||||
{
|
||||
SANE_Int dev_options = 0;
|
||||
SANE_Int method = 0;
|
||||
m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
||||
for (int i = 1; i < dev_options; ++i)
|
||||
{
|
||||
const SANE_Option_Descriptor* opt = m_sourceImpl->m_saneApi.sane_get_option_descriptor_api(m_devHandle, i);
|
||||
if (strcmp(opt->name, SANE_STD_OPT_NAME_SCAN_COUNT) == 0)
|
||||
{
|
||||
SANE_Int value = 0;
|
||||
SANE_Status ret = m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, &method);
|
||||
if (ret == SANE_STATUS_GOOD)
|
||||
{
|
||||
*scanCount = (HGInt)value;
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
HGResult HGSaneDeviceImpl::SetScanMode(const HGChar *scanMode)
|
||||
{
|
||||
SANE_Int dev_options = 0;
|
||||
SANE_Int method = 0;
|
||||
m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
||||
for (int i = 1; i < dev_options; ++i)
|
||||
{
|
||||
const SANE_Option_Descriptor* opt = m_sourceImpl->m_saneApi.sane_get_option_descriptor_api(m_devHandle, i);
|
||||
SANE_String value = (SANE_String)malloc(opt->size * 2 + 4);
|
||||
strcpy(value, scanMode);
|
||||
if (strcmp(opt->name, SANE_STD_OPT_NAME_SCAN_MODE) == 0)
|
||||
{
|
||||
SANE_Status ret = m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, i, SANE_ACTION_SET_VALUE, value, &method);
|
||||
if (ret == SANE_STATUS_GOOD)
|
||||
{
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
HGResult HGSaneDeviceImpl::SetScanCount(HGInt scanCount)
|
||||
{
|
||||
SANE_Int dev_options = 0;
|
||||
SANE_Int method = 0;
|
||||
m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
||||
for (int i = 1; i < dev_options; ++i)
|
||||
{
|
||||
const SANE_Option_Descriptor* opt = m_sourceImpl->m_saneApi.sane_get_option_descriptor_api(m_devHandle, i);
|
||||
SANE_Int value = (SANE_Int)scanCount;
|
||||
if (strcmp(opt->name, SANE_STD_OPT_NAME_SCAN_COUNT) == 0)
|
||||
{
|
||||
SANE_Status ret = m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, i, SANE_ACTION_SET_VALUE, &value, &method);
|
||||
if (ret == SANE_STATUS_GOOD)
|
||||
{
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
void HGSaneDeviceImpl::show_scan_ui_event_func(HGUInt event, HGPointer param)
|
||||
{
|
||||
HGSaneDeviceImpl* p = (HGSaneDeviceImpl*)param;
|
||||
|
|
|
@ -25,10 +25,12 @@ public:
|
|||
HGResult GetSourceCount(HGUInt *count);
|
||||
HGResult GetSourceName(HGUInt index, HGChar* name, HGUInt maxLen);
|
||||
HGResult OpenSource(HGUInt index, class HGSaneSourceImpl **sourceImpl);
|
||||
HGResult OpenDefaultSource(class HGSaneSourceImpl **sourceImpl);
|
||||
HGResult OpenSelectedSource(HGWindow parent, class HGSaneSourceImpl **sourceImpl);
|
||||
|
||||
private:
|
||||
void RemoveSource(class HGSaneSourceImpl* sourceImpl);
|
||||
bool filterDeviceSource(const char* sourceName);
|
||||
|
||||
private:
|
||||
std::vector<std::pair<std::string, std::string>> m_vSource;
|
||||
|
@ -53,7 +55,7 @@ public:
|
|||
|
||||
private:
|
||||
static HGResult FindFunctions(HGDll dll, const HGChar* saneManu, SANEAPI *saneAPI);
|
||||
void RemoveDevice(class HGSaneDeviceImpl* deviceImpl);
|
||||
void RemoveDevice(class HGSaneDeviceImpl* deviceImpl);
|
||||
|
||||
private:
|
||||
HGSaneManagerImpl *m_managerImpl;
|
||||
|
@ -92,6 +94,11 @@ private:
|
|||
HGResult GetValueInt32(HGUInt optionId, HGInt *value);
|
||||
HGResult SetValueStr256(HGUInt optionId, const HGChar *value);
|
||||
HGResult GetValueStr256(HGUInt optionId, HGChar *value, HGUInt maxLen);
|
||||
HGResult GetDpi(HGInt *dpi);
|
||||
HGResult GetScanMode(HGChar *scanMode, HGUInt maxLen);
|
||||
HGResult GetScanCount(HGInt *scanCount);
|
||||
HGResult SetScanMode(const HGChar *scanMode);
|
||||
HGResult SetScanCount(HGInt scanCount);
|
||||
static void show_scan_ui_event_func(HGUInt event, HGPointer param);
|
||||
static void show_scan_ui_image_func(HGImage image, HGPointer param);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef DEVICE_MENU_H
|
||||
#ifndef DEVICE_MENU_H
|
||||
#define DEVICE_MENU_H
|
||||
|
||||
#include <QMenu>
|
||||
|
@ -204,8 +204,8 @@ public:
|
|||
const SANE_Option_Descriptor* opt = saneApi->sane_get_option_descriptor_api(h, i);
|
||||
if(!opt)
|
||||
continue;
|
||||
|
||||
if (opt->type == SANE_TYPE_BUTTON || opt->type == SANE_TYPE_GROUP)
|
||||
|
||||
if (opt->type == SANE_TYPE_BUTTON || opt->type == SANE_TYPE_GROUP)
|
||||
continue;
|
||||
|
||||
saneApi->sane_control_option_api(h, i, SANE_ACTION_SET_AUTO, NULL, NULL);
|
||||
|
@ -215,7 +215,7 @@ public:
|
|||
}
|
||||
static SANE_Status get_default_value(const SANEAPI* saneApi, SANE_Handle h, int i, void* def)
|
||||
{
|
||||
return saneApi->sane_control_option_api(h, i, (SANE_Action)100, def, NULL);
|
||||
return saneApi->sane_control_option_api(h, i, (SANE_Action)100, def, NULL);
|
||||
}
|
||||
static SANE_Status set_custom_gamma(const SANEAPI* saneApi, SANE_Handle h, SANE_Gamma *gamma)
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
for(int i = 1; i < dev_options; ++i)
|
||||
{
|
||||
const SANE_Option_Descriptor* opt = saneApi->sane_get_option_descriptor_api(h, i);
|
||||
if(!opt)
|
||||
if(!opt || opt->type == SANE_TYPE_BUTTON || opt->type == SANE_TYPE_GROUP)
|
||||
continue;
|
||||
|
||||
unsigned int n = i;
|
||||
|
@ -311,11 +311,13 @@ public:
|
|||
}
|
||||
void add_scanner(const char* sane_name)
|
||||
{
|
||||
std::string devName = sane_name;
|
||||
|
||||
bool found = false;
|
||||
|
||||
for(auto& v: que_)
|
||||
{
|
||||
if(v.name == sane_name)
|
||||
if(v.name == devName)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
@ -327,7 +329,7 @@ public:
|
|||
SCANNER s;
|
||||
size_t pos = 0;
|
||||
|
||||
s.model = s.name = sane_name;
|
||||
s.model = s.name = devName;
|
||||
s.cfg = nullptr;
|
||||
pos = s.model.find(" - ");
|
||||
if(pos != std::string::npos)
|
||||
|
@ -379,11 +381,13 @@ public:
|
|||
{
|
||||
return applied_scheme_;
|
||||
}
|
||||
int open_scanner(const SANEAPI* saneAPI, SANE_Handle handle, const char* scanner_name, const char* scheme = nullptr)
|
||||
int open_scanner(const SANEAPI* saneAPI, SANE_Handle handle, const char* scanner_name, bool apply, const char* scheme = nullptr)
|
||||
{
|
||||
handle_ = handle;
|
||||
opened_scanner_ = scanner_name;
|
||||
apply_scheme(saneAPI, scheme);
|
||||
if (apply)
|
||||
apply_scheme(saneAPI, scheme);
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
int close_scanner(void)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "base/HGInc.h"
|
||||
#include <QMessageBox>
|
||||
#include <QCloseEvent>
|
||||
#include <QTimer>
|
||||
|
||||
Dialog_Device_Scan::Dialog_Device_Scan(const SANEAPI* saneApi, SANE_Handle dev, const char *devName,
|
||||
show_scan_ui_event_callback eventCallback, void *eventParam,
|
||||
|
@ -24,13 +25,26 @@ Dialog_Device_Scan::Dialog_Device_Scan(const SANEAPI* saneApi, SANE_Handle dev,
|
|||
m_thread = NULL;
|
||||
|
||||
setWindowTitle(QString::fromStdString(devName));
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowCloseButtonHint);
|
||||
m_timer = new QTimer(this);
|
||||
|
||||
ui->pushButton_Continue->setEnabled(true);
|
||||
ui->pushButton_Cancel->setEnabled(false);
|
||||
ui->pushButton_Complete->setEnabled(true);
|
||||
connect(this, SIGNAL(eventFunc(int, QString)), this, SLOT(on_eventFunc(int, QString)));
|
||||
connect(this, SIGNAL(imageCount(int)), this, SLOT(on_imageCount(int)));
|
||||
|
||||
on_pushButton_Continue_clicked();
|
||||
ui->pushButton_Cancel->setVisible(false);
|
||||
ui->pushButton_Complete->setVisible(true);
|
||||
|
||||
ui->label_imgRecived->setVisible(false);
|
||||
ui->lineEdit_imgRecived->setVisible(false);
|
||||
ui->label_totalImgRecived->setVisible(false);
|
||||
ui->lineEdit_imgRecived->setText(QString::number(0));
|
||||
|
||||
ui->label_imgUploaded->setVisible(false);
|
||||
ui->lineEdit_imgUploaded->setVisible(false);
|
||||
ui->label_totalImgUploaded->setVisible(false);
|
||||
ui->lineEdit_imgUploaded->setText(QString::number(0));
|
||||
|
||||
startScan();
|
||||
}
|
||||
|
||||
Dialog_Device_Scan::~Dialog_Device_Scan()
|
||||
|
@ -38,10 +52,17 @@ Dialog_Device_Scan::~Dialog_Device_Scan()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void Dialog_Device_Scan::on_eventFunc(QString errInfo)
|
||||
void Dialog_Device_Scan::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
ui->listWidget->addItem(errInfo);
|
||||
ui->listWidget->scrollToBottom();
|
||||
if (e->key() == Qt::Key_Escape)
|
||||
{
|
||||
e->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog_Device_Scan::on_eventFunc(int flag, QString errInfo)
|
||||
{
|
||||
ui->label->setText(errInfo);
|
||||
|
||||
m_stopThread = HGTRUE;
|
||||
m_saneAPI.sane_cancel_api(m_saneDev);
|
||||
|
@ -52,9 +73,23 @@ void Dialog_Device_Scan::on_eventFunc(QString errInfo)
|
|||
m_buffer = NULL;
|
||||
m_bufferSize = 0;
|
||||
|
||||
ui->pushButton_Continue->setEnabled(true);
|
||||
ui->pushButton_Cancel->setEnabled(false);
|
||||
ui->pushButton_Complete->setEnabled(true);
|
||||
ui->pushButton_Cancel->setVisible(false);
|
||||
ui->pushButton_Complete->setVisible(true);
|
||||
|
||||
ui->label_imgRecived->setVisible(false);
|
||||
ui->lineEdit_imgRecived->setVisible(false);
|
||||
ui->label_totalImgRecived->setVisible(false);
|
||||
|
||||
ui->label_imgUploaded->setVisible(false);
|
||||
ui->lineEdit_imgUploaded->setVisible(false);
|
||||
ui->label_totalImgUploaded->setVisible(true);
|
||||
ui->label_totalImgUploaded->setText(tr("Total scanned images: %1").arg(ui->lineEdit_imgRecived->text()));
|
||||
|
||||
if (0 == flag)
|
||||
{
|
||||
m_timer->start(1000);
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(on_pushButton_Complete_clicked()));
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog_Device_Scan::on_pushButton_Cancel_clicked()
|
||||
|
@ -65,9 +100,19 @@ void Dialog_Device_Scan::on_pushButton_Cancel_clicked()
|
|||
void Dialog_Device_Scan::on_pushButton_Complete_clicked()
|
||||
{
|
||||
accept();
|
||||
if (nullptr != m_eventCallback)
|
||||
{
|
||||
m_eventCallback(SHOW_SCAN_UI_EVENT_SCANFINISHED, m_eventParam);
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog_Device_Scan::on_pushButton_Continue_clicked()
|
||||
void Dialog_Device_Scan::on_imageCount(int count)
|
||||
{
|
||||
ui->lineEdit_imgRecived->setText(QString::number(count));
|
||||
ui->lineEdit_imgUploaded->setText(QString::number(count));
|
||||
}
|
||||
|
||||
void Dialog_Device_Scan::startScan()
|
||||
{
|
||||
SANE_Parameters params;
|
||||
memset(¶ms, 0, sizeof(SANE_Parameters));
|
||||
|
@ -78,20 +123,21 @@ void Dialog_Device_Scan::on_pushButton_Continue_clicked()
|
|||
m_buffer = (HGByte *)malloc(m_bufferSize);
|
||||
if (NULL == m_buffer)
|
||||
{
|
||||
ui->listWidget->addItem(tr("Out of memory"));
|
||||
ui->listWidget->scrollToBottom();
|
||||
ui->label->setText(tr("Out of memory"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_stopThread = HGFALSE;
|
||||
HGBase_OpenThread(ThreadFunc, this, &m_thread);
|
||||
|
||||
ui->pushButton_Continue->setEnabled(false);
|
||||
ui->pushButton_Cancel->setEnabled(true);
|
||||
ui->pushButton_Complete->setEnabled(false);
|
||||
ui->pushButton_Cancel->setVisible(true);
|
||||
ui->pushButton_Complete->setVisible(false);
|
||||
ui->label_imgRecived->setVisible(true);
|
||||
ui->lineEdit_imgRecived->setVisible(true);
|
||||
ui->label_imgUploaded->setVisible(true);
|
||||
ui->lineEdit_imgUploaded->setVisible(true);
|
||||
|
||||
ui->listWidget->addItem(tr("Start scan"));
|
||||
ui->listWidget->scrollToBottom();
|
||||
ui->label->setText(tr("Start scan"));
|
||||
}
|
||||
|
||||
void Dialog_Device_Scan::closeEvent(QCloseEvent *e)
|
||||
|
@ -111,7 +157,7 @@ void HGAPI Dialog_Device_Scan::ThreadFunc(HGThread thread, HGPointer param)
|
|||
SANE_Status stat = p->m_saneAPI.sane_start_api(p->m_saneDev);
|
||||
if (SANE_STATUS_GOOD != stat)
|
||||
{
|
||||
emit p->eventFunc(QString::fromUtf8(p->m_saneAPI.sane_strstatus_api(stat)));
|
||||
emit p->eventFunc(-1, QString::fromUtf8(p->m_saneAPI.sane_strstatus_api(stat)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -120,6 +166,7 @@ void HGAPI Dialog_Device_Scan::ThreadFunc(HGThread thread, HGPointer param)
|
|||
p->m_eventCallback(SHOW_SCAN_UI_EVENT_WORKING, p->m_eventParam);
|
||||
}
|
||||
|
||||
int imageCount = 0;
|
||||
while (!p->m_stopThread)
|
||||
{
|
||||
SANE_Parameters params;
|
||||
|
@ -142,19 +189,19 @@ void HGAPI Dialog_Device_Scan::ThreadFunc(HGThread thread, HGPointer param)
|
|||
if (SANE_STATUS_GOOD == stat2)
|
||||
{
|
||||
// m_bufferSize空间不够
|
||||
emit p->eventFunc(QString::fromUtf8(p->m_saneAPI.sane_strstatus_api(SANE_STATUS_INVAL)));
|
||||
emit p->eventFunc(-1, QString::fromUtf8(p->m_saneAPI.sane_strstatus_api(SANE_STATUS_INVAL)));
|
||||
break;
|
||||
}
|
||||
else if (SANE_STATUS_EOF == stat2)
|
||||
{
|
||||
if (0 == readSize)
|
||||
{
|
||||
emit p->eventFunc(tr("Scan complete"));
|
||||
emit p->eventFunc(0, tr("Scan complete"));
|
||||
break;
|
||||
}
|
||||
else if (SANE_STATUS_GOOD != stat1 || readSize != params.bytes_per_line * params.lines)
|
||||
{
|
||||
emit p->eventFunc(QString::fromUtf8(p->m_saneAPI.sane_strstatus_api(SANE_STATUS_INVAL)));
|
||||
emit p->eventFunc(-1, QString::fromUtf8(p->m_saneAPI.sane_strstatus_api(SANE_STATUS_INVAL)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +211,7 @@ void HGAPI Dialog_Device_Scan::ThreadFunc(HGThread thread, HGPointer param)
|
|||
}
|
||||
else
|
||||
{
|
||||
emit p->eventFunc(QString::fromUtf8(p->m_saneAPI.sane_strstatus_api(stat2)));
|
||||
emit p->eventFunc(-1, QString::fromUtf8(p->m_saneAPI.sane_strstatus_api(stat2)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -190,13 +237,9 @@ void HGAPI Dialog_Device_Scan::ThreadFunc(HGThread thread, HGPointer param)
|
|||
if (NULL != img)
|
||||
{
|
||||
p->m_imageCallback(img, p->m_imageParam);
|
||||
p->imageCount(++imageCount);
|
||||
HGBase_DestroyImage(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != p->m_eventCallback)
|
||||
{
|
||||
p->m_eventCallback(SHOW_SCAN_UI_EVENT_SCANFINISHED, p->m_eventParam);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,21 @@ public:
|
|||
show_scan_ui_image_callback imageCallback, void *imageParam, QWidget *parent = nullptr);
|
||||
~Dialog_Device_Scan();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
signals:
|
||||
void eventFunc(QString errInfo);
|
||||
void eventFunc(int flag, QString errInfo);
|
||||
void imageCount(int count);
|
||||
|
||||
private slots:
|
||||
void on_eventFunc(QString errInfo);
|
||||
void on_eventFunc(int flag, QString errInfo);
|
||||
void on_pushButton_Cancel_clicked();
|
||||
void on_pushButton_Complete_clicked();
|
||||
void on_pushButton_Continue_clicked();
|
||||
void on_imageCount(int count);
|
||||
|
||||
private:
|
||||
void startScan();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *e) override;
|
||||
|
@ -47,6 +54,8 @@ private:
|
|||
HGInt m_bufferSize;
|
||||
volatile HGBool m_stopThread;
|
||||
HGThread m_thread;
|
||||
|
||||
QTimer *m_timer;
|
||||
};
|
||||
|
||||
#endif // DIALOG_DEVICE_SCAN_H
|
||||
|
|
|
@ -6,21 +6,32 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>346</width>
|
||||
<height>219</height>
|
||||
<width>345</width>
|
||||
<height>163</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>345</width>
|
||||
<height>163</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>345</width>
|
||||
<height>163</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
@ -37,26 +48,221 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Continue">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Continue scan</string>
|
||||
<string/>
|
||||
</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>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<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_imgUploaded">
|
||||
<property name="text">
|
||||
<string>image uploaded:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_imgUploaded">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_totalImgUploaded">
|
||||
<property name="text">
|
||||
<string>total image uploaded:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<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_imgRecived">
|
||||
<property name="text">
|
||||
<string>image recived:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_imgRecived">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_totalImgRecived">
|
||||
<property name="text">
|
||||
<string>total image recived:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>11</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<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>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Cancel">
|
||||
<property name="text">
|
||||
<string>Cancel scan</string>
|
||||
<string>Cancel Scan</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Complete">
|
||||
<property name="text">
|
||||
<string>Complete scan</string>
|
||||
<string>Finish Scan</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -8,6 +8,7 @@ Dialog_Input::Dialog_Input(QWidget *parent) :
|
|||
ui(new Ui::Dialog_Input)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
}
|
||||
|
||||
Dialog_Input::~Dialog_Input()
|
||||
|
@ -34,23 +35,30 @@ void Dialog_Input::on_pushButton_clicked()
|
|||
}
|
||||
str.erase(pos + 1);
|
||||
|
||||
if(str.empty())
|
||||
// if(str.empty())
|
||||
// {
|
||||
// QString title(QString::fromStdString("\351\224\231\350\257\257")),
|
||||
// text(QString::fromStdString("\350\276\223\345\205\245\351\235\236\346\263\225"));
|
||||
|
||||
// QMessageBox::warning(this, title, text);
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (ui->lineEdit->text().isEmpty())
|
||||
{
|
||||
QString title(QString::fromStdString("\351\224\231\350\257\257")),
|
||||
text(QString::fromStdString("\350\276\223\345\205\245\351\235\236\346\263\225"));
|
||||
|
||||
QMessageBox::warning(this, title, text);
|
||||
|
||||
QMessageBox msg(QMessageBox::Information, tr("tips"), tr("The content can not be empty"), QMessageBox::Ok, this);
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
val_ = QString::fromStdString(str);
|
||||
done(1);
|
||||
accept();
|
||||
}
|
||||
|
||||
void Dialog_Input::on_pushButton_2_clicked()
|
||||
{
|
||||
done(0);
|
||||
reject();
|
||||
}
|
||||
|
||||
void Dialog_Input::init_value(const QString& str)
|
||||
|
@ -63,3 +71,15 @@ QString Dialog_Input::get_inputting_value(void)
|
|||
{
|
||||
return val_;
|
||||
}
|
||||
|
||||
QString Dialog_Input::getText()
|
||||
{
|
||||
QString text = ui->lineEdit->text();
|
||||
return text.toUtf8();
|
||||
}
|
||||
|
||||
void Dialog_Input::setEditText(const QString& text)
|
||||
{
|
||||
ui->lineEdit->setText(text);
|
||||
ui->lineEdit->selectAll();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
public:
|
||||
void init_value(const QString& str);
|
||||
QString get_inputting_value(void);
|
||||
QString getText();
|
||||
void setEditText(const QString& text);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "hg_settingdialog.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLatin1String>
|
||||
#include "cutpapertool.h"
|
||||
|
@ -13,7 +12,6 @@
|
|||
#include <typeinfo>
|
||||
#include "device_menu.h"
|
||||
#include "dialog_device_scan.h"
|
||||
|
||||
std::string hg_settingdialog::property_combox_data_type_ = "combox_value_type";
|
||||
|
||||
hg_settingdialog::hg_settingdialog(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, QWidget *parent)
|
||||
|
@ -21,19 +19,31 @@ hg_settingdialog::hg_settingdialog(const SANEAPI* saneApi, SANE_Handle handle, c
|
|||
, save_(false)
|
||||
, btn_cut_area_(nullptr), btn_gamma_(nullptr), clicked_gamma_(false)
|
||||
, custom_area_lable_(nullptr), comb_(nullptr)
|
||||
, m_devHandle(handle)
|
||||
, m_devName(devName)
|
||||
{
|
||||
HGChar cfgpath[512] = {0};
|
||||
QString old;
|
||||
HGBase_GetConfigPath(cfgpath, _countof(cfgpath) - 1);
|
||||
HGBase_GetConfigPath(cfgpath, 512);
|
||||
|
||||
HGBase_CreateDir(cfgpath);
|
||||
dev_que_.set_root_dir(cfgpath);
|
||||
old = QString::fromStdString(cfgpath) + PATH_SYMBOL + "scanner.schm";
|
||||
QString old = QString::fromStdString(cfgpath) + PATH_SYMBOL + "scanner.schm";
|
||||
if(QFile::exists(old))
|
||||
dev_que::update_old_cfg(old.toStdString().c_str());
|
||||
|
||||
dev_que_.add_scanner(devName);
|
||||
dev_que_.open_scanner(saneApi, handle, devName);
|
||||
int pid = 0;
|
||||
saneApi->sane_control_option_api(m_devHandle, (SANE_Int)0x8853, SANE_ACTION_GET_VALUE, &pid, NULL);
|
||||
|
||||
char buf[10] = { 0 };
|
||||
sprintf(buf, "%x", pid);
|
||||
std::string deviceName = m_devName;
|
||||
if (pid != 0)
|
||||
{
|
||||
deviceName = deviceName.substr(0, deviceName.find(" ")) + " " + buf;
|
||||
}
|
||||
dev_que_.add_scanner(deviceName.c_str());
|
||||
dev_que_.open_scanner(saneApi, handle, deviceName.c_str(), false);
|
||||
|
||||
std::string n(dev_que_.opened_scanner_name());
|
||||
for(int i = 0; i < dev_que_.scanners(); ++i)
|
||||
{
|
||||
|
@ -44,6 +54,7 @@ hg_settingdialog::hg_settingdialog(const SANEAPI* saneApi, SANE_Handle handle, c
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cur_scheme_ = cur_cfg_->get_scheme();
|
||||
if(!cur_scheme_)
|
||||
cur_scheme_ = new gb::sane_config_schm();
|
||||
|
@ -71,7 +82,6 @@ hg_settingdialog::hg_settingdialog(const SANEAPI* saneApi, SANE_Handle handle, c
|
|||
m_gammaData.table[i] = i & 0x0ff;
|
||||
|
||||
memcpy(&m_saneAPI, saneApi, sizeof(SANEAPI));
|
||||
m_devHandle = handle;
|
||||
|
||||
initUi();
|
||||
on_current_scheme_changed();
|
||||
|
@ -80,6 +90,10 @@ hg_settingdialog::hg_settingdialog(const SANEAPI* saneApi, SANE_Handle handle, c
|
|||
|
||||
hg_settingdialog::~hg_settingdialog()
|
||||
{
|
||||
QCoreApplication::removeTranslator(&m_translator);
|
||||
if (20127 != m_langCode)
|
||||
QCoreApplication::removeTranslator(&m_translator_qt);
|
||||
|
||||
cur_scheme_->release();
|
||||
cur_cfg_->release();
|
||||
}
|
||||
|
@ -164,6 +178,7 @@ void hg_settingdialog::updateOpt()
|
|||
char *init = (char*)malloc(opt->size * 2 + 4);
|
||||
|
||||
m_saneAPI.sane_control_option_api(m_devHandle, i, SANE_ACTION_GET_VALUE, init, &method);
|
||||
QString str = QString::fromStdString(init);
|
||||
m_list_defaultOptions.append(QPair<const void*, QVariant>(opt, QVariant(QString::fromStdString(init))));
|
||||
|
||||
if(first)
|
||||
|
@ -203,13 +218,14 @@ void hg_settingdialog::create_scheme_management_ui(QVBoxLayout* layout)
|
|||
{
|
||||
QLabel *title = new QLabel(this);
|
||||
bool enabled = false;
|
||||
QHBoxLayout *hbox = new QHBoxLayout();
|
||||
QHBoxLayout *hLayout = new QHBoxLayout();
|
||||
int width = 180;
|
||||
std::vector<std::string> schemes;
|
||||
std::string cur_schm(cur_cfg_->get_current_scheme_name());
|
||||
|
||||
cur_cfg_->get_all_schemes(schemes);
|
||||
comb_ = new QComboBox(this);
|
||||
comb_->addItem(tr("Default scheme"));
|
||||
layout->addSpacing(30);
|
||||
for(int i = 1; i < (int)schemes.size(); ++i)
|
||||
{
|
||||
|
@ -222,7 +238,7 @@ void hg_settingdialog::create_scheme_management_ui(QVBoxLayout* layout)
|
|||
}
|
||||
|
||||
if(!enabled)
|
||||
comb_->setCurrentIndex(-1);
|
||||
comb_->setCurrentIndex(0);
|
||||
|
||||
title->setFixedWidth(width);
|
||||
comb_->setFixedWidth(width);
|
||||
|
@ -231,35 +247,29 @@ void hg_settingdialog::create_scheme_management_ui(QVBoxLayout* layout)
|
|||
layout->addWidget(title);
|
||||
layout->addWidget(comb_);
|
||||
|
||||
rename_ = new QPushButton(this);
|
||||
rename_->setText(tr("change name"));
|
||||
rename_->setEnabled(enabled);
|
||||
rename_->setFixedWidth(width/3);
|
||||
hbox->addWidget(rename_);
|
||||
connect(rename_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
||||
layout->addSpacing(10);
|
||||
|
||||
m_pbtn_addNew = new QPushButton(this);
|
||||
m_pbtn_addNew->setText(tr("Add new"));
|
||||
m_pbtn_addNew->setFixedWidth(width / 2);
|
||||
layout->addWidget(m_pbtn_addNew);
|
||||
connect(m_pbtn_addNew, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
||||
|
||||
layout->addSpacing(10);
|
||||
|
||||
del_this_ = new QPushButton(this);
|
||||
del_this_->setText(tr("delete"));
|
||||
del_this_->setText(tr("Delete"));
|
||||
del_this_->setEnabled(enabled);
|
||||
del_this_->setFixedWidth(width / 3);
|
||||
hbox->addWidget(del_this_);
|
||||
del_this_->setFixedWidth(width / 2);
|
||||
layout->addWidget(del_this_);
|
||||
connect(del_this_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
||||
|
||||
apply_ = new QPushButton(this);
|
||||
apply_->setText(tr("apply"));
|
||||
apply_->setEnabled(enabled);
|
||||
apply_->setFixedWidth(width / 3);
|
||||
hbox->addWidget(apply_);
|
||||
connect(apply_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
||||
hbox->setSizeConstraint(QLayout::SetFixedSize);
|
||||
|
||||
layout->addLayout(hbox);
|
||||
layout->addSpacing(10);
|
||||
|
||||
del_all_ = new QPushButton(this);
|
||||
del_all_->setText(tr("delete all configurations"));
|
||||
del_all_->setText(tr("Delete all"));
|
||||
del_all_->setEnabled(enabled);
|
||||
del_all_->setFixedWidth(width);
|
||||
del_all_->setFixedWidth(width / 2);
|
||||
layout->addWidget(del_all_);
|
||||
connect(del_all_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
||||
|
||||
|
@ -281,6 +291,8 @@ void hg_settingdialog::createUI()
|
|||
{
|
||||
QTabWidget *tabWidgetCreation = new QTabWidget(this);
|
||||
|
||||
QPushButton *buttonAbout = new QPushButton(this);
|
||||
buttonAbout->setText(tr("about..."));
|
||||
QPushButton *buttonScan = new QPushButton(this);
|
||||
buttonScan->setText(tr("scan"));
|
||||
QPushButton *buttonOk = new QPushButton(this);
|
||||
|
@ -289,13 +301,26 @@ void hg_settingdialog::createUI()
|
|||
buttonCancel->setText(tr("cancel"));
|
||||
QHBoxLayout *hlayoutOkAndCancel = new QHBoxLayout;
|
||||
hlayoutOkAndCancel->addStretch();
|
||||
hlayoutOkAndCancel->addWidget(buttonAbout);
|
||||
hlayoutOkAndCancel->addWidget(buttonScan);
|
||||
hlayoutOkAndCancel->addWidget(buttonOk);
|
||||
hlayoutOkAndCancel->addWidget(buttonCancel);
|
||||
QWidget *widgetOkAndCancel = new QWidget();
|
||||
widgetOkAndCancel->setLayout(hlayoutOkAndCancel);
|
||||
connect(buttonAbout, SIGNAL(clicked(bool)), this, SLOT(slot_buttonAboutClicked()));
|
||||
connect(buttonScan, SIGNAL(clicked(bool)), this, SLOT(slot_buttonScanClicked()));
|
||||
connect(buttonOk, SIGNAL(clicked(bool)), this, SLOT(slot_buttonOkClicked()));
|
||||
connect(buttonCancel, SIGNAL(clicked(bool)), this, SLOT(slot_buttonCancelClicked()));
|
||||
|
||||
if (!m_showScan)
|
||||
{
|
||||
buttonScan->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonOk->setVisible(false);
|
||||
}
|
||||
|
||||
QHBoxLayout *h = new QHBoxLayout();
|
||||
QVBoxLayout *v1 = new QVBoxLayout(),
|
||||
*v2 = new QVBoxLayout();
|
||||
|
@ -1411,6 +1436,83 @@ void hg_settingdialog::slot_lineEditInput()
|
|||
free(buf);
|
||||
}
|
||||
}
|
||||
void hg_settingdialog::slot_buttonAboutClicked()
|
||||
{
|
||||
char info[256] = { 0 };
|
||||
SANE_Int data = 0;
|
||||
SANE_Status ret = SANE_STATUS_GOOD;
|
||||
QString content;
|
||||
QString title = tr("about ") + QString::fromStdString(m_devName);
|
||||
|
||||
ret = m_saneAPI.sane_control_option_api(m_devHandle, (SANE_Int)0x8855, SANE_ACTION_GET_VALUE, info, NULL);
|
||||
if (ret != SANE_STATUS_GOOD)
|
||||
{
|
||||
QString str = tr("Not supported");
|
||||
strcpy(info, str.toStdString().c_str());
|
||||
}
|
||||
content += tr("<p>Device model: %1</p>").arg(QString(info));
|
||||
info[0] = 0;
|
||||
ret = m_saneAPI.sane_control_option_api(m_devHandle, (SANE_Int)0x884A, SANE_ACTION_GET_VALUE, info, NULL);
|
||||
if (ret != SANE_STATUS_GOOD)
|
||||
{
|
||||
QString str = tr("Not supported");
|
||||
strcpy(info, str.toStdString().c_str());
|
||||
}
|
||||
content += tr("<p>Driver version: %1</p>").arg(QString(info));
|
||||
info[0] = 0;
|
||||
ret = m_saneAPI.sane_control_option_api(m_devHandle, (SANE_Int)0x8857, SANE_ACTION_GET_VALUE, info, NULL);
|
||||
if (ret != SANE_STATUS_GOOD)
|
||||
{
|
||||
QString str = tr("Not supported");
|
||||
strcpy(info, str.toStdString().c_str());
|
||||
}
|
||||
content += tr("<p>Firmware number: %1</p>").arg(QString(info));
|
||||
info[0] = 0;
|
||||
ret = m_saneAPI.sane_control_option_api(m_devHandle, (SANE_Int)0x8856, SANE_ACTION_GET_VALUE, info, NULL);
|
||||
if (ret != SANE_STATUS_GOOD)
|
||||
{
|
||||
QString str = tr("Not supported");
|
||||
strcpy(info, str.toStdString().c_str());
|
||||
}
|
||||
content += tr("<p>Serial number: %1</p>").arg(QString(info));
|
||||
info[0] = 0;
|
||||
|
||||
ret = m_saneAPI.sane_control_option_api(m_devHandle, (SANE_Int)0x9902, SANE_ACTION_GET_VALUE, &data, NULL);
|
||||
if (ret != SANE_STATUS_GOOD)
|
||||
{
|
||||
QString str = tr("Not supported");
|
||||
strcpy(info, str.toStdString().c_str());
|
||||
content += tr("<p>Roller count: %1</p>").arg(QString(info));
|
||||
info[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
content += tr("<p>Roller count: %1</p>").arg(QString::number(data));
|
||||
}
|
||||
|
||||
ret = m_saneAPI.sane_control_option_api(m_devHandle, (SANE_Int)0x8849, SANE_ACTION_GET_VALUE, &data, NULL);
|
||||
if (ret != SANE_STATUS_GOOD)
|
||||
{
|
||||
QString str = tr("Not supported");
|
||||
strcpy(info, str.toStdString().c_str());
|
||||
content += tr("<p>Roller count: %1</p>").arg(QString(info));
|
||||
info[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
content += tr("<p>History count: %1</p>").arg(QString::number(data));
|
||||
}
|
||||
|
||||
QMessageBox msg(QMessageBox::NoIcon, title,
|
||||
content, QMessageBox::Ok, this);
|
||||
msg.setStyleSheet("QLabel{""min-width: 250px;""}");
|
||||
msg.exec();
|
||||
}
|
||||
|
||||
void hg_settingdialog::slot_buttonScanClicked()
|
||||
{
|
||||
save_scheme();
|
||||
}
|
||||
|
||||
void hg_settingdialog::slot_buttonOkClicked()
|
||||
{
|
||||
|
@ -1438,51 +1540,9 @@ int hg_settingdialog::get_changed_items(void)
|
|||
return changed_count_;
|
||||
}
|
||||
|
||||
void hg_settingdialog::iniWrite(QString title, int id, QVariant value)
|
||||
gb::sane_config_schm *hg_settingdialog::getCurScheme()
|
||||
{
|
||||
(void)title;
|
||||
(void)id;
|
||||
(void)value;
|
||||
// m_qstrFileName = QCoreApplication::applicationDirPath() + "/config.ini";
|
||||
// m_configIniWrite = new QSettings(m_qstrFileName, QSettings::IniFormat);
|
||||
// m_configIniWrite->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
||||
// m_configIniWrite->setValue(title + "/id", id);
|
||||
// m_configIniWrite->setValue(title + "/value", value);
|
||||
|
||||
// delete m_configIniWrite;
|
||||
// m_configIniWrite = nullptr;
|
||||
}
|
||||
|
||||
void hg_settingdialog::iniRead(QString title, int id, QWidget *w)
|
||||
{
|
||||
(void)title;
|
||||
(void)id;
|
||||
(void)w;
|
||||
// m_configIniRead = new QSettings("config.ini", QSettings::IniFormat);
|
||||
// m_configIniRead->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
||||
// int id_ini = m_configIniRead->value(title + "/id").toInt();
|
||||
// QVariant value = m_configIniRead->value(title + "/value");
|
||||
|
||||
// if(id_ini == id)
|
||||
// {
|
||||
// if(typeid(*w) == typeid(QCheckBox))
|
||||
// reinterpret_cast<QCheckBox*>(w)->setChecked(value.toBool());
|
||||
|
||||
// else if(typeid(*w) == typeid(QSlider))
|
||||
// reinterpret_cast<QSlider*>(w)->setValue(value.toInt());
|
||||
|
||||
// else if(typeid(*w) == typeid(QSpinBox))
|
||||
// reinterpret_cast<QSpinBox*>(w)->setValue(value.toInt());
|
||||
|
||||
// else if(typeid(*w) == typeid(QDoubleSpinBox))
|
||||
// reinterpret_cast<QDoubleSpinBox*>(w)->setValue(value.toDouble());
|
||||
|
||||
// else if(typeid(*w) == typeid(QComboBox))
|
||||
// reinterpret_cast<QComboBox*>(w)->setCurrentText(value.toString());
|
||||
// }
|
||||
|
||||
// delete m_configIniRead;
|
||||
// m_configIniRead = nullptr;
|
||||
return cur_scheme_;
|
||||
}
|
||||
|
||||
//生成UTF-8编码的MD5值
|
||||
|
@ -1492,6 +1552,7 @@ QString hg_settingdialog::md5(QString key)
|
|||
md5.addData(key.toUtf8());
|
||||
return QString(md5.result().toHex());
|
||||
}
|
||||
|
||||
const void* hg_settingdialog::find_option_description(int id)
|
||||
{
|
||||
for(int i = 0; i < m_list_getOpt.size(); i++)
|
||||
|
@ -1502,6 +1563,7 @@ const void* hg_settingdialog::find_option_description(int id)
|
|||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const void* hg_settingdialog::find_option_description(const std::string& title, int* id)
|
||||
{
|
||||
for(int i = 0; i < m_list_getOpt.size(); i++)
|
||||
|
@ -1519,7 +1581,6 @@ const void* hg_settingdialog::find_option_description(const std::string& title,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void hg_settingdialog::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
if(e->type() == QEvent::Close) // consider as cancel ...
|
||||
|
@ -1705,10 +1766,12 @@ void hg_settingdialog::save_scheme(void)
|
|||
if(items == 0) // while shemes is default
|
||||
{
|
||||
cur_cfg_->select_scheme(nullptr);
|
||||
cur_cfg_->remove_scheme(cur_scheme_->get_scheme_name().c_str());
|
||||
cur_cfg_->save();
|
||||
return;
|
||||
}
|
||||
else
|
||||
add = createMsgBoxUi(add, name);
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
if(add)
|
||||
|
@ -1738,10 +1801,7 @@ void hg_settingdialog::save_scheme(void)
|
|||
sprintf(append, "-%d", ++ind);
|
||||
}
|
||||
}
|
||||
while(!cur_cfg_->add_scheme(cur_scheme_, (name + append).c_str()))
|
||||
{
|
||||
sprintf(append, "-%d", ++ind);
|
||||
}
|
||||
cur_cfg_->add_scheme(cur_scheme_, (name + append).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1769,6 +1829,7 @@ void hg_settingdialog::apply_current_scheme(void)
|
|||
{
|
||||
dev_que::apply_scheme(&m_saneAPI, m_devHandle, cur_scheme_);
|
||||
}
|
||||
|
||||
std::string sane_val_to_string(const char* val, SANE_Value_Type type)
|
||||
{
|
||||
char buf[128] = {0};
|
||||
|
@ -1796,6 +1857,35 @@ std::string sane_val_to_string(const char* val, SANE_Value_Type type)
|
|||
}
|
||||
void hg_settingdialog::on_current_scheme_changed()
|
||||
{
|
||||
del_this_->setEnabled(true);
|
||||
del_all_->setEnabled(false);
|
||||
|
||||
if (comb_->currentIndex() == 0)
|
||||
{
|
||||
del_this_->setEnabled(false);
|
||||
}
|
||||
if (comb_->count() > 1)
|
||||
{
|
||||
del_all_->setEnabled(true);
|
||||
}
|
||||
|
||||
QString text(find_current_scheme_menu());
|
||||
gb::sane_config_schm *cur = nullptr;
|
||||
|
||||
cur_cfg_->select_scheme(text.toStdString().c_str());
|
||||
cur = cur_cfg_->get_scheme();
|
||||
if(!cur)
|
||||
cur = new gb::sane_config_schm();
|
||||
cur->copy_default_value(cur_scheme_);
|
||||
cur_scheme_->end_setting(true);
|
||||
cur_scheme_->release();
|
||||
cur_scheme_ = cur;
|
||||
cur_scheme_->begin_setting();
|
||||
|
||||
apply_current_scheme();
|
||||
updateUIStatus();
|
||||
changed_count_++;
|
||||
|
||||
QString scheme(comb_->currentText());
|
||||
bool enabled = false;
|
||||
gb::sane_config_schm *schm = cur_cfg_->get_scheme(scheme.toStdString().c_str());
|
||||
|
@ -1803,10 +1893,6 @@ void hg_settingdialog::on_current_scheme_changed()
|
|||
if(schm)
|
||||
enabled = true;
|
||||
|
||||
rename_->setEnabled(enabled);
|
||||
apply_->setEnabled(enabled);
|
||||
del_this_->setEnabled(enabled);
|
||||
del_all_->setEnabled(enabled);
|
||||
memset(&m_gammaData, 0, sizeof(m_gammaData));
|
||||
for(int i = 0; i < sizeof(m_gammaData.table) / sizeof(m_gammaData.table[0]); ++i)
|
||||
m_gammaData.table[i] = i & 0x0ff;
|
||||
|
@ -1852,61 +1938,44 @@ void hg_settingdialog::slot_pushButton_scheme_management(void)
|
|||
{
|
||||
QPushButton* btn = qobject_cast<QPushButton*>(sender());
|
||||
|
||||
if(btn == rename_)
|
||||
if(btn == m_pbtn_addNew)
|
||||
{
|
||||
int id = 0;
|
||||
QString text(find_current_scheme_menu(&id));
|
||||
if(!text.isEmpty() && id >= 0)
|
||||
{
|
||||
Dialog_Input dlg;
|
||||
Dialog_Input dlg(this);
|
||||
|
||||
dlg.init_value(text);
|
||||
dlg.setWindowTitle(tr("configuration scheme name change"));
|
||||
if(dlg.exec() && text != dlg.get_inputting_value())
|
||||
dlg.setEditText(text);
|
||||
dlg.setWindowTitle(tr("Add new scheme"));
|
||||
if(dlg.exec())
|
||||
{
|
||||
std::vector<std::string> now;
|
||||
std::string str = dlg.get_inputting_value().toStdString();
|
||||
|
||||
cur_cfg_->get_all_schemes(now);
|
||||
for(auto& v: now)
|
||||
QString newCfgName = dlg.getText();
|
||||
for (int i = 0; i < comb_->count(); ++i)
|
||||
{
|
||||
if(v == str)
|
||||
if (newCfgName == comb_->itemText(i))
|
||||
{
|
||||
QMessageBox::information(this, tr("tips"), tr("scheme name: ") + QString::fromStdString(str) + tr(" already exists"));
|
||||
QMessageBox::information(this, tr("tips"), tr("The configuration scheme already exists"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
disconnect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed()));
|
||||
comb_->removeItem(id);
|
||||
comb_->insertItem(id, QString::fromStdString(str));
|
||||
comb_->setCurrentIndex(id);
|
||||
comb_->insertItem(id, newCfgName);
|
||||
connect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed()));
|
||||
|
||||
cur_cfg_->rename_scheme(text.toStdString().c_str(), str.c_str());
|
||||
gb::sane_config_schm *scheme = cur_scheme_->copy();
|
||||
cur_scheme_->end_setting(true);
|
||||
cur_scheme_->release();
|
||||
cur_scheme_ = scheme;
|
||||
cur_cfg_->add_scheme(cur_scheme_, newCfgName.toStdString().c_str());
|
||||
cur_cfg_->select_scheme(cur_scheme_->get_scheme_name().c_str());
|
||||
cur_cfg_->save();
|
||||
comb_->setCurrentIndex(id);
|
||||
changed_count_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(btn == apply_)
|
||||
{
|
||||
QString text(find_current_scheme_menu());
|
||||
gb::sane_config_schm *cur = nullptr;
|
||||
|
||||
cur_cfg_->select_scheme(text.toStdString().c_str());
|
||||
cur = cur_cfg_->get_scheme();
|
||||
if(!cur)
|
||||
cur = new gb::sane_config_schm();
|
||||
cur->copy_default_value(cur_scheme_);
|
||||
cur_scheme_->end_setting(true);
|
||||
cur_scheme_->release();
|
||||
cur_scheme_ = cur;
|
||||
cur_scheme_->begin_setting();
|
||||
|
||||
apply_current_scheme();
|
||||
updateUIStatus();
|
||||
changed_count_++;
|
||||
}
|
||||
else if(btn == del_this_)
|
||||
{
|
||||
int id = -1;
|
||||
|
@ -1946,6 +2015,7 @@ void hg_settingdialog::slot_pushButton_scheme_management(void)
|
|||
restore_2_default_settings();
|
||||
updateUIStatus();
|
||||
comb_->clear();
|
||||
comb_->addItem(tr("Default scheme"));
|
||||
changed_count_++;
|
||||
cur_cfg_->remove_all_schemes();
|
||||
cur_cfg_->save();
|
||||
|
@ -1964,5 +2034,6 @@ void hg_settingdialog::restore_2_default_settings(void)
|
|||
cur_scheme_ = s;
|
||||
cur_scheme_->begin_setting();
|
||||
|
||||
on_current_scheme_changed();
|
||||
// on_current_scheme_changed();
|
||||
comb_->setCurrentIndex(0);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <QtWidgets>
|
||||
#include <QSettings>
|
||||
#include <algorithm>
|
||||
#include "HGSaneUI.h"
|
||||
#include "cfg/gb_json.h"
|
||||
#include "device_menu.h"
|
||||
|
||||
|
@ -15,6 +14,7 @@ class hg_settingdialog : public QDialog
|
|||
int changed_count_;
|
||||
bool save_;
|
||||
bool clicked_gamma_;
|
||||
bool quit_ = false;
|
||||
dev_que dev_que_;
|
||||
gb::scanner_cfg *cur_cfg_;
|
||||
gb::sane_config_schm *cur_scheme_;
|
||||
|
@ -25,8 +25,7 @@ class hg_settingdialog : public QDialog
|
|||
|
||||
QMenu *top_menu_;
|
||||
QLineEdit *edit_name_;
|
||||
QPushButton *rename_;
|
||||
QPushButton *apply_;
|
||||
QPushButton *m_pbtn_addNew;
|
||||
QPushButton *del_this_;
|
||||
QPushButton *del_all_;
|
||||
QLabel *custom_area_lable_;
|
||||
|
@ -57,10 +56,17 @@ public:
|
|||
QVector<QWidget*> find_control(int opt_num);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
int get_changed_items(void);
|
||||
gb::sane_config_schm *getCurScheme();
|
||||
|
||||
private:
|
||||
static hg_settingdialog *hg_setting_ui_;
|
||||
SANEAPI m_saneAPI;
|
||||
SANE_Handle m_devHandle;
|
||||
bool m_showScan;
|
||||
std::string m_devName;
|
||||
QTranslator m_translator;
|
||||
QTranslator m_translator_qt;
|
||||
int m_langCode;
|
||||
|
||||
private:
|
||||
QString m_qstrFileName;
|
||||
|
@ -68,8 +74,6 @@ private:
|
|||
QSettings *m_configIniRead;
|
||||
|
||||
private:
|
||||
void iniWrite(QString title, int id, QVariant value);
|
||||
void iniRead(QString title, int id, QWidget *w);
|
||||
QString md5(QString key);
|
||||
const void* find_option_description(int id); // return const SANE_Option_Descriptor* pointer
|
||||
const void* find_option_description(const std::string& title, int* id); // return const SANE_Option_Descriptor* pointer
|
||||
|
@ -101,6 +105,8 @@ private slots:
|
|||
void slot_gammaButtonClicked();
|
||||
void slot_word_list_comboBoxClicked(int value);
|
||||
void slot_lineEditInput();
|
||||
void slot_buttonAboutClicked();
|
||||
void slot_buttonScanClicked();
|
||||
void slot_buttonOkClicked();
|
||||
void slot_buttonCancelClicked();
|
||||
void slot_pushButton_scheme_management(void);
|
||||
|
|
Loading…
Reference in New Issue