调整日志

This commit is contained in:
yangjiaxuan 2022-11-24 17:02:26 +08:00
parent 0cf9a6e990
commit f3c24c7d06
10 changed files with 463 additions and 368 deletions

View File

@ -411,11 +411,7 @@ void MainWindow::on_btnDownloadUpgrade_clicked()
HGChar savePath[512];
HGBase_GetConfigPath(savePath, 512);
HGResult ret = HGBase_CreateDir(savePath);
if(ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "create DownloadUpgrade dir failed,%s", savePath);
}
HGBase_CreateDir(savePath);
HGChar fileName[128];
sprintf(fileName, "%s.%s", versionNum.toStdString().c_str(), suffix);
strcat(savePath, fileName);
@ -521,11 +517,7 @@ void MainWindow::on_btnModifyPassword_clicked()
{
HGChar cfgPath[256]= {0};
HGBase_GetConfigPath(cfgPath, 256);
HGResult ret = HGBase_CreateDir(cfgPath);
if(ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "while modifying password, create config path failed, %s", cfgPath);
}
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "config.ini");
HGChar str[256] = {0};
HGBase_GetProfileString(cfgPath, "login", "password", "", str, 256);

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -52,6 +52,7 @@ void HGAPI Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
{
(void)thread;
Dialog_ExportImageFile *p = (Dialog_ExportImageFile *)param;
HGResult ret = HGBASE_ERR_FAIL;
if (p->m_isSaveAsMulti)
{
@ -60,8 +61,8 @@ void HGAPI Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
if (p->m_isOcr)
{
HGOCRMgr ocrMgr = nullptr;
HGImgProc_CreateOCRMgr(0, &ocrMgr);
if (nullptr != ocrMgr)
ret = HGImgProc_CreateOCRMgr(0, &ocrMgr);
if (HGBASE_ERR_OK == ret)
{
for (int i = 0; i < p->m_srcFiles.size(); ++i)
{
@ -89,28 +90,36 @@ void HGAPI Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
HGImgFmt_LoadImageFromReader(imgFmtReader, j, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
if (nullptr != img)
{
HGImgProc_AddToImageOCRList(ocrMgr, img);
ret = HGImgProc_AddToImageOCRList(ocrMgr, img);
HGBase_DestroyImage(img);
if (ret != HGBASE_ERR_OK)
{
break;
}
}
}
HGImgFmt_CloseImageReader(imgFmtReader);
}
if (ret != HGBASE_ERR_OK)
break;
}
HGResult ret = HGImgProc_ImageListOCRToFile(ocrMgr, 0, getStdString(fileName).c_str(), NULL, NULL);
if(ret != HGBASE_ERR_OK)
if (ret == HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "HGImgProc_ImageListOCRToFile:%u", ret);
ret = HGImgProc_ImageListOCRToFile(ocrMgr, 0, getStdString(fileName).c_str(), NULL, NULL);
}
HGImgProc_DestroyOCRMgr(ocrMgr);
}
}
else
{
HGImgFmtWriter imgFmtWriter = nullptr;
HGImgFmt_OpenImageWriter(getStdString(fileName).c_str(), 0, &imgFmtWriter);
if (nullptr != imgFmtWriter)
ret = HGImgFmt_OpenImageWriter(getStdString(fileName).c_str(), 0, &imgFmtWriter);
if (HGBASE_ERR_OK == ret)
{
for (int i = 0; i < p->m_srcFiles.size(); ++i)
{
@ -160,13 +169,21 @@ void HGAPI Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
}
HGImgFmt_SaveImageToWriter(imgFmtWriter, img, &saveInfo);
ret = HGImgFmt_SaveImageToWriter(imgFmtWriter, img, &saveInfo);
HGBase_DestroyImage(img);
if (ret != HGBASE_ERR_OK)
{
break;
}
}
}
HGImgFmt_CloseImageReader(imgFmtReader);
}
if (ret != HGBASE_ERR_OK)
break;
}
HGImgFmt_CloseImageWriter(imgFmtWriter);
@ -236,17 +253,23 @@ void HGAPI Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
}
MainWindow::saveImage(img, &saveInfo, p->m_isOcr, getStdString(saveFileName).c_str());
ret = MainWindow::saveImage(img, &saveInfo, p->m_isOcr, getStdString(saveFileName).c_str());
HGBase_DestroyImage(img);
if (ret != HGBASE_ERR_OK)
break;
}
}
HGImgFmt_CloseImageReader(imgFmtReader);
if (ret != HGBASE_ERR_OK)
break;
}
}
}
emit p->finish();
emit p->finish(ret);
}
void Dialog_ExportImageFile::on_updateProgress(int value)
@ -254,12 +277,13 @@ void Dialog_ExportImageFile::on_updateProgress(int value)
ui->progressBar->setValue(value);
}
void Dialog_ExportImageFile::on_finish()
void Dialog_ExportImageFile::on_finish(HGResult ret)
{
QMessageBox msg(QMessageBox::Information, tr("tip"), tr("export succeed"), QMessageBox::Ok, this);
QString str = (ret == HGBASE_ERR_OK) ? tr("export succeed") : MainWindow::getLogInfo(ret);
QMessageBox msg(QMessageBox::Information, tr("tip"), str, QMessageBox::Ok, this);
msg.setButtonText(QMessageBox::Ok, tr("ok"));
close();
msg.exec();
close();
}
void Dialog_ExportImageFile::on_pushButton_clicked()

View File

@ -23,10 +23,10 @@ private:
signals:
void updateProgress(int value);
void finish();
void finish(HGResult ret);
private slots:
void on_updateProgress(int value);
void on_finish();
void on_finish(HGResult ret);
void on_pushButton_clicked();

View File

@ -2,6 +2,8 @@
#include "ui_dialog_multirotateimagefile.h"
#include "imgfmt/HGImgFmt.h"
#include "HGUIGlobal.h"
#include "mainwindow.h"
#include <QMessageBox>
Dialog_MultiRotateImageFile::Dialog_MultiRotateImageFile(const QStringList &fileList, int rotateType, QWidget *parent) :
QDialog(parent),
@ -38,6 +40,7 @@ void HGAPI Dialog_MultiRotateImageFile::ThreadFunc(HGThread thread, HGPointer pa
{
(void)thread;
Dialog_MultiRotateImageFile *p = (Dialog_MultiRotateImageFile *)param;
HGResult ret = HGBASE_ERR_FAIL;
for (int i = 0; i < (int)p->m_fileList.count(); ++i)
{
@ -102,16 +105,22 @@ void HGAPI Dialog_MultiRotateImageFile::ThreadFunc(HGThread thread, HGPointer pa
if (nullptr != img)
{
if (HGBASE_ERR_OK == HGImgFmt_SaveImage(img, 0, nullptr, getStdString(p->m_fileList[i]).c_str()))
ret = HGImgFmt_SaveImage(img, 0, nullptr, getStdString(p->m_fileList[i]).c_str());
if (HGBASE_ERR_OK == ret)
{
emit p->updateImageFile(p->m_fileList[i]);
}
HGBase_DestroyImage(img);
}
if (ret != HGBASE_ERR_OK)
{
break;
}
}
emit p->finish();
emit p->finish(ret);
}
void Dialog_MultiRotateImageFile::on_updateProgress(int value)
@ -124,8 +133,12 @@ void Dialog_MultiRotateImageFile::on_updateImageFile(QString fileName)
emit refreshImageFile(fileName);
}
void Dialog_MultiRotateImageFile::on_finish()
void Dialog_MultiRotateImageFile::on_finish(HGResult ret)
{
QString str = (ret == HGBASE_ERR_OK) ? tr("operation success") : MainWindow::getLogInfo(ret);
QMessageBox msg(QMessageBox::Information, tr("tip"), str, QMessageBox::Ok, this);
msg.setButtonText(QMessageBox::Ok, tr("ok"));
msg.exec();
close();
}

View File

@ -25,11 +25,11 @@ private:
signals:
void updateProgress(int value);
void updateImageFile(QString fileName);
void finish();
void finish(HGResult ret);
private slots:
void on_updateProgress(int value);
void on_updateImageFile(QString fileName);
void on_finish();
void on_finish(HGResult ret);
void on_pushButton_clicked();

View File

@ -378,14 +378,10 @@ HGResult MainWindow::saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool
HGResult ret = HGBASE_ERR_FAIL;
// 韫囩晫鏆恑nfo
HGOCRMgr ocrMgr = nullptr;
HGImgProc_CreateOCRMgr(0, &ocrMgr);
if (nullptr != ocrMgr)
ret = HGImgProc_CreateOCRMgr(0, &ocrMgr);
if (HGBASE_ERR_OK == ret)
{
ret = HGImgProc_ImageOCRToFile(ocrMgr, image, 0, fileName);
if (ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "HGImgProc_ImageOCRToFile:%u", ret);
}
HGImgProc_DestroyOCRMgr(ocrMgr);
}
@ -926,8 +922,8 @@ void MainWindow::on_new_image(void *img, int statu)
}
else
{
m_dialogLog->addLog(tr("save failed"), true);
m_wndStatusBar->setDeviceStatusInfo(tr("save failed"), true);
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
}
else if (2 == m_scanType)
@ -961,7 +957,8 @@ void MainWindow::on_new_image(void *img, int statu)
HGResult ret = HGBase_CreateDir(getStdString(m_aquireIntoSaveParam.m_savePath).c_str());
if (ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "create aquireInto path failed, %s", getStdString(m_aquireIntoSaveParam.m_savePath).c_str());
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
QString scanFileName;
@ -982,7 +979,13 @@ void MainWindow::on_new_image(void *img, int statu)
}
}
HGImgFmt_OpenImageWriter(getStdString(getStdFileName(scanFileName)).c_str(), 0, &m_scanImgFmtWriter);
ret = HGImgFmt_OpenImageWriter(getStdString(getStdFileName(scanFileName)).c_str(), 0, &m_scanImgFmtWriter);
if(ret != HGBASE_ERR_OK)
{
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
if (nullptr != m_scanImgFmtWriter)
m_scanFileName = scanFileName;
}
@ -1011,7 +1014,13 @@ void MainWindow::on_new_image(void *img, int statu)
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
}
HGImgFmt_SaveImageToWriter(m_scanImgFmtWriter, image, &saveInfo);
HGResult ret = HGImgFmt_SaveImageToWriter(m_scanImgFmtWriter, image, &saveInfo);
if(ret != HGBASE_ERR_OK)
{
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
++m_aquireIntoMultiPageCount;
}
}
@ -1061,10 +1070,11 @@ void MainWindow::on_new_image(void *img, int statu)
savePath = getStdFileName(savePath + colorModeName + "/");
}
HGResult result = HGBase_CreateDir(getStdString(savePath).c_str());
if (result != HGBASE_ERR_OK)
HGResult ret = HGBase_CreateDir(getStdString(savePath).c_str());
if(ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "HGBase_CreateDir:%u file:%s line:%d", result, __FILE__, __LINE__);
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
QString scanFileName;
@ -1107,12 +1117,17 @@ void MainWindow::on_new_image(void *img, int statu)
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
}
HGResult ret = saveImage(image, &saveInfo, m_aquireIntoSaveParam.m_isOcr, getStdString(scanFileName).c_str());
ret = saveImage(image, &saveInfo, m_aquireIntoSaveParam.m_isOcr, getStdString(scanFileName).c_str());
if(ret == HGBASE_ERR_OK)
{
m_thumb->addItem(scanFileName);
++m_aquireIntoSaveParam.m_fileNameStartIndex;
}
else
{
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
}
}
@ -1394,11 +1409,7 @@ QString MainWindow::getCacheFileName(HGImage img)
HGBase_GetImageInfo(img, &imgInfo);
QString cachePath = Dialog_ClrCache::getCachePath();
HGResult ret = HGBase_CreateDir(getStdString(cachePath).c_str());
if(ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "create cache file failed, %s", getStdString(cachePath).c_str());
}
HGBase_CreateDir(getStdString(cachePath).c_str());
char uuid[256] = {0};
HGBase_GetUuid(uuid, 256);
@ -1916,6 +1927,7 @@ void MainWindow::on_act_exit_triggered()
void MainWindow::on_act_save_triggered()
{
HGResult ret = HGBASE_ERR_FAIL;
HGImage img = nullptr;
m_view->getImage(&img);
if (nullptr == img || -1 == m_currIndex || 1 != m_multiPageCount)
@ -2033,7 +2045,8 @@ void MainWindow::on_act_save_triggered()
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
}
if (HGBASE_ERR_OK == saveImage(img, &saveInfo, isOcr, getStdString(savePath).c_str()))
ret = saveImage(img, &saveInfo, isOcr, getStdString(savePath).c_str());
if (HGBASE_ERR_OK == ret)
{
if (auto_save_changes_)
{
@ -2051,9 +2064,9 @@ void MainWindow::on_act_save_triggered()
}
else
{
QMessageBox::critical(this, tr("tips"), tr("save failed"));
m_dialogLog->addLog(tr("save failed"), true);
m_wndStatusBar->setDeviceStatusInfo(tr("save failed"), true);
QMessageBox::critical(this, tr("tips"), getLogInfo(ret));
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
}
else
@ -2091,8 +2104,8 @@ void MainWindow::on_act_save_triggered()
tiffInfo.yResolution = yDpi;
HGTiffWriter tiffWriter = nullptr;
HGImgFmt_OpenTiffWriter(getStdString(m_currFilePath).c_str(), &tiffWriter);
if (nullptr != tiffWriter)
saveRet = HGImgFmt_OpenTiffWriter(getStdString(m_currFilePath).c_str(), &tiffWriter);
if (HGBASE_ERR_OK == saveRet)
{
saveRet = HGImgFmt_SaveImageToTiffWriter(tiffWriter, img, &tiffInfo);
HGImgFmt_CloseTiffWriter(tiffWriter);
@ -2117,7 +2130,9 @@ void MainWindow::on_act_save_triggered()
}
else
{
QMessageBox::critical(this, tr("tips"), tr("save failed"));
QMessageBox::critical(this, tr("tips"), getLogInfo(ret));
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
}
@ -2187,7 +2202,8 @@ void MainWindow::on_act_saveAs_triggered()
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
}
if (HGBASE_ERR_OK == saveImage(img, &saveInfo, isOcr, getStdString(savePath).c_str()))
HGResult ret = saveImage(img, &saveInfo, isOcr, getStdString(savePath).c_str());
if (HGBASE_ERR_OK == ret)
{
if(!auto_save_changes_)
{
@ -2196,9 +2212,9 @@ void MainWindow::on_act_saveAs_triggered()
}
else
{
QMessageBox::critical(this, tr("tips"), tr("save failed"));
m_dialogLog->addLog(tr("save failed"), true);
m_wndStatusBar->setDeviceStatusInfo(tr("save failed"), true);
QMessageBox::critical(this, tr("tips"), getLogInfo(ret));
m_dialogLog->addLog(getLogInfo(ret), true);
m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true);
}
}
else
@ -2556,11 +2572,7 @@ void HGAPI MainWindow::FwUpgradeAndDevLockThread(HGThread thread, HGPointer para
HGChar savePath[512];
HGBase_GetConfigPath(savePath, 512);
HGResult ret = HGBase_CreateDir(savePath);
if(ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "create fwUpgrade file failed, %s", savePath);
}
HGBase_CreateDir(savePath);
HGChar fileName[128];
sprintf(fileName, "%s.%s", versionInfo[0].version, suffix);
strcat(savePath, fileName);
@ -3670,29 +3682,23 @@ bool MainWindow::isLimitAccessFolder(QString filePath)
HGChar procName[512];
HGBase_GetProcessName(procName, 512);
strcat(documentsPath, procName);
HGResult ret = HGBase_CreateDir(getStdString(documentsPath).c_str());
if (ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "Mainwindow::isLimitAccessFolder(), create documentsPath1 file failed, %s", getStdString(documentsPath).c_str());
}
HGBase_CreateDir(getStdString(documentsPath).c_str());
HGChar uuid[512];
HGBase_GetUuid(uuid, 512);
strcat(documentsPath, "/");
strcat(documentsPath, uuid);
HGResult result = HGBase_CreateDir(getStdString(documentsPath).c_str());
if(result != HGBASE_ERR_OK)
HGResult ret = HGBase_CreateDir(getStdString(documentsPath).c_str());
if(ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "Mainwindow::isLimitAccessFolder(), create documentsPath2 file failed, %s", getStdString(documentsPath).c_str());
if(!filePath.isEmpty())
{
HGChar uuid2[512];
HGBase_GetUuid(uuid2, 512);
filePath += uuid2;
HGResult result2 = HGBase_CreateDir(getStdString(filePath).c_str());
if (result2 != HGBASE_ERR_OK)
ret = HGBase_CreateDir(getStdString(filePath).c_str());
if (ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "Mainwindow::isLimitAccessFolder(), create scanPath3 file failed, %s", getStdString(filePath).c_str());
QMessageBox::critical(this, tr("error"), tr("folder limit"));
m_dialogLog->addLog(tr("folder limit"), true);
m_wndStatusBar->setDeviceStatusInfo(tr("folder limit"), true);
@ -3824,6 +3830,21 @@ void MainWindow::upgradeFwAndLockDevice()
}
}
QString MainWindow::getLogInfo(HGResult ret)
{
QString str;
if (HGBASE_ERR_ACCESSDENIED == ret)
{
str = tr("Insufficient access rights");
}
else if (HGIMGPROC_ERR_FAIL == ret)
{
str = tr("Image processing failed");
}
return str;
}
//void MainWindow::deleteFile(QString filePath)
//{
// QDir dir(filePath);
@ -3962,11 +3983,7 @@ void MainWindow::on_actionact_update_triggered()
HGChar savePath[512];
HGBase_GetConfigPath(savePath, 512);
HGResult ret = HGBase_CreateDir(savePath);
if(ret != HGBASE_ERR_OK)
{
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "create upgrade app savefile failed, %s", savePath);
}
HGBase_CreateDir(savePath);
HGChar fileName[128];
sprintf(fileName, "%s.%s", versionNum.toStdString().c_str(), suffix);

View File

@ -83,6 +83,7 @@ public:
void exitFullScreen();
static HGResult saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool ocr, const HGChar *fileName);
static QString getLogInfo(HGResult ret);
private slots:
void on_act_90Left_triggered();

View File

@ -1051,6 +1051,18 @@ This operation will NOT rotate the files that may contain multiple pages, such a
<source>stop</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>operation success</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>tip</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ok</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Dialog_OpenImageIndex</name>
@ -1727,10 +1739,6 @@ Do you want to clear?</source>
<source>Insert images</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>save failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>find savePath in thumbnail</source>
<translation type="unfinished"></translation>
@ -2089,6 +2097,14 @@ Are you sure to close?</source>
<source>CumtennScan</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Insufficient access rights</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Image processing failed</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Phonon::</name>
@ -8356,10 +8372,6 @@ No: add new configuration</source>
<source>线</source>
<translation type="unfinished"></translation>
</message>
<message>
<source></source>
<translation type="unfinished"></translation>
</message>
<message>
<source>RGB</source>
<translation type="unfinished"></translation>
@ -8408,5 +8420,9 @@ No: add new configuration</source>
<source></source>
<translation type="unfinished"></translation>
</message>
<message>
<source></source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>