调整中晶选择ocr语言类型功能流程
This commit is contained in:
parent
e90186304f
commit
8cde1641c6
|
@ -147,12 +147,17 @@ Dialog_Export::Dialog_Export(int total, const std::vector<int> &selectedIndexs,
|
|||
|
||||
ui->label_ocrType->setVisible(false);
|
||||
ui->comboBox_ocrType->setVisible(false);
|
||||
|
||||
#if defined(OEM_ZHONGJING) && defined(HG_CMP_MSC)
|
||||
ui->label_ocrType->setVisible(isOcr());
|
||||
ui->comboBox_ocrType->setVisible(isOcr());
|
||||
QStringList ocrType = { tr("English"), tr("Simplified Chinese"), tr("Traditional Chinese"), tr("Japanese"), tr("Korean") };
|
||||
ui->comboBox_ocrType->addItems(ocrType);
|
||||
ui->comboBox_ocrType->setCurrentIndex(getCfgValue("export", "ocrLanguage", 0));
|
||||
if (!getOcrPath().empty())
|
||||
{
|
||||
ui->label_ocrType->setVisible(isOcr());
|
||||
ui->comboBox_ocrType->setVisible(isOcr());
|
||||
QStringList ocrType = { tr("English"), tr("Simplified Chinese"), tr("Traditional Chinese"), tr("Japanese"), tr("Korean") };
|
||||
ui->comboBox_ocrType->addItems(ocrType);
|
||||
ui->comboBox_ocrType->setCurrentIndex(getCfgValue("export", "ocrLanguage", 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -212,6 +217,11 @@ void Dialog_Export::getSaveIndexs(std::vector<int> &indexs)
|
|||
indexs = m_saveIndexs;
|
||||
}
|
||||
|
||||
int Dialog_Export::getOcrLanguageType()
|
||||
{
|
||||
return ui->comboBox_ocrType->currentIndex();// 0-english, 1-chinese_sim, 2-chinese_tra, 3-japanese, 4-korean...
|
||||
}
|
||||
|
||||
void Dialog_Export::on_dialog_accepted()
|
||||
{
|
||||
QString extName(m_supportType[m_suffix].ext);
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
bool isOcr();
|
||||
bool isSaveAsMultiPage();
|
||||
void getSaveIndexs(std::vector<int> &indexs);
|
||||
int getOcrLanguageType();
|
||||
|
||||
private slots:
|
||||
void on_dialog_accepted();
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destPath, const QString &destName, const QString &destExt,
|
||||
bool isSaveAsMulti, int jpegQuality, int tiffCompressionBW, int tiffCompression, int tiffQuality, bool isOcr,
|
||||
const QStringList &srcFiles, QWidget *parent)
|
||||
int ocrLanguageType, const QStringList &srcFiles, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::Dialog_ExportImageFile)
|
||||
, m_destPath(destPath)
|
||||
|
@ -26,6 +26,7 @@ Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destPath, const QS
|
|||
, m_tiffCompression(tiffCompression)
|
||||
, m_tiffQuality(tiffQuality)
|
||||
, m_isOcr(isOcr)
|
||||
, m_ocrLanguageType(ocrLanguageType)
|
||||
, m_srcFiles(srcFiles)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -117,7 +118,7 @@ void HGAPI Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
|
|||
|
||||
HGImgFmt_CloseImageWriter(writer);
|
||||
|
||||
bool result = createOcrPdf(tmpFileName, getStdString(fileName).c_str(), getCfgValue("export", "ocrLanguage", 0));
|
||||
bool result = createOcrPdf(tmpFileName, getStdString(fileName).c_str(), m_ocrLanguageType);
|
||||
QFile::remove(tmpFileName);
|
||||
if (!result)
|
||||
{
|
||||
|
@ -318,7 +319,7 @@ void HGAPI Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
|
|||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
||||
}
|
||||
|
||||
ret = MainWindow::saveImage(img, &saveInfo, p->m_isOcr, getStdString(saveFileName).c_str());
|
||||
ret = MainWindow::saveImage(img, &saveInfo, p->m_isOcr, p->m_ocrLanguageType, getStdString(saveFileName).c_str());
|
||||
HGBase_DestroyImage(img);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class Dialog_ExportImageFile : public QDialog
|
|||
public:
|
||||
explicit Dialog_ExportImageFile(const QString &destPath, const QString &destName, const QString &destExt,
|
||||
bool isSaveAsMulti, int jpegQuality, int tiffCompressionBW, int tiffCompression, int tiffQuality, bool isOcr,
|
||||
const QStringList &srcFiles, QWidget *parent = nullptr);
|
||||
int ocrLanguageType, const QStringList &srcFiles, QWidget *parent = nullptr);
|
||||
~Dialog_ExportImageFile();
|
||||
|
||||
private:
|
||||
|
@ -45,6 +45,7 @@ private:
|
|||
int m_tiffCompression;
|
||||
int m_tiffQuality;
|
||||
bool m_isOcr;
|
||||
int m_ocrLanguageType;
|
||||
QStringList m_srcFiles;
|
||||
|
||||
bool m_stopThread;
|
||||
|
|
|
@ -112,11 +112,15 @@ Dialog_SaveAs::Dialog_SaveAs(QWidget *parent) :
|
|||
ui->comboBox_ocrType->setVisible(false);
|
||||
|
||||
#if defined(OEM_ZHONGJING) && defined(HG_CMP_MSC)
|
||||
ui->label_ocrType->setVisible(isOcr());
|
||||
ui->comboBox_ocrType->setVisible(isOcr());
|
||||
QStringList ocrType = { tr("English"), tr("Simplified Chinese"), tr("Traditional Chinese"), tr("Japanese"), tr("Korean") };
|
||||
ui->comboBox_ocrType->addItems(ocrType);
|
||||
ui->comboBox_ocrType->setCurrentIndex(getCfgValue("saveAs", "ocrLanguage", 0));
|
||||
if (!getOcrPath().empty())
|
||||
{
|
||||
ui->label_ocrType->setVisible(isOcr());
|
||||
ui->comboBox_ocrType->setVisible(isOcr());
|
||||
QStringList ocrType = { tr("English"), tr("Simplified Chinese"), tr("Traditional Chinese"), tr("Japanese"), tr("Korean") };
|
||||
ui->comboBox_ocrType->addItems(ocrType);
|
||||
ui->comboBox_ocrType->setCurrentIndex(getCfgValue("saveAs", "ocrLanguage", 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -160,6 +164,11 @@ bool Dialog_SaveAs::isOcr()
|
|||
return (m_suffix >= 10);
|
||||
}
|
||||
|
||||
int Dialog_SaveAs::getOcrLanguageType()
|
||||
{
|
||||
return ui->comboBox_ocrType->currentIndex();// 0-english, 1-chinese_sim, 2-chinese_tra, 3-japanese, 4-korean...
|
||||
}
|
||||
|
||||
void Dialog_SaveAs::on_dialog_accepted()
|
||||
{
|
||||
QString extName;
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
int getTiffCompression();
|
||||
int getTiffQuality();
|
||||
bool isOcr();
|
||||
int getOcrLanguageType();
|
||||
|
||||
private slots:
|
||||
void on_dialog_accepted();
|
||||
|
|
|
@ -422,7 +422,7 @@ void MainWindow::exitFullScreen()
|
|||
m_dlgFullScreen = nullptr;
|
||||
}
|
||||
|
||||
HGResult MainWindow::saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool ocr, const HGChar *fileName)
|
||||
HGResult MainWindow::saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool ocr, int ocrLanguageType, const HGChar *fileName)
|
||||
{
|
||||
if (!ocr)
|
||||
{
|
||||
|
@ -435,7 +435,7 @@ HGResult MainWindow::saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool
|
|||
HGChar tmpFileName[256];
|
||||
HGBase_GetTmpFileName("bmp", tmpFileName, 256);
|
||||
ret = HGImgFmt_SaveImage(image, 0, info, tmpFileName);
|
||||
bool result = createOcrPdf(tmpFileName, fileName, getCfgValue("saveAs", "ocrLanguage", 0));
|
||||
bool result = createOcrPdf(tmpFileName, fileName, ocrLanguageType);
|
||||
QFile::remove(tmpFileName);
|
||||
return (result) ? HGBASE_ERR_OK : HGIMGPROC_ERR_OCR;
|
||||
#else
|
||||
|
@ -1230,7 +1230,7 @@ void MainWindow::on_new_image(void *img, int statu)
|
|||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
||||
}
|
||||
|
||||
ret = saveImage(image, &saveInfo, m_aquireIntoSaveParam.m_isOcr, getStdString(scanFileName).c_str());
|
||||
ret = saveImage(image, &saveInfo, m_aquireIntoSaveParam.m_isOcr, 0, getStdString(scanFileName).c_str());
|
||||
if(ret == HGBASE_ERR_OK)
|
||||
{
|
||||
m_thumb->addItem(scanFileName);
|
||||
|
@ -2060,6 +2060,7 @@ void MainWindow::on_act_save_triggered()
|
|||
int tiffCompression = auto_save_info_.tiffCompression;
|
||||
int tiffQuality = auto_save_info_.tiffQuality;
|
||||
bool isOcr = auto_save_info_.isOcr;
|
||||
int ocrLanguageType = 0;
|
||||
bool find = false;
|
||||
int count = 0;
|
||||
|
||||
|
@ -2099,6 +2100,7 @@ void MainWindow::on_act_save_triggered()
|
|||
tiffQuality = auto_save_info_.tiffQuality = dlg.getTiffQuality();
|
||||
tiffCompression = auto_save_info_.tiffCompression = dlg.getTiffCompression();
|
||||
tiffCompressionBW = auto_save_info_.tiffCompressionBW = dlg.getTiffCompressionBW();
|
||||
ocrLanguageType = dlg.getOcrLanguageType();
|
||||
}
|
||||
if(auto_save_changes_ && save_from_changed_)
|
||||
{
|
||||
|
@ -2156,7 +2158,7 @@ void MainWindow::on_act_save_triggered()
|
|||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
||||
}
|
||||
|
||||
ret = saveImage(img, &saveInfo, isOcr, getStdString(savePath).c_str());
|
||||
ret = saveImage(img, &saveInfo, isOcr, ocrLanguageType, getStdString(savePath).c_str());
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
if (auto_save_changes_)
|
||||
|
@ -2289,6 +2291,7 @@ void MainWindow::on_act_saveAs_triggered()
|
|||
int tiffCompression = dlg.getTiffCompression();
|
||||
int tiffQuality = dlg.getTiffQuality();
|
||||
bool isOcr = dlg.isOcr();
|
||||
int ocrLanguageType = dlg.getOcrLanguageType();
|
||||
|
||||
HGImgFmtSaveInfo saveInfo;
|
||||
saveInfo.jpegQuality = (HGUInt)jpegQuality;
|
||||
|
@ -2312,7 +2315,7 @@ void MainWindow::on_act_saveAs_triggered()
|
|||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
||||
}
|
||||
|
||||
HGResult ret = saveImage(img, &saveInfo, isOcr, getStdString(savePath).c_str());
|
||||
HGResult ret = saveImage(img, &saveInfo, isOcr, ocrLanguageType, getStdString(savePath).c_str());
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
if(!auto_save_changes_)
|
||||
|
@ -2388,9 +2391,10 @@ void MainWindow::on_act_Export_triggered()
|
|||
int tiffCompression = dlg.getTiffCompression();
|
||||
int tiffQuality = dlg.getTiffQuality();
|
||||
bool isOcr = dlg.isOcr();
|
||||
int ocrLanguageType = dlg.getOcrLanguageType();
|
||||
|
||||
Dialog_ExportImageFile dlgExport(savePath, saveName, saveExt, isSaveAsMulti, jpegQuality,
|
||||
tiffCompressionBW, tiffCompression, tiffQuality, isOcr, srcFiles, this);
|
||||
tiffCompressionBW, tiffCompression, tiffQuality, isOcr, ocrLanguageType, srcFiles, this);
|
||||
dlgExport.exec();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
virtual ~MainWindow() override;
|
||||
|
||||
void exitFullScreen();
|
||||
static HGResult saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool ocr, const HGChar *fileName);
|
||||
static HGResult saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool ocr, int ocrLanguageType, const HGChar *fileName);
|
||||
static QString getLogInfo(HGResult ret);
|
||||
|
||||
private slots:
|
||||
|
|
Loading…
Reference in New Issue