synchronize from dev branch

This commit is contained in:
gb 2023-09-23 11:17:08 +08:00
parent d0f1ff82f7
commit 436ac96be8
1320 changed files with 4733 additions and 258859 deletions

View File

@ -1,4 +1,7 @@
<RCC> <RCC>
<qresource prefix="/qt">
<file>etc/qt.conf</file>
</qresource>
<qresource prefix="/translation"> <qresource prefix="/translation">
<file>FWUpgrade_zh_CN.qm</file> <file>FWUpgrade_zh_CN.qm</file>
<file>qt_zh_CN.qm</file> <file>qt_zh_CN.qm</file>

Binary file not shown.

View File

@ -269,7 +269,7 @@
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="211"/> <location filename="mainwindow.ui" line="211"/>
<location filename="mainwindow.cpp" line="462"/> <location filename="mainwindow.cpp" line="491"/>
<source>Have not corrected</source> <source>Have not corrected</source>
<translation></translation> <translation></translation>
</message> </message>
@ -326,19 +326,19 @@
<translation type="vanished">%1%2</translation> <translation type="vanished">%1%2</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="411"/> <location filename="mainwindow.cpp" line="439"/>
<location filename="mainwindow.cpp" line="518"/> <location filename="mainwindow.cpp" line="548"/>
<location filename="mainwindow.cpp" line="519"/> <location filename="mainwindow.cpp" line="549"/>
<location filename="mainwindow.cpp" line="520"/>
<location filename="mainwindow.cpp" line="532"/>
<location filename="mainwindow.cpp" line="544"/>
<location filename="mainwindow.cpp" line="550"/> <location filename="mainwindow.cpp" line="550"/>
<location filename="mainwindow.cpp" line="880"/> <location filename="mainwindow.cpp" line="562"/>
<location filename="mainwindow.cpp" line="881"/> <location filename="mainwindow.cpp" line="574"/>
<location filename="mainwindow.cpp" line="580"/>
<location filename="mainwindow.cpp" line="913"/> <location filename="mainwindow.cpp" line="913"/>
<location filename="mainwindow.cpp" line="914"/> <location filename="mainwindow.cpp" line="914"/>
<location filename="mainwindow.cpp" line="948"/> <location filename="mainwindow.cpp" line="946"/>
<location filename="mainwindow.cpp" line="949"/> <location filename="mainwindow.cpp" line="947"/>
<location filename="mainwindow.cpp" line="982"/>
<location filename="mainwindow.cpp" line="983"/>
<source>do not support</source> <source>do not support</source>
<translation></translation> <translation></translation>
</message> </message>
@ -347,27 +347,27 @@
<translation type="vanished">%1</translation> <translation type="vanished">%1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="580"/> <location filename="mainwindow.cpp" line="611"/>
<source>no device opened</source> <source>no device opened</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="625"/> <location filename="mainwindow.cpp" line="656"/>
<location filename="mainwindow.cpp" line="670"/> <location filename="mainwindow.cpp" line="701"/>
<location filename="mainwindow.cpp" line="680"/> <location filename="mainwindow.cpp" line="711"/>
<location filename="mainwindow.cpp" line="703"/> <location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="753"/> <location filename="mainwindow.cpp" line="786"/>
<location filename="mainwindow.cpp" line="817"/> <location filename="mainwindow.cpp" line="850"/>
<location filename="mainwindow.cpp" line="833"/> <location filename="mainwindow.cpp" line="866"/>
<location filename="mainwindow.cpp" line="840"/> <location filename="mainwindow.cpp" line="873"/>
<location filename="mainwindow.cpp" line="847"/> <location filename="mainwindow.cpp" line="880"/>
<location filename="mainwindow.cpp" line="854"/> <location filename="mainwindow.cpp" line="887"/>
<location filename="mainwindow.cpp" line="863"/> <location filename="mainwindow.cpp" line="896"/>
<source>tips</source> <source>tips</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="625"/> <location filename="mainwindow.cpp" line="656"/>
<source>no version available</source> <source>no version available</source>
<translation></translation> <translation></translation>
</message> </message>
@ -376,7 +376,7 @@
<translation type="vanished"></translation> <translation type="vanished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="656"/> <location filename="mainwindow.cpp" line="687"/>
<source>Open File</source> <source>Open File</source>
<translation></translation> <translation></translation>
</message> </message>
@ -385,9 +385,9 @@
<translation type="vanished">(* .zip)</translation> <translation type="vanished">(* .zip)</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="744"/> <location filename="mainwindow.cpp" line="776"/>
<location filename="mainwindow.cpp" line="764"/> <location filename="mainwindow.cpp" line="797"/>
<location filename="mainwindow.cpp" line="785"/> <location filename="mainwindow.cpp" line="818"/>
<source>device: %1 upgrade firmware success</source> <source>device: %1 upgrade firmware success</source>
<translation>%1 </translation> <translation>%1 </translation>
</message> </message>
@ -400,24 +400,24 @@
<translation type="vanished">: %1, : %2, : %3</translation> <translation type="vanished">: %1, : %2, : %3</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="518"/> <location filename="mainwindow.cpp" line="548"/>
<source>support</source> <source>support</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="518"/> <location filename="mainwindow.cpp" line="548"/>
<source>upgrade: %1</source> <source>upgrade: %1</source>
<oldsource>upgrade: %2</oldsource> <oldsource>upgrade: %2</oldsource>
<translation>: %1</translation> <translation>线: %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="656"/> <location filename="mainwindow.cpp" line="687"/>
<source>ZIP Files(*.zip *.zip)</source> <source>ZIP Files(*.zip *.zip)</source>
<translation>(*.zip)</translation> <translation>(*.zip)</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="670"/> <location filename="mainwindow.cpp" line="701"/>
<location filename="mainwindow.cpp" line="703"/> <location filename="mainwindow.cpp" line="734"/>
<source>the selected firmware is not newer than the current version</source> <source>the selected firmware is not newer than the current version</source>
<translation></translation> <translation></translation>
</message> </message>
@ -426,7 +426,7 @@
<translation type="vanished"></translation> <translation type="vanished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="681"/> <location filename="mainwindow.cpp" line="712"/>
<source>firmware file mismatch, continue?</source> <source>firmware file mismatch, continue?</source>
<translation></translation> <translation></translation>
</message> </message>
@ -439,99 +439,98 @@
<translation type="vanished">: %1, : %2</translation> <translation type="vanished">: %1, : %2</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="519"/> <location filename="mainwindow.cpp" line="549"/>
<source>FirmWare number: %1</source> <source>FirmWare number: %1</source>
<translation>: %1</translation> <translation>: %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="520"/> <location filename="mainwindow.cpp" line="550"/>
<source>Serial number: %1</source> <source>Serial number: %1</source>
<translation>: %1</translation> <translation>: %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="521"/> <location filename="mainwindow.cpp" line="551"/>
<source>speed mode: %1</source> <source>speed mode: %1</source>
<translation>: %1</translation> <translation>: %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="550"/> <location filename="mainwindow.cpp" line="580"/>
<source>Motor Version: %1</source> <source>Motor Version: %1</source>
<translation> %1</translation> <translation> %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="571"/> <location filename="mainwindow.cpp" line="602"/>
<source>Device is opened by other process</source> <source>Device is opened by other process</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="575"/> <location filename="mainwindow.cpp" line="606"/>
<source>open device error</source> <source>open device error</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="748"/> <location filename="mainwindow.cpp" line="801"/>
<location filename="mainwindow.cpp" line="768"/> <location filename="mainwindow.cpp" line="822"/>
<location filename="mainwindow.cpp" line="789"/>
<source>device: %1 upgrade firmware failed, io error</source> <source>device: %1 upgrade firmware failed, io error</source>
<translation>%1 IO错误</translation> <translation>%1 IO错误</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="753"/> <location filename="mainwindow.cpp" line="786"/>
<source>download firmware fail</source> <source>download firmware fail</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="808"/> <location filename="mainwindow.cpp" line="841"/>
<source>Roller scanned count has been set to 0.</source> <source>Roller scanned count has been set to 0.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="812"/> <location filename="mainwindow.cpp" line="845"/>
<source>Do not supported</source> <source>Do not supported</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="815"/> <location filename="mainwindow.cpp" line="848"/>
<source>Roller scanned count reset failed.</source> <source>Roller scanned count reset failed.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="833"/> <location filename="mainwindow.cpp" line="866"/>
<source>old password is wrong</source> <source>old password is wrong</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="840"/> <location filename="mainwindow.cpp" line="873"/>
<source>new password can not be empty</source> <source>new password can not be empty</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="847"/> <location filename="mainwindow.cpp" line="880"/>
<source>new password is inconsistent</source> <source>new password is inconsistent</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="854"/> <location filename="mainwindow.cpp" line="887"/>
<source>modify password fail</source> <source>modify password fail</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="863"/> <location filename="mainwindow.cpp" line="896"/>
<source>modify password success</source> <source>modify password success</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="944"/> <location filename="mainwindow.cpp" line="978"/>
<source>correcting...</source> <source>correcting...</source>
<translation>...</translation> <translation>...</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="964"/> <location filename="mainwindow.cpp" line="998"/>
<source>Export special test paper</source> <source>Export special test paper</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="964"/> <location filename="mainwindow.cpp" line="998"/>
<source>jpg(*.jpg)</source> <source>jpg(*.jpg)</source>
<translation>jpg(*.jpg)</translation> <translation>jpg(*.jpg)</translation>
</message> </message>
@ -540,107 +539,114 @@
<translation type="vanished"></translation> <translation type="vanished"></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="289"/> <location filename="mainwindow.cpp" line="316"/>
<location filename="mainwindow.cpp" line="304"/> <location filename="mainwindow.cpp" line="331"/>
<location filename="mainwindow.cpp" line="881"/> <location filename="mainwindow.cpp" line="776"/>
<location filename="mainwindow.cpp" line="887"/> <location filename="mainwindow.cpp" line="780"/>
<location filename="mainwindow.cpp" line="914"/> <location filename="mainwindow.cpp" line="914"/>
<location filename="mainwindow.cpp" line="920"/> <location filename="mainwindow.cpp" line="920"/>
<location filename="mainwindow.cpp" line="927"/> <location filename="mainwindow.cpp" line="947"/>
<location filename="mainwindow.cpp" line="948"/> <location filename="mainwindow.cpp" line="953"/>
<location filename="mainwindow.cpp" line="955"/> <location filename="mainwindow.cpp" line="960"/>
<location filename="mainwindow.cpp" line="982"/>
<location filename="mainwindow.cpp" line="989"/>
<source>Prompt</source> <source>Prompt</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="53"/> <location filename="mainwindow.cpp" line="63"/>
<location filename="mainwindow.cpp" line="927"/> <location filename="mainwindow.cpp" line="960"/>
<source>Please confirm that the device has correctly placed the calibration paper!</source> <source>Please confirm that the device has correctly placed the calibration paper!</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="54"/> <location filename="mainwindow.cpp" line="64"/>
<source>Prompt of Hualing device</source> <source>Prompt of Hualing device</source>
<oldsource>Prompt of Hualin device</oldsource> <oldsource>Prompt of Hualin device</oldsource>
<translation>&quot;&quot;</translation> <translation>&quot;&quot;</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="55"/> <location filename="mainwindow.cpp" line="65"/>
<source>Please confirm that the device has placed a special scanning test paper for distortion correction!</source> <source>Please confirm that the device has placed a special scanning test paper for distortion correction!</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="221"/> <location filename="mainwindow.cpp" line="248"/>
<source>Warning</source> <source>Warning</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="221"/> <location filename="mainwindow.cpp" line="248"/>
<source>Device is Running! please wait for the process to end.</source> <source>Device is Running! please wait for the process to end.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="288"/> <location filename="mainwindow.cpp" line="315"/>
<location filename="mainwindow.cpp" line="289"/> <location filename="mainwindow.cpp" line="316"/>
<source>Count distortion failed</source> <source>Count distortion failed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="295"/> <location filename="mainwindow.cpp" line="322"/>
<source>Count distortion succeed: %1</source> <source>Count distortion succeed: %1</source>
<translation>: %1</translation> <translation>: %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="458"/> <location filename="mainwindow.cpp" line="487"/>
<location filename="mainwindow.cpp" line="528"/> <location filename="mainwindow.cpp" line="558"/>
<location filename="mainwindow.cpp" line="807"/> <location filename="mainwindow.cpp" line="840"/>
<source>roll count: %1</source> <source>roll count: %1</source>
<translation> %1</translation> <translation> %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="459"/> <location filename="mainwindow.cpp" line="488"/>
<location filename="mainwindow.cpp" line="540"/> <location filename="mainwindow.cpp" line="570"/>
<source>scan count: %1</source> <source>scan count: %1</source>
<translation> %1</translation> <translation> %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="886"/> <location filename="mainwindow.cpp" line="781"/>
<source>device: %1 upgrade firmware failed: %2</source>
<translation>%1 : %2</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="919"/>
<source>Get distortion failed</source> <source>Get distortion failed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="887"/> <location filename="mainwindow.cpp" line="920"/>
<source>Get failed</source> <source>Get failed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="892"/> <location filename="mainwindow.cpp" line="925"/>
<source>Get distortion succeed: %1</source> <source>Get distortion succeed: %1</source>
<translation>: %1</translation> <translation>: %1</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="971"/> <location filename="mainwindow.cpp" line="1005"/>
<source>Color mode: %1, Dpi: %2</source> <source>Color mode: %1, Dpi: %2</source>
<translation>: %1, :%2</translation> <translation>: %1, :%2</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="919"/> <location filename="mainwindow.cpp" line="952"/>
<location filename="mainwindow.cpp" line="920"/> <location filename="mainwindow.cpp" line="953"/>
<source>Set failed</source> <source>Set failed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="909"/> <location filename="mainwindow.cpp" line="942"/>
<source>Set succeed</source> <source>Set succeed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="955"/> <location filename="mainwindow.cpp" line="989"/>
<source>Correct failed</source> <source>Correct failed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="300"/> <location filename="mainwindow.cpp" line="327"/>
<source>Have already corrected</source> <source>Have already corrected</source>
<translation></translation> <translation></translation>
</message> </message>

View File

@ -47,10 +47,15 @@ void HGAPI Dialog_upgradeFirmware::ThreadFunc(HGThread thread, HGPointer param)
(void)thread; (void)thread;
Dialog_upgradeFirmware *p = (Dialog_upgradeFirmware *)param; Dialog_upgradeFirmware *p = (Dialog_upgradeFirmware *)param;
if (SANE_STATUS_GOOD == sane_io_control(p->m_handle, IO_CTRL_CODE_SET_FIRMWARE_UPGRADE, (void*)p->m_filePath.c_str(), nullptr)) SANE_Status ret = sane_io_control(p->m_handle, IO_CTRL_CODE_SET_FIRMWARE_UPGRADE, (void*)p->m_filePath.c_str(), nullptr);
if (SANE_STATUS_GOOD == ret)
{ {
p->m_result = 0; p->m_result = 0;
} }
else
{
p->m_result = ret;
}
emit p->finish(); emit p->finish();
} }

View File

@ -0,0 +1,2 @@
[Platforms]
WindowsArguments = dpiawareness=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -34,8 +34,6 @@ MainWindow::MainWindow(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->tabWidget->removeTab(4);
m_curDevName.clear(); m_curDevName.clear();
m_curDevHandle = nullptr; m_curDevHandle = nullptr;
m_curFwVersion.clear(); m_curFwVersion.clear();
@ -170,11 +168,28 @@ QString MainWindow::GetDevType(const QString& fwVersion, bool *canLock)
{ {
QString dev = fwVersion.left(2); QString dev = fwVersion.left(2);
if (fwVersion.mid(2, 2) == "40" || fwVersion.mid(2, 2) == "50" if (fwVersion.mid(2, 2) == "40" || fwVersion.mid(2, 2) == "50"
|| fwVersion.mid(2, 2) == "60" || fwVersion.mid(2, 2) == "70") || fwVersion.mid(2, 2) == "60" || fwVersion.mid(2, 2) == "70"
|| fwVersion.mid(2, 2) == "80" || fwVersion.mid(2, 2) == "90")
{ {
// 3288 // 3288
QString ver = fwVersion.mid(2, 2); QString ppm = fwVersion.mid(2, 2);
QString date = fwVersion.mid(4, 6); QString date = fwVersion.mid(4, 6);
if (dev == "G3")
{
if (date >= "220424" && date <= "230105")
{
devType = dev + "x0" + "/" + "220424-230105";
}
else if (date >= "230106" && date <= "230305")
{
devType = dev + "x0" + "/" + "230106-230305";
}
else if (date >= "230306")
{
devType = dev + "x0" + "/" + "230306-";
}
}
} }
else else
{ {
@ -567,8 +582,8 @@ void MainWindow::on_comboDevList_currentIndexChanged(int index)
if (!devType.isEmpty()) if (!devType.isEmpty())
{ {
ui->btnGetVersionList->setEnabled(true); ui->btnGetVersionList->setEnabled(true);
ui->btnOpenFilePath->setEnabled(true);
} }
ui->btnOpenFilePath->setEnabled(true);
ui->btnClearRollCount->setEnabled(true); ui->btnClearRollCount->setEnabled(true);
bool isAndroid = isAndroidDevice(); bool isAndroid = isAndroidDevice();
@ -755,13 +770,15 @@ void MainWindow::on_btnDownloadUpgrade_clicked()
{ {
Dialog_upgradeFirmware dlg(m_curDevHandle, savePath, this); Dialog_upgradeFirmware dlg(m_curDevHandle, savePath, this);
dlg.exec(); dlg.exec();
if (0 == dlg.getUpgradeStatus()) int status = dlg.getUpgradeStatus();
if (0 == status)
{ {
ui->labelDevInfo->setText(QString(tr("device: %1 upgrade firmware success")).arg(m_curDevName)); QMessageBox::information(this, tr("Prompt"), QString(tr("device: %1 upgrade firmware success")).arg(m_curDevName));
} }
else else
{ {
ui->labelDevInfo->setText(QString(tr("device: %1 upgrade firmware failed, io error")).arg(m_curDevName)); QMessageBox::information(this, tr("Prompt"),
QString(tr("device: %1 upgrade firmware failed: %2")).arg(m_curDevName).arg(sane_strstatus((SANE_Status)status)));
} }
} }
else else
@ -796,13 +813,15 @@ void MainWindow::on_btnUpgrade_clicked()
{ {
Dialog_upgradeFirmware dlg(m_curDevHandle, filePath, this); Dialog_upgradeFirmware dlg(m_curDevHandle, filePath, this);
dlg.exec(); dlg.exec();
if (0 == dlg.getUpgradeStatus()) int status = dlg.getUpgradeStatus();
if (0 == status)
{ {
ui->labelDevInfo->setText(QString(tr("device: %1 upgrade firmware success")).arg(m_curDevName)); QMessageBox::information(this, tr("Prompt"), QString(tr("device: %1 upgrade firmware success")).arg(m_curDevName));
} }
else else
{ {
ui->labelDevInfo->setText(QString(tr("device: %1 upgrade firmware failed, io error")).arg(m_curDevName)); QMessageBox::information(this, tr("Prompt"),
QString(tr("device: %1 upgrade firmware failed: %2")).arg(m_curDevName).arg(sane_strstatus((SANE_Status)status)));
} }
} }
} }

View File

@ -551,7 +551,7 @@
<rect> <rect>
<x>80</x> <x>80</x>
<y>10</y> <y>10</y>
<width>108</width> <width>491</width>
<height>31</height> <height>31</height>
</rect> </rect>
</property> </property>

View File

@ -1,55 +0,0 @@
#include "base/HGDef.h"
#include "base/HGInc.h"
#include <string>
#include "base/HGUtility.h"
#include "imgfmt/HGImgFmt.h"
#include "imgproc/HGOCR.h"
int main(int argc, char *argv[])
{
std::string filePath;
for (int i = 1; i < argc; i++)
{
char* z = argv[i];
if (z == strstr(z, "-filePath="))
filePath = z + strlen("-filePath=");
}
int ret = -1;
HGOCRMgr ocrMgr = NULL;
HGImgProc_CreateOCRMgr(HGIMGPROC_OCRALGO_DEFAULT, &ocrMgr);
if (NULL == ocrMgr)
{
return ret;
}
HGImgFmtReader reader = NULL;
HGImgFmt_OpenImageReader(filePath.c_str(), 0, &reader);
if (NULL != reader)
{
HGUInt count = 0;
HGImgFmt_GetImagePageCount(reader, &count);
for (HGUInt i = 0; i < count; ++i)
{
HGImage image = NULL;
HGImgFmt_LoadImageFromReader(reader, i, NULL, 0, 0, &image);
if (NULL != image)
{
HGImgProc_AddToImageOCRList(ocrMgr, image);
HGBase_DestroyImage(image);
}
}
HGImgFmt_CloseImageReader(reader);
}
HGBase_DeleteFile(filePath.c_str());
if (HGBASE_ERR_OK == HGImgProc_ImageListOCRToFile(ocrMgr, 0, filePath.c_str(), NULL, NULL))
{
ret = 0;
}
HGImgProc_DestroyOCRMgr(ocrMgr);
return ret;
}

View File

@ -1,4 +1,7 @@
<RCC> <RCC>
<qresource prefix="/qt">
<file>etc/qt.conf</file>
</qresource>
<qresource prefix="/translation"> <qresource prefix="/translation">
<file>Scanner_zh_CN.qm</file> <file>Scanner_zh_CN.qm</file>
<file>qt_zh_CN.qm</file> <file>qt_zh_CN.qm</file>

View File

@ -36,7 +36,7 @@ void Dialog_Feedback::on_pbtn_submit_clicked()
#elif defined(OEM_ZIGUANG) #elif defined(OEM_ZIGUANG)
oemName = HGVERSION_OEMNAME_UNIS; oemName = HGVERSION_OEMNAME_UNIS;
#elif defined(OEM_NEUTRAL) #elif defined(OEM_NEUTRAL)
oemName = HGVERSION_OEMNAME_HUAGAO_NEU; oemName = HGVERSION_OEMNAME_NEUTRAL;
#elif defined(OEM_DELI) #elif defined(OEM_DELI)
oemName = HGVERSION_OEMNAME_DELI; oemName = HGVERSION_OEMNAME_DELI;
#else #else

View File

@ -78,25 +78,12 @@ void Dialog_FullScreen::showImage()
assert(!m_currFilePath.isEmpty()); assert(!m_currFilePath.isEmpty());
HGImage img = nullptr; HGImage img = nullptr;
HGImgFmtReader imgFmtReader = nullptr;
HGPdfReader pdfReader = nullptr; HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
HGImgFmt_OpenPdfReader(getStdString(m_currFilePath).c_str(), &pdfReader); if (nullptr != imgFmtReader)
if (nullptr != pdfReader)
{ {
float scale = 200.0f / 72.0f; HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
HGImgFmt_LoadImageFromPdfReader(pdfReader, (HGUInt)m_multiIndex, scale, scale, 0, HGBASE_IMGORIGIN_TOP, &img); HGImgFmt_CloseImageReader(imgFmtReader);
HGBase_SetImageDpi(img, 200, 200);
HGImgFmt_ClosePdfReader(pdfReader);
}
else
{
HGImgFmtReader imgFmtReader = nullptr;
HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
if (nullptr != imgFmtReader)
{
HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
HGImgFmt_CloseImageReader(imgFmtReader);
}
} }
if (nullptr != img) if (nullptr != img)

View File

@ -30,7 +30,7 @@ Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *vers
#elif defined(OEM_ZIGUANG) #elif defined(OEM_ZIGUANG)
oemName = HGVERSION_OEMNAME_UNIS; oemName = HGVERSION_OEMNAME_UNIS;
#elif defined(OEM_NEUTRAL) #elif defined(OEM_NEUTRAL)
oemName = HGVERSION_OEMNAME_HUAGAO_NEU; oemName = HGVERSION_OEMNAME_NEUTRAL;
#elif defined(OEM_DELI) #elif defined(OEM_DELI)
oemName = HGVERSION_OEMNAME_DELI; oemName = HGVERSION_OEMNAME_DELI;
#else #else

2
app/scanner/etc/qt.conf Normal file
View File

@ -0,0 +1,2 @@
[Platforms]
WindowsArguments = dpiawareness=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -1746,26 +1746,12 @@ HGImage MainWindow::createImage()
assert(!m_currFilePath.isEmpty()); assert(!m_currFilePath.isEmpty());
HGImage img = nullptr; HGImage img = nullptr;
HGImgFmtReader imgFmtReader = nullptr;
HGPdfReader pdfReader = nullptr; HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
HGImgFmt_OpenPdfReader(getStdString(m_currFilePath).c_str(), &pdfReader); if (nullptr != imgFmtReader)
if (nullptr != pdfReader)
{ {
HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
float scale = 200.0f / 72.0f; HGImgFmt_CloseImageReader(imgFmtReader);
HGImgFmt_LoadImageFromPdfReader(pdfReader, (HGUInt)m_multiIndex, scale, scale, 0, HGBASE_IMGORIGIN_TOP, &img);
//HGBase_SetImageDpi(img, 200, 200);
HGImgFmt_ClosePdfReader(pdfReader);
}
else
{
HGImgFmtReader imgFmtReader = nullptr;
HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
if (nullptr != imgFmtReader)
{
HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
HGImgFmt_CloseImageReader(imgFmtReader);
}
} }
return img; return img;
@ -2698,7 +2684,10 @@ void MainWindow::on_act_imageInfo_triggered()
imageValues.append(QString::number(depth));//add image depth imageValues.append(QString::number(depth));//add image depth
imageValues.append(depth == 0 ? tr("None") : (depth == 1 ? tr("Mono") : (depth == 8 ? tr("Gray") : tr("Color"))));//add image color imageValues.append(depth == 0 ? tr("None") : (depth == 1 ? tr("Mono") : (depth == 8 ? tr("Gray") : tr("Color"))));//add image color
if (0 == xDpi || 0 == yDpi) HGUInt imgFmtType = 0;
HGImgFmt_GetImgFmtType(m_currFilePath.toLocal8Bit().toStdString().c_str(), &imgFmtType);
if (HGIMGFMT_TYPE_PDF == imgFmtType || HGIMGFMT_TYPE_GIF == imgFmtType
|| HGIMGFMT_TYPE_PNM == imgFmtType)
{ {
QString info = tr("Not supported"); QString info = tr("Not supported");
imageValues.append(info); imageValues.append(info);

View File

@ -1266,6 +1266,10 @@ HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos, bool app
QString oldCurrItemFilePath; QString oldCurrItemFilePath;
if (-1 != oldCurrItemIndex) if (-1 != oldCurrItemIndex)
oldCurrItemFilePath = m_frontItems[oldCurrItemIndex]->fileName; oldCurrItemFilePath = m_frontItems[oldCurrItemIndex]->fileName;
int oldSignItemIndex = m_signItemIndex;
QString oldSignItemFilePath;
if (-1 != oldSignItemIndex)
oldSignItemFilePath = m_frontItems[oldSignItemIndex]->fileName;
std::vector<int> oldSelectedIndexs; std::vector<int> oldSelectedIndexs;
for (int i = 0; i < (int)m_frontItems.size(); ++i) for (int i = 0; i < (int)m_frontItems.size(); ++i)
@ -1332,8 +1336,11 @@ HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos, bool app
else else
{ {
m_frontItems[oldIndex]->selected = true; m_frontItems[oldIndex]->selected = true;
m_curItemIndex = oldIndex; if (notifyCurrentItem)
m_signItemIndex = oldIndex; {
m_curItemIndex = oldIndex;
m_signItemIndex = oldIndex;
}
locateItem(oldIndex); locateItem(oldIndex);
recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect);
} }
@ -1362,6 +1369,12 @@ HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos, bool app
m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus);
Show(); Show();
if (!notifyCurrentItem)
{
m_curItemIndex = findIndex(oldCurrItemFilePath);
m_signItemIndex = findIndex(oldSignItemFilePath);
}
int newItemCount = (int)m_frontItems.size(); int newItemCount = (int)m_frontItems.size();
int newCurrItemIndex = m_curItemIndex; int newCurrItemIndex = m_curItemIndex;
QString newCurrItemFilePath; QString newCurrItemFilePath;
@ -1978,7 +1991,7 @@ HGResult HGImgThumb::itemIsSelect(int index, bool *select)
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
} }
HGResult HGImgThumb::updateItem(int index, const QString &fileName) HGResult HGImgThumb::updateItem(int index, const QString &newFileName, bool refresh)
{ {
if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection)
{ {
@ -1990,7 +2003,7 @@ HGResult HGImgThumb::updateItem(int index, const QString &fileName)
return HGBASE_ERR_INVALIDARG; return HGBASE_ERR_INVALIDARG;
} }
QString stdFileName = getStdFileName(fileName); QString stdFileName = getStdFileName(newFileName);
QFileInfo fileInfo(stdFileName); QFileInfo fileInfo(stdFileName);
if (!fileInfo.isFile()) if (!fileInfo.isFile())
{ {
@ -2005,23 +2018,52 @@ HGResult HGImgThumb::updateItem(int index, const QString &fileName)
QString oldFileName = m_frontItems[index]->fileName; QString oldFileName = m_frontItems[index]->fileName;
m_frontItems[index]->fileName = stdFileName; m_frontItems[index]->fileName = stdFileName;
HGBase_EnterLock(m_lockBack); if (refresh)
std::list<QString>::iterator iter;
for (iter = m_backList.begin(); iter != m_backList.end(); ++iter)
{ {
if (0 == (*iter).compare(oldFileName)) HGBase_EnterLock(m_lockBack);
std::list<QString>::iterator iter;
for (iter = m_backList.begin(); iter != m_backList.end(); ++iter)
{ {
m_backList.erase(iter); if (0 == (*iter).compare(oldFileName))
break; {
m_backList.erase(iter);
break;
}
} }
m_backList.push_front(stdFileName);
HGBase_LeaveLock(m_lockBack);
HGBase_SetEvent(m_event);
}
else
{
HGBase_EnterLock(m_lockBack);
std::list<QString>::iterator iter;
for (iter = m_backList.begin(); iter != m_backList.end(); ++iter)
{
if (0 == (*iter).compare(oldFileName))
{
*iter = stdFileName;
break;
}
}
HGBase_LeaveLock(m_lockBack);
} }
m_backList.push_front(stdFileName);
HGBase_LeaveLock(m_lockBack);
HGBase_SetEvent(m_event);
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
} }
HGResult HGImgThumb::updateItem(const QString &fileName, const QString &newFileName, bool refresh)
{
if (fileName.isEmpty())
{
return HGBASE_ERR_INVALIDARG;
}
QString stdFileName = getStdFileName(fileName);
int index = findIndex(stdFileName);
return updateItem(index, newFileName, refresh);
}
HGResult HGImgThumb::refreshItem(int index) HGResult HGImgThumb::refreshItem(int index)
{ {
if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection)
@ -2061,7 +2103,7 @@ HGResult HGImgThumb::refreshItem(const QString &fileName)
} }
QString stdFileName = getStdFileName(fileName); QString stdFileName = getStdFileName(fileName);
int index = findIndex(fileName); int index = findIndex(stdFileName);
return refreshItem(index); return refreshItem(index);
} }
@ -2923,7 +2965,7 @@ void HGImgThumb::keyPressEvent(QKeyEvent *e)
if (e->key() != Qt::Key_Left && e->key() != Qt::Key_Right if (e->key() != Qt::Key_Left && e->key() != Qt::Key_Right
&& e->key() != Qt::Key_Up && e->key() != Qt::Key_Down && e->key() != Qt::Key_Up && e->key() != Qt::Key_Down
&& e->key() != Qt::Key_Home && e->key() != Qt::Key_End && e->key() != Qt::Key_Home && e->key() != Qt::Key_End
&& e->key() != Qt::Key_A) && e->key() != Qt::Key_A && e->key() != Qt::Key_Delete)
{ {
return; return;
} }
@ -3323,6 +3365,10 @@ void HGImgThumb::keyPressEvent(QKeyEvent *e)
} }
} }
} }
else if (e->key() == Qt::Key_Delete)
{
emit keyDeleteDown();
}
if (-1 != m_curItemIndex) if (-1 != m_curItemIndex)
{ {

View File

@ -69,7 +69,8 @@ public:
HGResult bookSort(); HGResult bookSort();
HGResult selectItem(int index, bool select); HGResult selectItem(int index, bool select);
HGResult itemIsSelect(int index, bool *select); HGResult itemIsSelect(int index, bool *select);
HGResult updateItem(int index, const QString &fileName); HGResult updateItem(int index, const QString &newFileName, bool refresh);
HGResult updateItem(const QString &fileName, const QString &newFileName, bool refresh);
HGResult refreshItem(int index); HGResult refreshItem(int index);
HGResult refreshItem(const QString &fileName); HGResult refreshItem(const QString &fileName);
HGResult refreshAllItems(); HGResult refreshAllItems();
@ -77,6 +78,7 @@ public:
void notify_mouse_leave(void); void notify_mouse_leave(void);
signals: signals:
void keyDeleteDown();
void currItemChanged(int index); void currItemChanged(int index);
void itemDoubleClicked(int index); void itemDoubleClicked(int index);
void itemCountChanged(int count); void itemCountChanged(int count);

View File

@ -36,6 +36,7 @@ HGImgView::HGImgView(QWidget* parent)
m_qImage = nullptr; m_qImage = nullptr;
m_showImage = false; m_showImage = false;
memset(&m_showRect, 0, sizeof(HGRectF)); memset(&m_showRect, 0, sizeof(HGRectF));
m_enableHighQuality = true;
m_mouseMoveStatus = MouseStatus_Null; m_mouseMoveStatus = MouseStatus_Null;
m_mousePressStatus = MouseStatus_Null; m_mousePressStatus = MouseStatus_Null;
m_mousePressBeginX = -1; m_mousePressBeginX = -1;
@ -833,8 +834,21 @@ HGResult HGImgView::enableScroll(bool enable)
HGResult HGImgView::addImage(HGImage image) HGResult HGImgView::addImage(HGImage image)
{ {
if (NULL == image)
{
return HGBASE_ERR_INVALIDARG;
}
HGImageInfo imageInfo;
HGBase_GetImageInfo(image, &imageInfo);
HGUInt type = imageInfo.type;
if (type == HGBASE_IMGTYPE_BGR)
type = HGBASE_IMGTYPE_RGB;
else if (type == HGBASE_IMGTYPE_BGRA)
type = HGBASE_IMGTYPE_RGBA;
HGImage img = nullptr; HGImage img = nullptr;
HGResult ret = HGBase_CloneImage(image, 0, HGBASE_IMGORIGIN_TOP, &img); HGResult ret = HGBase_CloneImage(image, type, HGBASE_IMGORIGIN_TOP, &img);
if (ret != HGBASE_ERR_OK) if (ret != HGBASE_ERR_OK)
{ {
return ret; return ret;
@ -909,6 +923,12 @@ HGResult HGImgView::getImage(HGImage *image)
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
} }
HGResult HGImgView::enableHighQuality(bool enable)
{
m_enableHighQuality = enable;
return HGBASE_ERR_OK;
}
HGResult HGImgView::rotateLeft() HGResult HGImgView::rotateLeft()
{ {
if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image)
@ -1617,11 +1637,11 @@ void HGImgView::paintEvent(QPaintEvent* e)
QRect srcRect(xSrc, ySrc, wSrc, hSrc); QRect srcRect(xSrc, ySrc, wSrc, hSrc);
QRect destRect(xDest, yDest, wDest, hDest); QRect destRect(xDest, yDest, wDest, hDest);
painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setRenderHint(m_enableHighQuality ? QPainter::SmoothPixmapTransform : QPainter::LosslessImageRendering);
painter.drawImage(destRect, *m_qImage, srcRect); painter.drawImage(destRect, *m_qImage, srcRect);
#else #else
QRectF destRect(m_showRect.left, m_showRect.top, m_showRect.right - m_showRect.left, m_showRect.bottom - m_showRect.top); QRectF destRect(m_showRect.left, m_showRect.top, m_showRect.right - m_showRect.left, m_showRect.bottom - m_showRect.top);
painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setRenderHint(m_enableHighQuality ? QPainter::SmoothPixmapTransform : QPainter::LosslessImageRendering);
painter.drawImage(destRect, *m_qImage); painter.drawImage(destRect, *m_qImage);
#endif #endif

View File

@ -31,6 +31,7 @@ public:
HGResult addImage(HGImage image); HGResult addImage(HGImage image);
HGResult clearImage(); HGResult clearImage();
HGResult getImage(HGImage *image); HGResult getImage(HGImage *image);
HGResult enableHighQuality(bool enable);
HGResult rotateLeft(); HGResult rotateLeft();
HGResult rotateRight(); HGResult rotateRight();
@ -132,6 +133,7 @@ private:
QImage *m_qImage; QImage *m_qImage;
bool m_showImage; bool m_showImage;
HGRectF m_showRect; HGRectF m_showRect;
bool m_enableHighQuality;
MouseStatus m_mouseMoveStatus; MouseStatus m_mouseMoveStatus;
MouseStatus m_mousePressStatus; MouseStatus m_mousePressStatus;
int m_mousePressBeginX; int m_mousePressBeginX;

View File

@ -1,4 +1,7 @@
<RCC> <RCC>
<qresource prefix="/qt">
<file>etc/qt.conf</file>
</qresource>
<qresource prefix="/translation"> <qresource prefix="/translation">
<file>Scanner_zh_CN.qm</file> <file>Scanner_zh_CN.qm</file>
<file>qt_zh_CN.qm</file> <file>qt_zh_CN.qm</file>

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
#if defined(HG_CMP_MSC) #if defined(HG_CMP_MSC)
DeviceUserMgr::DeviceUserMgr(QString password, QWidget *wnd) DeviceUserMgr::DeviceUserMgr(const QString &password, QWidget *wnd)
{ {
m_password = password; m_password = password;
m_wnd = wnd; m_wnd = wnd;
@ -23,22 +23,34 @@ DeviceUserMgr::~DeviceUserMgr()
class DeviceUser* DeviceUserMgr::OpenDeviceUser() class DeviceUser* DeviceUserMgr::OpenDeviceUser()
{ {
HGTwainDS ds = nullptr; HGTwainDS ds = nullptr;
HGTwain_OpenSelectedDSEx(m_twainDSM, &ds); HGResult ret = HGTwain_CreateSelectedDSEx(m_twainDSM, &ds);
if (nullptr == ds) if (nullptr == ds)
{
if (HGTWAIN_ERR_CANCELUI != ret)
{
QMessageBox::information(m_wnd, tr("Prompt"), tr("Device source not found!"));
}
return nullptr; return nullptr;
}
return new DeviceUser(m_wnd, ds, m_password); return new DeviceUser(m_wnd, ds, m_password);
} }
DeviceUser *DeviceUserMgr::OpenDefaultDeviceUser() DeviceUser *DeviceUserMgr::OpenDefaultDeviceUser()
{ {
HGTwainDS ds = nullptr; HGTwainDS ds = nullptr;
HGTwain_OpenDefaultDS(m_twainDSM, &ds); HGTwain_CreateDefaultDS(m_twainDSM, &ds);
if (nullptr == ds) if (nullptr == ds)
{
QMessageBox::information(m_wnd, tr("Prompt"), tr("Device source not found!"));
return nullptr; return nullptr;
}
return new DeviceUser(m_wnd, ds, m_password); return new DeviceUser(m_wnd, ds, m_password);
} }
DeviceUser::DeviceUser(QWidget *wnd, HGTwainDS ds, QString password) DeviceUser::DeviceUser(QWidget *wnd, HGTwainDS ds, const QString &password)
{ {
m_wnd = wnd; m_wnd = wnd;
m_twainDS = ds; m_twainDS = ds;
@ -48,9 +60,25 @@ DeviceUser::DeviceUser(QWidget *wnd, HGTwainDS ds, QString password)
DeviceUser::~DeviceUser() DeviceUser::~DeviceUser()
{ {
HGTwain_CloseDS(m_twainDS); HGTwain_CloseDS(m_twainDS);
HGTwain_DestroyDS(m_twainDS);
m_twainDS = nullptr; m_twainDS = nullptr;
} }
HGResult DeviceUser::Open()
{
return HGTwain_OpenDS(m_twainDS);
}
HGResult DeviceUser::OpenDefault()
{
return HGTwain_OpenDS(m_twainDS);
}
HGResult DeviceUser::Close()
{
return HGTwain_CloseDS(m_twainDS);
}
QString DeviceUser::GetName() QString DeviceUser::GetName()
{ {
HGChar devName[256] = {0}; HGChar devName[256] = {0};
@ -147,11 +175,11 @@ void HGAPI DeviceUser::DSImageFunc(HGTwainDS ds, HGImage image, HGPointer param)
#else #else
DeviceUserMgr::DeviceUserMgr(QString password, QWidget *wnd) DeviceUserMgr::DeviceUserMgr(const QString &password, QWidget *wnd)
{ {
m_wnd = wnd; m_wnd = wnd;
m_saneMgr = nullptr;
m_password = password; m_password = password;
m_saneMgr = nullptr;
HGSane_CreateManager(&m_saneMgr); HGSane_CreateManager(&m_saneMgr);
} }
@ -164,42 +192,11 @@ DeviceUserMgr::~DeviceUserMgr()
class DeviceUser* DeviceUserMgr::OpenDeviceUser() class DeviceUser* DeviceUserMgr::OpenDeviceUser()
{ {
HGSaneSource source = nullptr; HGSaneSource source = nullptr;
HGSane_OpenSelectedSource(m_saneMgr, m_wnd, &source); HGSane_OpenSource(m_saneMgr, 0, &source);
if (nullptr == source) if (nullptr == source)
return nullptr; return nullptr;
HGUInt devCount = 0; return new DeviceUser(m_wnd, source, m_password);
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 *DeviceUserMgr::OpenDefaultDeviceUser() DeviceUser *DeviceUserMgr::OpenDefaultDeviceUser()
@ -209,45 +206,14 @@ DeviceUser *DeviceUserMgr::OpenDefaultDeviceUser()
if (nullptr == source) if (nullptr == source)
return nullptr; return nullptr;
HGUInt devCount = 0; return new DeviceUser(m_wnd, source, m_password);
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) DeviceUser::DeviceUser(QWidget *wnd, HGSaneSource source, const QString &password)
{ {
m_wnd = wnd; m_wnd = wnd;
m_source = source; m_source = source;
m_saneDev = dev; m_saneDev = nullptr;
m_password = password; m_password = password;
} }
@ -259,6 +225,59 @@ DeviceUser::~DeviceUser()
m_source = nullptr; m_source = nullptr;
} }
HGResult DeviceUser::Open()
{
if (nullptr != m_saneDev)
{
return HGSANE_ERR_FAIL;
}
HGUInt count = 0;
HGSane_GetDeviceCount(m_source, &count);
if (0 == count)
{
QMessageBox::information(m_wnd, tr("Prompt"), tr("Scanner not found!"));
return HGSANE_ERR_FAIL;
}
else
{
return HGSane_OpenSelectedDevice(m_source, m_wnd, &m_saneDev);
}
}
HGResult DeviceUser::OpenDefault()
{
if (nullptr != m_saneDev)
{
return HGSANE_ERR_FAIL;
}
HGUInt count = 0;
HGSane_GetDeviceCount(m_source, &count);
if (0 == count)
{
QMessageBox::information(m_wnd, tr("Prompt"), tr("Scanner not found!"));
return HGSANE_ERR_FAIL;
}
else
{
HGChar errInfo[256];
return HGSane_OpenDevice(m_source, 0, &m_saneDev, errInfo, 256);
}
}
HGResult DeviceUser::Close()
{
if (nullptr == m_saneDev)
{
return HGSANE_ERR_FAIL;
}
HGSane_CloseDevice(m_saneDev);
m_saneDev = nullptr;
return HGBASE_ERR_OK;
}
QString DeviceUser::GetName() QString DeviceUser::GetName()
{ {
HGChar devName[256]; HGChar devName[256];

View File

@ -12,7 +12,7 @@ class DeviceUserMgr : public QObject
Q_OBJECT Q_OBJECT
public: public:
DeviceUserMgr(QString password, QWidget *wnd); DeviceUserMgr(const QString &password, QWidget *wnd);
~DeviceUserMgr(); ~DeviceUserMgr();
// 弹出设备选择对话框选择twain源 // 弹出设备选择对话框选择twain源
@ -30,10 +30,13 @@ class DeviceUser : public QObject
Q_OBJECT Q_OBJECT
friend class DeviceUserMgr; friend class DeviceUserMgr;
DeviceUser(QWidget *wnd, HGTwainDS ds, QString password); DeviceUser(QWidget *wnd, HGTwainDS ds, const QString &password);
public: public:
~DeviceUser(); ~DeviceUser();
HGResult Open();
HGResult OpenDefault();
HGResult Close();
// 获取设备名字 // 获取设备名字
QString GetName(); QString GetName();
// 弹出配置对话框 // 弹出配置对话框
@ -73,7 +76,7 @@ class DeviceUserMgr : public QObject
Q_OBJECT Q_OBJECT
public: public:
DeviceUserMgr(QString password, QWidget *wnd); DeviceUserMgr(const QString &password, QWidget *wnd);
~DeviceUserMgr(); ~DeviceUserMgr();
// 弹出设备选择对话框,选择设备 // 弹出设备选择对话框,选择设备
@ -91,10 +94,13 @@ class DeviceUser : public QObject
Q_OBJECT Q_OBJECT
friend class DeviceUserMgr; friend class DeviceUserMgr;
DeviceUser(QWidget *wnd, HGSaneSource source, HGSaneDevice dev, QString password); DeviceUser(QWidget *wnd, HGSaneSource source, const QString &password);
public: public:
~DeviceUser(); ~DeviceUser();
HGResult Open();
HGResult OpenDefault();
HGResult Close();
// 获取设备名字 // 获取设备名字
QString GetName(); QString GetName();
// 弹出配置对话框 // 弹出配置对话框

View File

@ -16,7 +16,7 @@
#include <QDebug> #include <QDebug>
#include <QMessageBox> #include <QMessageBox>
Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) : Dialog_AquireInto::Dialog_AquireInto(int fileNameStartIndex, QWidget* parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::Dialog_AquireInto) ui(new Ui::Dialog_AquireInto)
{ {
@ -42,11 +42,22 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
ui->comboBox_cfgScheme->setCurrentIndex(0); ui->comboBox_cfgScheme->setCurrentIndex(0);
} }
setCfgBaseOnSection(getCurrentCfgName()); QString cfgName = getCurrentCfgName();
setCfgBaseOnSection(cfgName);
if (-1 != fileNameStartIndex)
{
ui->spin_index->setValue(fileNameStartIndex);
if (cfgName == tr("default scheme"))
{
saveCfgValue(cfgName.toLocal8Bit().toStdString().c_str(), "startIndex", fileNameStartIndex);
}
}
ui->lab_digitExp->setText(QString(tr("e.g. '%1%2'")).arg(ui->lineEdit_fileName->text()) ui->lab_digitExp->setText(QString(tr("e.g. '%1%2'")).arg(ui->lineEdit_fileName->text())
.arg(ui->spin_index->value(), ui->cbox_digit->currentIndex() + 1, 10, QLatin1Char('0'))); .arg(ui->spin_index->value(), ui->cbox_digit->currentIndex() + 1, 10, QLatin1Char('0')));
ui->btn_option->setEnabled(0 == ui->cbox_format->currentIndex() || 6 == ui->cbox_format->currentIndex()); ui->btn_option->setEnabled(0 == ui->cbox_format->currentIndex() || 6 == ui->cbox_format->currentIndex() || 7 == ui->cbox_format->currentIndex() ||
8 == ui->cbox_format->currentIndex());
ui->cbtn_multiFile->setEnabled(ui->cbox_format->currentIndex() > 5 && ui->cbox_format->currentIndex() < 12); ui->cbtn_multiFile->setEnabled(ui->cbox_format->currentIndex() > 5 && ui->cbox_format->currentIndex() < 12);
ui->radio_multiAll->setEnabled(ui->cbtn_multiFile->isChecked()); ui->radio_multiAll->setEnabled(ui->cbtn_multiFile->isChecked());
ui->radio_multiCustom->setEnabled(ui->cbtn_multiFile->isChecked()); ui->radio_multiCustom->setEnabled(ui->cbtn_multiFile->isChecked());
@ -55,6 +66,12 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
ui->spin_index->setFixedWidth(160); ui->spin_index->setFixedWidth(160);
ui->cbox_digit->setFixedWidth(80); ui->cbox_digit->setFixedWidth(80);
#if defined (x86_64) || defined (loongarch64)
ui->cbox_format->removeItem(11);
ui->cbox_format->removeItem(10);
#endif
} }
Dialog_AquireInto::~Dialog_AquireInto() Dialog_AquireInto::~Dialog_AquireInto()

View File

@ -35,7 +35,7 @@ class Dialog_AquireInto : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit Dialog_AquireInto(QWidget* parent = nullptr); explicit Dialog_AquireInto(int fileNameStartIndex, QWidget* parent = nullptr);
~Dialog_AquireInto(); ~Dialog_AquireInto();
AquireIntoSaveParam getSaveParam(); AquireIntoSaveParam getSaveParam();

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>707</width> <width>705</width>
<height>398</height> <height>380</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -28,16 +28,22 @@
<layout class="QHBoxLayout" name="horizontalLayout_11"> <layout class="QHBoxLayout" name="horizontalLayout_11">
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>240</width>
<height>0</height>
</size>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>211</width> <width>300</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="title"> <property name="title">
<string>configuration scheme management</string> <string>configuration scheme management</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0,0,0,0">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">

View File

@ -78,25 +78,12 @@ void Dialog_FullScreen::showImage()
assert(!m_currFilePath.isEmpty()); assert(!m_currFilePath.isEmpty());
HGImage img = nullptr; HGImage img = nullptr;
HGImgFmtReader imgFmtReader = nullptr;
HGPdfReader pdfReader = nullptr; HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
HGImgFmt_OpenPdfReader(getStdString(m_currFilePath).c_str(), &pdfReader); if (nullptr != imgFmtReader)
if (nullptr != pdfReader)
{ {
float scale = 200.0f / 72.0f; HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
HGImgFmt_LoadImageFromPdfReader(pdfReader, (HGUInt)m_multiIndex, scale, scale, 0, HGBASE_IMGORIGIN_TOP, &img); HGImgFmt_CloseImageReader(imgFmtReader);
HGBase_SetImageDpi(img, 200, 200);
HGImgFmt_ClosePdfReader(pdfReader);
}
else
{
HGImgFmtReader imgFmtReader = nullptr;
HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
if (nullptr != imgFmtReader)
{
HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
HGImgFmt_CloseImageReader(imgFmtReader);
}
} }
if (nullptr != img) if (nullptr != img)

View File

@ -21,6 +21,7 @@ Dialog_ImageEditor::Dialog_ImageEditor(QWidget *parent)
for (int i = 0; i < ui->comboBox_lineWidth->count(); i++) for (int i = 0; i < ui->comboBox_lineWidth->count(); i++)
ui->comboBox_lineWidth->setItemData(i, m_lineWidth[i]); ui->comboBox_lineWidth->setItemData(i, m_lineWidth[i]);
m_scene->setColor(QColor("red"));
ui->comboBox_textSize->setCurrentIndex(2); ui->comboBox_textSize->setCurrentIndex(2);
ui->graphicsView->setScene(m_scene); ui->graphicsView->setScene(m_scene);
ui->graphicsView->setParent(this); ui->graphicsView->setParent(this);
@ -28,6 +29,11 @@ Dialog_ImageEditor::Dialog_ImageEditor(QWidget *parent)
QColor backgroundColor = qRgb(240, 240, 240); QColor backgroundColor = qRgb(240, 240, 240);
ui->graphicsView->setBackgroundBrush(QBrush(backgroundColor)); ui->graphicsView->setBackgroundBrush(QBrush(backgroundColor));
connect(m_scene, SIGNAL(itemChanged()), this, SLOT(on_itemChanged()));
ui->btn_undo->setEnabled(m_scene->isCanUndo());
ui->btn_redo->setEnabled(m_scene->isCanRedo());
} }
Dialog_ImageEditor::~Dialog_ImageEditor() Dialog_ImageEditor::~Dialog_ImageEditor()
@ -52,17 +58,23 @@ QImage Dialog_ImageEditor::exportImage()
image.setDotsPerMeterX(m_dpi_x); image.setDotsPerMeterX(m_dpi_x);
image.setDotsPerMeterY(m_dpi_y); image.setDotsPerMeterY(m_dpi_y);
QPainter painter(&image); QPainter painter(&image);
m_scene->render(&painter); //¹Ø¼üº¯Êý m_scene->render(&painter); //<EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return image; return image;
} }
void Dialog_ImageEditor::on_itemChanged()
{
ui->btn_undo->setEnabled(m_scene->isCanUndo());
ui->btn_redo->setEnabled(m_scene->isCanRedo());
}
void Dialog_ImageEditor::on_btn_rect_clicked(bool checked) void Dialog_ImageEditor::on_btn_rect_clicked(bool checked)
{ {
if (checked) if (checked)
{ {
m_scene->setItemFlag(GraphicsScene::Rect); m_scene->setItemFlag(GraphicsScene::Rect);
ui->btn_arrow->setChecked(false); ui->btn_arrow->setChecked(false);
//ui->btn_rect->setChecked(false); ui->btn_mask->setChecked(false);
ui->btn_ellipse->setChecked(false); ui->btn_ellipse->setChecked(false);
ui->btn_text->setChecked(false); ui->btn_text->setChecked(false);
ui->btn_line->setChecked(false); ui->btn_line->setChecked(false);
@ -79,7 +91,7 @@ void Dialog_ImageEditor::on_btn_ellipse_clicked(bool checked)
m_scene->setItemFlag(GraphicsScene::Ellipse); m_scene->setItemFlag(GraphicsScene::Ellipse);
ui->btn_arrow->setChecked(false); ui->btn_arrow->setChecked(false);
ui->btn_rect->setChecked(false); ui->btn_rect->setChecked(false);
//ui->btn_ellipse->setChecked(false); ui->btn_mask->setChecked(false);
ui->btn_text->setChecked(false); ui->btn_text->setChecked(false);
ui->btn_line->setChecked(false); ui->btn_line->setChecked(false);
ui->btn_pen->setChecked(false); ui->btn_pen->setChecked(false);
@ -97,7 +109,7 @@ void Dialog_ImageEditor::on_btn_line_clicked(bool checked)
ui->btn_rect->setChecked(false); ui->btn_rect->setChecked(false);
ui->btn_ellipse->setChecked(false); ui->btn_ellipse->setChecked(false);
ui->btn_text->setChecked(false); ui->btn_text->setChecked(false);
//ui->btn_line->setChecked(false); ui->btn_mask->setChecked(false);
ui->btn_pen->setChecked(false); ui->btn_pen->setChecked(false);
} }
else else
@ -112,7 +124,7 @@ void Dialog_ImageEditor::on_btn_text_clicked(bool checked)
ui->btn_arrow->setChecked(false); ui->btn_arrow->setChecked(false);
ui->btn_rect->setChecked(false); ui->btn_rect->setChecked(false);
ui->btn_ellipse->setChecked(false); ui->btn_ellipse->setChecked(false);
//ui->btn_text->setChecked(false); ui->btn_mask->setChecked(false);
ui->btn_line->setChecked(false); ui->btn_line->setChecked(false);
ui->btn_pen->setChecked(false); ui->btn_pen->setChecked(false);
} }
@ -125,7 +137,7 @@ void Dialog_ImageEditor::on_btn_arrow_clicked(bool checked)
if (checked) if (checked)
{ {
m_scene->setItemFlag(GraphicsScene::Arrow); m_scene->setItemFlag(GraphicsScene::Arrow);
//ui->btn_arrow->setChecked(false); ui->btn_mask->setChecked(false);
ui->btn_rect->setChecked(false); ui->btn_rect->setChecked(false);
ui->btn_ellipse->setChecked(false); ui->btn_ellipse->setChecked(false);
ui->btn_text->setChecked(false); ui->btn_text->setChecked(false);
@ -146,7 +158,7 @@ void Dialog_ImageEditor::on_btn_pen_clicked(bool checked)
ui->btn_ellipse->setChecked(false); ui->btn_ellipse->setChecked(false);
ui->btn_text->setChecked(false); ui->btn_text->setChecked(false);
ui->btn_line->setChecked(false); ui->btn_line->setChecked(false);
//ui->btn_pen->setChecked(false); ui->btn_mask->setChecked(false);
} }
else else
m_scene->setItemFlag(GraphicsScene::None); m_scene->setItemFlag(GraphicsScene::None);
@ -154,8 +166,9 @@ void Dialog_ImageEditor::on_btn_pen_clicked(bool checked)
void Dialog_ImageEditor::on_btn_color_clicked() void Dialog_ImageEditor::on_btn_color_clicked()
{ {
QColorDialog dlg; QColorDialog dlg(this);
if (!dlg.exec()) return; if (!dlg.exec())
return;
ui->btn_color->setStyleSheet(QString("QPushButton{background-color:%1;border:1px solid %2}").arg(dlg.selectedColor().name()).arg(dlg.selectedColor().name())); ui->btn_color->setStyleSheet(QString("QPushButton{background-color:%1;border:1px solid %2}").arg(dlg.selectedColor().name()).arg(dlg.selectedColor().name()));
m_scene->setColor(dlg.selectedColor()); m_scene->setColor(dlg.selectedColor());
@ -173,7 +186,10 @@ void Dialog_ImageEditor::on_comboBox_textSize_currentIndexChanged(int index)
void Dialog_ImageEditor::on_btn_undo_clicked() void Dialog_ImageEditor::on_btn_undo_clicked()
{ {
m_scene->unDo(); m_scene->undo();
ui->btn_undo->setEnabled(m_scene->isCanUndo());
ui->btn_redo->setEnabled(m_scene->isCanRedo());
} }
void Dialog_ImageEditor::on_btn_ok_clicked() void Dialog_ImageEditor::on_btn_ok_clicked()
@ -255,3 +271,35 @@ void Dialog_ImageEditor::resizeEvent(QResizeEvent* event)
QDialog::resizeEvent(event); QDialog::resizeEvent(event);
} }
void Dialog_ImageEditor::on_btn_redo_clicked()
{
m_scene->redo();
ui->btn_undo->setEnabled(m_scene->isCanUndo());
ui->btn_redo->setEnabled(m_scene->isCanRedo());
}
void Dialog_ImageEditor::on_btn_clear_clicked()
{
m_scene->clear();
ui->btn_undo->setEnabled(m_scene->isCanUndo());
ui->btn_redo->setEnabled(m_scene->isCanRedo());
}
void Dialog_ImageEditor::on_btn_mask_clicked(bool checked)
{
if (checked)
{
m_scene->setItemFlag(GraphicsScene::Mask);
ui->btn_arrow->setChecked(false);
ui->btn_rect->setChecked(false);
ui->btn_ellipse->setChecked(false);
ui->btn_text->setChecked(false);
ui->btn_line->setChecked(false);
ui->btn_pen->setChecked(false);
}
else
m_scene->setItemFlag(GraphicsScene::None);
}

View File

@ -22,6 +22,9 @@ public:
QImage exportImage(); QImage exportImage();
private slots:
void on_itemChanged();
private slots: private slots:
void on_btn_rect_clicked(bool checked); void on_btn_rect_clicked(bool checked);
@ -55,6 +58,12 @@ private slots:
void on_btn_fit_clicked(); void on_btn_fit_clicked();
void on_btn_redo_clicked();
void on_btn_clear_clicked();
void on_btn_mask_clicked(bool checked);
protected: protected:
void resizeEvent(QResizeEvent* event); void resizeEvent(QResizeEvent* event);

View File

@ -6,354 +6,448 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1378</width> <width>1093</width>
<height>378</height> <height>607</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog_ImageEditor</string> <string>Dialog_ImageEditor</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QGraphicsView" name="graphicsView"/> <layout class="QHBoxLayout" name="horizontalLayout_5">
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="btn_rect"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>rect</string>
</property>
<property name="text">
<string>Rect</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_ellipse">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>ellipse</string>
</property>
<property name="text">
<string>Ellipse</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_line">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>line</string>
</property>
<property name="text">
<string>Line</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_pen">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Pen</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_arrow">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>arrow</string>
</property>
<property name="text">
<string>Arrow</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_text">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>text</string>
</property>
<property name="text">
<string>Text</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_color">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>color</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>LineWidth</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_lineWidth">
<item> <item>
<property name="text"> <widget class="QPushButton" name="btn_rect">
<string>1 pix</string> <property name="focusPolicy">
</property> <enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>rect</string>
</property>
<property name="text">
<string>Rect</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <widget class="QPushButton" name="btn_ellipse">
<string>3 pix</string> <property name="focusPolicy">
</property> <enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>ellipse</string>
</property>
<property name="text">
<string>Ellipse</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <widget class="QPushButton" name="btn_line">
<string>5 pix</string> <property name="focusPolicy">
</property> <enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>line</string>
</property>
<property name="text">
<string>Line</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <widget class="QPushButton" name="btn_arrow">
<string>8 pix</string> <property name="focusPolicy">
</property> <enum>Qt::NoFocus</enum>
</item> </property>
</widget> <property name="toolTip">
</item> <string>arrow</string>
<item> </property>
<widget class="QLabel" name="label_2"> <property name="text">
<property name="text"> <string>Arrow</string>
<string>TextSize</string> </property>
</property> <property name="checkable">
</widget> <bool>true</bool>
</item> </property>
<item> </widget>
<widget class="QComboBox" name="comboBox_textSize">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>20</string>
</property>
</item> </item>
<item> <item>
<property name="text"> <widget class="QPushButton" name="btn_pen">
<string>26</string> <property name="focusPolicy">
</property> <enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Pen</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <widget class="QPushButton" name="btn_text">
<string>36</string> <property name="focusPolicy">
</property> <enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>text</string>
</property>
<property name="text">
<string>Text</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <widget class="QPushButton" name="btn_mask">
<string>48</string> <property name="focusPolicy">
</property> <enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>mask</string>
</property>
<property name="text">
<string>Mask</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <spacer name="verticalSpacer_2">
<string>72</string> <property name="orientation">
</property> <enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item> </item>
<item> <item>
<property name="text"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<string>96</string> <item>
</property> <widget class="QLabel" name="label_3">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_color">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>color</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<property name="text"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<string>128</string> <item>
</property> <widget class="QLabel" name="label">
<property name="text">
<string>LineWidth</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_lineWidth">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>1 pix</string>
</property>
</item>
<item>
<property name="text">
<string>3 pix</string>
</property>
</item>
<item>
<property name="text">
<string>5 pix</string>
</property>
</item>
<item>
<property name="text">
<string>8 pix</string>
</property>
</item>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<property name="text"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<string>160</string> <item>
</property> <widget class="QLabel" name="label_2">
<property name="text">
<string>TextSize</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_textSize">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>20</string>
</property>
</item>
<item>
<property name="text">
<string>26</string>
</property>
</item>
<item>
<property name="text">
<string>36</string>
</property>
</item>
<item>
<property name="text">
<string>48</string>
</property>
</item>
<item>
<property name="text">
<string>72</string>
</property>
</item>
<item>
<property name="text">
<string>96</string>
</property>
</item>
<item>
<property name="text">
<string>128</string>
</property>
</item>
<item>
<property name="text">
<string>160</string>
</property>
</item>
<item>
<property name="text">
<string>200</string>
</property>
</item>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<property name="text"> <spacer name="verticalSpacer">
<string>200</string> <property name="orientation">
</property> <enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
</size>
</property>
</spacer>
</item> </item>
</widget> </layout>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="orientation"> <item>
<enum>Qt::Horizontal</enum> <widget class="QGraphicsView" name="graphicsView"/>
</property> </item>
<property name="sizeHint" stdset="0"> <item>
<size> <layout class="QHBoxLayout" name="horizontalLayout">
<width>40</width> <item>
<height>20</height> <widget class="QPushButton" name="btn_undo">
</size> <property name="focusPolicy">
</property> <enum>Qt::NoFocus</enum>
</spacer> </property>
</item> <property name="toolTip">
<item> <string>undo</string>
<widget class="QPushButton" name="btn_zoomIn"> </property>
<property name="focusPolicy"> <property name="text">
<enum>Qt::NoFocus</enum> <string>Undo</string>
</property> </property>
<property name="toolTip"> <property name="shortcut">
<string>zoomin</string> <string>Ctrl+Z</string>
</property> </property>
<property name="text"> </widget>
<string>Zoomin</string> </item>
</property> <item>
</widget> <widget class="QPushButton" name="btn_redo">
</item> <property name="focusPolicy">
<item> <enum>Qt::NoFocus</enum>
<widget class="QPushButton" name="btn_fit"> </property>
<property name="toolTip"> <property name="toolTip">
<string>fit</string> <string>redo</string>
</property> </property>
<property name="text"> <property name="text">
<string>Fit</string> <string>Redo</string>
</property> </property>
</widget> <property name="shortcut">
</item> <string>Ctrl+Y</string>
<item> </property>
<widget class="QPushButton" name="btn_zoom"> </widget>
<property name="focusPolicy"> </item>
<enum>Qt::NoFocus</enum> <item>
</property> <widget class="QPushButton" name="btn_clear">
<property name="toolTip"> <property name="focusPolicy">
<string>100%</string> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="text"> <property name="toolTip">
<string>1:1</string> <string>clear</string>
</property> </property>
</widget> <property name="text">
</item> <string>Clear</string>
<item> </property>
<widget class="QPushButton" name="btn_zoomOut"> </widget>
<property name="focusPolicy"> </item>
<enum>Qt::NoFocus</enum> <item>
</property> <spacer name="horizontalSpacer_4">
<property name="toolTip"> <property name="orientation">
<string>zoomout</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="text"> <property name="sizeHint" stdset="0">
<string>Zoomout</string> <size>
</property> <width>40</width>
</widget> <height>20</height>
</item> </size>
<item> </property>
<spacer name="horizontalSpacer_4"> </spacer>
<property name="orientation"> </item>
<enum>Qt::Horizontal</enum> <item>
</property> <widget class="QPushButton" name="btn_zoomIn">
<property name="sizeHint" stdset="0"> <property name="focusPolicy">
<size> <enum>Qt::NoFocus</enum>
<width>40</width> </property>
<height>20</height> <property name="toolTip">
</size> <string>zoomin</string>
</property> </property>
</spacer> <property name="text">
</item> <string>Zoomin</string>
<item> </property>
<widget class="QPushButton" name="btn_undo"> </widget>
<property name="focusPolicy"> </item>
<enum>Qt::NoFocus</enum> <item>
</property> <widget class="QPushButton" name="btn_fit">
<property name="toolTip"> <property name="toolTip">
<string>undo</string> <string>fit</string>
</property> </property>
<property name="text"> <property name="text">
<string>Undo</string> <string>Fit</string>
</property> </property>
<property name="shortcut"> </widget>
<string>Ctrl+Z</string> </item>
</property> <item>
</widget> <widget class="QPushButton" name="btn_zoom">
</item> <property name="focusPolicy">
<item> <enum>Qt::NoFocus</enum>
<spacer name="horizontalSpacer_3"> </property>
<property name="orientation"> <property name="toolTip">
<enum>Qt::Horizontal</enum> <string>100%</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="text">
<size> <string>1:1</string>
<width>40</width> </property>
<height>20</height> </widget>
</size> </item>
</property> <item>
</spacer> <widget class="QPushButton" name="btn_zoomOut">
</item> <property name="focusPolicy">
<item> <enum>Qt::NoFocus</enum>
<widget class="QPushButton" name="btn_ok"> </property>
<property name="toolTip"> <property name="toolTip">
<string>ok</string> <string>zoomout</string>
</property> </property>
<property name="text"> <property name="text">
<string>Ok</string> <string>Zoomout</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="btn_cancel"> <spacer name="horizontalSpacer_3">
<property name="toolTip"> <property name="orientation">
<string>cancel</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="text"> <property name="sizeHint" stdset="0">
<string>Cancel</string> <size>
</property> <width>40</width>
</widget> <height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_ok">
<property name="toolTip">
<string>ok</string>
</property>
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_cancel">
<property name="toolTip">
<string>cancel</string>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -20,12 +20,12 @@ Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) :
ui->view_before->addImage(img); ui->view_before->addImage(img);
ui->view_after->addImage(img); ui->view_after->addImage(img);
m_brightness = getCfgValue("adjust", "brightness", 0); m_brightness = 0;//getCfgValue("adjust", "brightness", 0);
m_base_widget->setBrightness(m_brightness); m_base_widget->setBrightness(m_brightness);
m_contrast = getCfgValue("adjust", "contrast", 0); m_contrast = 0;//getCfgValue("adjust", "contrast", 0);
m_base_widget->setContrast(m_contrast); m_base_widget->setContrast(m_contrast);
QString gamma = getCfgValue("adjust", "gamma", QString("1.0")); //QString gamma = getCfgValue("adjust", "gamma", QString("1.0"));
m_gamma = atof(gamma.toStdString().c_str()); m_gamma = 1.0;//atof(gamma.toStdString().c_str());
m_base_widget->setGamma(m_gamma); m_base_widget->setGamma(m_gamma);
ui->cbtn_preview->setChecked(getCfgValue("adjust", "preview", false)); ui->cbtn_preview->setChecked(getCfgValue("adjust", "preview", false));
@ -138,9 +138,9 @@ void Dialog_ImgProc_Adjust::on_buttonBox_accepted()
saveCfgValue("adjust", "preview", ui->cbtn_preview->isChecked()); saveCfgValue("adjust", "preview", ui->cbtn_preview->isChecked());
saveCfgValue("adjust", "applyImg", ui->cbtn_applyImg->isChecked()); saveCfgValue("adjust", "applyImg", ui->cbtn_applyImg->isChecked());
saveCfgValue("adjust", "brightness", m_brightness); // saveCfgValue("adjust", "brightness", m_brightness);
saveCfgValue("adjust", "contrast", m_contrast); // saveCfgValue("adjust", "contrast", m_contrast);
char gamma[32]; // char gamma[32];
sprintf(gamma, "%f", m_gamma); // sprintf(gamma, "%f", m_gamma);
saveCfgValue("adjust", "gamma", QString(gamma)); // saveCfgValue("adjust", "gamma", QString(gamma));
} }

View File

@ -7,6 +7,7 @@ Dialog_MoveTo::Dialog_MoveTo(int count, int index, QWidget *parent) :
ui(new Ui::Dialog_MoveTo) ui(new Ui::Dialog_MoveTo)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
ui->spinBox->setMaximum(count); ui->spinBox->setMaximum(count);
ui->spinBox->setMinimum(1); ui->spinBox->setMinimum(1);

View File

@ -122,7 +122,7 @@ Dialog_SaveAs::Dialog_SaveAs(bool isSaveAs, QWidget *parent) :
else if (m_suffix < 0) else if (m_suffix < 0)
m_suffix = 0; m_suffix = 0;
ui->fileDialog->selectNameFilter(ui->fileDialog->nameFilters().at(m_suffix)); ui->fileDialog->selectNameFilter(ui->fileDialog->nameFilters().at(m_suffix));
ui->btn_option->setEnabled(0 == m_suffix || 6 == m_suffix); ui->btn_option->setEnabled(0 == m_suffix || 6 == m_suffix || 7 == m_suffix || 8 == m_suffix);
ui->cbox_subFolder->setChecked(false); ui->cbox_subFolder->setChecked(false);
ui->cbox_subFolder->setChecked(getCfgValue("saveAs", "subFolderByTime", false)); ui->cbox_subFolder->setChecked(getCfgValue("saveAs", "subFolderByTime", false));

2
app/scanner2/etc/qt.conf Normal file
View File

@ -0,0 +1,2 @@
[Platforms]
WindowsArguments = dpiawareness=0

View File

@ -9,6 +9,7 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <typeinfo> #include <typeinfo>
#include <math.h> #include <math.h>
#include "assert.h"
GraphicsTextEdit::GraphicsTextEdit(QWidget* parent) GraphicsTextEdit::GraphicsTextEdit(QWidget* parent)
: QTextEdit(parent) : QTextEdit(parent)
@ -69,16 +70,24 @@ GraphicsScene::GraphicsScene(QObject* parent)
: QGraphicsScene(parent) : QGraphicsScene(parent)
, m_status(Normal) , m_status(Normal)
, m_activeItem(nullptr) , m_activeItem(nullptr)
, m_btn_pressed(0)
, m_pen(QColor(255, 0, 0, 255)) , m_pen(QColor(255, 0, 0, 255))
, m_brush(QColor(255, 255, 255, 255)) , m_brush(QColor(255, 255, 255, 255))
, m_font(tr("SongTi")) , m_font(tr("SongTi"))
, m_edit(nullptr) , m_edit(nullptr)
{ {
m_ItemList.clear();
m_curItemIndex = -1;
} }
GraphicsScene::~GraphicsScene() GraphicsScene::~GraphicsScene()
{ {
for (int i = 0; i < (int)m_ItemList.size(); ++i)
{
delete m_ItemList[i];
m_ItemList[i] = nullptr;
}
m_ItemList.clear();
m_curItemIndex = -1;
} }
void GraphicsScene::setColor(const QColor& color) void GraphicsScene::setColor(const QColor& color)
@ -101,33 +110,13 @@ void GraphicsScene::setLineWidth(int width)
void GraphicsScene::setItemFlag(int flag) void GraphicsScene::setItemFlag(int flag)
{ {
if (m_status == CreateText) flush();
{
if (m_activeItem != nullptr)
{
QString text = m_edit->document()->toPlainText();
QFont font = m_edit->font();
removeItem(m_activeItem);
QGraphicsTextItem* item = addText(text, font);
item->setPos(m_edit->mapToParent(QPoint()));
item->setDefaultTextColor(m_pen.color());
delete m_edit;
m_edit = nullptr;
m_activeItem = nullptr;
}
}
if (m_activeItem != nullptr)
{
if (typeid(*m_activeItem) == typeid(QGraphicsProxyWidget))
removeItem(m_activeItem);
m_activeItem = nullptr;
m_status = Normal;
}
switch (flag) switch (flag)
{ {
case Mask:
m_status = CreateMask;
break;
case Rect: case Rect:
m_status = CreateRect; m_status = CreateRect;
break; break;
@ -152,15 +141,62 @@ void GraphicsScene::setItemFlag(int flag)
} }
} }
void GraphicsScene::unDo() bool GraphicsScene::isCanUndo()
{ {
m_activeItem = nullptr; if (m_ItemList.empty() || -1 == m_curItemIndex)
return false;
return true;
}
QList<QGraphicsItem*> items = this->items(); void GraphicsScene::undo()
if (items.count() < 2) {
flush();
if (!isCanUndo())
return; return;
removeItem(items.first()); --m_curItemIndex;
updateShow();
}
bool GraphicsScene::isCanRedo()
{
if (m_ItemList.empty() || (int)m_ItemList.size() - 1 == m_curItemIndex)
return false;
return true;
}
void GraphicsScene::redo()
{
flush();
if (!isCanRedo())
return;
++m_curItemIndex;
updateShow();
}
void GraphicsScene::clear()
{
flush();
if (m_ItemList.empty())
return;
if (-1 == m_curItemIndex)
return;
if (NULL == m_ItemList[m_curItemIndex])
return;
for (int i = (int)m_ItemList.size() - 1; i > m_curItemIndex; --i)
{
delete m_ItemList[i];
m_ItemList[i] = nullptr;
m_ItemList.erase(m_ItemList.begin() + i);
}
m_ItemList.push_back(NULL);
++m_curItemIndex;
updateShow();
} }
#define PI acos(-1) #define PI acos(-1)
@ -179,6 +215,92 @@ float lineLength(const QPointF& p1, const QPointF& p2)
return sqrt(pow(p1.x() - p2.x(), 2) + pow(p1.y() - p2.y(), 2)); return sqrt(pow(p1.x() - p2.x(), 2) + pow(p1.y() - p2.y(), 2));
} }
void GraphicsScene::flush()
{
if (nullptr == m_activeItem)
{
return;
}
if (m_status == CreateText)
{
assert(typeid(*m_activeItem) == typeid(QGraphicsProxyWidget));
QString text = m_edit->document()->toPlainText();
QFont font = m_edit->font();
removeItem(m_activeItem);
m_activeItem = nullptr;
QGraphicsTextItem* item = addText(text, font);
item->setPos(m_edit->mapToParent(QPoint()));
item->setDefaultTextColor(m_pen.color());
for (int i = (int)m_ItemList.size() - 1; i > m_curItemIndex; --i)
{
delete m_ItemList[i];
m_ItemList[i] = nullptr;
m_ItemList.erase(m_ItemList.begin() + i);
}
m_ItemList.push_back(item);
++m_curItemIndex;
delete m_edit;
m_edit = nullptr;
}
else
{
assert(typeid(*m_activeItem) != typeid(QGraphicsProxyWidget));
for (int i = (int)m_ItemList.size() - 1; i > m_curItemIndex; --i)
{
delete m_ItemList[i];
m_ItemList[i] = nullptr;
m_ItemList.erase(m_ItemList.begin() + i);
}
m_ItemList.push_back(m_activeItem);
++m_curItemIndex;
m_activeItem = nullptr;
}
}
void GraphicsScene::updateShow()
{
if (m_ItemList.empty() || -1 == m_curItemIndex || NULL == m_ItemList[m_curItemIndex])
{
while (1)
{
QList<QGraphicsItem*> items = this->items();
if (items.count() < 2)
break;
removeItem(items.first());
}
return;
}
int startIndex = m_curItemIndex;
for (int i = m_curItemIndex; i >= 0; --i)
{
if (m_ItemList[i] == NULL)
{
break;
}
startIndex = i;
}
while (1)
{
QList<QGraphicsItem*> items = this->items();
if (items.count() < 2)
break;
removeItem(items.first());
}
for (int i = startIndex; i <= m_curItemIndex; ++i)
{
this->addItem(m_ItemList[i]);
}
}
QPainterPath GraphicsScene::createArrowPath(const QPointF& p1, const QPointF& p2) QPainterPath GraphicsScene::createArrowPath(const QPointF& p1, const QPointF& p2)
{ {
float angle; float angle;
@ -225,7 +347,17 @@ void GraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
if (!sceneRect().contains(mouseEvent->scenePos())) if (!sceneRect().contains(mouseEvent->scenePos()))
return; return;
if (m_status == CreateRect) if (m_status == CreateMask)
{
QGraphicsRectItem* item = reinterpret_cast<QGraphicsRectItem*>(m_activeItem);
QPointF pos = mouseEvent->scenePos();
float left = qMin(pos.x(), m_startPoint.x());
float top = qMin(pos.y(), m_startPoint.y());
float right = qMax(pos.x(), m_startPoint.x());
float bottom = qMax(pos.y(), m_startPoint.y());
item->setRect(QRectF(QPointF(left, top), QPointF(right, bottom)));
}
else if (m_status == CreateRect)
{ {
QGraphicsRectItem* item = reinterpret_cast<QGraphicsRectItem*>(m_activeItem); QGraphicsRectItem* item = reinterpret_cast<QGraphicsRectItem*>(m_activeItem);
QPointF pos = mouseEvent->scenePos(); QPointF pos = mouseEvent->scenePos();
@ -266,16 +398,16 @@ void GraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{ {
if (mouseEvent->button() == Qt::MouseButton::LeftButton) if (m_status == CreateMask)
m_btn_pressed = 1;
else if (mouseEvent->button() == Qt::MouseButton::RightButton)
m_btn_pressed = 2;
if (m_status == CreateRect)
{ {
m_activeItem = addRect(QRectF(mouseEvent->scenePos(), QSize(1, 1)), QPen(m_brush.color()), m_brush); m_activeItem = addRect(QRectF(mouseEvent->scenePos(), QSize(1, 1)), QPen(m_brush.color()), m_brush);
m_startPoint = mouseEvent->scenePos(); m_startPoint = mouseEvent->scenePos();
} }
else if (m_status == CreateRect)
{
m_activeItem = addRect(QRectF(mouseEvent->scenePos(), QSize(1, 1)), m_pen, QBrush());
m_startPoint = mouseEvent->scenePos();
}
else if (m_status == CreateEllipse) else if (m_status == CreateEllipse)
{ {
m_activeItem = addEllipse(QRectF(mouseEvent->scenePos(), QSize(1, 1)), m_pen, QBrush()); m_activeItem = addEllipse(QRectF(mouseEvent->scenePos(), QSize(1, 1)), m_pen, QBrush());
@ -308,30 +440,38 @@ void GraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
return; return;
} }
m_btn_pressed = 0;
if (m_activeItem != nullptr)
if (typeid(*m_activeItem) != typeid(QGraphicsProxyWidget))
m_activeItem = nullptr;
if (m_status == CreateText) if (m_status == CreateText)
{ {
if (m_activeItem != nullptr) if (m_activeItem != nullptr)
{ {
assert(typeid(*m_activeItem) == typeid(QGraphicsProxyWidget));
QRectF r(m_edit->mapToParent(QPoint()), m_edit->size()); QRectF r(m_edit->mapToParent(QPoint()), m_edit->size());
if (r.contains(mouseEvent->scenePos())) if (r.contains(mouseEvent->scenePos()))
{ {
QGraphicsScene::mouseReleaseEvent(mouseEvent); QGraphicsScene::mouseReleaseEvent(mouseEvent);
return; return;
} }
QString text = m_edit->document()->toPlainText(); QString text = m_edit->document()->toPlainText();
QFont font = m_edit->font(); QFont font = m_edit->font();
removeItem(m_activeItem); removeItem(m_activeItem);
m_activeItem = nullptr;
QGraphicsTextItem* item = addText(text, font); QGraphicsTextItem* item = addText(text, font);
item->setPos(m_edit->mapToParent(QPoint())); item->setPos(m_edit->mapToParent(QPoint()));
item->setDefaultTextColor(m_pen.color()); item->setDefaultTextColor(m_pen.color());
for (int i = (int)m_ItemList.size() - 1; i > m_curItemIndex; --i)
{
delete m_ItemList[i];
m_ItemList[i] = nullptr;
m_ItemList.erase(m_ItemList.begin() + i);
}
m_ItemList.push_back(item);
++m_curItemIndex;
delete m_edit; delete m_edit;
m_edit = nullptr; m_edit = nullptr;
m_activeItem = nullptr; emit itemChanged();
} }
else else
{ {
@ -343,6 +483,23 @@ void GraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
m_activeItem = widget; m_activeItem = widget;
m_edit->setFocus(); m_edit->setFocus();
} }
}
else
{
if (m_activeItem != nullptr)
{
assert(typeid(*m_activeItem) != typeid(QGraphicsProxyWidget));
for (int i = (int)m_ItemList.size() - 1; i > m_curItemIndex; --i)
{
delete m_ItemList[i];
m_ItemList[i] = nullptr;
m_ItemList.erase(m_ItemList.begin() + i);
}
m_ItemList.push_back(m_activeItem);
++m_curItemIndex;
m_activeItem = nullptr;
emit itemChanged();
}
} }
} }

View File

@ -3,8 +3,8 @@
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsPixmapItem> #include <QGraphicsPixmapItem>
#include <QTextEdit> #include <QTextEdit>
#include <vector>
class GraphicsTextEdit : public QTextEdit class GraphicsTextEdit : public QTextEdit
{ {
@ -29,6 +29,7 @@ public:
enum STATUS enum STATUS
{ {
Normal = 0, Normal = 0,
CreateMask,
CreateRect, CreateRect,
CreateEllipse, CreateEllipse,
CreateLine, CreateLine,
@ -41,6 +42,7 @@ public:
enum enum
{ {
None, None,
Mask,
Rect, Rect,
Ellipse, Ellipse,
Line, Line,
@ -61,8 +63,18 @@ public:
void setItemFlag(int flag); void setItemFlag(int flag);
void unDo(); bool isCanUndo();
void undo();
bool isCanRedo();
void redo();
void clear();
signals:
void itemChanged();
private: private:
void flush();
void updateShow();
QPainterPath createArrowPath(const QPointF& p1, const QPointF& p2); QPainterPath createArrowPath(const QPointF& p1, const QPointF& p2);
protected: protected:
@ -72,12 +84,13 @@ protected:
private: private:
STATUS m_status; STATUS m_status;
QGraphicsItem* m_activeItem; QGraphicsItem* m_activeItem;
int m_btn_pressed;
QPointF m_startPoint; QPointF m_startPoint;
QPen m_pen; QPen m_pen;
QBrush m_brush; QBrush m_brush;
QFont m_font; QFont m_font;
GraphicsTextEdit* m_edit; GraphicsTextEdit* m_edit;
std::vector<QGraphicsItem*> m_ItemList;
int m_curItemIndex;
}; };
#endif // GRAPHICSSCENE_H #endif // GRAPHICSSCENE_H

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 59 KiB

File diff suppressed because it is too large Load Diff

View File

@ -52,12 +52,9 @@ enum askIfClear
notClearAndScan notClearAndScan
}; };
//class dialog_wrong_img;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
std::vector<class dialog_wrong_img*> wrong_imgs_;
public: public:
MainWindow(const QString& appLang, QWidget *parent = nullptr); MainWindow(const QString& appLang, QWidget *parent = nullptr);
@ -98,11 +95,13 @@ private slots:
signals: signals:
void post_new_image(QString fileName); void post_new_image(QString fileName);
void preview_image();
private slots: private slots:
void on_AcquireInto2(); void on_AcquireInto2();
void on_reloadAcquireIntoCfg(); void on_reloadAcquireIntoCfg();
void on_m_acquireIntoCfg_changed(QString schemeName); void on_m_acquireIntoCfg_changed(QString schemeName);
void on_keyDeleteDown();
void on_itemCountChanged(int count); void on_itemCountChanged(int count);
void on_itemSelectingChanged(); void on_itemSelectingChanged();
void on_currItemChanged(int index); void on_currItemChanged(int index);
@ -120,10 +119,10 @@ private slots:
void on_multiPageLineEditFinished(); void on_multiPageLineEditFinished();
void on_clearCache(); void on_clearCache();
void on_post_new_image(QString fileName); void on_post_new_image(QString fileName);
void on_preview_image();
void on_newImage(void *image); void on_newImage(void *image);
void on_scanFinishEvent(); void on_scanFinishEvent();
void on_scanWorkingEvent(); void on_scanWorkingEvent();
//void on_wrong_image_decide(dialog_wrong_img* dlg, bool save);
void on_m_pbtn_push_clicked(); void on_m_pbtn_push_clicked();
void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText); void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText);
void on_dialog_sideBar_finish(bool ok); void on_dialog_sideBar_finish(bool ok);
@ -252,6 +251,7 @@ private:
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
bool m_canClose;
DeviceUserMgr *m_devUserMgr; DeviceUserMgr *m_devUserMgr;
DeviceUser *m_devUser; DeviceUser *m_devUser;
QAction *m_act_acquireInto2; QAction *m_act_acquireInto2;
@ -262,6 +262,8 @@ private:
bool m_admin_loggedIn; bool m_admin_loggedIn;
HGImgView *m_view; HGImgView *m_view;
HGImgThumb *m_thumb; HGImgThumb *m_thumb;
std::list<QString> m_curBatchFileList;
std::list<QString> m_curBatchTmpFileList;
QMenu *m_thumbMenu; QMenu *m_thumbMenu;
QMenu* m_menu_imageInsert; QMenu* m_menu_imageInsert;
QAction *m_moveToAction; QAction *m_moveToAction;
@ -304,9 +306,19 @@ private:
int m_multiPageCount; int m_multiPageCount;
int m_multiIndex; int m_multiIndex;
bool m_modify; // m_view上面的图像是否改变 bool m_modify; // m_view上面的图像是否改变
bool m_singleScan; // 是否单张扫描 enum ScanType
int m_scanType; // 1-扫描到缓存目录2-扫描到本地目录 {
ScanType_None,
ScanType_ScanToCache,
ScanType_SingleScanToCache,
ScanType_ScanInto,
ScanType_InsertScanInto
};
ScanType m_scanType; // 1-扫描到缓存目录2-单张扫描到缓存目录3-扫描到指定目录4-插入扫描到指定目录
int m_scanInsertPos; // 扫描插入位置,-1表示插入到最后 int m_scanInsertPos; // 扫描插入位置,-1表示插入到最后
int m_scanCurIndex;
HGLock m_lockPreviewImage;
HGImage m_previewImage;
QString m_scanFileName; QString m_scanFileName;
HGImgFmtWriter m_scanImgFmtWriter; HGImgFmtWriter m_scanImgFmtWriter;
AquireIntoSaveParam m_aquireIntoSaveParam; AquireIntoSaveParam m_aquireIntoSaveParam;

View File

@ -7,6 +7,7 @@
Widget_Imgproc_SideBar::Widget_Imgproc_SideBar(QWidget *parent) : Widget_Imgproc_SideBar::Widget_Imgproc_SideBar(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::Widget_Imgproc_SideBar) ui(new Ui::Widget_Imgproc_SideBar)
, m_applyToImage(true)
, m_curImage(NULL) , m_curImage(NULL)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -28,6 +29,7 @@ Widget_Imgproc_SideBar::~Widget_Imgproc_SideBar()
void Widget_Imgproc_SideBar::setImage(HGImage image) void Widget_Imgproc_SideBar::setImage(HGImage image)
{ {
HGBase_DestroyImage(m_curImage); HGBase_DestroyImage(m_curImage);
m_curImage = nullptr;
HGBase_CloneImage(image, 0, 0, &m_curImage); HGBase_CloneImage(image, 0, 0, &m_curImage);
on_pbtn_restoreDefault_clicked(); on_pbtn_restoreDefault_clicked();
} }
@ -49,29 +51,41 @@ void Widget_Imgproc_SideBar::paintEvent(QPaintEvent *e)
void Widget_Imgproc_SideBar::on_spin_brightness_valueChanged(int arg1) void Widget_Imgproc_SideBar::on_spin_brightness_valueChanged(int arg1)
{ {
ui->slider_brightness->setValue(arg1); ui->slider_brightness->setValue(arg1);
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), if (m_applyToImage)
ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); {
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(),
ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked());
}
} }
void Widget_Imgproc_SideBar::on_spin_contrast_valueChanged(int arg1) void Widget_Imgproc_SideBar::on_spin_contrast_valueChanged(int arg1)
{ {
ui->slider_contrast->setValue(arg1); ui->slider_contrast->setValue(arg1);
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), if (m_applyToImage)
{
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(),
ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked());
}
} }
void Widget_Imgproc_SideBar::on_dspin_gamma_valueChanged(double arg1) void Widget_Imgproc_SideBar::on_dspin_gamma_valueChanged(double arg1)
{ {
ui->slider_gamma->setValue(static_cast<int>(arg1 * 100)); ui->slider_gamma->setValue(static_cast<int>(arg1 * 100));
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), if (m_applyToImage)
{
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(),
ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked());
}
} }
void Widget_Imgproc_SideBar::on_slider_gamma_valueChanged(int value) void Widget_Imgproc_SideBar::on_slider_gamma_valueChanged(int value)
{ {
ui->dspin_gamma->setValue(static_cast<double>(value / 100.0)); ui->dspin_gamma->setValue(static_cast<double>(value / 100.0));
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), if (m_applyToImage)
{
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(),
ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked());
}
} }
void Widget_Imgproc_SideBar::on_pbtn_restoreDefault_clicked() void Widget_Imgproc_SideBar::on_pbtn_restoreDefault_clicked()
@ -84,6 +98,10 @@ void Widget_Imgproc_SideBar::on_pbtn_restoreDefault_clicked()
void Widget_Imgproc_SideBar::on_pbtn_ok_clicked() void Widget_Imgproc_SideBar::on_pbtn_ok_clicked()
{ {
m_applyToImage = false;
on_pbtn_restoreDefault_clicked();
m_applyToImage = true;
emit finish(true); emit finish(true);
} }
@ -95,6 +113,9 @@ void Widget_Imgproc_SideBar::on_pbtn_cancel_clicked()
void Widget_Imgproc_SideBar::on_checkBox_enhanceText_toggled(bool checked) void Widget_Imgproc_SideBar::on_checkBox_enhanceText_toggled(bool checked)
{ {
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), if (m_applyToImage)
{
emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(),
ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked());
}
} }

View File

@ -46,6 +46,7 @@ private slots:
private: private:
Ui::Widget_Imgproc_SideBar *ui; Ui::Widget_Imgproc_SideBar *ui;
bool m_applyToImage;
HGImage m_curImage; HGImage m_curImage;
}; };

View File

@ -6,342 +6,361 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>220</width> <width>255</width>
<height>376</height> <height>422</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<widget class="QPushButton" name="pbtn_ok"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="geometry"> <item>
<rect> <widget class="QGroupBox" name="gbox_brightness">
<x>60</x> <property name="title">
<y>340</y> <string>Brightness</string>
<width>75</width> </property>
<height>23</height> <layout class="QHBoxLayout" name="horizontalLayout">
</rect> <item>
</property> <widget class="QSlider" name="slider_brightness">
<property name="text"> <property name="minimumSize">
<string>Ok</string> <size>
</property> <width>121</width>
</widget> <height>0</height>
<widget class="QPushButton" name="pbtn_cancel"> </size>
<property name="geometry"> </property>
<rect> <property name="maximumSize">
<x>140</x> <size>
<y>340</y> <width>121</width>
<width>75</width> <height>27</height>
<height>23</height> </size>
</rect> </property>
</property> <property name="minimum">
<property name="text"> <number>-255</number>
<string>Cancel</string> </property>
</property> <property name="maximum">
</widget> <number>255</number>
<widget class="QWidget" name="layoutWidget"> </property>
<property name="geometry"> <property name="value">
<rect> <number>0</number>
<x>10</x> </property>
<y>250</y> <property name="tracking">
<width>143</width> <bool>false</bool>
<height>22</height> </property>
</rect> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
<layout class="QHBoxLayout" name="horizontalLayout_5"> </property>
<item> <property name="tickPosition">
<widget class="QCheckBox" name="checkBox_enhanceText"> <enum>QSlider::TicksAbove</enum>
<property name="text"> </property>
<string>Enhance Text</string> <property name="tickInterval">
</property> <number>32</number>
</widget> </property>
</item> </widget>
<item> </item>
<spacer name="horizontalSpacer_3"> <item>
<property name="orientation"> <widget class="QSpinBox" name="spin_brightness">
<enum>Qt::Horizontal</enum> <property name="minimumSize">
</property> <size>
<property name="sizeHint" stdset="0"> <width>50</width>
<size> <height>0</height>
<width>40</width> </size>
<height>20</height> </property>
</size> <property name="maximumSize">
</property> <size>
</spacer> <width>16777215</width>
</item> <height>16777215</height>
</layout> </size>
</widget> </property>
<widget class="QGroupBox" name="gbox_brightness"> <property name="minimum">
<property name="geometry"> <number>-255</number>
<rect> </property>
<x>10</x> <property name="maximum">
<y>10</y> <number>255</number>
<width>201</width> </property>
<height>71</height> <property name="value">
</rect> <number>0</number>
</property> </property>
<property name="title"> <property name="displayIntegerBase">
<string>Brightness</string> <number>10</number>
</property> </property>
<widget class="QSlider" name="slider_brightness"> </widget>
<property name="geometry"> </item>
<rect> <item>
<x>10</x> <spacer name="horizontalSpacer">
<y>35</y> <property name="orientation">
<width>121</width> <enum>Qt::Horizontal</enum>
<height>27</height> </property>
</rect> <property name="sizeHint" stdset="0">
</property> <size>
<property name="maximumSize"> <width>10</width>
<size> <height>20</height>
<width>121</width> </size>
<height>27</height> </property>
</size> </spacer>
</property> </item>
<property name="minimum"> </layout>
<number>-255</number> </widget>
</property> </item>
<property name="maximum"> <item>
<number>255</number> <widget class="QGroupBox" name="gbox_contrast">
</property> <property name="title">
<property name="value"> <string>Contrast</string>
<number>0</number> </property>
</property> <layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="tracking"> <item>
<bool>false</bool> <widget class="QSlider" name="slider_contrast">
</property> <property name="minimumSize">
<property name="orientation"> <size>
<enum>Qt::Horizontal</enum> <width>121</width>
</property> <height>0</height>
<property name="tickPosition"> </size>
<enum>QSlider::TicksAbove</enum> </property>
</property> <property name="maximumSize">
<property name="tickInterval"> <size>
<number>32</number> <width>16777215</width>
</property> <height>16777215</height>
</widget> </size>
<widget class="QSpinBox" name="spin_brightness"> </property>
<property name="geometry"> <property name="minimum">
<rect> <number>-127</number>
<x>140</x> </property>
<y>40</y> <property name="maximum">
<width>51</width> <number>127</number>
<height>20</height> </property>
</rect> <property name="value">
</property> <number>0</number>
<property name="minimumSize"> </property>
<size> <property name="tracking">
<width>0</width> <bool>false</bool>
<height>0</height> </property>
</size> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
<property name="maximumSize"> </property>
<size> <property name="invertedAppearance">
<width>51</width> <bool>false</bool>
<height>20</height> </property>
</size> <property name="invertedControls">
</property> <bool>false</bool>
<property name="minimum"> </property>
<number>-255</number> <property name="tickPosition">
</property> <enum>QSlider::TicksAbove</enum>
<property name="maximum"> </property>
<number>255</number> <property name="tickInterval">
</property> <number>16</number>
<property name="value"> </property>
<number>0</number> </widget>
</property> </item>
<property name="displayIntegerBase"> <item>
<number>10</number> <widget class="QSpinBox" name="spin_contrast">
</property> <property name="minimumSize">
</widget> <size>
</widget> <width>51</width>
<widget class="QGroupBox" name="gbox_gamma"> <height>0</height>
<property name="geometry"> </size>
<rect> </property>
<x>10</x> <property name="maximumSize">
<y>170</y> <size>
<width>201</width> <width>16777215</width>
<height>71</height> <height>16777215</height>
</rect> </size>
</property> </property>
<property name="title"> <property name="minimum">
<string>Gamma correction</string> <number>-127</number>
</property> </property>
<widget class="QSlider" name="slider_gamma"> <property name="maximum">
<property name="geometry"> <number>127</number>
<rect> </property>
<x>10</x> <property name="value">
<y>35</y> <number>0</number>
<width>121</width> </property>
<height>27</height> <property name="displayIntegerBase">
</rect> <number>10</number>
</property> </property>
<property name="maximumSize"> </widget>
<size> </item>
<width>121</width> <item>
<height>27</height> <spacer name="horizontalSpacer_2">
</size> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
<property name="minimum"> </property>
<number>1</number> <property name="sizeHint" stdset="0">
</property> <size>
<property name="maximum"> <width>9</width>
<number>500</number> <height>20</height>
</property> </size>
<property name="value"> </property>
<number>100</number> </spacer>
</property> </item>
<property name="tracking"> </layout>
<bool>false</bool> </widget>
</property> </item>
<property name="orientation"> <item>
<enum>Qt::Horizontal</enum> <widget class="QGroupBox" name="gbox_gamma">
</property> <property name="title">
<property name="tickPosition"> <string>Gamma correction</string>
<enum>QSlider::TicksAbove</enum> </property>
</property> <layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="tickInterval"> <item>
<number>25</number> <widget class="QSlider" name="slider_gamma">
</property> <property name="minimumSize">
</widget> <size>
<widget class="QDoubleSpinBox" name="dspin_gamma"> <width>121</width>
<property name="geometry"> <height>0</height>
<rect> </size>
<x>140</x> </property>
<y>40</y> <property name="maximumSize">
<width>51</width> <size>
<height>20</height> <width>16777215</width>
</rect> <height>16777215</height>
</property> </size>
<property name="minimumSize"> </property>
<size> <property name="minimum">
<width>0</width> <number>1</number>
<height>0</height> </property>
</size> <property name="maximum">
</property> <number>500</number>
<property name="maximumSize"> </property>
<size> <property name="value">
<width>51</width> <number>100</number>
<height>20</height> </property>
</size> <property name="tracking">
</property> <bool>false</bool>
<property name="minimum"> </property>
<double>0.010000000000000</double> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
<property name="maximum"> </property>
<double>5.000000000000000</double> <property name="tickPosition">
</property> <enum>QSlider::TicksAbove</enum>
<property name="singleStep"> </property>
<double>0.010000000000000</double> <property name="tickInterval">
</property> <number>25</number>
<property name="value"> </property>
<double>1.000000000000000</double> </widget>
</property> </item>
</widget> <item>
</widget> <widget class="QDoubleSpinBox" name="dspin_gamma">
<widget class="QGroupBox" name="gbox_contrast"> <property name="minimumSize">
<property name="geometry"> <size>
<rect> <width>51</width>
<x>10</x> <height>0</height>
<y>90</y> </size>
<width>201</width> </property>
<height>71</height> <property name="maximumSize">
</rect> <size>
</property> <width>16777215</width>
<property name="title"> <height>16777215</height>
<string>Contrast</string> </size>
</property> </property>
<widget class="QSlider" name="slider_contrast"> <property name="minimum">
<property name="geometry"> <double>0.010000000000000</double>
<rect> </property>
<x>10</x> <property name="maximum">
<y>34</y> <double>5.000000000000000</double>
<width>121</width> </property>
<height>27</height> <property name="singleStep">
</rect> <double>0.010000000000000</double>
</property> </property>
<property name="maximumSize"> <property name="value">
<size> <double>1.000000000000000</double>
<width>121</width> </property>
<height>27</height> </widget>
</size> </item>
</property> <item>
<property name="minimum"> <spacer name="horizontalSpacer_4">
<number>-127</number> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
<property name="maximum"> </property>
<number>127</number> <property name="sizeHint" stdset="0">
</property> <size>
<property name="value"> <width>9</width>
<number>0</number> <height>20</height>
</property> </size>
<property name="tracking"> </property>
<bool>false</bool> </spacer>
</property> </item>
<property name="orientation"> </layout>
<enum>Qt::Horizontal</enum> </widget>
</property> </item>
<property name="invertedAppearance"> <item>
<bool>false</bool> <layout class="QHBoxLayout" name="horizontalLayout_5">
</property> <item>
<property name="invertedControls"> <widget class="QCheckBox" name="checkBox_enhanceText">
<bool>false</bool> <property name="text">
</property> <string>Enhance Text</string>
<property name="tickPosition"> </property>
<enum>QSlider::TicksAbove</enum> </widget>
</property> </item>
<property name="tickInterval"> <item>
<number>16</number> <spacer name="horizontalSpacer_3">
</property> <property name="orientation">
</widget> <enum>Qt::Horizontal</enum>
<widget class="QSpinBox" name="spin_contrast"> </property>
<property name="geometry"> <property name="sizeHint" stdset="0">
<rect> <size>
<x>140</x> <width>40</width>
<y>40</y> <height>20</height>
<width>51</width> </size>
<height>20</height> </property>
</rect> </spacer>
</property> </item>
<property name="minimumSize"> </layout>
<size> </item>
<width>0</width> <item>
<height>0</height> <layout class="QHBoxLayout" name="horizontalLayout_2">
</size> <item>
</property> <widget class="QPushButton" name="pbtn_restoreDefault">
<property name="maximumSize"> <property name="text">
<size> <string>Restore defaults</string>
<width>51</width> </property>
<height>20</height> </widget>
</size> </item>
</property> <item>
<property name="minimum"> <spacer name="horizontalSpacer_5">
<number>-127</number> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
<property name="maximum"> </property>
<number>127</number> <property name="sizeHint" stdset="0">
</property> <size>
<property name="value"> <width>40</width>
<number>0</number> <height>20</height>
</property> </size>
<property name="displayIntegerBase"> </property>
<number>10</number> </spacer>
</property> </item>
</widget> </layout>
</widget> </item>
<widget class="QPushButton" name="pbtn_restoreDefault"> <item>
<property name="geometry"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<rect> <item>
<x>10</x> <spacer name="horizontalSpacer_6">
<y>290</y> <property name="orientation">
<width>104</width> <enum>Qt::Horizontal</enum>
<height>23</height> </property>
</rect> <property name="sizeHint" stdset="0">
</property> <size>
<property name="text"> <width>40</width>
<string>Restore defaults</string> <height>20</height>
</property> </size>
</widget> </property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbtn_ok">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbtn_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -1,4 +1,7 @@
<RCC> <RCC>
<qresource prefix="/qt">
<file>etc/qt.conf</file>
</qresource>
<qresource prefix="/translation"> <qresource prefix="/translation">
<file>Upgrade_zh_CN.qm</file> <file>Upgrade_zh_CN.qm</file>
</qresource> </qresource>

2
app/upgrade/etc/qt.conf Normal file
View File

@ -0,0 +1,2 @@
[Platforms]
WindowsArguments = dpiawareness=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -4,121 +4,121 @@ cd /d ./build2/qt
if "%OEM%" == "hw" ( if "%OEM%" == "hw" (
%QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_HANWANG" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_HANWANG" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_HANWANG" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_HANWANG" -r -tp vc HGTwainUI.pro
MSBuild.exe HWTwainUI.vcxproj /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HWTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d ../ cd /d ../
%QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_HANWANG" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_HANWANG" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_HANWANG" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_HANWANG" -r -tp vc HGTwainUI.pro
MSBuild.exe HWTwainUI.vcxproj /m:8 /p:Configuration=Release MSBuild.exe HWTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) else ( ) else (
if "%OEM%" == "lsc" ( if "%OEM%" == "lsc" (
%QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_LISICHENG" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_LISICHENG" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_LISICHENG" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_LISICHENG" -r -tp vc HGTwainUI.pro
MSBuild.exe LSCTwainUI.vcxproj /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe LSCTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d ../ cd /d ../
%QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_LISICHENG" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_LISICHENG" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_LISICHENG" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_LISICHENG" -r -tp vc HGTwainUI.pro
MSBuild.exe LSCTwainUI.vcxproj /m:8 /p:Configuration=Release MSBuild.exe LSCTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) else ( ) else (
if "%OEM%" == "cts" ( if "%OEM%" == "cts" (
%QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_CANGTIAN" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_CANGTIAN" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_CANGTIAN" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_CANGTIAN" -r -tp vc HGTwainUI.pro
MSBuild.exe CTSTwainUI.vcxproj /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe CTSTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d ../ cd /d ../
%QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_CANGTIAN" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_CANGTIAN" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_CANGTIAN" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_CANGTIAN" -r -tp vc HGTwainUI.pro
MSBuild.exe CTSTwainUI.vcxproj /m:8 /p:Configuration=Release MSBuild.exe CTSTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) else ( ) else (
if "%OEM%" == "zj" ( if "%OEM%" == "zj" (
%QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_ZHONGJING" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_ZHONGJING" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_ZHONGJING" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_ZHONGJING" -r -tp vc HGTwainUI.pro
MSBuild.exe ZJTwainUI.vcxproj /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe ZJTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d ../ cd /d ../
%QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_ZHONGJING" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_ZHONGJING" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_ZHONGJING" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_ZHONGJING" -r -tp vc HGTwainUI.pro
MSBuild.exe ZJTwainUI.vcxproj /m:8 /p:Configuration=Release MSBuild.exe ZJTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) else ( ) else (
if "%OEM%" == "zg" ( if "%OEM%" == "zg" (
%QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_ZIGUANG" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_ZIGUANG" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_ZIGUANG" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_ZIGUANG" -r -tp vc HGTwainUI.pro
MSBuild.exe ZGTwainUI.vcxproj /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe ZGTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d ../ cd /d ../
%QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_ZIGUANG" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_ZIGUANG" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_ZIGUANG" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_ZIGUANG" -r -tp vc HGTwainUI.pro
MSBuild.exe ZGTwainUI.vcxproj /m:8 /p:Configuration=Release MSBuild.exe ZGTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) else ( ) else (
if "%OEM%" == "neu" ( if "%OEM%" == "neu" (
%QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_NEUTRAL" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_NEUTRAL" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_NEUTRAL" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_NEUTRAL" -r -tp vc HGTwainUI.pro
MSBuild.exe NEUTwainUI.vcxproj /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe NEUTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d ../ cd /d ../
%QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_NEUTRAL" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_NEUTRAL" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_NEUTRAL" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_NEUTRAL" -r -tp vc HGTwainUI.pro
MSBuild.exe NEUTwainUI.vcxproj /m:8 /p:Configuration=Release MSBuild.exe NEUTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) else ( ) else (
if "%OEM%" == "dl" ( if "%OEM%" == "dl" (
%QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_DELI" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017_64/bin/qmake "DEFINES += OEM_DELI" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_DELI" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_DELI" -r -tp vc HGTwainUI.pro
MSBuild.exe DLTwainUI.vcxproj /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe DLTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d ../ cd /d ../
%QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_DELI" -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017/bin/qmake "DEFINES += OEM_DELI" -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_DELI" -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake "DEFINES += OEM_DELI" -r -tp vc HGTwainUI.pro
MSBuild.exe DLTwainUI.vcxproj /m:8 /p:Configuration=Release MSBuild.exe DLTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) else ( ) else (
%QT_PATH%/msvc2017_64/bin/qmake -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017_64/bin/qmake -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x64-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGTwainUI.pro
MSBuild.exe HGTwainUI.vcxproj /m:8 /p:Configuration=Release /p:Platform=x64 MSBuild.exe HGTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release /p:Platform=x64
cd /d ../ cd /d ../
%QT_PATH%/msvc2017/bin/qmake -r -tp vc HGSolutionWin.pro %QT_PATH%/msvc2017/bin/qmake -r -tp vc HGSolutionWin.pro
MSBuild.exe HGSolutionWin.sln /m:8 /p:Configuration=Release MSBuild.exe HGSolutionWin.sln -t:rebuild /m:8 /p:Configuration=Release
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGTwainUI.pro
MSBuild.exe HGTwainUI.vcxproj /m:8 /p:Configuration=Release MSBuild.exe HGTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) )
) )

View File

@ -27,17 +27,13 @@ rm -f HGBase/Makefile
rm -f HGFWUpgrade/Makefile rm -f HGFWUpgrade/Makefile
rm -f HGImgFmt/Makefile rm -f HGImgFmt/Makefile
rm -f HGImgProc/Makefile rm -f HGImgProc/Makefile
rm -f HGSaneUI/Makefile
rm -f HGSaneUser/Makefile
rm -f HGTwainUI/Makefile rm -f HGTwainUI/Makefile
rm -f HGOCR/Makefile rm -f HGSaneUser/Makefile
rm -f HGScanner/Makefile
rm -f HGScanner2/Makefile rm -f HGScanner2/Makefile
rm -f HGScannerLib/Makefile rm -f HGScannerLib/Makefile
rm -f HGUpgrade/Makefile rm -f HGUpgrade/Makefile
rm -f HGUpload/Makefile rm -f HGUpload/Makefile
rm -f HGVersion/Makefile rm -f HGVersion/Makefile
rm -f HGWebScan/Makefile
rm -f HGWebService/Makefile rm -f HGWebService/Makefile
if [ "${1}" == "hwall" ] || [ "${1}" == "hw" ]|| [ "${1}" == "hwweb" ] || [ "${1}" == "hwso" ] || [ "${1}" == "hwtwain" ]; then if [ "${1}" == "hwall" ] || [ "${1}" == "hw" ]|| [ "${1}" == "hwweb" ] || [ "${1}" == "hwso" ] || [ "${1}" == "hwtwain" ]; then
@ -66,13 +62,8 @@ if [ "${1}" == "hwall" ] || [ "${1}" == "hw" ]|| [ "${1}" == "hwweb" ] || [ "${
if [ "${1}" == "hw" ]; then if [ "${1}" == "hw" ]; then
cd HGOCR cd HGTwainUI
qmake -qt=qt5 -makefile "DEFINES += OEM_HANWANG" HGOCR.pro qmake -qt=qt5 -makefile "DEFINES += OEM_HANWANG" HGTwainUI.pro
make -j8
cd ../
cd HGSaneUI
qmake -qt=qt5 -makefile "DEFINES += OEM_HANWANG" HGSaneUI.pro
make -j8 make -j8
cd ../ cd ../
@ -137,13 +128,8 @@ elif [ "${1}" == "lscall" ] || [ "${1}" == "lsc" ] || [ "${1}" == "lscweb" ] ||
if [ "${1}" == "lsc" ]; then if [ "${1}" == "lsc" ]; then
cd HGOCR cd HGTwainUI
qmake -qt=qt5 -makefile "DEFINES += OEM_LISICHENG" HGOCR.pro qmake -qt=qt5 -makefile "DEFINES += OEM_LISICHENG" HGTwainUI.pro
make -j8
cd ../
cd HGSaneUI
qmake -qt=qt5 -makefile "DEFINES += OEM_LISICHENG" HGSaneUI.pro
make -j8 make -j8
cd ../ cd ../
@ -208,13 +194,8 @@ elif [ "${1}" == "ctsall" ] || [ "${1}" == "cts" ] || [ "${1}" == "ctsweb" ] ||
if [ "${1}" == "cts" ]; then if [ "${1}" == "cts" ]; then
cd HGOCR cd HGTwainUI
qmake -qt=qt5 -makefile "DEFINES += OEM_CANGTIAN" HGOCR.pro qmake -qt=qt5 -makefile "DEFINES += OEM_CANGTIAN" HGTwainUI.pro
make -j8
cd ../
cd HGSaneUI
qmake -qt=qt5 -makefile "DEFINES += OEM_CANGTIAN" HGSaneUI.pro
make -j8 make -j8
cd ../ cd ../
@ -279,13 +260,8 @@ elif [ "${1}" == "zjall" ] || [ "${1}" == "zj" ] || [ "${1}" == "zjweb" ] || [ "
if [ "${1}" == "zj" ]; then if [ "${1}" == "zj" ]; then
cd HGOCR cd HGTwainUI
qmake -qt=qt5 -makefile "DEFINES += OEM_ZHONGJING" HGOCR.pro qmake -qt=qt5 -makefile "DEFINES += OEM_ZHONGJING" HGTwainUI.pro
make -j8
cd ../
cd HGSaneUI
qmake -qt=qt5 -makefile "DEFINES += OEM_ZHONGJING" HGSaneUI.pro
make -j8 make -j8
cd ../ cd ../
@ -350,13 +326,8 @@ elif [ "${1}" == "zgall" ] || [ "${1}" == "zg" ] || [ "${1}" == "zgweb" ] || [ "
if [ "${1}" == "zg" ]; then if [ "${1}" == "zg" ]; then
cd HGOCR cd HGTwainUI
qmake -qt=qt5 -makefile "DEFINES += OEM_ZIGUANG" HGOCR.pro qmake -qt=qt5 -makefile "DEFINES += OEM_ZIGUANG" HGTwainUI.pro
make -j8
cd ../
cd HGSaneUI
qmake -qt=qt5 -makefile "DEFINES += OEM_ZIGUANG" HGSaneUI.pro
make -j8 make -j8
cd ../ cd ../
@ -421,13 +392,8 @@ elif [ "${1}" == "dlall" ] || [ "${1}" == "dl" ] || [ "${1}" == "dlweb" ] || [ "
if [ "${1}" == "dl" ]; then if [ "${1}" == "dl" ]; then
cd HGOCR cd HGTwainUI
qmake -qt=qt5 -makefile "DEFINES += OEM_DELI" HGOCR.pro qmake -qt=qt5 -makefile "DEFINES += OEM_DELI" HGTwainUI.pro
make -j8
cd ../
cd HGSaneUI
qmake -qt=qt5 -makefile "DEFINES += OEM_DELI" HGSaneUI.pro
make -j8 make -j8
cd ../ cd ../
@ -497,13 +463,8 @@ else
make -j8 make -j8
cd ../ cd ../
cd HGOCR cd HGTwainUI
qmake -qt=qt5 -makefile HGOCR.pro qmake -qt=qt5 -makefile HGTwainUI.pro
make -j8
cd ../
cd HGSaneUI
qmake -qt=qt5 -makefile HGSaneUI.pro
make -j8 make -j8
cd ../ cd ../

View File

@ -80,6 +80,10 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden

View File

@ -87,6 +87,7 @@ win32 {
unix { unix {
DEFINES += _GLIBCXX_USE_CXX11_ABI=0
DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1) DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1)
contains(DISTRIBUTION, UnionTech) { contains(DISTRIBUTION, UnionTech) {
MY_OS = uos MY_OS = uos
@ -111,10 +112,13 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct QMAKE_LFLAGS += -z defs -B direct

View File

@ -101,6 +101,10 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
@ -128,6 +132,10 @@ unix {
LIBS += $$PWD/../../../third_party/libzip/$${MY_OS}/$${MY_ARCH}/lib/libzip.a LIBS += $$PWD/../../../third_party/libzip/$${MY_OS}/$${MY_ARCH}/lib/libzip.a
LIBS += $$PWD/../../../third_party/tinyxml2/$${MY_OS}/$${MY_ARCH}/lib/libtinyxml2.a LIBS += $$PWD/../../../third_party/tinyxml2/$${MY_OS}/$${MY_ARCH}/lib/libtinyxml2.a
LIBS += $$PWD/../../../third_party/zlib/$${MY_OS}/$${MY_ARCH}/lib/libz.a LIBS += $$PWD/../../../third_party/zlib/$${MY_OS}/$${MY_ARCH}/lib/libz.a
contains(QT_ARCH, sw_64) {
LIBS += $$PWD/../../../third_party/openssl/$${MY_OS}/$${MY_ARCH}/lib/libcrypto.a
LIBS += $$PWD/../../../third_party/openssl/$${MY_OS}/$${MY_ARCH}/lib/libssl.a
}
} }
INCLUDEPATH += $$PWD/../../../utility INCLUDEPATH += $$PWD/../../../utility

View File

@ -130,6 +130,15 @@ unix {
LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libopencv_core.a LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libopencv_core.a
LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libzlib.a LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libzlib.a
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libopencv_highgui.a
LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libopencv_features2d.a
LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libopencv_imgproc.a
LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libopencv_core.a
LIBS += $$PWD/../../../third_party/opencv/$${MY_OS}/$${MY_ARCH}/lib/libzlib.a
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden

View File

@ -1,151 +0,0 @@
CONFIG -= qt
TEMPLATE = app
DEFINES += UNTITLED_LIBRARY
CONFIG += c++11
CONFIG += console
# 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
# 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
include($$PWD/../HGOEM.pri)
CONFIG(debug, debug|release) {
MY_CONFIGURE = Debug
}
CONFIG(release, debug|release) {
MY_CONFIGURE = Release
}
win32 {
MY_OS = windows
TARGET = $${OEM_PREFIX}OCR
contains(QT_ARCH, i386) {
MY_ARCH = x86
}
contains(QT_ARCH, x86_64) {
MY_ARCH = x64
}
CONFIG(debug, debug|release) {
QMAKE_CFLAGS_DEBUG += -MTd
QMAKE_CXXFLAGS_DEBUG += -MTd
}
CONFIG(release, debug|release) {
QMAKE_CFLAGS_RELEASE += -MT
QMAKE_CXXFLAGS_RELEASE += -MT
QMAKE_LFLAGS_RELEASE += /MAP
QMAKE_CFLAGS_RELEASE += /Zi
QMAKE_LFLAGS_RELEASE += /debug /opt:ref
}
LIBS += -lgdi32 -lgdiplus -ldbghelp -lws2_32
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base -l$${OEM_PREFIX}ImgFmt -l$${OEM_PREFIX}ImgProc
}
unix {
DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1)
contains(DISTRIBUTION, UnionTech) {
MY_OS = uos
} else {
MY_OS = kylin
}
TARGET = $${OEM_PREFIX2}OCR
contains(QT_ARCH, x86_64) {
MY_ARCH = amd64
MY_ARCH2 = x86_64
}
contains(QT_ARCH, arm64) {
MY_ARCH = aarch64
MY_ARCH2 = aarch64
}
contains(QT_ARCH, mips64) {
MY_ARCH = mips64
MY_ARCH2 = mips64
}
contains(QT_ARCH, loongarch64) {
MY_ARCH = loongarch64
MY_ARCH2 = loongarch64
}
CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct
LIBS += -lpthread -ldl
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base -l$${OEM_PREFIX2}ImgFmt -l$${OEM_PREFIX2}ImgProc
}
INCLUDEPATH += $$PWD/../../../modules
INCLUDEPATH += $$PWD/../../../utility
DESTDIR = $$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}
UI_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
MOC_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
OBJECTS_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
RCC_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
message(MY_OS: $$MY_OS)
message(MY_ARCH: $$MY_ARCH)
message(OEM_PREFIX: $$OEM_PREFIX)
message(OEM_PREFIX2: $$OEM_PREFIX2)
message(OEM_PREFIX3: $$OEM_PREFIX3)
message(OEM_NAME: $$OEM_NAME)
message(MY_CONFIGURE: $$MY_CONFIGURE)
message(TARGET: $$TARGET)
message(DESTDIR: $$DESTDIR)
message(UI_DIR: $$UI_DIR)
message(MOC_DIR: $$MOC_DIR)
message(OBJECTS_DIR: $$OBJECTS_DIR)
message(RCC_DIR: $$RCC_DIR)
win32 {
CONFIG(release, debug|release) {
DESTEXE_PATH = $${PWD}/../../../../release/win/$${MY_ARCH}/$${MY_CONFIGURE}/
DESTEXE_PATH = $$replace(DESTEXE_PATH, /, \\)
message(DESTEXE_PATH: $$DESTEXE_PATH)
SRCEXE_FILE = $${DESTDIR}/$${TARGET}.exe
SRCEXE_FILE = $$replace(SRCEXE_FILE, /, \\)
message(SRCEXE_FILE: $$SRCEXE_FILE)
SRCPDB_FILE = $${DESTDIR}/$${TARGET}.pdb
SRCPDB_FILE = $$replace(SRCPDB_FILE, /, \\)
message(SRCPDB_FILE: $$SRCPDB_FILE)
QMAKE_POST_LINK += xcopy /y $$SRCEXE_FILE $$DESTEXE_PATH && xcopy /y $$SRCPDB_FILE $$DESTEXE_PATH
}
}
unix {
CONFIG(release, debug|release) {
DESTEXE_PATH = $$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2}/
message(DESTEXE_PATH: $$DESTEXE_PATH)
SRCEXE_FILE = $${DESTDIR}/$${TARGET}
message(SRCEXE_FILE: $$SRCEXE_FILE)
QMAKE_POST_LINK += cp $$SRCEXE_FILE $$DESTEXE_PATH
}
}
SOURCES += \
../../../app/ocr/main.cpp
HEADERS += \

View File

@ -1,10 +0,0 @@
LIBRARY
EXPORTS
show_srclist_ui
show_devlist_ui
show_setting_ui
show_scan_ui
show_msgbox_info
show_msgbox_warning

View File

@ -1,194 +0,0 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets gui-private
TEMPLATE = lib
DEFINES += UNTITLED_LIBRARY
CONFIG += c++11
CONFIG += dll
# 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
# 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
include($$PWD/../HGOEM.pri)
CONFIG(debug, debug|release) {
MY_CONFIGURE = Debug
}
CONFIG(release, debug|release) {
MY_CONFIGURE = Release
}
win32 {
MY_OS = windows
TARGET = $${OEM_PREFIX}SaneUI
contains(QT_ARCH, i386) {
MY_ARCH = x86
}
contains(QT_ARCH, x86_64) {
MY_ARCH = x64
}
CONFIG(debug, debug|release) {
QMAKE_LFLAGS_DEBUG += /NOENTRY
}
CONFIG(release, debug|release) {
QMAKE_LFLAGS_RELEASE += /MAP
QMAKE_CFLAGS_RELEASE += /Zi
QMAKE_LFLAGS_RELEASE += /debug /opt:ref
QMAKE_LFLAGS_RELEASE += /NOENTRY
}
#DEF_FILE = HGSaneUI.def
#LIBS += -lgdi32 -lgdiplus -ldbghelp -luser32
#LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base
#LIBS += -L$$PWD/../../../../sdk/lib/win/$${MY_ARCH}/OEM/$${OEM_NAME} -llang
}
unix {
SOURCES += \
../../../modules/saneui/HGSaneUI.cpp \
../../../modules/saneui/cfg/cJSON.c \
../../../modules/saneui/cfg/gb_json.cpp \
../../../modules/saneui/app_cfg.cpp \
../../../modules/saneui/HGUIGlobal.cpp \
../../../modules/saneui/cutdialog.cpp \
../../../modules/saneui/cutpapertool.cpp \
../../../modules/saneui/device_menu.cpp \
../../../modules/saneui/dialog_device_scan.cpp \
../../../modules/saneui/dialog_device_select.cpp \
../../../modules/saneui/dialog_input.cpp \
../../../modules/saneui/dllmain.cpp \
../../../modules/saneui/gaosixy.cpp \
../../../modules/saneui/hg_settingdialog.cpp \
../../../modules/saneui/setpicclrtool.cpp \
../../../modules/saneui/widget.cpp \
../../../utility/HGString.cpp \
../../../modules/saneui/dialog_source_select.cpp
HEADERS += \
../../../modules/saneui/HGSaneUI.h \
../../../modules/saneui/cfg/cJSON.h \
../../../modules/saneui/cfg/gb_json.h \
../../../modules/saneui/app_cfg.h \
../../../modules/saneui/HGUIGlobal.h \
../../../modules/saneui/cutdialog.h \
../../../modules/saneui/cutpapertool.h \
../../../modules/saneui/device_menu.h \
../../../modules/saneui/dialog_device_scan.h \
../../../modules/saneui/dialog_device_select.h \
../../../modules/saneui/dialog_input.h \
../../../modules/saneui/gaosixy.h \
../../../modules/saneui/hg_settingdialog.h \
../../../modules/saneui/setpicclrtool.h \
../../../modules/saneui/widget.h \
../../../utility/HGString.h \
../../../modules/saneui/dialog_source_select.h
FORMS += \
../../../modules/saneui/cutdialog.ui \
../../../modules/saneui/cutpapertool.ui \
../../../modules/saneui/dialog_device_scan.ui \
../../../modules/saneui/dialog_device_select.ui \
../../../modules/saneui/dialog_input.ui \
../../../modules/saneui/setpicclrtool.ui \
../../../modules/saneui/widget.ui \
../../../modules/saneui/dialog_source_select.ui
RESOURCES += \
../../../modules/saneui/SaneUI_resource.qrc
TRANSLATIONS += \
../../../modules/saneui/SaneUI_zh_CN.ts \
../../../modules/saneui/SaneUI_zh_EN.ts \
../../../modules/saneui/qt_zh_CN.ts
DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1)
contains(DISTRIBUTION, UnionTech) {
MY_OS = uos
} else {
MY_OS = kylin
}
TARGET = $${OEM_PREFIX2}SaneUI
contains(QT_ARCH, x86_64) {
MY_ARCH = amd64
MY_ARCH2 = x86_64
}
contains(QT_ARCH, arm64) {
MY_ARCH = aarch64
MY_ARCH2 = aarch64
}
contains(QT_ARCH, mips64) {
MY_ARCH = mips64
MY_ARCH2 = mips64
}
contains(QT_ARCH, loongarch64) {
MY_ARCH = loongarch64
MY_ARCH2 = loongarch64
}
CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct
LIBS += -lpthread -ldl
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base
LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -llang
}
INCLUDEPATH += $$PWD/../../../modules
INCLUDEPATH += $$PWD/../../../utility
INCLUDEPATH += $$PWD/../../../modules/saneui
INCLUDEPATH += $$PWD/../../../../sdk/include
DESTDIR = $$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}
UI_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
MOC_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
OBJECTS_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
RCC_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
message(MY_OS: $$MY_OS)
message(MY_ARCH: $$MY_ARCH)
message(OEM_PREFIX: $$OEM_PREFIX)
message(OEM_PREFIX2: $$OEM_PREFIX2)
message(OEM_NAME: $$OEM_NAME)
message(MY_CONFIGURE: $$MY_CONFIGURE)
message(TARGET: $$TARGET)
message(DESTDIR: $$DESTDIR)
message(UI_DIR: $$UI_DIR)
message(MOC_DIR: $$MOC_DIR)
message(OBJECTS_DIR: $$OBJECTS_DIR)
message(RCC_DIR: $$RCC_DIR)
unix {
CONFIG(release, debug|release) {
DESTDLL_PATH = $$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2}/
message(DESTDLL_PATH: $$DESTDLL_PATH)
DESTHEADER_PATH = $${PWD}/../../../../sdk/include/saneui/
message(DESTHEADER_PATH: $$DESTHEADER_PATH)
SRCDLL_FILE = $${DESTDIR}/lib$${TARGET}.so
message(SRCDLL_FILE: $$SRCDLL_FILE)
SRCHEADER_FILE = $${PWD}/../../../modules/saneui/*.h
message(SRCHEADER_FILE: $$SRCHEADER_FILE)
QMAKE_POST_LINK += cp $$SRCDLL_FILE $$DESTDLL_PATH && cp $$SRCHEADER_FILE $$DESTHEADER_PATH
}
}

View File

@ -52,9 +52,9 @@ win32 {
QMAKE_LFLAGS_RELEASE += /NOENTRY QMAKE_LFLAGS_RELEASE += /NOENTRY
} }
# DEF_FILE = HGSaneUser.def DEF_FILE = HGSaneUser.def
# LIBS += -lgdi32 -lgdiplus -ldbghelp LIBS += -lgdi32 -lgdiplus -ldbghelp
# LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base -l$${OEM_PREFIX}SaneUI LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base -l$${OEM_PREFIX}TwainUI
} }
unix { unix {
@ -68,6 +68,7 @@ unix {
../../../modules/sane_user/HGSaneErr.h \ ../../../modules/sane_user/HGSaneErr.h \
../../../modules/sane_user/HGSaneImpl.hpp ../../../modules/sane_user/HGSaneImpl.hpp
DEFINES += _GLIBCXX_USE_CXX11_ABI=0
DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1) DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1)
contains(DISTRIBUTION, UnionTech) { contains(DISTRIBUTION, UnionTech) {
MY_OS = uos MY_OS = uos
@ -92,15 +93,19 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc #QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct QMAKE_LFLAGS += -z defs -B direct
LIBS += -lpthread -ldl LIBS += -lpthread -ldl
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base -l$${OEM_PREFIX2}SaneUI LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base -l$${OEM_PREFIX2}TwainUI
} }
INCLUDEPATH += $$PWD/../../../modules INCLUDEPATH += $$PWD/../../../modules

View File

@ -117,10 +117,14 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc # QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct QMAKE_LFLAGS += -z defs -B direct

View File

@ -94,6 +94,7 @@ win32 {
unix { unix {
DEFINES += _GLIBCXX_USE_CXX11_ABI=0
DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1) DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1)
contains(DISTRIBUTION, UnionTech) { contains(DISTRIBUTION, UnionTech) {
MY_OS = uos MY_OS = uos
@ -102,31 +103,39 @@ unix {
} }
contains(QT_ARCH, x86_64) { contains(QT_ARCH, x86_64) {
DEFINES += x86_64
MY_ARCH = amd64 MY_ARCH = amd64
MY_ARCH2 = x86_64 MY_ARCH2 = x86_64
} }
contains(QT_ARCH, arm64) { contains(QT_ARCH, arm64) {
DEFINES += aarch64
MY_ARCH = aarch64 MY_ARCH = aarch64
MY_ARCH2 = aarch64 MY_ARCH2 = aarch64
} }
contains(QT_ARCH, mips64) { contains(QT_ARCH, mips64) {
DEFINES += mips64
MY_ARCH = mips64 MY_ARCH = mips64
MY_ARCH2 = mips64 MY_ARCH2 = mips64
} }
contains(QT_ARCH, loongarch64) { contains(QT_ARCH, loongarch64) {
DEFINES += loongarch64
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
DEFINES += sw_64
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct QMAKE_LFLAGS += -z defs -B direct
LIBS += -lpthread -ldl LIBS += -lpthread -ldl
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base -l$${OEM_PREFIX2}ImgFmt -l$${OEM_PREFIX2}ImgProc\ LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base -l$${OEM_PREFIX2}ImgFmt -l$${OEM_PREFIX2}ImgProc\
-l$${OEM_PREFIX2}SaneUI -l$${OEM_PREFIX2}SaneUser -l$${OEM_PREFIX2}TwainUI -l$${OEM_PREFIX2}SaneUser
LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -llang LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -llang
} }

View File

@ -82,6 +82,10 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden

View File

@ -4,18 +4,14 @@ SUBDIRS += \
HGBase \ HGBase \
HGImgFmt \ HGImgFmt \
HGImgProc \ HGImgProc \
HGSaneUI \
HGSaneUser \
HGTwainUI \ HGTwainUI \
HGSaneUser \
HGVersion \ HGVersion \
HGScannerLib \ HGScannerLib \
HGUpload \ HGUpload \
HGWebScan \
HGWebService \ HGWebService \
HGUpgrade \ HGUpgrade \
HGFWUpgrade \ HGFWUpgrade \
HGScanner \
HGOCR \
HGScanner2 HGScanner2
HGImgFmt.depends = \ HGImgFmt.depends = \
@ -25,15 +21,12 @@ HGImgProc.depends = \
HGBase \ HGBase \
HGImgFmt HGImgFmt
HGSaneUI.depends = \ HGTwainUI.depends = \
HGBase HGBase
HGSaneUser.depends = \ HGSaneUser.depends = \
HGBase \ HGBase \
HGSaneUI HGTwainUI
HGTwainUI.depends = \
HGBase
HGVersion.depends = \ HGVersion.depends = \
HGBase HGBase
@ -46,11 +39,6 @@ HGScannerLib.depends = \
HGUpload.depends = \ HGUpload.depends = \
HGBase HGBase
HGWebScan.depends = \
HGBase \
HGImgFmt \
HGImgProc
HGWebService.depends = \ HGWebService.depends = \
HGBase \ HGBase \
HGImgFmt \ HGImgFmt \
@ -66,21 +54,9 @@ HGFWUpgrade.depends = \
HGImgProc \ HGImgProc \
HGVersion HGVersion
HGScanner.depends = \
HGBase \
HGImgFmt \
HGImgProc \
HGVersion
HGOCR.depends = \
HGBase \
HGImgFmt \
HGImgProc
HGScanner2.depends = \ HGScanner2.depends = \
HGBase \ HGBase \
HGImgFmt \ HGImgFmt \
HGImgProc \ HGImgProc \
HGVersion \ HGVersion \
HGSaneUser \ HGSaneUser
HGOCR

View File

@ -9,12 +9,9 @@ SUBDIRS += \
HGVersion \ HGVersion \
HGScannerLib \ HGScannerLib \
HGUpload \ HGUpload \
HGWebScan \
HGWebService \ HGWebService \
HGUpgrade \ HGUpgrade \
HGFWUpgrade \ HGFWUpgrade \
HGScanner \
HGOCR \
HGScanner2 HGScanner2
HGImgFmt.depends = \ HGImgFmt.depends = \
@ -42,11 +39,6 @@ HGScannerLib.depends = \
HGUpload.depends = \ HGUpload.depends = \
HGBase HGBase
HGWebScan.depends = \
HGBase \
HGImgFmt \
HGImgProc
HGWebService.depends = \ HGWebService.depends = \
HGBase \ HGBase \
HGImgFmt \ HGImgFmt \
@ -62,21 +54,9 @@ HGFWUpgrade.depends = \
HGImgProc \ HGImgProc \
HGVersion HGVersion
HGScanner.depends = \
HGBase \
HGImgFmt \
HGImgProc \
HGVersion
HGOCR.depends = \
HGBase \
HGImgFmt \
HGImgProc
HGScanner2.depends = \ HGScanner2.depends = \
HGBase \ HGBase \
HGImgFmt \ HGImgFmt \
HGImgProc \ HGImgProc \
HGVersion \ HGVersion \
HGTwainUser \ HGTwainUser
HGOCR

View File

@ -11,4 +11,6 @@ show_setting_ui
show_progress_ui show_progress_ui
show_messagebox_ui show_messagebox_ui
show_twain_srclist_ui show_twain_srclist_ui
show_srclist_ui
close_ui close_ui
pump_ui_message

View File

@ -34,67 +34,9 @@ win32 {
SOURCES += ../../../modules/twainui/qmfcapp.cpp SOURCES += ../../../modules/twainui/qmfcapp.cpp
SOURCES += ../../../modules/twainui/qwinhost.cpp SOURCES += ../../../modules/twainui/qwinhost.cpp
SOURCES += ../../../modules/twainui/qwinwidget.cpp SOURCES += ../../../modules/twainui/qwinwidget.cpp
SOURCES += ../../../modules/twainui/twainui.cpp
SOURCES += ../../../modules/twainui/hg_settingdialog.cpp
HEADERS += ../../../modules/twainui/qmfcapp.hpp HEADERS += ../../../modules/twainui/qmfcapp.hpp
HEADERS += ../../../modules/twainui/qwinhost.hpp HEADERS += ../../../modules/twainui/qwinhost.hpp
HEADERS += ../../../modules/twainui/qwinwidget.hpp HEADERS += ../../../modules/twainui/qwinwidget.hpp
HEADERS += ../../../modules/twainui/hg_settingdialog.h
SOURCES += \
../../../modules/twainui/app_cfg.cpp \
../../../modules/twainui/HGUIGlobal.cpp \
../../../modules/twainui/Manager.cpp \
../../../modules/twainui/cfg/cJSON.c \
../../../modules/twainui/cfg/gb_json.cpp \
../../../modules/twainui/cutdialog.cpp \
../../../modules/twainui/cutpapertool.cpp \
../../../modules/twainui/device_menu.cpp \
../../../modules/twainui/dialog_input.cpp \
../../../modules/twainui/dllmain.cpp \
../../../modules/twainui/gaosixy.cpp \
../../../modules/twainui/setpicclrtool.cpp \
../../../utility/HGString.cpp \
../../../modules/twainui/widget.cpp \
../../../modules/twainui/dialog_progress_ui.cpp \
../../../modules/twainui/dialog_device_select.cpp \
../../../modules/twainui/dialog_twain_source_select.cpp
HEADERS += \
../../../modules/twainui/app_cfg.h \
../../../modules/twainui/HGUIGlobal.h \
../../../modules/twainui/Manager.h \
../../../modules/twainui/cfg/cJSON.h \
../../../modules/twainui/cfg/gb_json.h \
../../../modules/twainui/cutdialog.h \
../../../modules/twainui/cutpapertool.h \
../../../modules/twainui/device_menu.h \
../../../modules/twainui/dialog_input.h \
../../../modules/twainui/gaosixy.h \
../../../modules/twainui/setpicclrtool.h \
../../../utility/HGString.h \
../../../modules/twainui/widget.h \
../../../modules/twainui/dialog_progress_ui.h \
../../../modules/twainui/dialog_device_select.h \
../../../modules/twainui/dialog_twain_source_select.h
FORMS += \
../../../modules/twainui/cutdialog.ui \
../../../modules/twainui/cutpapertool.ui \
../../../modules/twainui/dialog_input.ui \
../../../modules/twainui/setpicclrtool.ui \
../../../modules/twainui/widget.ui \
../../../modules/twainui/dialog_progress_ui.ui \
../../../modules/twainui/dialog_device_select.ui \
../../../modules/twainui/dialog_twain_source_select.ui
RESOURCES += \
../../../modules/twainui/TwainUI_resource.qrc
TRANSLATIONS += \
../../../modules/twainui/TwainUI_zh_CN.ts \
../../../modules/twainui/TwainUI_zh_EN.ts \
../../../modules/twainui/qt_zh_CN.ts
MY_OS = windows MY_OS = windows
TARGET = $${OEM_PREFIX}TwainUI TARGET = $${OEM_PREFIX}TwainUI
@ -120,64 +62,7 @@ win32 {
unix { unix {
SOURCES += ../../../modules/twainui/twainui.cpp DEFINES += _GLIBCXX_USE_CXX11_ABI=0
SOURCES += ../../../modules/twainui/hg_settingdialog.cpp
HEADERS += ../../../modules/twainui/hg_settingdialog.h
SOURCES += \
../../../modules/twainui/app_cfg.cpp \
../../../modules/twainui/HGUIGlobal.cpp \
../../../modules/twainui/Manager.cpp \
../../../modules/twainui/cfg/cJSON.c \
../../../modules/twainui/cfg/gb_json.cpp \
../../../modules/twainui/cutdialog.cpp \
../../../modules/twainui/cutpapertool.cpp \
../../../modules/twainui/device_menu.cpp \
../../../modules/twainui/dialog_input.cpp \
../../../modules/twainui/dllmain.cpp \
../../../modules/twainui/gaosixy.cpp \
../../../modules/twainui/setpicclrtool.cpp \
../../../utility/HGString.cpp \
../../../modules/twainui/widget.cpp \
../../../modules/twainui/dialog_progress_ui.cpp \
../../../modules/twainui/dialog_device_select.cpp \
../../../modules/twainui/dialog_twain_source_select.cpp
HEADERS += \
../../../modules/twainui/app_cfg.h \
../../../modules/twainui/HGUIGlobal.h \
../../../modules/twainui/Manager.h \
../../../modules/twainui/cfg/cJSON.h \
../../../modules/twainui/cfg/gb_json.h \
../../../modules/twainui/cutdialog.h \
../../../modules/twainui/cutpapertool.h \
../../../modules/twainui/device_menu.h \
../../../modules/twainui/dialog_input.h \
../../../modules/twainui/gaosixy.h \
../../../modules/twainui/setpicclrtool.h \
../../../utility/HGString.h \
../../../modules/twainui/widget.h \
../../../modules/twainui/dialog_progress_ui.h \
../../../modules/twainui/dialog_device_select.h \
../../../modules/twainui/dialog_twain_source_select.h
FORMS += \
../../../modules/twainui/cutdialog.ui \
../../../modules/twainui/cutpapertool.ui \
../../../modules/twainui/dialog_input.ui \
../../../modules/twainui/setpicclrtool.ui \
../../../modules/twainui/widget.ui \
../../../modules/twainui/dialog_progress_ui.ui \
../../../modules/twainui/dialog_device_select.ui \
../../../modules/twainui/dialog_twain_source_select.ui
RESOURCES += \
../../../modules/twainui/TwainUI_resource.qrc
TRANSLATIONS += \
../../../modules/twainui/TwainUI_zh_CN.ts \
../../../modules/twainui/TwainUI_zh_EN.ts \
../../../modules/twainui/qt_zh_CN.ts
DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1) DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1)
contains(DISTRIBUTION, UnionTech) { contains(DISTRIBUTION, UnionTech) {
MY_OS = uos MY_OS = uos
@ -187,25 +72,33 @@ unix {
TARGET = $${OEM_PREFIX2}TwainUI TARGET = $${OEM_PREFIX2}TwainUI
contains(QT_ARCH, x86_64) { contains(QT_ARCH, x86_64) {
DEFINES += x86_64
MY_ARCH = amd64 MY_ARCH = amd64
MY_ARCH2 = x86_64 MY_ARCH2 = x86_64
} }
contains(QT_ARCH, arm64) { contains(QT_ARCH, arm64) {
DEFINES += aarch64
MY_ARCH = aarch64 MY_ARCH = aarch64
MY_ARCH2 = aarch64 MY_ARCH2 = aarch64
} }
contains(QT_ARCH, mips64) { contains(QT_ARCH, mips64) {
DEFINES += mips64
MY_ARCH = mips64 MY_ARCH = mips64
MY_ARCH2 = mips64 MY_ARCH2 = mips64
} }
contains(QT_ARCH, loongarch64) { contains(QT_ARCH, loongarch64) {
DEFINES += loongarch64
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
DEFINES += sw_64
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct QMAKE_LFLAGS += -z defs -B direct
@ -247,6 +140,9 @@ win32 {
DESTDLL_PATH = $${PWD}/../../../../release/win/$${MY_ARCH}/$${MY_CONFIGURE}/ DESTDLL_PATH = $${PWD}/../../../../release/win/$${MY_ARCH}/$${MY_CONFIGURE}/
DESTDLL_PATH = $$replace(DESTDLL_PATH, /, \\) DESTDLL_PATH = $$replace(DESTDLL_PATH, /, \\)
message(DESTDLL_PATH: $$DESTDLL_PATH) message(DESTDLL_PATH: $$DESTDLL_PATH)
DESTHEADER_PATH = $${PWD}/../../../../sdk/include/twainui/
DESTHEADER_PATH = $$replace(DESTHEADER_PATH, /, \\)
message(DESTHEADER_PATH: $$DESTHEADER_PATH)
SRCLIB_FILE = $${DESTDIR}/$${TARGET}.lib SRCLIB_FILE = $${DESTDIR}/$${TARGET}.lib
SRCLIB_FILE = $$replace(SRCLIB_FILE, /, \\) SRCLIB_FILE = $$replace(SRCLIB_FILE, /, \\)
@ -254,12 +150,15 @@ win32 {
SRCDLL_FILE = $${DESTDIR}/$${TARGET}.dll SRCDLL_FILE = $${DESTDIR}/$${TARGET}.dll
SRCDLL_FILE = $$replace(SRCDLL_FILE, /, \\) SRCDLL_FILE = $$replace(SRCDLL_FILE, /, \\)
message(SRCDLL_FILE: $$SRCDLL_FILE) message(SRCDLL_FILE: $$SRCDLL_FILE)
SRCHEADER_FILE = $${PWD}/../../../modules/twainui/twainui.h
SRCHEADER_FILE = $$replace(SRCHEADER_FILE, /, \\)
message(SRCHEADER_FILE: $$SRCHEADER_FILE)
SRCPDB_FILE = $${DESTDIR}/$${TARGET}.pdb SRCPDB_FILE = $${DESTDIR}/$${TARGET}.pdb
SRCPDB_FILE = $$replace(SRCPDB_FILE, /, \\) SRCPDB_FILE = $$replace(SRCPDB_FILE, /, \\)
message(SRCPDB_FILE: $$SRCPDB_FILE) message(SRCPDB_FILE: $$SRCPDB_FILE)
QMAKE_POST_LINK += xcopy /y $$SRCLIB_FILE $$DESTLIB_PATH && xcopy /y $$SRCDLL_FILE $$DESTDLL_PATH \ QMAKE_POST_LINK += xcopy /y $$SRCLIB_FILE $$DESTLIB_PATH && xcopy /y $$SRCDLL_FILE $$DESTDLL_PATH \
&& xcopy /y $$SRCPDB_FILE $$DESTDLL_PATH && xcopy /y $$SRCHEADER_FILE $$DESTHEADER_PATH && xcopy /y $$SRCPDB_FILE $$DESTDLL_PATH
} }
} }
@ -268,10 +167,77 @@ unix {
CONFIG(release, debug|release) { CONFIG(release, debug|release) {
DESTDLL_PATH = $$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2}/ DESTDLL_PATH = $$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2}/
message(DESTDLL_PATH: $$DESTDLL_PATH) message(DESTDLL_PATH: $$DESTDLL_PATH)
DESTHEADER_PATH = $${PWD}/../../../../sdk/include/twainui/
message(DESTHEADER_PATH: $$DESTHEADER_PATH)
SRCDLL_FILE = $${DESTDIR}/lib$${TARGET}.so SRCDLL_FILE = $${DESTDIR}/lib$${TARGET}.so
message(SRCDLL_FILE: $$SRCDLL_FILE) message(SRCDLL_FILE: $$SRCDLL_FILE)
SRCHEADER_FILE = $${PWD}/../../../modules/twainui/twainui.h
message(SRCHEADER_FILE: $$SRCHEADER_FILE)
QMAKE_POST_LINK += cp $$SRCDLL_FILE $$DESTDLL_PATH QMAKE_POST_LINK += cp $$SRCDLL_FILE $$DESTDLL_PATH && cp $$SRCHEADER_FILE $$DESTHEADER_PATH
} }
} }
SOURCES += ../../../modules/twainui/twainui.cpp
HEADERS += ../../../modules/twainui/twainui.h
SOURCES += ../../../modules/twainui/hg_settingdialog.cpp
HEADERS += ../../../modules/twainui/hg_settingdialog.h
SOURCES += \
../../../modules/twainui/app_cfg.cpp \
../../../modules/twainui/HGUIGlobal.cpp \
../../../modules/twainui/Manager.cpp \
../../../modules/twainui/cfg/cJSON.c \
../../../modules/twainui/cfg/gb_json.cpp \
../../../modules/twainui/cutdialog.cpp \
../../../modules/twainui/cutpapertool.cpp \
../../../modules/twainui/device_menu.cpp \
../../../modules/twainui/dialog_input.cpp \
../../../modules/twainui/dllmain.cpp \
../../../modules/twainui/gaosixy.cpp \
../../../modules/twainui/setpicclrtool.cpp \
../../../utility/HGString.cpp \
../../../modules/twainui/widget.cpp \
../../../modules/twainui/dialog_progress_ui.cpp \
../../../modules/twainui/dialog_device_select.cpp \
../../../modules/twainui/dialog_twain_source_select.cpp \
../../../modules/twainui/dialog_source_select.cpp
HEADERS += \
../../../modules/twainui/app_cfg.h \
../../../modules/twainui/HGUIGlobal.h \
../../../modules/twainui/Manager.h \
../../../modules/twainui/cfg/cJSON.h \
../../../modules/twainui/cfg/gb_json.h \
../../../modules/twainui/cutdialog.h \
../../../modules/twainui/cutpapertool.h \
../../../modules/twainui/device_menu.h \
../../../modules/twainui/dialog_input.h \
../../../modules/twainui/gaosixy.h \
../../../modules/twainui/setpicclrtool.h \
../../../utility/HGString.h \
../../../modules/twainui/widget.h \
../../../modules/twainui/dialog_progress_ui.h \
../../../modules/twainui/dialog_device_select.h \
../../../modules/twainui/dialog_twain_source_select.h \
../../../modules/twainui/dialog_source_select.h
FORMS += \
../../../modules/twainui/cutdialog.ui \
../../../modules/twainui/cutpapertool.ui \
../../../modules/twainui/dialog_input.ui \
../../../modules/twainui/setpicclrtool.ui \
../../../modules/twainui/widget.ui \
../../../modules/twainui/dialog_progress_ui.ui \
../../../modules/twainui/dialog_device_select.ui \
../../../modules/twainui/dialog_twain_source_select.ui \
../../../modules/twainui/dialog_source_select.ui
RESOURCES += \
../../../modules/twainui/TwainUI_resource.qrc
TRANSLATIONS += \
../../../modules/twainui/TwainUI_zh_CN.ts \
../../../modules/twainui/TwainUI_zh_EN.ts \
../../../modules/twainui/qt_zh_CN.ts

View File

@ -6,10 +6,12 @@ HGTwain_CreateDSM
HGTwain_DestroyDSM HGTwain_DestroyDSM
HGTwain_GetDSCount HGTwain_GetDSCount
HGTwain_GetDSNameWithIndex HGTwain_GetDSNameWithIndex
HGTwain_CreateDS
HGTwain_CreateDefaultDS
HGTwain_CreateSelectedDS
HGTwain_CreateSelectedDSEx
HGTwain_DestroyDS
HGTwain_OpenDS HGTwain_OpenDS
HGTwain_OpenDefaultDS
HGTwain_OpenSelectedDS
HGTwain_OpenSelectedDSEx
HGTwain_CloseDS HGTwain_CloseDS
HGTwain_GetDSName HGTwain_GetDSName
HGTwain_GetDSDeviceName HGTwain_GetDSDeviceName

View File

@ -82,6 +82,7 @@ win32 {
unix { unix {
DEFINES += _GLIBCXX_USE_CXX11_ABI=0
DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1) DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1)
contains(DISTRIBUTION, UnionTech) { contains(DISTRIBUTION, UnionTech) {
MY_OS = uos MY_OS = uos
@ -106,10 +107,13 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct QMAKE_LFLAGS += -z defs -B direct

View File

@ -76,6 +76,9 @@ unix {
contains(QT_ARCH, loongarch64) { contains(QT_ARCH, loongarch64) {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden

View File

@ -85,9 +85,14 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_CFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct QMAKE_LFLAGS += -z defs -B direct

View File

@ -83,6 +83,10 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden

View File

@ -92,6 +92,10 @@ unix {
MY_ARCH = loongarch64 MY_ARCH = loongarch64
MY_ARCH2 = loongarch64 MY_ARCH2 = loongarch64
} }
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden QMAKE_CXXFLAGS += -fvisibility=hidden
@ -107,6 +111,10 @@ unix {
LIBS += $$PWD/../../../third_party/libzip/$${MY_OS}/$${MY_ARCH}/lib/libzip.a LIBS += $$PWD/../../../third_party/libzip/$${MY_OS}/$${MY_ARCH}/lib/libzip.a
LIBS += $$PWD/../../../third_party/zlib/$${MY_OS}/$${MY_ARCH}/lib/libz.a LIBS += $$PWD/../../../third_party/zlib/$${MY_OS}/$${MY_ARCH}/lib/libz.a
LIBS += $$PWD/../../../third_party/libcurl/$${MY_OS}/$${MY_ARCH}/lib/libcurl.a LIBS += $$PWD/../../../third_party/libcurl/$${MY_OS}/$${MY_ARCH}/lib/libcurl.a
contains(QT_ARCH, sw_64) {
LIBS += $$PWD/../../../third_party/openssl/$${MY_OS}/$${MY_ARCH}/lib/libcrypto.a
LIBS += $$PWD/../../../third_party/openssl/$${MY_OS}/$${MY_ARCH}/lib/libssl.a
}
} }
INCLUDEPATH += $$PWD/../../../modules INCLUDEPATH += $$PWD/../../../modules

View File

@ -27,8 +27,8 @@ struct HGImageImpl
m_top = 0; m_top = 0;
m_right = 0; m_right = 0;
m_bottom = 0; m_bottom = 0;
m_xDpi = 0; m_xDpi = 96;
m_yDpi = 0; m_yDpi = 96;
} }
~HGImageImpl() ~HGImageImpl()
@ -175,7 +175,7 @@ HGResult HGAPI HGBase_CreateImage(HGUInt width, HGUInt height, HGUInt type, HGUI
} }
else else
{ {
hBmp = CreateHBITMAP(width, height, type, origin, 0, 0, &data); hBmp = CreateHBITMAP(width, height, type, origin, 96, 96, &data);
if (NULL == hBmp) if (NULL == hBmp)
return HGBASE_ERR_OUTOFMEMORY; return HGBASE_ERR_OUTOFMEMORY;
else else
@ -207,8 +207,8 @@ HGResult HGAPI HGBase_CreateImage(HGUInt width, HGUInt height, HGUInt type, HGUI
imageImpl->m_top = 0; imageImpl->m_top = 0;
imageImpl->m_right = imageImpl->m_width; imageImpl->m_right = imageImpl->m_width;
imageImpl->m_bottom = imageImpl->m_height; imageImpl->m_bottom = imageImpl->m_height;
imageImpl->m_xDpi = 0; imageImpl->m_xDpi = 96;
imageImpl->m_yDpi = 0; imageImpl->m_yDpi = 96;
*image = (HGImage)imageImpl; *image = (HGImage)imageImpl;
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
@ -266,8 +266,8 @@ HGResult HGAPI HGBase_CreateImageWithData(HGByte* data, const HGImageInfo* info,
imageImpl->m_top = 0; imageImpl->m_top = 0;
imageImpl->m_right = imageImpl->m_width; imageImpl->m_right = imageImpl->m_width;
imageImpl->m_bottom = imageImpl->m_height; imageImpl->m_bottom = imageImpl->m_height;
imageImpl->m_xDpi = 0; imageImpl->m_xDpi = 96;
imageImpl->m_yDpi = 0; imageImpl->m_yDpi = 96;
*image = (HGImage)imageImpl; *image = (HGImage)imageImpl;
return HGBASE_ERR_OK; return HGBASE_ERR_OK;

View File

@ -1109,7 +1109,7 @@ HGResult HGAPI HGImgFmt_LoadImageFromReader(HGImgFmtReader reader, HGUInt index,
if (ret == HGBASE_ERR_OK && NULL != image) if (ret == HGBASE_ERR_OK && NULL != image)
{ {
ret = HGImgFmt_LoadImageFromPdfReader((HGPdfReader)imgFmtReaderImpl->handle, index, 1.0f, 1.0f, imgType, imgOrigin, image); ret = HGImgFmt_LoadImageFromPdfReader((HGPdfReader)imgFmtReaderImpl->handle, index, 300.0f / 72.0f, 300.0f / 72.0f, imgType, imgOrigin, image);
} }
return ret; return ret;

View File

@ -104,7 +104,7 @@ HGResult HGAPI HGImgFmt_LoadPdfImage(const HGChar* fileName, HGPdfPageInfo* info
ret = HGImgFmt_GetPdfPageInfo(reader, 0, info); ret = HGImgFmt_GetPdfPageInfo(reader, 0, info);
if (HGBASE_ERR_OK == ret && NULL != image) if (HGBASE_ERR_OK == ret && NULL != image)
ret = HGImgFmt_LoadImageFromPdfReader(reader, 0, 1.0f, 1.0f, imgType, imgOrigin, image); ret = HGImgFmt_LoadImageFromPdfReader(reader, 0, 200.0f / 72.0f, 200.0f / 72.0f, imgType, imgOrigin, image);
HGImgFmt_ClosePdfReader(reader); HGImgFmt_ClosePdfReader(reader);
return ret; return ret;

View File

@ -229,6 +229,7 @@ HGResult HGPdfReaderImpl::LoadImage(HGUInt page, HGFloat xScale, HGFloat yScale,
HGImageInfo imgInfo = { (uint32_t)width, (uint32_t)height, HGBASE_IMGTYPE_RGB, (uint32_t)pix->stride, HGBASE_IMGORIGIN_TOP }; HGImageInfo imgInfo = { (uint32_t)width, (uint32_t)height, HGBASE_IMGTYPE_RGB, (uint32_t)pix->stride, HGBASE_IMGORIGIN_TOP };
if (HGBASE_ERR_OK == HGBase_CreateImageWithData(pix->samples, &imgInfo, &image2)) if (HGBASE_ERR_OK == HGBase_CreateImageWithData(pix->samples, &imgInfo, &image2))
{ {
HGBase_SetImageDpi(image2, (HGUInt)(xScale * 72 + 0.5f), (HGUInt)(yScale * 72 + 0.5f));
ret = HGBase_CloneImage(image2, imgType, imgOrigin, image); ret = HGBase_CloneImage(image2, imgType, imgOrigin, image);
HGBase_DestroyImage(image2); HGBase_DestroyImage(image2);
} }

View File

@ -1,5 +1,6 @@
#include "HGSaneImpl.hpp" #include "HGSaneImpl.hpp"
#include "../base/HGInc.h" #include "../base/HGInc.h"
#include "../base/HGUtility.h"
HGSaneManagerImpl::HGSaneManagerImpl() HGSaneManagerImpl::HGSaneManagerImpl()
{ {
@ -31,11 +32,32 @@ HGResult HGSaneManagerImpl::Create()
pclose(file); pclose(file);
} }
if (archName.empty()) std::string osName;
FILE* fp = popen("cat /etc/issue | cut -d\' \' -f1", "r");
if (NULL != fp)
{
char buff[1024] = { 0 };
fread(buff, 1024, 1, fp);
int len = (int)strlen(buff);
for (int i = 0; i < len; ++i)
{
if (buff[i] == '\n')
buff[i] = '\0';
}
osName = buff;
pclose(fp);
}
if (archName.empty() || osName.empty())
{ {
return HGBASE_ERR_FAIL; return HGBASE_ERR_FAIL;
} }
if (archName == "mips64")
archName += "el";
char manuPath[] = "/etc/sane.d/dll.d"; char manuPath[] = "/etc/sane.d/dll.d";
DIR* dir = opendir(manuPath); DIR* dir = opendir(manuPath);
@ -93,7 +115,14 @@ HGResult HGSaneManagerImpl::Create()
pr.first = manuName; pr.first = manuName;
char sanePath[256]; char sanePath[256];
sprintf(sanePath, "/usr/lib/%s-linux-gnu/sane/libsane-%s.so.1", archName.c_str(), manuName.c_str()); if (osName == "NeoKylin")
{
sprintf(sanePath, "/usr/lib64/sane/libsane-%s.so.1", manuName.c_str());
}
else
{
sprintf(sanePath, "/usr/lib/%s-linux-gnu/sane/libsane-%s.so.1", archName.c_str(), manuName.c_str());
}
pr.second = sanePath; pr.second = sanePath;
if(!filterDeviceSource(pr.first.c_str())) if(!filterDeviceSource(pr.first.c_str()))
@ -323,11 +352,18 @@ HGResult HGSaneSourceImpl::Open(const HGChar* saneManu, const HGChar* sanePath)
return HGBASE_ERR_INVALIDARG; return HGBASE_ERR_INVALIDARG;
} }
HGChar fileName[260];
HGBase_GetFileName(sanePath, fileName, 260);
HGDll dll = NULL; HGDll dll = NULL;
HGResult ret = HGBase_CreateDll(sanePath, &dll); HGResult ret = HGBase_CreateDll(fileName, &dll);
if (HGBASE_ERR_OK != ret) if (HGBASE_ERR_OK != ret)
{ {
return ret; ret = HGBase_CreateDll(sanePath, &dll);
if (HGBASE_ERR_OK != ret)
{
return ret;
}
} }
SANEAPI saneAPI; SANEAPI saneAPI;
@ -472,12 +508,49 @@ HGResult HGSaneSourceImpl::OpenSelectedDevice(HGWindow parent, class HGSaneDevic
return HGBASE_ERR_INVALIDARG; return HGBASE_ERR_INVALIDARG;
} }
SANE_Handle handle = NULL; std::vector<DEVQUEUI> devs;
char devName[256] = {0};
if (-2 == show_devlist_ui(&m_saneApi, NULL, parent, &handle, devName, 256)) HGUInt count = 0;
{ GetDeviceCount(&count);
return HGBASE_ERR_NOTSUPPORT; for (HGUInt i = 0; i < count; ++i)
} {
HGChar name[256] = {0};
GetDeviceName(i, name, 256);
SANE_Handle handle = NULL;
m_saneApi.sane_open_api(name, &handle);
if (NULL != handle)
{
HGChar sn[256] = {0};
m_saneApi.sane_control_option_api(handle, (SANE_Int)0x8856, SANE_ACTION_GET_VALUE, sn, NULL);
DEVQUEUI dev;
dev.id = i + 1;
dev.name = name;
dev.sn = sn;
devs.push_back(dev);
m_saneApi.sane_close_api(handle);
}
}
int id = choose_scanner(devs);
if (-1 == id)
{
return HGSANE_ERR_FAIL;
}
SANE_Handle handle = NULL;
char devName[256] = {0};
for (int i = 0; i < devs.size(); ++i)
{
if (devs[i].id == id)
{
strcpy(devName, devs[i].name.c_str());
m_saneApi.sane_open_api(devs[i].name.c_str(), &handle);
break;
}
}
if (NULL == handle) if (NULL == handle)
{ {
@ -590,18 +663,22 @@ void HGSaneSourceImpl::RemoveDevice(class HGSaneDeviceImpl* deviceImpl)
} }
} }
HGSaneDeviceImpl *HGSaneDeviceImpl::m_curDevice = NULL;
HGSaneDeviceImpl::HGSaneDeviceImpl(HGSaneSourceImpl* sourceImpl) HGSaneDeviceImpl::HGSaneDeviceImpl(HGSaneSourceImpl* sourceImpl)
{ {
m_sourceImpl = sourceImpl; m_sourceImpl = sourceImpl;
m_devName.clear(); m_devName.clear();
m_devHandle = NULL; m_devHandle = NULL;
m_buffer = NULL; m_scanNotify = NULL;
m_bufferSize = 0; m_dpi = 0;
m_dpi = 0;
m_eventFunc = NULL; m_eventFunc = NULL;
m_eventParam = NULL; m_eventParam = NULL;
m_imageFunc = NULL; m_imageFunc = NULL;
m_imageParam = NULL; m_imageParam = NULL;
m_stopThread = HGFALSE;
m_thread = NULL;
m_cancelScan = false;
} }
HGSaneDeviceImpl::~HGSaneDeviceImpl() HGSaneDeviceImpl::~HGSaneDeviceImpl()
@ -621,6 +698,8 @@ HGResult HGSaneDeviceImpl::Init(const HGChar* devName, SANE_Handle handle)
m_devName = devName; m_devName = devName;
m_sourceImpl->m_saneApi.sane_set_io_mode_api(handle, SANE_FALSE); m_sourceImpl->m_saneApi.sane_set_io_mode_api(handle, SANE_FALSE);
m_devHandle = handle; m_devHandle = handle;
char* cfg = apply_current_config(m_devName.c_str(), m_devHandle, &m_sourceImpl->m_saneApi);
twain_ui_free(cfg);
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
} }
@ -652,6 +731,8 @@ HGResult HGSaneDeviceImpl::Open(const HGChar* devName, HGChar* errInfo, HGUInt e
m_devName = devName; m_devName = devName;
m_sourceImpl->m_saneApi.sane_set_io_mode_api(handle, SANE_FALSE); m_sourceImpl->m_saneApi.sane_set_io_mode_api(handle, SANE_FALSE);
m_devHandle = handle; m_devHandle = handle;
char* cfg = apply_current_config(m_devName.c_str(), m_devHandle, &m_sourceImpl->m_saneApi);
twain_ui_free(cfg);
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
} }
@ -778,92 +859,287 @@ HGResult HGSaneDeviceImpl::ClearDeviceLog()
HGResult HGSaneDeviceImpl::ShowSettingDlg(HGWindow parent) HGResult HGSaneDeviceImpl::ShowSettingDlg(HGWindow parent)
{ {
int ret = show_setting_ui(&m_sourceImpl->m_saneApi, m_devHandle, m_devName.c_str(), parent); int pid = 0;
if (-1 == ret) if (SANE_STATUS_GOOD != m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, (SANE_Int)0x8853,
{ SANE_ACTION_GET_VALUE, &pid, NULL))
return HGSANE_ERR_FAIL;
}
else if (-2 == ret)
{
return HGBASE_ERR_NOTSUPPORT;
}
else if (-3 == ret)
{ {
return HGSANE_ERR_DEVICEOFFLINE; return HGSANE_ERR_DEVICEOFFLINE;
} }
m_curDevice = this;
int ret = show_setting_ui(m_devHandle, parent, &m_sourceImpl->m_saneApi, m_devName.c_str(), false, UIResultCallback);
if (0 != ret)
{
return HGSANE_ERR_FAIL;
}
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
} }
HGResult HGSaneDeviceImpl::Start(HGWindow parent, HGSane_DeviceEventFunc eventFunc, HGPointer eventParam, HGResult HGSaneDeviceImpl::Start(HGWindow parent, HGSane_DeviceEventFunc eventFunc, HGPointer eventParam,
HGSane_DeviceImageFunc imageFunc, HGPointer imageParam) HGSane_DeviceImageFunc imageFunc, HGPointer imageParam)
{ {
HGResult ret = GetDpi(&m_dpi); if (NULL != m_thread)
if (HGBASE_ERR_OK != ret)
{ {
return ret; return HGSANE_ERR_FAIL;
} }
int pid = 0;
if (SANE_STATUS_GOOD != m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, (SANE_Int)0x8853,
SANE_ACTION_GET_VALUE, &pid, NULL))
{
return HGSANE_ERR_DEVICEOFFLINE;
}
m_curDevice = this;
int ret = show_progress_ui(parent, UIResultCallback, &m_scanNotify);
if (0 != ret)
{
return HGSANE_ERR_FAIL;
}
GetDpi(&m_dpi);
m_eventFunc = eventFunc; m_eventFunc = eventFunc;
m_eventParam = eventParam; m_eventParam = eventParam;
m_imageFunc = imageFunc; m_imageFunc = imageFunc;
m_imageParam = imageParam; m_imageParam = imageParam;
if (-2 == show_scan_ui(&m_sourceImpl->m_saneApi, m_devHandle, m_devName.c_str(), parent, GetScanMode(m_oldScanMode, 256);
show_scan_ui_event_func, this, show_scan_ui_image_func, this)) GetScanCount(&m_oldScanCount);
{
m_dpi = 0;
return HGBASE_ERR_NOTSUPPORT;
}
m_stopThread = HGFALSE;
m_cancelScan = false;
HGBase_OpenThread(ThreadFunc, this, &m_thread);
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
} }
HGResult HGSaneDeviceImpl::StartWithSingleScan(HGWindow parent, HGSane_DeviceEventFunc eventFunc, HGPointer eventParam, HGResult HGSaneDeviceImpl::StartWithSingleScan(HGWindow parent, HGSane_DeviceEventFunc eventFunc, HGPointer eventParam,
HGSane_DeviceImageFunc imageFunc, HGPointer imageParam) HGSane_DeviceImageFunc imageFunc, HGPointer imageParam)
{ {
HGChar scanMode[256] = {0}; if (NULL != m_thread)
HGResult ret = GetScanMode(scanMode, 256);
if (HGBASE_ERR_OK != ret)
{ {
return ret; return HGSANE_ERR_FAIL;
} }
HGInt scanCount = 0; int pid = 0;
ret = GetScanCount(&scanCount); if (SANE_STATUS_GOOD != m_sourceImpl->m_saneApi.sane_control_option_api(m_devHandle, (SANE_Int)0x8853,
if (HGBASE_ERR_OK != ret) SANE_ACTION_GET_VALUE, &pid, NULL))
{ {
return ret; return HGSANE_ERR_DEVICEOFFLINE;
} }
ret = GetDpi(&m_dpi); m_curDevice = this;
if (HGBASE_ERR_OK != ret) int ret = show_progress_ui(parent, UIResultCallback, &m_scanNotify);
if (0 != ret)
{ {
return ret; return HGSANE_ERR_FAIL;
} }
GetDpi(&m_dpi);
m_eventFunc = eventFunc;
m_eventParam = eventParam;
m_imageFunc = imageFunc;
m_imageParam = imageParam;
GetScanMode(m_oldScanMode, 256);
GetScanCount(&m_oldScanCount);
HGChar newScanMode[256] = {0}; HGChar newScanMode[256] = {0};
strcpy(newScanMode, OPTION_VALUE_SMZS_SMZDZS); strcpy(newScanMode, OPTION_VALUE_SMZS_SMZDZS);
SetScanMode(newScanMode); SetScanMode(newScanMode);
SetScanCount(1); SetScanCount(1);
m_eventFunc = eventFunc; m_stopThread = HGFALSE;
m_eventParam = eventParam; m_cancelScan = false;
m_imageFunc = imageFunc; HGBase_OpenThread(ThreadFunc, this, &m_thread);
m_imageParam = imageParam; return HGBASE_ERR_OK;
}
if (-2 == show_scan_ui(&m_sourceImpl->m_saneApi, m_devHandle, m_devName.c_str(), parent, void HGSaneDeviceImpl::UIResultCallback(ui_result result)
show_scan_ui_event_func, this, show_scan_ui_image_func, this)) {
assert(NULL != m_curDevice);
assert(result != UI_RESULT_START_SCAN);
if (result == UI_RESULT_CLOSE_NORMAL)
{ {
SetScanMode(scanMode); if (NULL != m_curDevice->m_thread)
SetScanCount(scanCount); {
m_dpi = 0; m_curDevice->m_stopThread = HGTRUE;
return HGBASE_ERR_NOTSUPPORT; m_curDevice->m_sourceImpl->m_saneApi.sane_cancel_api(m_curDevice->m_devHandle);
HGBase_CloseThread(m_curDevice->m_thread);
m_curDevice->m_thread = NULL;
if (NULL != m_curDevice->m_eventFunc)
m_curDevice->m_eventFunc((HGSaneDevice)m_curDevice, HGSANE_EVENT_TYPE_SCANFINISHED, m_curDevice->m_eventParam);
m_curDevice->SetScanMode(m_curDevice->m_oldScanMode);
m_curDevice->SetScanCount(m_curDevice->m_oldScanCount);
}
close_ui(UI_INDICATOR);
}
else if (result == UI_RESULT_CLOSE_CANCEL)
{
if (NULL != m_curDevice->m_thread)
{
m_curDevice->m_cancelScan = true;
m_curDevice->m_sourceImpl->m_saneApi.sane_cancel_api(m_curDevice->m_devHandle);
}
}
else if (result == UI_RESULT_CLOSE_SETTING)
{
close_ui(UI_SETTING);
}
}
void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param)
{
HGSaneDeviceImpl *p = (HGSaneDeviceImpl *)param;
SANEAPI &saneAPI = m_curDevice->m_sourceImpl->m_saneApi;
if (NULL != p->m_eventFunc)
p->m_eventFunc((HGSaneDevice)p, HGSANE_EVENT_TYPE_WORKING, p->m_eventParam);
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_WORKING, NULL, 0);
SANE_Status stat = saneAPI.sane_start_api(p->m_devHandle);
if (SANE_STATUS_GOOD != stat)
{
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(stat), (int)stat);
return;
} }
SetScanMode(scanMode); while (!p->m_stopThread)
SetScanCount(scanCount); {
return HGBASE_ERR_OK; SANE_Parameters params;
memset(&params, 0, sizeof(SANE_Parameters));
SANE_Status stat1 = saneAPI.sane_get_parameters_api(p->m_devHandle, &params);
if (SANE_STATUS_GOOD != stat1)
{
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(stat1), (int)stat1);
break;
}
HGUInt bufferSize = params.bytes_per_line * params.lines;
HGByte *buffer = (HGByte *)malloc(bufferSize);
if (NULL == buffer)
{
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(SANE_STATUS_NO_MEM), (int)SANE_STATUS_NO_MEM);
break;
}
SANE_Int readSize = 0;
SANE_Status stat2 = SANE_STATUS_GOOD;
while (readSize < bufferSize)
{
SANE_Int len = 0;
stat2 = saneAPI.sane_read_api(p->m_devHandle, buffer + readSize, bufferSize - readSize, &len);
readSize += len;
if (SANE_STATUS_GOOD != stat2)
{
break;
}
}
if (SANE_STATUS_GOOD == stat2)
{
// bufferSize空间不够
free(buffer);
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(SANE_STATUS_NO_MEM), (int)SANE_STATUS_NO_MEM);
break;
}
else if (SANE_STATUS_EOF == stat2)
{
if (0 == readSize)
{
free(buffer);
if (p->m_cancelScan)
{
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(SANE_STATUS_CANCELLED), (int)SANE_STATUS_CANCELLED);
}
else
{
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, NULL, 0);
}
break;
}
if (readSize != params.bytes_per_line * params.lines)
{
free(buffer);
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(SANE_STATUS_IO_ERROR), (int)SANE_STATUS_IO_ERROR);
break;
}
}
else
{
free(buffer);
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(stat2), (int)stat2);
break;
}
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_IMAGE_OK, NULL, 0);
if (nullptr != p->m_imageFunc)
{
HGUInt imgType = 0;
if (params.format == SANE_FRAME_GRAY)
{
if (1 == params.depth)
imgType = HGBASE_IMGTYPE_BINARY;
else if (8 == params.depth)
imgType = HGBASE_IMGTYPE_GRAY;
}
else if (params.format == SANE_FRAME_RGB)
{
imgType = HGBASE_IMGTYPE_RGB;
}
HGImageInfo imgInfo = { (HGUInt)params.pixels_per_line, (HGUInt)params.lines,
imgType, (HGUInt)params.bytes_per_line, HGBASE_IMGORIGIN_TOP };
HGImage img = NULL;
HGBase_CreateImageWithData(buffer, &imgInfo, &img);
if (NULL != img)
{
HGBase_SetImageDpi(img, p->m_dpi, p->m_dpi);
p->m_imageFunc((HGSaneDevice)p, img, p->m_imageParam);
HGBase_DestroyImage(img);
}
}
free(buffer);
buffer = NULL;
bufferSize = 0;
if (!p->m_cancelScan)
{
SANE_Status stat3 = saneAPI.sane_start_api(p->m_devHandle);
if (SANE_STATUS_NO_DOCS == stat3)
{
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, NULL, 0);
break;
}
else if (SANE_STATUS_GOOD != stat3)
{
if (NULL != p->m_scanNotify)
p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(stat3), (int)stat3);
break;
}
}
}
} }
HGResult HGSaneDeviceImpl::SetValueInt32(HGUInt optionId, HGInt value) HGResult HGSaneDeviceImpl::SetValueInt32(HGUInt optionId, HGInt value)
@ -960,7 +1236,7 @@ HGResult HGSaneDeviceImpl::GetScanMode(HGChar *scanMode, HGUInt maxLen)
HGChar *value = (char*)malloc(opt->size * 2 + 4); HGChar *value = (char*)malloc(opt->size * 2 + 4);
if (strcmp(opt->name, SANE_STD_OPT_NAME_SCAN_MODE) == 0) 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); 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) if (ret == SANE_STATUS_GOOD)
{ {
strcpy(scanMode, value); strcpy(scanMode, value);
@ -1044,22 +1320,3 @@ HGResult HGSaneDeviceImpl::SetScanCount(HGInt scanCount)
return HGBASE_ERR_FAIL; return HGBASE_ERR_FAIL;
} }
void HGSaneDeviceImpl::show_scan_ui_event_func(HGUInt event, HGPointer param)
{
HGSaneDeviceImpl* p = (HGSaneDeviceImpl*)param;
if (NULL != p->m_eventFunc)
{
p->m_eventFunc((HGSaneDevice)p, event, p->m_eventParam);
}
}
void HGSaneDeviceImpl::show_scan_ui_image_func(HGImage image, HGPointer param)
{
HGSaneDeviceImpl* p = (HGSaneDeviceImpl*)param;
if (NULL != p->m_imageFunc)
{
HGBase_SetImageDpi(image, p->m_dpi, p->m_dpi);
p->m_imageFunc((HGSaneDevice)p, image, p->m_imageParam);
}
}

View File

@ -8,7 +8,7 @@
#include "../base/HGLock.h" #include "../base/HGLock.h"
#include "sane/sane_ex.h" #include "sane/sane_ex.h"
#include "sane/sane_option_definitions.h" #include "sane/sane_option_definitions.h"
#include "saneui/HGSaneUI.h" #include "twainui/twainui.h"
#include <list> #include <list>
#include <vector> #include <vector>
#include <string> #include <string>
@ -90,6 +90,10 @@ public:
HGResult StartWithSingleScan(HGWindow parent, HGSane_DeviceEventFunc eventFunc, HGPointer eventParam, HGResult StartWithSingleScan(HGWindow parent, HGSane_DeviceEventFunc eventFunc, HGPointer eventParam,
HGSane_DeviceImageFunc imageFunc, HGPointer imageParam); HGSane_DeviceImageFunc imageFunc, HGPointer imageParam);
private:
static void UIResultCallback(ui_result result);
static void HGAPI ThreadFunc(HGThread thread, HGPointer param);
private: private:
HGResult SetValueInt32(HGUInt optionId, HGInt value); HGResult SetValueInt32(HGUInt optionId, HGInt value);
HGResult GetValueInt32(HGUInt optionId, HGInt *value); HGResult GetValueInt32(HGUInt optionId, HGInt *value);
@ -100,20 +104,23 @@ private:
HGResult GetScanCount(HGInt *scanCount); HGResult GetScanCount(HGInt *scanCount);
HGResult SetScanMode(const HGChar *scanMode); HGResult SetScanMode(const HGChar *scanMode);
HGResult SetScanCount(HGInt scanCount); 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);
private: private:
HGSaneSourceImpl* m_sourceImpl; HGSaneSourceImpl* m_sourceImpl;
std::string m_devName; std::string m_devName;
SANE_Handle m_devHandle; SANE_Handle m_devHandle;
HGByte* m_buffer; static HGSaneDeviceImpl *m_curDevice;
HGInt m_bufferSize; std::function<void(int/*event*/, void*/*msg*/, int/*flag*/)> m_scanNotify;
HGInt m_dpi; HGInt m_dpi;
HGSane_DeviceEventFunc m_eventFunc; HGSane_DeviceEventFunc m_eventFunc;
HGPointer m_eventParam; HGPointer m_eventParam;
HGSane_DeviceImageFunc m_imageFunc; HGSane_DeviceImageFunc m_imageFunc;
HGPointer m_imageParam; HGPointer m_imageParam;
HGChar m_oldScanMode[256];
HGInt m_oldScanCount;
volatile HGBool m_stopThread;
HGThread m_thread;
volatile bool m_cancelScan;
}; };
#endif /* __HGSANEIMPL_HPP__ */ #endif /* __HGSANEIMPL_HPP__ */

View File

@ -1,245 +0,0 @@
#include "HGSaneUI.h"
#include "dialog_source_select.h"
#include "dialog_device_select.h"
#include "dialog_device_scan.h"
#include "hg_settingdialog.h"
#include "lang/app_language.h"
#include <QMessageBox>
#include <QTranslator>
#include <QCoreApplication>
#ifdef HG_CMP_MSC
#include "qwinwidget.hpp"
extern HINSTANCE g_hInst;
extern bool g_ownApplication;
#endif
int show_srclist_ui(const char **manuNames, const char **sanePaths, HGWindow parent, HGDll *dll,
SANEAPI* saneApi, char *manuName, unsigned int maxLen)
{
if (nullptr == manuNames || nullptr == sanePaths || nullptr == dll || nullptr == saneApi)
return -1;
QWidget *qParent = nullptr;
#ifdef HG_CMP_MSC
if (!g_ownApplication)
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
QWinWidget win(parent);
if (nullptr != parent)
{
win.showCentered();
qParent = &win;
}
#else
qParent = parent;
#endif
QTranslator translator;
int cp = lang_get_cur_code_page();
if (20127 == cp)
translator.load(":translation/SaneUI_zh_EN.qm");
else
translator.load(":translation/SaneUI_zh_CN.qm");
QCoreApplication::installTranslator(&translator);
*dll = nullptr;
memset(saneApi, 0, sizeof(SANEAPI));
Dialog_Source_Select dlg(manuNames, sanePaths, qParent);
if (dlg.exec())
{
if (nullptr != manuName)
{
std::string strManuName = dlg.GetManuName();
if (maxLen >= strManuName.size() + 1)
strcpy(manuName, strManuName.c_str());
}
*dll = dlg.GetDll();
dlg.GetSaneAPI(saneApi);
}
QCoreApplication::removeTranslator(&translator);
return 0;
}
int show_devlist_ui(const SANEAPI* saneApi, const char **devNames, HGWindow parent,
SANE_Handle *handle, char *devName, unsigned int maxLen)
{
if (nullptr == saneApi || nullptr == handle)
return -1;
QWidget *qParent = nullptr;
#ifdef HG_CMP_MSC
if (!g_ownApplication)
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
QWinWidget win(parent);
if (nullptr != parent)
{
win.showCentered();
qParent = &win;
}
#else
qParent = parent;
#endif
QTranslator translator;
int cp = lang_get_cur_code_page();
if (20127 == cp)
translator.load(":translation/SaneUI_zh_EN.qm");
else
translator.load(":translation/SaneUI_zh_CN.qm");
QCoreApplication::installTranslator(&translator);
*handle = nullptr;
Dialog_Device_Select dlg(saneApi, devNames, qParent);
if (dlg.exec())
{
if (nullptr != devName)
{
std::string strDevName = dlg.GetDevName();
if (maxLen >= strDevName.size() + 1)
strcpy(devName, strDevName.c_str());
}
*handle = dlg.GetDevHandle();
}
QCoreApplication::removeTranslator(&translator);
return 0;
}
int show_setting_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent)
{
if (nullptr == saneApi || nullptr == handle)
return -1;
QWidget *qParent = nullptr;
#ifdef HG_CMP_MSC
if (!g_ownApplication)
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
QWinWidget win(parent);
if (nullptr != parent)
{
win.showCentered();
qParent = &win;
}
#else
qParent = parent;
#endif
QTranslator translator;
QTranslator translator2;
int cp = lang_get_cur_code_page();
if (20127 == cp)
{
translator.load(":translation/SaneUI_zh_EN.qm");
}
else
{
translator.load(":translation/SaneUI_zh_CN.qm");
translator2.load(":translation/qt_zh_CN.qm");
}
QCoreApplication::installTranslator(&translator);
if (20127 != cp)
QCoreApplication::installTranslator(&translator2);
hg_settingdialog dlg(saneApi, handle, devName, qParent);
if (!dlg.IsValid())
{
QCoreApplication::removeTranslator(&translator);
if (20127 != cp)
QCoreApplication::removeTranslator(&translator2);
return -3;
}
dlg.exec();
QCoreApplication::removeTranslator(&translator);
if (20127 != cp)
QCoreApplication::removeTranslator(&translator2);
return 0;
}
int show_scan_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent,
show_scan_ui_event_callback eventCallback, void *eventParam,
show_scan_ui_image_callback imageCallback, void *imageParam)
{
if (nullptr == saneApi || nullptr == handle)
return -1;
QWidget *qParent = nullptr;
#ifdef HG_CMP_MSC
if (!g_ownApplication)
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
QWinWidget win(parent);
if (nullptr != parent)
{
win.showCentered();
qParent = &win;
}
#else
qParent = parent;
#endif
QTranslator translator;
int cp = lang_get_cur_code_page();
if (20127 == cp)
translator.load(":translation/SaneUI_zh_EN.qm");
else
translator.load(":translation/SaneUI_zh_CN.qm");
QCoreApplication::installTranslator(&translator);
Dialog_Device_Scan dlg(saneApi, handle, devName, eventCallback, eventParam,
imageCallback, imageParam, qParent);
dlg.exec();
QCoreApplication::removeTranslator(&translator);
return 0;
}
int show_msgbox_info(const char *title, const char *text, HGWindow parent)
{
if (nullptr == title || nullptr == text)
return -1;
QWidget *qParent = nullptr;
#ifdef HG_CMP_MSC
if (!g_ownApplication)
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
QWinWidget win(parent);
if (nullptr != parent)
{
win.showCentered();
qParent = &win;
}
#else
qParent = parent;
#endif
QMessageBox::information(qParent, QString::fromUtf8(title), QString::fromUtf8(text));
return 0;
}
int show_msgbox_warning(const char *title, const char *text, HGWindow parent)
{
if (nullptr == title || nullptr == text)
return -1;
QWidget *qParent = nullptr;
#ifdef HG_CMP_MSC
if (!g_ownApplication)
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
QWinWidget win(parent);
if (nullptr != parent)
{
win.showCentered();
qParent = &win;
}
#else
qParent = parent;
#endif
QMessageBox::warning(qParent, QString::fromUtf8(title), QString::fromUtf8(text));
return 0;
}

View File

@ -1,27 +0,0 @@
#ifndef SANE_UI_H
#define SANE_UI_H
#include "../base/HGDef.h"
#include "../base/HGDll.h"
#include "../base/HGImage.h"
#include "sane/sane_ex.h"
#define SHOW_SCAN_UI_EVENT_WORKING 1L
#define SHOW_SCAN_UI_EVENT_SCANFINISHED 2L
typedef void (*show_scan_ui_event_callback)(HGUInt event, void *eventParam);
typedef void (*show_scan_ui_image_callback)(HGImage image, void *imageParam);
HGEXPORT int show_srclist_ui(const char **manuNames, const char **sanePaths, HGWindow parent, HGDll *dll,
SANEAPI* saneApi, char *manuName, unsigned int maxLen);
HGEXPORT int show_devlist_ui(const SANEAPI* saneApi, const char **devNames, HGWindow parent,
SANE_Handle *handle, char *devName, unsigned int maxLen);
HGEXPORT int show_setting_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent);
HGEXPORT int show_scan_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent,
show_scan_ui_event_callback eventCallback, void *eventParam,
show_scan_ui_image_callback imageCallback, void *imageParam);
HGEXPORT int show_msgbox_info(const char *title, const char *text, HGWindow parent);
HGEXPORT int show_msgbox_warning(const char *title, const char *text, HGWindow parent);
#endif

View File

@ -1,20 +0,0 @@
#include "HGUIGlobal.h"
#include "base/HGDef.h"
#include "base/HGInc.h"
#include "base/HGUtility.h"
QString getStdFileName(const QString &fileName)
{
char result[512] = {0};
HGBase_StandardiseFileName(fileName.toStdString().c_str(), result, 512);
return result;
}
std::string getStdString(const QString &str)
{
#ifdef HG_CMP_MSC
return str.toLocal8Bit().data();
#else
return str.toStdString();
#endif
}

View File

@ -1,10 +0,0 @@
#ifndef __HGUIGLOBAL_H__
#define __HGUIGLOBAL_H__
#include <QString>
QString getStdFileName(const QString &fileName);
std::string getStdString(const QString &str);
#endif /* __HGUIGLOBAL_H__ */

View File

@ -1,19 +0,0 @@
<RCC>
<qresource prefix="/translation">
<file>SaneUI_zh_CN.qm</file>
<file>SaneUI_zh_EN.qm</file>
<file>qt_zh_CN.qm</file>
</qresource>
<qresource prefix="/logo">
<file>image_rsc/logo/auge_logo.ico</file>
<file>image_rsc/logo/Cumtenn_logo.ico</file>
<file>image_rsc/logo/deli.ico</file>
<file>image_rsc/logo/Hanvon_logo1.ico</file>
<file>image_rsc/logo/Lanxum_logo.ico</file>
<file>image_rsc/logo/logo.ico</file>
<file>image_rsc/logo/Microtek_logo.ico</file>
<file>image_rsc/logo/NoBrand_logo.ico</file>
<file>image_rsc/logo/RightWay_logo.ico</file>
<file>image_rsc/logo/uniscan.ico</file>
</qresource>
</RCC>

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,122 +0,0 @@
#include "app_cfg.h"
#include "base/HGInc.h"
#include "base/HGUtility.h"
#include "base/HGIni.h"
#include "HGUIGlobal.h"
#include "HGString.h"
#ifdef HG_CMP_MSC
#include <shlobj.h>
#endif
QString getCfgValue(const char *appName, const char *key, const QString &def)
{
HGChar cfgPath[512];
HGBase_GetConfigPath(cfgPath, 512);
strcat(cfgPath, "config.ini");
HGChar value[512] = {0};
HGBase_GetProfileString(cfgPath, appName, key, getStdString(def).c_str(), value, 512);
return StdStringToUtf8(value).c_str();
}
int getCfgValue(const char *appName, const char *key, int def)
{
HGChar cfgPath[512];
HGBase_GetConfigPath(cfgPath, 512);
strcat(cfgPath, "config.ini");
HGInt value = 0;
HGBase_GetProfileInt(cfgPath, appName, key, def, &value);
return value;
}
bool getCfgValue(const char *appName, const char *key, bool def)
{
HGChar cfgPath[512];
HGBase_GetConfigPath(cfgPath, 512);
strcat(cfgPath, "config.ini");
HGInt value = 0;
HGBase_GetProfileInt(cfgPath, appName, key, (HGInt)def, &value);
return (bool)value;
}
void saveCfgValue(const char *appName, const char *key, const QString &value)
{
HGChar cfgPath[512];
HGBase_GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "config.ini");
HGBase_SetProfileString(cfgPath, appName, key, getStdString(value).c_str());
}
void saveCfgValue(const char *appName, const char *key, int value)
{
HGChar cfgPath[512];
HGBase_GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "config.ini");
HGBase_SetProfileInt(cfgPath, appName, key, value);
}
void saveCfgValue(const char *appName, const char *key, bool value)
{
HGChar cfgPath[512];
HGBase_GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "config.ini");
HGBase_SetProfileInt(cfgPath, appName, key, (HGInt)value);
}
HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen)
{
if (NULL == configPath || 0 == maxLen)
{
return HGBASE_ERR_INVALIDARG;
}
const char* appName = "HuaGoScan";
#if defined(OEM_HANWANG)
appName = "HanvonScan";
#elif defined(OEM_LISICHENG)
appName = "LanxumScan";
#elif defined(OEM_CANGTIAN)
appName = "CumtennScan";
#elif defined(OEM_ZHONGJING)
appName = "MicrotekScan";
#elif defined(OEM_ZIGUANG)
appName = "UniScan";
#elif defined(OEM_DELI)
appName = "DeliScan";
#endif
#if defined(HG_CMP_MSC)
CHAR cfgPath[MAX_PATH] = { 0 };
BOOL ret = SHGetSpecialFolderPathA(NULL, cfgPath, CSIDL_APPDATA, FALSE);
if (!ret)
return HGBASE_ERR_FAIL;
if (cfgPath[strlen(cfgPath) - 1] != '\\')
strcat(cfgPath, "\\");
strcat(cfgPath, appName);
strcat(cfgPath, "\\Cfg\\");
#else
char cfgPath[512] = { 0 };
struct passwd* pw = getpwuid(getuid());
strcpy(cfgPath, pw->pw_dir);
if (cfgPath[strlen(cfgPath) - 1] != '/')
strcat(cfgPath, "/");
strcat(cfgPath, ".");
strcat(cfgPath, appName);
strcat(cfgPath, "/Cfg/");
#endif
if (maxLen < strlen(cfgPath) + 1)
return HGBASE_ERR_FAIL;
strcpy(configPath, cfgPath);
return HGBASE_ERR_OK;
}

View File

@ -1,16 +0,0 @@
#ifndef __APP_CFG_H__
#define __APP_CFG_H__
#include <QString>
#include "base/HGDef.h"
QString getCfgValue(const char *appName, const char *key, const QString &def);
int getCfgValue(const char *appName, const char *key, int def);
bool getCfgValue(const char *appName, const char *key, bool def);
void saveCfgValue(const char *appName, const char *key, const QString &value);
void saveCfgValue(const char *appName, const char *key, int value);
void saveCfgValue(const char *appName, const char *key, bool value);
HGResult GetConfigPath(HGChar* configPath, HGUInt maxLen);
#endif /* __APP_CFG_H__ */

View File

@ -1,756 +0,0 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* cJSON */
/* JSON parser in C. */
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <float.h>
#include <limits.h>
#include <ctype.h>
#include "cJSON.h"
static const char *ep;
const char *cJSON_GetErrorPtr(void) {return ep;}
static int cJSON_strcasecmp(const char *s1,const char *s2)
{
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
}
static void* ask_memory(size_t bytes)
{
// printf("allocate %u bytes memory in cJSON\n", bytes);
return malloc(bytes);
}
static void *(*cJSON_malloc)(size_t sz) = ask_memory;
static void (*cJSON_free)(void *ptr) = free;
static char* cJSON_strdup(const char* str)
{
size_t len;
char* copy;
len = strlen(str) + 1;
if (!(copy = (char*)cJSON_malloc(len))) return 0;
memcpy(copy,str,len);
return copy;
}
void cJSON_InitHooks(cJSON_Hooks* hooks)
{
if (!hooks) { /* Reset hooks */
cJSON_malloc = ask_memory;
cJSON_free = free;
return;
}
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:ask_memory;
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
}
/* Internal constructor. */
static cJSON *cJSON_New_Item(void)
{
cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
if (node) memset(node,0,sizeof(cJSON));
return node;
}
/* Delete a cJSON structure. */
void cJSON_Delete(cJSON *c)
{
cJSON *next;
while (c)
{
next=c->next;
if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
if (!(c->type&cJSON_StringIsConst) && c->string) cJSON_free(c->string);
cJSON_free(c);
c=next;
}
}
/* Parse the input text to generate a number, and populate the result into item. */
static const char *parse_number(cJSON *item,const char *num)
{
double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
if (*num=='-') sign=-1,num++; /* Has sign? */
if (*num=='0') num++; /* is zero */
if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */
if (*num=='.' && num[1]>='0' && num[1]<='9') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */
if (*num=='e' || *num=='E') /* Exponent? */
{ num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */
while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */
}
n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
item->valuedouble=n;
item->valueint=(int)n;
item->type=cJSON_Number;
return num;
}
static int pow2gt (int x) { --x; x|=x>>1; x|=x>>2; x|=x>>4; x|=x>>8; x|=x>>16; return x+1; }
typedef struct {char *buffer; int length; int offset; } printbuffer;
static char* ensure(printbuffer *p,int needed)
{
char *newbuffer;int newsize;
if (!p || !p->buffer) return 0;
needed+=p->offset;
if (needed<=p->length) return p->buffer+p->offset;
newsize=pow2gt(needed);
newbuffer=(char*)cJSON_malloc(newsize);
if (!newbuffer) {cJSON_free(p->buffer);p->length=0,p->buffer=0;return 0;}
if (newbuffer) memcpy(newbuffer,p->buffer,p->length);
cJSON_free(p->buffer);
p->length=newsize;
p->buffer=newbuffer;
return newbuffer+p->offset;
}
static int update(printbuffer *p)
{
char *str;
if (!p || !p->buffer) return 0;
str=p->buffer+p->offset;
return p->offset+strlen(str);
}
/* Render the number nicely from the given item into a string. */
static char *print_number(cJSON *item,printbuffer *p)
{
char *str=0;
double d=item->valuedouble;
if (d==0)
{
if (p) str=ensure(p,2);
else str=(char*)cJSON_malloc(2); /* special case for 0. */
if (str) strcpy(str,"0");
}
else if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
{
if (p) str=ensure(p,21);
else str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
if (str) sprintf(str,"%d",item->valueint);
}
else
{
if (p) str=ensure(p,64);
else str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
if (str)
{
if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60)sprintf(str,"%.0f",d);
else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
else sprintf(str,"%f",d);
}
}
return str;
}
static unsigned parse_hex4(const char *str)
{
unsigned h=0;
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
h=h<<4;str++;
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
h=h<<4;str++;
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
h=h<<4;str++;
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
return h;
}
/* Parse the input text into an unescaped cstring, and populate item. */
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
static const char *parse_string(cJSON *item,const char *str)
{
const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
if (*str!='\"') {ep=str;return 0;} /* not a string! */
while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
if (!out) return 0;
ptr=str+1;ptr2=out;
while (*ptr!='\"' && *ptr)
{
if (*ptr!='\\') *ptr2++=*ptr++;
else
{
ptr++;
switch (*ptr)
{
case 'b': *ptr2++='\b'; break;
case 'f': *ptr2++='\f'; break;
case 'n': *ptr2++='\n'; break;
case 'r': *ptr2++='\r'; break;
case 't': *ptr2++='\t'; break;
case 'u': /* transcode utf16 to utf8. */
uc=parse_hex4(ptr+1);ptr+=4; /* get the unicode char. */
if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; /* check for invalid. */
if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */
{
if (ptr[1]!='\\' || ptr[2]!='u') break; /* missing second-half of surrogate. */
uc2=parse_hex4(ptr+3);ptr+=6;
if (uc2<0xDC00 || uc2>0xDFFF) break; /* invalid second-half of surrogate. */
uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF));
}
len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
switch (len) {
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 1: *--ptr2 =(uc | firstByteMark[len]);
}
ptr2+=len;
break;
default: *ptr2++=*ptr; break;
}
ptr++;
}
}
*ptr2=0;
if (*ptr=='\"') ptr++;
item->valuestring=out;
item->type=cJSON_String;
return ptr;
}
/* Render the cstring provided to an escaped version that can be printed. */
static char *print_string_ptr(const char *str,printbuffer *p)
{
const char *ptr;char *ptr2,*out;int len=0,flag=0;unsigned char token;
for (ptr=str;*ptr;ptr++) flag|=((*ptr>0 && *ptr<32)||(*ptr=='\"')||(*ptr=='\\'))?1:0;
if (!flag)
{
len=ptr-str;
if (p) out=ensure(p,len+3);
else out=(char*)cJSON_malloc(len+3);
if (!out) return 0;
ptr2=out;*ptr2++='\"';
strcpy(ptr2,str);
ptr2[len]='\"';
ptr2[len+1]=0;
return out;
}
if (!str)
{
if (p) out=ensure(p,3);
else out=(char*)cJSON_malloc(3);
if (!out) return 0;
strcpy(out,"\"\"");
return out;
}
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
if (p) out=ensure(p,len+3);
else out=(char*)cJSON_malloc(len+3);
if (!out) return 0;
ptr2=out;ptr=str;
*ptr2++='\"';
while (*ptr)
{
if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
else
{
*ptr2++='\\';
switch (token=*ptr++)
{
case '\\': *ptr2++='\\'; break;
case '\"': *ptr2++='\"'; break;
case '\b': *ptr2++='b'; break;
case '\f': *ptr2++='f'; break;
case '\n': *ptr2++='n'; break;
case '\r': *ptr2++='r'; break;
case '\t': *ptr2++='t'; break;
default: sprintf(ptr2,"u%04x",token);ptr2+=5; break; /* escape and print */
}
}
}
*ptr2++='\"';*ptr2++=0;
return out;
}
/* Invote print_string_ptr (which is useful) on an item. */
static char *print_string(cJSON *item,printbuffer *p) {return print_string_ptr(item->valuestring,p);}
/* Predeclare these prototypes. */
static const char *parse_value(cJSON *item,const char *value);
static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p);
static const char *parse_array(cJSON *item,const char *value);
static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p);
static const char *parse_object(cJSON *item,const char *value);
static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p);
/* Utility to jump whitespace and cr/lf */
static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;}
/* Parse an object - create a new root, and populate. */
cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated)
{
const char *end=0;
cJSON *c=cJSON_New_Item();
ep=0;
if (!c) return 0; /* memory fail */
end=parse_value(c,skip(value));
if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */
/* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);ep=end;return 0;}}
if (return_parse_end) *return_parse_end=end;
return c;
}
/* Default options for cJSON_Parse */
cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);}
/* Render a cJSON item/entity/structure to text. */
char *cJSON_Print(cJSON *item) {return print_value(item,0,1,0);}
char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0,0);}
char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt)
{
printbuffer p;
p.buffer=(char*)cJSON_malloc(prebuffer);
p.length=prebuffer;
p.offset=0;
return print_value(item,0,fmt,&p);
return p.buffer;
}
/* Parser core - when encountering text, process appropriately. */
static const char *parse_value(cJSON *item,const char *value)
{
if (!value) return 0; /* Fail on null. */
if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
if (*value=='\"') { return parse_string(item,value); }
if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
if (*value=='[') { return parse_array(item,value); }
if (*value=='{') { return parse_object(item,value); }
ep=value;return 0; /* failure. */
}
/* Render a value to text. */
static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p)
{
char *out=0;
if (!item) return 0;
if (p)
{
switch ((item->type)&255)
{
case cJSON_NULL: {out=ensure(p,5); if (out) strcpy(out,"null"); break;}
case cJSON_False: {out=ensure(p,6); if (out) strcpy(out,"false"); break;}
case cJSON_True: {out=ensure(p,5); if (out) strcpy(out,"true"); break;}
case cJSON_Number: out=print_number(item,p);break;
case cJSON_String: out=print_string(item,p);break;
case cJSON_Array: out=print_array(item,depth,fmt,p);break;
case cJSON_Object: out=print_object(item,depth,fmt,p);break;
}
}
else
{
switch ((item->type)&255)
{
case cJSON_NULL: out=cJSON_strdup("null"); break;
case cJSON_False: out=cJSON_strdup("false");break;
case cJSON_True: out=cJSON_strdup("true"); break;
case cJSON_Number: out=print_number(item,0);break;
case cJSON_String: out=print_string(item,0);break;
case cJSON_Array: out=print_array(item,depth,fmt,0);break;
case cJSON_Object: out=print_object(item,depth,fmt,0);break;
}
}
return out;
}
/* Build an array from input text. */
static const char *parse_array(cJSON *item,const char *value)
{
cJSON *child;
if (*value!='[') {ep=value;return 0;} /* not an array! */
item->type=cJSON_Array;
value=skip(value+1);
if (*value==']') return value+1; /* empty array. */
item->child=child=cJSON_New_Item();
if (!item->child) return 0; /* memory fail */
value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
if (!value) return 0;
while (*value==',')
{
cJSON *new_item;
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
child->next=new_item;new_item->prev=child;child=new_item;
value=skip(parse_value(child,skip(value+1)));
if (!value) return 0; /* memory fail */
}
if (*value==']') return value+1; /* end of array */
ep=value;return 0; /* malformed. */
}
/* Render an array to text */
static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p)
{
char **entries;
char *out=0,*ptr,*ret;int len=5;
cJSON *child=item->child;
int numentries=0,i=0,fail=0;
size_t tmplen=0;
/* How many entries in the array? */
while (child) numentries++,child=child->next;
/* Explicitly handle numentries==0 */
if (!numentries)
{
if (p) out=ensure(p,3);
else out=(char*)cJSON_malloc(3);
if (out) strcpy(out,"[]");
return out;
}
if (p)
{
/* Compose the output array. */
i=p->offset;
ptr=ensure(p,1);if (!ptr) return 0; *ptr='['; p->offset++;
child=item->child;
while (child && !fail)
{
print_value(child,depth+1,fmt,p);
p->offset=update(p);
if (child->next) {len=fmt?2:1;ptr=ensure(p,len+1);if (!ptr) return 0;*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;p->offset+=len;}
child=child->next;
}
ptr=ensure(p,2);if (!ptr) return 0; *ptr++=']';*ptr=0;
out=(p->buffer)+i;
}
else
{
/* Allocate an array to hold the values for each */
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
if (!entries) return 0;
memset(entries,0,numentries*sizeof(char*));
/* Retrieve all the results: */
child=item->child;
while (child && !fail)
{
ret=print_value(child,depth+1,fmt,0);
entries[i++]=ret;
if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
child=child->next;
}
/* If we didn't fail, try to ask_memory the output string */
if (!fail) out=(char*)cJSON_malloc(len);
/* If that fails, we fail. */
if (!out) fail=1;
/* Handle failure. */
if (fail)
{
for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]);
cJSON_free(entries);
return 0;
}
/* Compose the output array. */
*out='[';
ptr=out+1;*ptr=0;
for (i=0;i<numentries;i++)
{
tmplen=strlen(entries[i]);memcpy(ptr,entries[i],tmplen);ptr+=tmplen;
if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;}
cJSON_free(entries[i]);
}
cJSON_free(entries);
*ptr++=']';*ptr++=0;
}
return out;
}
/* Build an object from the text. */
static const char *parse_object(cJSON *item,const char *value)
{
cJSON *child;
if (*value!='{') {ep=value;return 0;} /* not an object! */
item->type=cJSON_Object;
value=skip(value+1);
if (*value=='}') return value+1; /* empty array. */
item->child=child=cJSON_New_Item();
if (!item->child) return 0;
value=skip(parse_string(child,skip(value)));
if (!value) return 0;
child->string=child->valuestring;child->valuestring=0;
if (*value!=':') {ep=value;return 0;} /* fail! */
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
if (!value) return 0;
while (*value==',')
{
cJSON *new_item;
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
child->next=new_item;new_item->prev=child;child=new_item;
value=skip(parse_string(child,skip(value+1)));
if (!value) return 0;
child->string=child->valuestring;child->valuestring=0;
if (*value!=':') {ep=value;return 0;} /* fail! */
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
if (!value) return 0;
}
if (*value=='}') return value+1; /* end of array */
ep=value;return 0; /* malformed. */
}
/* Render an object to text. */
static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
{
char **entries=0,**names=0;
char *out=0,*ptr,*ret,*str;int len=7,i=0,j;
cJSON *child=item->child;
int numentries=0,fail=0;
size_t tmplen=0;
/* Count the number of entries. */
while (child) numentries++,child=child->next;
/* Explicitly handle empty object case */
if (!numentries)
{
if (p) out=ensure(p,fmt?depth+4:3);
else out=(char*)cJSON_malloc(fmt?depth+4:3);
if (!out) return 0;
ptr=out;*ptr++='{';
if (fmt) {*ptr++='\n';for (i=0;i<depth-1;i++) *ptr++='\t';}
*ptr++='}';*ptr++=0;
return out;
}
if (p)
{
/* Compose the output: */
i=p->offset;
len=fmt?2:1; ptr=ensure(p,len+1); if (!ptr) return 0;
*ptr++='{'; if (fmt) *ptr++='\n'; *ptr=0; p->offset+=len;
child=item->child;depth++;
while (child)
{
if (fmt)
{
ptr=ensure(p,depth); if (!ptr) return 0;
for (j=0;j<depth;j++) *ptr++='\t';
p->offset+=depth;
}
print_string_ptr(child->string,p);
p->offset=update(p);
len=fmt?2:1;
ptr=ensure(p,len); if (!ptr) return 0;
*ptr++=':';if (fmt) *ptr++='\t';
p->offset+=len;
print_value(child,depth,fmt,p);
p->offset=update(p);
len=(fmt?1:0)+(child->next?1:0);
ptr=ensure(p,len+1); if (!ptr) return 0;
if (child->next) *ptr++=',';
if (fmt) *ptr++='\n';*ptr=0;
p->offset+=len;
child=child->next;
}
ptr=ensure(p,fmt?(depth+1):2); if (!ptr) return 0;
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
*ptr++='}';*ptr=0;
out=(p->buffer)+i;
}
else
{
/* Allocate space for the names and the objects */
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
if (!entries) return 0;
names=(char**)cJSON_malloc(numentries*sizeof(char*));
if (!names) {cJSON_free(entries);return 0;}
memset(entries,0,sizeof(char*)*numentries);
memset(names,0,sizeof(char*)*numentries);
/* Collect all the results into our arrays: */
child=item->child;depth++;if (fmt) len+=depth;
while (child)
{
names[i]=str=print_string_ptr(child->string,0);
entries[i++]=ret=print_value(child,depth,fmt,0);
if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
child=child->next;
}
/* Try to allocate the output string */
if (!fail) out=(char*)cJSON_malloc(len);
if (!out) fail=1;
/* Handle failure */
if (fail)
{
for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);}
cJSON_free(names);cJSON_free(entries);
return 0;
}
/* Compose the output: */
*out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
for (i=0;i<numentries;i++)
{
if (fmt) for (j=0;j<depth;j++) *ptr++='\t';
tmplen=strlen(names[i]);memcpy(ptr,names[i],tmplen);ptr+=tmplen;
*ptr++=':';if (fmt) *ptr++='\t';
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
if (i!=numentries-1) *ptr++=',';
if (fmt) *ptr++='\n';*ptr=0;
cJSON_free(names[i]);cJSON_free(entries[i]);
}
cJSON_free(names);cJSON_free(entries);
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
*ptr++='}';*ptr++=0;
}
return out;
}
/* Get Array size/item / object item. */
int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
/* Utility for array list handling. */
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
/* Utility for handling references. */
static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
/* Add item to array/object. */
void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (!(item->type&cJSON_StringIsConst) && item->string) cJSON_free(item->string);item->string=(char*)string;item->type|=cJSON_StringIsConst;cJSON_AddItemToArray(object,item);}
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
/* Replace array/object items with new ones. */
void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) {cJSON_AddItemToArray(array,newitem);return;}
newitem->next=c;newitem->prev=c->prev;c->prev=newitem;if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;}
void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
/* Create basic types: */
cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
cJSON *cJSON_CreateTrue(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
cJSON *cJSON_CreateFalse(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;}
cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;}
cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
/* Create Arrays: */
cJSON *cJSON_CreateIntArray(const int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON *cJSON_CreateFloatArray(const float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON *cJSON_CreateDoubleArray(const double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
/* Duplication */
cJSON *cJSON_Duplicate(cJSON *item,int recurse)
{
cJSON *newitem,*cptr,*nptr=0,*newchild;
/* Bail on bad ptr */
if (!item) return 0;
/* Create new item */
newitem=cJSON_New_Item();
if (!newitem) return 0;
/* Copy over all vars */
newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble;
if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}}
if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}}
/* If non-recursive, then we're done! */
if (!recurse) return newitem;
/* Walk the ->next chain for the child. */
cptr=item->child;
while (cptr)
{
newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */
if (!newchild) {cJSON_Delete(newitem);return 0;}
if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */
else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */
cptr=cptr->next;
}
return newitem;
}
void cJSON_Minify(char *json)
{
char *into=json;
while (*json)
{
if (*json==' ') json++;
else if (*json=='\t') json++; /* Whitespace characters. */
else if (*json=='\r') json++;
else if (*json=='\n') json++;
else if (*json=='/' && json[1]=='/') while (*json && *json!='\n') json++; /* double-slash comments, to end of line. */
else if (*json=='/' && json[1]=='*') {while (*json && !(*json=='*' && json[1]=='/')) json++;json+=2;} /* multiline comments. */
else if (*json=='\"'){*into++=*json++;while (*json && *json!='\"'){if (*json=='\\') *into++=*json++;*into++=*json++;}*into++=*json++;} /* string literals, which are \" sensitive. */
else *into++=*json++; /* All other characters. */
}
*into=0; /* and null-terminate. */
}

View File

@ -1,154 +0,0 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef cJSON__h
#define cJSON__h
#include <stdlib.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* cJSON Types: */
#define cJSON_False 0
#define cJSON_True 1
#define cJSON_NULL 2
#define cJSON_Number 3
#define cJSON_String 4
#define cJSON_Array 5
#define cJSON_Object 6
#define cJSON_IsReference 256
#define cJSON_StringIsConst 512
typedef void *(*malloc_fnxx)(size_t sz);
typedef void (*free_fnxx)(void *ptr);
/* The cJSON structure: */
typedef struct cJSON {
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
int type; /* The type of the item, as above. */
char *valuestring; /* The item's string, if type==cJSON_String */
int valueint; /* The item's number, if type==cJSON_Number */
double valuedouble; /* The item's number, if type==cJSON_Number */
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
} cJSON;
typedef struct cJSON_Hooks {
malloc_fnxx malloc_fn;
free_fnxx free_fn;
} cJSON_Hooks;
/* Supply malloc, realloc and free functions to cJSON */
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
extern cJSON *cJSON_Parse(const char *value);
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
extern char *cJSON_Print(cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
extern char *cJSON_PrintUnformatted(cJSON *item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt);
/* Delete a cJSON entity and all subentities. */
extern void cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
extern int cJSON_GetArraySize(cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
/* Get item "string" from object. Case insensitive. */
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
extern const char *cJSON_GetErrorPtr(void);
/* These calls create a cJSON item of the appropriate type. */
extern cJSON *cJSON_CreateNull(void);
extern cJSON *cJSON_CreateTrue(void);
extern cJSON *cJSON_CreateFalse(void);
extern cJSON *cJSON_CreateBool(int b);
extern cJSON *cJSON_CreateNumber(double num);
extern cJSON *cJSON_CreateString(const char *string);
extern cJSON *cJSON_CreateArray(void);
extern cJSON *cJSON_CreateObject(void);
/* These utilities create an Array of count items. */
extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
/* Append item to the specified array/object. */
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
extern void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
/* Update array items. */
extern void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem); /* Shifts pre-existing items to the right. */
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
/* Duplicate a cJSON item */
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
extern void cJSON_Minify(char *json);
/* Macros for creating things quickly. */
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
#define cJSON_SetNumberValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,237 +0,0 @@
#pragma once
#if defined(WIN32) || defined(_WIN64)
#include <Windows.h>
#define PATH_SYMBOL "\\"
#else
#define PATH_SYMBOL "/"
#define NULL nullptr
#define DWORD_PTR char*
#define _countof(a) sizeof(a) / sizeof(a[0])
#endif
#include "cJSON.h"
//#include "../../code_device/hgsane/cJSON.h"
#include <vector>
#include <string>
#include <map>
#include <algorithm>
namespace gb
{
class scanner_cfg;
class refer
{
volatile long ref_;
protected:
refer();
virtual ~refer();
public:
long add_ref(void);
long release(void);
};
class json : public refer
{
cJSON *obj_;
cJSON *cur_child_;
cJSON walk_head_;
bool is_array_;
cJSON* find_sibling(cJSON* first, const char* name, cJSON*** addr);
cJSON* find_child(cJSON *parent, std::vector<std::string>& path, bool create, cJSON*** addr = NULL);
cJSON* find(const char* path, bool create = false, cJSON*** addr = NULL);
protected:
~json();
public:
json(char* json_txt = 0);
static std::string to_string(cJSON* root, bool formatted);
static std::string get_value_as_string(cJSON* root, bool integer = false);
static void free_node_data(cJSON* node);
static cJSON* create_element(bool is_array = false);
static cJSON* create_element_with_name(const char* name);
public:
bool attach_text(char* json_txt);
bool attach_cjson(cJSON* cjson);
bool create_empty(bool array = false);
void clear(void);
std::string to_string(bool formatted);
// can be path: child/value ...
bool get_value(const char* key, bool& val);
bool get_value(const char* key, int& val);
bool get_value(const char* key, double& val);
bool get_value(const char* key, std::string& val);
bool get_value(const char* key, json*& val); // caller shoud call "delete" to free the returned object !!!
bool get_value_as_string(const char* key, std::string& val, bool integer);
bool get_as_array(const char* key, std::vector<std::string>& val);
int count(void);
bool first_child(std::string& val, std::string* name = NULL);
bool next_child(std::string& val, std::string* name = NULL);
bool set_value(const char* key, bool val);
bool set_value(const char* key, int val);
bool set_value(const char* key, double val);
bool set_value(const char* key, std::string val);
bool set_value(const char* key, const char* val);
bool set_value(const char* key, json* obj);
bool change_key(const char* old_key, const char* new_key);
bool remove(const char* key);
};
class base64
{
char base64_ind_[128];
char base64_char_[80];
char padding_char_;
bool is_valid_base64_table(const char* table);
bool initialize_base64_table(const char* table);
public:
base64();
~base64();
public:
bool set_base64_table(const char* table = NULL);
std::string encode(const char* data, size_t bytes, unsigned int line_bytes = -1, bool need_padding = true);
std::string decode(const char* data, size_t bytes);
};
class sane_config_schm : public refer
{
std::string scheme_name_;
scanner_cfg *scanner_;
std::string file_;
json* jsn_;
json* bkp_;
json* def_val_;
bool in_setting_;
std::map<int, std::string> id_name_; // (id, default-val)
void clear();
std::string default_value(const char* name);
protected:
~sane_config_schm();
public:
sane_config_schm(scanner_cfg* scanner = nullptr);
static std::string opt_data_appendix_;
static bool hex(unsigned char ch, unsigned char* val);
static bool hex_char(const char* data, unsigned char* val);
static std::string to_hex_letter(const char* data, size_t bytes);
static std::string from_hex_letter(const char* data, size_t bytes);
static bool is_option_data(std::string& name); // reset baase option name into 'name' if name was option data, and return true
public:
sane_config_schm* copy(void);
bool load_from_file(const char* file);
bool load_from_mem(const char* mem, bool in_b64 = true);
bool save_to(const char* file);
void set_default_value(int sn, const char* name, const char* val, size_t bytes);
void copy_default_value(sane_config_schm* from);
bool first_config(std::string& name, std::string& val);
bool next_config(std::string& name, std::string& val);
bool get_config(const char* name, std::string& val);
void begin_setting(bool restore = false);
void config_changed(const char* name, const char* val, size_t bytes, bool extra = false);
void config_changed(int sn, const char* val, size_t bytes, bool extra = false);
void remove_config(const char* name/*nullptr for clear*/);
void set_value(const char* name, const char* val, size_t bytes, bool extra = false);
bool has_changed(int* items = nullptr);
bool is_equal(sane_config_schm* r);
void end_setting(bool cancel);
int id_from_name(const char* name);
std::string to_text_stream(bool b64 = true, bool with_ver = true);
std::string get_version(void);
std::string get_scheme_name(void);
void set_scheme_name(const char* name);
void update(bool(* is_float)(int, void*), void* param, const char*(* t2n)(const char*), std::string* discard = NULL);
};
class scanner_cfg : public refer
{
// format: in base64
//
// {
// "global": {
// "ver": "4.33",
// "cur": -1
// },
// "scheme_1": sane_config_schm*,
// "scheme_2": sane_config_schm*,
// "scheme_3": sane_config_schm*,
// ...
// }
//
std::string path_;
std::string scanner_name_; // scanner type: HUAGOSCAN G100 - 0100
json *global_; // version, current scheme, ...
typedef struct _cfg_schm
{
std::string name;
sane_config_schm* schm;
bool operator==(const char* n)
{
return name == n;
}
}CFGSCHM;
std::vector<CFGSCHM> schemes_;
sane_config_schm* user_default_;
static std::string global_name_;
static std::string cur_sel_;
static std::string default_setting_name_;
void clear(void);
void init_version(void);
void init_select(void);
void walk_sibling_schemes(cJSON* first);
protected:
~scanner_cfg();
public:
scanner_cfg();
typedef struct _update_func
{
void(* trans_number)(const char* name, std::string& val, void* param);
const char* (* title2name)(const char* title, void* param);
std::string discard_msg; // update failed items ...
void* func_param;
}UDF, *LPUDF;
static bool update(const char* file, LPUDF func);
static std::string user_default_scheme_name(void);
public:
int load_file(const char* file);
int load_mem(const char* mem, bool in_base64 = true);
int save(const char* file = nullptr);
std::string to_text(bool in_base64);
void get_all_schemes(std::vector<std::string>& schemes); // return all schemes name queue, the first is always be 'Default settings'
sane_config_schm* get_scheme(const char* scheme_name = nullptr/*return current scheme if was null*/); // call sane_config_schm::release() if not use anymore
std::string get_current_scheme_name(void);
bool remove_scheme(const char* scheme_name);
void remove_all_schemes(void);
bool select_scheme(const char* scheme_name);
sane_config_schm* copy_scheme(const char* cp_from_name); // for UI setting, call release() if not use anymore
bool add_scheme(sane_config_schm* schm, const char* name = nullptr);
bool rename_scheme(const char* from, const char* to);
};
};

View File

@ -1,465 +0,0 @@
#include "cutdialog.h"
#include "ui_cutdialog.h"
#include <QDebug>
#include <QToolTip>
#include <qpainterpath.h>
#include "HGString.h"
#include "sane/sane_option_definitions.h"
cutDialog::cutDialog(QWidget *parent) :
QWidget(parent),
ui(new Ui::cutDialog)
{
ui->setupUi(this);
divisor = 8;
dpi = 1;
sizeType = 0;
paperWidth = 185;
h_w = 260.0/185.0;
sizeRate = 1;
paperHeight = paperWidth*h_w;
this->setFixedSize(paperWidth,paperHeight);
setMouseTracking(true);
m_startPoint = QPoint(10,10);
m_endPoint = QPoint(50,50);
m_mouse_down = false;
initAllCorner();
}
cutDialog::~cutDialog()
{
delete ui;
}
void cutDialog::setPaperSize(QString type, const int w)
{
paperType = type;
if (paperType == OPTION_VALUE_ZZCC_A3) h_w = 420.0 / 297.0;
else if (paperType == OPTION_VALUE_ZZCC_8K) h_w = 390.0 / 270.0;
else if (paperType == OPTION_VALUE_ZZCC_16K) h_w = 270.0 / 190.0;
else if (paperType == OPTION_VALUE_ZZCC_16KHX) h_w = 190.0 / 270.0;
else if (paperType == OPTION_VALUE_ZZCC_A4) h_w = 297.0 / 210.0;
else if (paperType == OPTION_VALUE_ZZCC_A4HX) h_w = 210.0 / 297.0;
else if (paperType == OPTION_VALUE_ZZCC_A5) h_w = 210.0 / 148.0;
else if (paperType == OPTION_VALUE_ZZCC_A5HX) h_w = 148.0 / 210.0;
else if (paperType == OPTION_VALUE_ZZCC_A6) h_w = 148.0 / 105.0;
else if (paperType == OPTION_VALUE_ZZCC_A6HX) h_w = 105.0 / 148.0;
else if (paperType == OPTION_VALUE_ZZCC_B4) h_w = 353.0 / 250.0;
else if (paperType == OPTION_VALUE_ZZCC_B5) h_w = 250.0 / 176.0;
else if (paperType == OPTION_VALUE_ZZCC_B5HX) h_w = 176.0 / 250.0;
else if (paperType == OPTION_VALUE_ZZCC_B6) h_w = 176.0 / 125.0;
else if (paperType == OPTION_VALUE_ZZCC_B6HX) h_w = 125.0 / 176.0;
else if (paperType == OPTION_VALUE_ZZCC_Letter) h_w = 279.0 / 216.0;
else if (paperType == OPTION_VALUE_ZZCC_LetterHX) h_w = 216.0 / 279.0;
else if (paperType == OPTION_VALUE_ZZCC_DoubleLetter) h_w = 559.0 / 216.0;
else if (paperType == OPTION_VALUE_ZZCC_LEGAL) h_w = 356.0 / 216.0;
else if (paperType == OPTION_VALUE_ZZCC_SLSJ) h_w = 560.0 / 270.0;
else if(paperType == OPTION_VALUE_ZZCC_ZDSMCC) h_w = 3307.0*2/2338;
else if(paperType == OPTION_VALUE_ZZCC_PPYSCC) {
if(dpi == 100.0) h_w = 1795.0/1189;
if(dpi == 150.0) h_w = 1795.0/1784;
if(dpi == 200.0) h_w = 3307.0/2338;
if(dpi == 240.0) h_w = 4308.0/2854;
if(dpi == 200.0) h_w = 5385.0/3567;
};
if(type.contains("3")) divisor = 2;
else if (type.contains("4")) divisor = 4;
else if (type.contains("5")) divisor = 6;
else if (type.contains("6")) divisor = 8;
else divisor = 4;
paperWidth = w;
if(type.contains(StdStringToUtf8("横向").c_str()))
paperWidth = paperWidth*h_w*1.5;
double realW = paperWidth;
if (paperType == OPTION_VALUE_ZZCC_A3 || paperType == OPTION_VALUE_ZZCC_A4HX) realRate = 297.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_A4 || paperType == OPTION_VALUE_ZZCC_A5HX) realRate = 210.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_A5 || paperType == OPTION_VALUE_ZZCC_A6HX) realRate = 148.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_A6) realRate = 105.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_16K) realRate = 190.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_8K || paperType == OPTION_VALUE_ZZCC_16KHX) realRate = 270.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_B4 || paperType == OPTION_VALUE_ZZCC_B5HX) realRate = 250.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_B5 || paperType == OPTION_VALUE_ZZCC_B6HX) realRate = 176.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_B6) realRate = 125.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_Letter) realRate = 216.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_LetterHX) realRate = 279.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_DoubleLetter) realRate = 216.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_LEGAL) realRate = 216.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_SLSJ) realRate = 270.0 / realW;
else if(paperType == OPTION_VALUE_ZZCC_ZDSMCC) realRate = 297.0/realW;
else if(paperType == OPTION_VALUE_ZZCC_PPYSCC) {
if(dpi == 100.0) realRate = 1189.0*0.039377/dpi/realW;
if(dpi == 150.0) realRate = 1784*0.039377/dpi/realW;
if(dpi == 200.0) realRate = 2338*0.039377/dpi/realW;
if(dpi == 240.0) realRate = 2854*0.039377/dpi/realW;
if(dpi == 200.0) realRate = 3567*0.039377/dpi/realW;
};
paperHeight = paperWidth*h_w;
this->setFixedSize(paperWidth+4,paperHeight+4);
scaleRec = QRectF(0,0,paperWidth,paperHeight+0.5);
m_rect = QRectF(m_startPoint,m_endPoint);
update();
refreshView();
}
void cutDialog::setDpiValue(const double d)
{
dpi = d;
if(sizeType == PIXEL) sizeRate = 0.03937*dpi;
update();
}
void cutDialog::setSizeType(const SIZETYPE &t)
{
sizeType = t;
switch (sizeType) {
case MILLIM:
sizeRate = 1;
break;
case INCH:
sizeRate = 0.03937;
break;
case PIXEL:
sizeRate = 0.03937*dpi;
break;
}
update();
}
void cutDialog::setCutRectWidth(double w)
{
m_endPoint.setX(m_startPoint.x()+scaleRec.width()*w/getPaperSize().width());
update();
}
void cutDialog::setCutRectHeight(double h)
{
m_endPoint.setY(m_startPoint.y()+scaleRec.height()*h/getPaperSize().height());
update();
}
void cutDialog::setCutRectStartX(double x)
{
m_startPoint.setX(scaleRec.width()*x/getPaperSize().width());
update();
}
void cutDialog::setCutRectStartY(double y)
{
m_startPoint.setY(scaleRec.height()*y/getPaperSize().height());
update();
}
QSizeF cutDialog::getPaperSize() const
{
double realW = paperWidth*realRate*sizeRate;
double realH = paperHeight*realRate*sizeRate;
return QSizeF(realW,realH);
}
QSizeF cutDialog::getCutRectSize() const
{
double realCutW = getPaperSize().width()*m_rect.width()/scaleRec.width();
double realCutH = getPaperSize().height()*m_rect.height()/scaleRec.height();
return QSizeF(realCutW,realCutH);
}
QPointF cutDialog::getCutRectStartPos() const
{
double realCutX = getPaperSize().width()*m_startPoint.x()/scaleRec.width();
double realCutY = getPaperSize().height()*m_startPoint.y()/scaleRec.height();
return QPointF(realCutX,realCutY);
}
QRectF cutDialog::getCutRectPixel() const
{
double x = 0.03937*dpi*paperWidth*realRate*m_startPoint.x()/scaleRec.width();
double y = 0.03937*dpi*paperHeight*realRate*m_startPoint.y()/scaleRec.height();
double w = 0.03937*dpi*paperWidth*realRate*m_rect.width()/scaleRec.width();
double h = 0.03937*dpi*paperHeight*realRate*m_rect.height()/scaleRec.height();
return QRectF(x,y,w,h);
}
void cutDialog::setCutRectPixel(QRectF &rect)
{
m_startPoint.setX(scaleRec.width()*rect.x()/(paperWidth*realRate*0.03937*dpi));
m_startPoint.setY(scaleRec.height()*rect.y()/(paperHeight*realRate*0.03937*dpi));
m_endPoint.setX(m_startPoint.x()+scaleRec.width()*rect.width()/(paperWidth*realRate*0.03937*dpi));
m_endPoint.setY(m_startPoint.y()+scaleRec.height()*rect.height()/(paperHeight*realRate*0.03937*dpi));
m_rect = QRectF(m_startPoint,m_endPoint);
update();
}
int cutDialog::getCutRectRight() const
{
return getPaperSize().width()*m_rect.right()/scaleRec.right();
}
int cutDialog::getCutRectBottom() const
{
return getPaperSize().height()*m_rect.bottom()/scaleRec.bottom();
}
void cutDialog::mousePressEvent(QMouseEvent *event)
{
int x = event->x()/**paperWidth/width()*/;
int y = event->y()/**paperHeight/height()*/;
m_moveStart = QPoint(x,y);
m_mouse_down = event->button() == Qt::LeftButton;
update();
}
void cutDialog::mouseMoveEvent(QMouseEvent *event)
{
int x = event->x()/**paperWidth/width()*/;
int y = event->y()/**paperHeight/height()*/;
if(m_mouse_down){
int dx = m_moveStart.x() - x;
int dy = m_moveStart.y() - y;
m_moveStart = QPoint(x,y);
if(m_leftCorn){
m_startPoint.setX(x);
}else if(m_rightCorn){
m_endPoint.setX(x);
}else if(m_topCorn){
m_startPoint.setY(y);
}else if(m_bottomCorn){
m_endPoint.setY(y);
}else if(m_leftTop){
m_startPoint.setX(x);
m_startPoint.setY(y);
}else if(m_leftBottom){
m_startPoint.setX(x);
m_endPoint.setY(y);
}else if(m_rightTop){
m_startPoint.setY(y);
m_endPoint.setX(x);
}else if(m_rightBottom){
m_endPoint.setX(x);
m_endPoint.setY(y);
}
else if(!m_out){
if(m_startPoint.x() - dx < 0) dx = 0;
if(m_startPoint.y() - dy < 0) dy = 0;
if(m_endPoint.x() - dx > scaleRec.right()) dx = 0;
if(m_endPoint.y() - dy > scaleRec.bottom()) dy = 0;
m_startPoint.setX(m_rect.left()-dx);
m_startPoint.setY(m_rect.top()-dy);
m_endPoint.setX(m_rect.right()-dx);
m_endPoint.setY(m_rect.bottom()-dy);
}
if(m_startPoint.x()<=0) m_startPoint.setX(0);
if(m_startPoint.y()<=0) m_startPoint.setY(0);
if(m_endPoint.x()>=scaleRec.width()) m_endPoint.setX(scaleRec.right());
if(m_endPoint.y()>=scaleRec.height()) m_endPoint.setY(scaleRec.bottom());
if(qAbs(m_startPoint.x() - m_endPoint.x()) <= 10 || m_startPoint.x() > m_endPoint.x()){
m_startPoint.setX(m_rect.left());
m_endPoint.setX(m_rect.right());
}
if(qAbs(m_startPoint.y() - m_endPoint.y()) <= 10 || m_startPoint.y() > m_endPoint.y()){
m_startPoint.setY(m_rect.top());
m_endPoint.setY(m_rect.bottom());
}
update();
}else{
mousePosition(QPoint(x,y));
}
}
void cutDialog::mouseReleaseEvent(QMouseEvent *)
{
m_mouse_down = false;
update();
}
void cutDialog::enterEvent(QEvent *)
{
emit lineEditEnable(false);
}
void cutDialog::leaveEvent(QEvent *)
{
emit lineEditEnable(true);
}
void cutDialog::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.translate(0,0);
drawScale(painter);
drawCutRect(painter);
drawTransparentColor(painter);
if(m_mouse_down){
if(sizeType == INCH || sizeType == MILLIM){
emit cutRectX(QString::number(getCutRectStartPos().x(),'f',2).toDouble());
emit cutRectY(QString::number(getCutRectStartPos().y(),'f',2).toDouble());
emit cutRectWidth(QString::number(getCutRectSize().width(),'f',2).toDouble());
emit cutRectHeight(QString::number(getCutRectSize().height(),'f',2).toDouble());
}else{
emit cutRectX(double(int(getCutRectStartPos().x())));
emit cutRectY(double(int(getCutRectStartPos().y())));
emit cutRectWidth(double(int(getCutRectSize().width())));
emit cutRectHeight(double(int(getCutRectSize().height())));
}
}
painter.end();
}
void cutDialog::drawScale(QPainter& painter)
{
painter.setPen(QPen(Qt::black,1));
scaleRec = QRectF(0,0,paperWidth,paperHeight+0.5);
painter.drawRect(scaleRec);
for(int i = 6 ; i <= paperWidth-6; i++){
if(int(paperWidth/2) == i || int(paperWidth/4) == i || int(paperWidth*3/4) == i){
painter.setPen(QPen(Qt::gray,1));
painter.drawLine(i,0,i,paperHeight);
painter.setPen(QPen(Qt::black,1));
}
if(i%divisor == 0){
painter.drawLine(i,paperHeight-4,i,paperHeight);
painter.drawLine(i,0,i,4);
}
if(i%(divisor*5) == 0){
painter.drawLine(i,paperHeight-8,i,paperHeight);
painter.drawLine(i,0,i,8);
}
}
for(int i = 6 ; i <= paperHeight-6; i++){
if(int(paperHeight/2) == i || int(paperHeight/4) == i || int(paperHeight*3/4) == i){
painter.setPen(QPen(Qt::gray,1));
painter.drawLine(0,i,paperWidth,i);
painter.setPen(QPen(Qt::black,1));
}
if(i%divisor == 0){
painter.drawLine(0,i,4,i);
painter.drawLine(paperWidth,i,paperWidth-4,i);
}
if(i%(divisor*5) == 0){
painter.drawLine(0,i,8,i);
painter.drawLine(paperWidth,i,paperWidth-8,i);
}
}
}
void cutDialog::drawCutRect(QPainter &painter)
{
painter.setPen(QPen(Qt::green,1));
m_rect = QRectF(m_startPoint,m_endPoint);
QRectF r(m_rect);
if(r.right() + 6 > paperWidth)
r.setRight(paperWidth - 6);
if(r.bottom() + 2 > paperHeight)
r.setBottom(paperHeight - 2);
painter.drawRect(r);
painter.setPen(QPen(Qt::red,1));
painter.setBrush(Qt::red);
painter.drawEllipse(r.left()-2,(r.bottom()-r.top())/2+r.top()-2,4,4);
painter.drawEllipse(r.left()-2,r.top()-2,4,4);
painter.drawEllipse(r.left()-2,r.bottom()-2,4,4);
painter.drawEllipse(r.right()-2,r.top()-2,4,4);
painter.drawEllipse(r.right()-2,r.bottom()-2,4,4);
painter.drawEllipse(r.right()-2,(r.bottom()-r.top())/2+r.top()-2,4,4);
painter.drawEllipse((r.right()-r.left())/2+r.left()-2,r.top()-2,4,4);
painter.drawEllipse((r.right()-r.left())/2+r.left()-2,r.bottom()-2,4,4);
}
void cutDialog::drawTransparentColor(QPainter &painter)
{
QPainterPath painterPath;
QPainterPath p;
p.addRect(scaleRec);
painterPath.addRect(m_rect);
QPainterPath drawPath =p.subtracted(painterPath);
painter.setOpacity(0.7);
painter.fillPath(drawPath,QBrush(Qt::gray));
}
void cutDialog::mousePosition(const QPoint& e)
{
initAllCorner();
QRectF r = QRectF(m_rect);
int x = e.x();
int y = e.y();
m_left = qAbs(x - r.left()) < 5;
m_right = qAbs(x - r.right()) < 5;
m_bottom = qAbs(y - r.bottom()) < 5;
m_top = qAbs(y - r.top()) < 5;
m_out = r.left()-x>=5 || x-r.right()>=5 || r.top()-y>=5 || y-r.bottom()>=5;
bool lorr = m_left | m_right;
bool torb = m_top | m_bottom;
if(lorr && torb)
{
if((m_left && m_top) || (m_right && m_bottom))
setCursor(Qt::SizeFDiagCursor);
else
setCursor(Qt::SizeBDiagCursor);
}
else if(lorr)
setCursor(Qt::SizeHorCursor);
else if(torb)
setCursor(Qt::SizeVerCursor);
else if(!m_out)
{
setCursor(Qt::SizeAllCursor);
m_bottom = m_left = m_right = m_top = false;
}else if(m_out){
setCursor(Qt::ArrowCursor);
m_bottom = m_left = m_right = m_top = false;
}
if(m_left && m_top) m_leftTop = true;
else if(m_left && m_bottom) m_leftBottom = true;
else if(m_right && m_top) m_rightTop = true;
else if(m_right && m_bottom) m_rightBottom = true;
else if(m_left && !m_top && !m_bottom) m_leftCorn = true;
else if(m_right && !m_top && !m_bottom) m_rightCorn = true;
else if(m_top && !m_left && !m_right) m_topCorn = true;
else if(m_bottom && !m_left && !m_right) m_bottomCorn = true;
else initAllCorner();
}
void cutDialog::refreshView()
{
if(MILLIM == sizeType || sizeType == INCH){
emit cutRectX(QString::number(getCutRectStartPos().x(),'f',2).toDouble());
emit cutRectY(QString::number(getCutRectStartPos().y(),'f',2).toDouble());
emit cutRectWidth(QString::number(getCutRectSize().width(),'f',2).toDouble());
emit cutRectHeight(QString::number(getCutRectSize().height(),'f',2).toDouble());
}else{
emit cutRectX(QString::number(getCutRectStartPos().x(),'f',0).toDouble());
emit cutRectY(QString::number(getCutRectStartPos().y(),'f',0).toDouble());
emit cutRectWidth(double(int(getCutRectSize().width())));
emit cutRectHeight(double(int(getCutRectSize().height())));
}
}
void cutDialog::initAllCorner()
{
m_left = false;
m_right = false;
m_bottom = false;
m_top = false;
m_leftCorn = false;
m_rightCorn = false;
m_topCorn = false;
m_bottomCorn = false;
m_leftTop = false;
m_leftBottom = false;
m_rightTop = false;
m_rightBottom = false;
}

View File

@ -1,100 +0,0 @@
#ifndef CUTDIALOG_H
#define CUTDIALOG_H
#include <QWidget>
#include <QMouseEvent>
#include <QPainter>
#include <QCursor>
namespace Ui {
class cutDialog;
}
enum SIZETYPE{
MILLIM ,
INCH,
PIXEL
};
class cutDialog : public QWidget
{
Q_OBJECT
public:
explicit cutDialog(QWidget *parent = nullptr);
~cutDialog();
void setPaperSize(QString type = "A1", const int w = 200);
void setDpiValue(const double d);
void setSizeType(const SIZETYPE& t);
void setCutRectWidth(double w);
void setCutRectHeight(double h);
void setCutRectStartX(double x);
void setCutRectStartY(double y);
QSizeF getPaperSize()const;
QSizeF getCutRectSize()const;
QPointF getCutRectStartPos()const;
QRectF getCutRectPixel()const;
void setCutRectPixel(QRectF& rect);
int getCutRectRight()const;
int getCutRectBottom()const;
void refreshView();
signals:
void cutRectX(double x);
void cutRectY(double y);
void cutRectWidth(double w);
void cutRectHeight(double h);
void lineEditEnable(bool b);
private:
void mousePressEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void enterEvent(QEvent*);
void leaveEvent(QEvent*);
//void resizeEvent(QResizeEvent*);
void paintEvent(QPaintEvent *);
void drawScale(QPainter &painter);
void drawCutRect(QPainter &painter);
void drawTransparentColor(QPainter &painter);
void drawPaperSize();
void mousePosition(const QPoint &e);
void initAllCorner();
//void mouseChangeRect(int dx,int dy);
private:
Ui::cutDialog *ui;
QPointF m_startPoint;
QPointF m_endPoint;
QPointF m_moveStart;
QRectF m_rect;
QRectF scaleRec;
QString paperType;
double paperWidth;
double paperHeight;
int divisor;
int sizeType;
double dpi;
double h_w;
double realRate;
double sizeRate;
bool m_mouse_down;
bool m_left;
bool m_right;
bool m_bottom;
bool m_top;
bool m_leftCorn;
bool m_rightCorn;
bool m_topCorn;
bool m_bottomCorn;
bool m_leftTop;
bool m_rightTop;
bool m_leftBottom;
bool m_rightBottom;
bool m_out;
};
#endif // CUTDIALOG_H

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cutDialog</class>
<widget class="QWidget" name="cutDialog">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>321</width>
<height>342</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>2</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>2</width>
<height>0</height>
</size>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>cutDialog</string>
</property>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -1,217 +0,0 @@
#include "cutpapertool.h"
#include "ui_cutpapertool.h"
#include <QDebug>
#include <QValidator>
CutPaperTool::CutPaperTool(int d, const QString& t, int w, int unit, QWidget *parent) :
QDialog(parent),
ui(new Ui::CutPaperTool)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
connect(ui->widget,SIGNAL(cutRectX(double)),this,SLOT(cutRectXSlot(double)));
connect(ui->widget,SIGNAL(cutRectY(double)),this,SLOT(cutRectYSlot(double)));
connect(ui->widget,SIGNAL(cutRectWidth(double)),this,SLOT(cutRectWidthSlot(double)));
connect(ui->widget,SIGNAL(cutRectHeight(double)),this,SLOT(cutRectHeightSlot(double)));
connect(ui->widget,SIGNAL(lineEditEnable(bool)),this,SLOT(lineEditEnableSlot(bool)));
ui->widget->setSizeType(MILLIM);
dpi = d;
ui->dpiLab->setText(QString::number(dpi));
ui->widget->setDpiValue(dpi);
paperType = t;
ui->paperLab->setText(paperType);
ui->widget->setPaperSize(paperType, w);
setSizeLabel();
this->setFixedWidth(ui->widget->width()+40);
setSizeInit();
ui->comboBox_2->setCurrentIndex(unit);
}
CutPaperTool::~CutPaperTool()
{
delete ui;
}
void CutPaperTool::paintEvent(QPaintEvent *)
{
}
QRectF CutPaperTool::getCutRectPixel()
{
return QRectF(ui->widget->getCutRectPixel());
}
void CutPaperTool::setCutRectPixel(QRectF &rect)
{
ui->widget->setCutRectPixel(rect);
ui->startXEdt->setText(QString::number(rect.x()/dpi/0.03937));
ui->startYEdt->setText(QString::number(rect.y()/dpi/0.03937));
ui->rectWidth->setText(QString::number(rect.width()/dpi/0.03937));
ui->rectHeight->setText(QString::number(rect.height()/dpi/0.03937));
update();
setSizeLabel();
ui->widget->refreshView();
}
int CutPaperTool::getUnit()
{
return ui->comboBox_2->currentIndex();
}
void CutPaperTool::setSizeLabel()
{
QString wSize;
QString hSize;
if(ui->comboBox_2->currentIndex() == INCH){
wSize = QString::number(ui->widget->getPaperSize().width(),'f',2);
hSize = QString::number(ui->widget->getPaperSize().height(),'f',2);
}
else {
wSize = QString::number(int(ui->widget->getPaperSize().width()+0.001));
hSize = QString::number(int(ui->widget->getPaperSize().height()+0.001));
}
ui->sizeLabel->setText("("+wSize + " * " +hSize+")");
}
void CutPaperTool::setSizeInit()
{
ui->widget->setCutRectStartX(0);
ui->widget->setCutRectStartY(0);
ui->widget->setCutRectWidth(ui->widget->getPaperSize().width());
ui->widget->setCutRectHeight(ui->widget->getPaperSize().height());
ui->startXEdt->setText("0");
ui->startYEdt->setText("0");
ui->rectWidth->setText(QString::number(int(ui->widget->getPaperSize().width())));
ui->rectHeight->setText(QString::number(int(ui->widget->getPaperSize().height())));
}
void CutPaperTool::cutRectXSlot(double x)
{
ui->startXEdt->setText(QString::number(x));
}
void CutPaperTool::cutRectYSlot(double y)
{
ui->startYEdt->setText(QString::number(y));
}
void CutPaperTool::cutRectWidthSlot(double w)
{
ui->rectWidth->setText(QString::number(w));
}
void CutPaperTool::cutRectHeightSlot(double h)
{
ui->rectHeight->setText(QString::number(h));
}
void CutPaperTool::lineEditEnableSlot(bool b)
{
ui->startXEdt->setEnabled(b);
ui->startYEdt->setEnabled(b);
ui->rectWidth->setEnabled(b);
ui->rectHeight->setEnabled(b);
}
void CutPaperTool::on_startXEdt_textEdited(QString arg1)
{
double x = arg1.toDouble();
if(x >ui->widget->getCutRectRight()) {
//arg1.chop(1);
//x = arg1.toDouble();
//x = ui->widget->getCutRectRight();
return ;
}
if(type == PIXEL) x = arg1.toInt();
ui->widget->setCutRectStartX(x);
}
void CutPaperTool::on_startYEdt_textEdited(QString arg1)
{
double y = arg1.toDouble();
if(y >ui->widget->getCutRectBottom()) {
//arg1.chop(1);
//y = arg1.toDouble();
return ;
}
if(type == PIXEL) y = arg1.toInt();
ui->widget->setCutRectStartY(y);
}
void CutPaperTool::on_rectWidth_textEdited(QString arg1)
{
double v = arg1.toDouble();
if(v > ui->widget->getPaperSize().width() - ui->widget->getCutRectStartPos().x()) {
//arg1.chop(1);
//v = arg1.toDouble();
//v=ui->widget->getPaperSize().width() - ui->widget->getCutRectStartPos().x();
return ;
}
if(type == PIXEL) v = arg1.toInt();
ui->widget->setCutRectWidth(v);
}
void CutPaperTool::on_rectHeight_textEdited(QString arg1)
{
double v = arg1.toDouble();
if(v > ui->widget->getPaperSize().height() - ui->widget->getCutRectStartPos().y()) {
//arg1.chop(1);
//v = arg1.toDouble();
//v = ui->widget->getPaperSize().height() - ui->widget->getCutRectStartPos().y();
return ;
}
if(type == PIXEL) v = arg1.toInt();
ui->widget->setCutRectHeight(v);
}
void CutPaperTool::on_comboBox_2_currentIndexChanged(int index)
{
switch(index)
{
case 0:
ui->xLabel->setText("mm");
ui->yLabel->setText("mm");
ui->wLabel->setText("mm");
ui->hLabel->setText("mm");
ui->widget->setSizeType(MILLIM);
break;
case 1:
ui->xLabel->setText("in");
ui->yLabel->setText("in");
ui->wLabel->setText("in");
ui->hLabel->setText("in");
ui->widget->setSizeType(INCH);
break;
case 2:
ui->xLabel->setText("px");
ui->yLabel->setText("px");
ui->wLabel->setText("px");
ui->hLabel->setText("px");
ui->widget->setSizeType(PIXEL);
break;
}
update();
setSizeLabel();
ui->widget->refreshView();
}
void CutPaperTool::on_buttonBox_accepted()
{
accept();
}
void CutPaperTool::on_buttonBox_rejected()
{
reject();
}
void CutPaperTool::on_pbtn_init_clicked()
{
setSizeInit();
}

View File

@ -1,57 +0,0 @@
#ifndef CUTPAPERTOOL_H
#define CUTPAPERTOOL_H
#include <QDialog>
#include "cutdialog.h"
namespace Ui {
class CutPaperTool;
}
class CutPaperTool : public QDialog
{
Q_OBJECT
public:
explicit CutPaperTool(int d, const QString& t, int w, int unit, QWidget *parent = nullptr);
~CutPaperTool();
QRectF getCutRectPixel();
void setCutRectPixel(QRectF& rect);
int getUnit();
private:
void paintEvent(QPaintEvent *);
void setSizeLabel();
void setSizeInit();
private slots:
void cutRectXSlot(double x);
void cutRectYSlot(double y);
void cutRectWidthSlot(double w);
void cutRectHeightSlot(double h);
void lineEditEnableSlot(bool b);
void on_startXEdt_textEdited(QString arg1);
void on_startYEdt_textEdited(QString arg1);
void on_rectWidth_textEdited(QString arg1);
void on_rectHeight_textEdited(QString arg1);
void on_comboBox_2_currentIndexChanged(int index);
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_pbtn_init_clicked();
private:
Ui::CutPaperTool *ui;
SIZETYPE type;
int dpi;
QString paperType;
};
#endif // CUTPAPERTOOL_H

View File

@ -1,298 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CutPaperTool</class>
<widget class="QWidget" name="CutPaperTool">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>439</width>
<height>676</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>自定义扫描区域</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>纸张尺寸:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="paperLab">
<property name="text">
<string>A4</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="sizeLabel">
<property name="text">
<string>(210*297)</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>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>DPI(像素/英寸)</string>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dpiLab">
<property name="text">
<string>200</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>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>单位:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>毫米mm</string>
</property>
</item>
<item>
<property name="text">
<string>英寸in)</string>
</property>
</item>
<item>
<property name="text">
<string>像素px</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbtn_init">
<property name="text">
<string>初始化选择区域</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_4">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>421</width>
<height>430</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="cutDialog" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>x:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="startXEdt"/>
</item>
<item>
<widget class="QLabel" name="xLabel">
<property name="text">
<string>mm</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>y:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="startYEdt"/>
</item>
<item>
<widget class="QLabel" name="yLabel">
<property name="text">
<string>mm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="wLabel_2">
<property name="text">
<string>w:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="rectWidth"/>
</item>
<item>
<widget class="QLabel" name="wLabel">
<property name="text">
<string>mm</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>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>h:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="rectHeight"/>
</item>
<item>
<widget class="QLabel" name="hLabel">
<property name="text">
<string>mm</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>cutDialog</class>
<extends>QWidget</extends>
<header location="global">cutdialog.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,189 +0,0 @@
#include "device_menu.h"
#define ACTION_DEVICE_NAME_PROPERTY "device_name"
device_menu::device_menu(QWidget *parent)
: QMenu(parent)
, cur_action_(nullptr), none_action_(nullptr)
{
group_action_ = new QActionGroup(this);
deviceMenuUpdate(nullptr);
connect(group_action_, SIGNAL(triggered(QAction*)), this, SLOT(on_act_triggered(QAction*)));
}
device_menu::device_menu(const QString &title, QWidget *parent)
: QMenu(title, parent)
, cur_action_(nullptr), none_action_(nullptr)
{
group_action_ = new QActionGroup(this);
deviceMenuUpdate(nullptr);
connect(group_action_, SIGNAL(triggered(QAction*)), this, SLOT(on_act_triggered(QAction*)));
}
QMenu* device_menu::find_device_menu(const QString& dev_name)
{
std::lock_guard<std::mutex> lock(mutex_);
std::vector<POPMENU>::iterator it = std::find(menus_.begin(), menus_.end(), dev_name);
if(it == menus_.end())
return nullptr;
else
return it->menu;
}
QAction* device_menu::find_device_config(const QString& dev_name, const QString& cfg_name)
{
std::lock_guard<std::mutex> lock(mutex_);
std::vector<POPMENU>::iterator it = std::find(menus_.begin(), menus_.end(), dev_name);
if(it == menus_.end())
return NULL;
for(size_t i = 0; i < it->actions.size(); ++i)
{
if(it->actions[i]->text() == cfg_name)
return it->actions[i];
}
return NULL;
}
void device_menu::connectedDevice(const QString &device)
{
QMenu* menu = find_device_menu(device);
if (menu)
menu->setEnabled(true);
}
void device_menu::disconnectedDevice(const QString &device)
{
QMenu* menu = find_device_menu(device);
if (menu)
menu->setEnabled(false);
}
void device_menu::setOptionChecked(const QString &device, const QString &opt, bool checked)
{
QAction* act = find_device_config(device, opt);
if(act)
{
act->setChecked(checked);
if(checked)
cur_action_ = act;
else
{
if(cur_action_ == act)
cur_action_ = nullptr;
}
}
else if(checked)
cur_action_ = nullptr;
}
void device_menu::get_online_devices(QList<QString>& dev_names)
{
std::lock_guard<std::mutex> lock(mutex_);
for(size_t i = 0; i < menus_.size(); ++i)
{
if(menus_[i].menu->isEnabled())
dev_names.push_back(menus_[i].menu->title());
}
}
void device_menu::deviceMenuUpdate(dev_que* que)
{
std::lock_guard<std::mutex> lock(mutex_);
cur_action_ = nullptr;
if(none_action_)
{
removeAction(none_action_);
none_action_ = nullptr;
}
for(size_t i = 0; i < menus_.size(); ++i)
menus_[i].menu->setEnabled(false);
if (!que || que->scanners() == 0)
{
if(menus_.empty())
{
none_action_ = addAction(tr("no device"));
none_action_->setEnabled(false);
}
return;
}
for (size_t i = 0; i < que->scanners(); i++)
{
SCANNER s = que->get_at(i);
std::vector<POPMENU>::iterator it = std::find(menus_.begin(), menus_.end(), QString::fromStdString((s.name)));
POPMENU pm;
std::vector<std::string> schemes;
if(it == menus_.end())
pm.menu = addMenu(QString::fromStdString(s.name));
else
{
pm = *it;
menus_.erase(it);
}
pm.menu->setEnabled(true);
pm.menu->setToolTipsVisible(true);
for(size_t j = 0; j < pm.actions.size(); ++j)
{
pm.menu->removeAction(pm.actions[j]);
group_action_->removeAction(pm.actions[j]);
}
pm.actions.clear();
s.cfg->get_all_schemes(schemes);
for (size_t j = 0; j < schemes.size(); j++)
{
QAction *child = group_action_->addAction(QString::fromStdString(schemes[j]));
child->setProperty(ACTION_DEVICE_NAME_PROPERTY, QVariant(QString::fromStdString(s.name)));
child->setCheckable(true);
if(que->opened_scanner_name() == s.name &&
schemes[j] == s.cfg->get_current_scheme_name())
{
cur_action_ = child;
child->setChecked(true);
}
pm.menu->addAction(child);
pm.actions.push_back(child);
QString tips;
if(tips.isNull())
{
tips = tr("default setting");
}
// child->setToolTip(tips);
}
menus_.push_back(pm);
s.cfg->release();
}
}
void device_menu::on_act_triggered(QAction* act)
{
QString deviceName = act->property(ACTION_DEVICE_NAME_PROPERTY).toString();
QString opt = act->text();
bool checked_now = act->isChecked();
if(cur_action_ == act)
{
checked_now = false;
act->setChecked(false);
cur_action_ = nullptr;
// emit scanOptionsChanged("", "", false);
// return;
}
else {
cur_action_ = act;
checked_now = true;
}
emit scanOptionsChanged(deviceName, opt, checked_now);
}

Some files were not shown because too many files have changed in this diff Show More