From 5df744133f9b00d55717d27a1f8963e558607b74 Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Thu, 24 Nov 2022 17:40:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B0=83=E6=95=B4app?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BF=A1=E6=81=AF=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scanner/dialog_exportimagefile.cpp | 4 +- app/scanner/dialog_multirotateimagefile.cpp | 2 +- app/scanner/mainwindow.cpp | 56 +++++++++++++-------- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/app/scanner/dialog_exportimagefile.cpp b/app/scanner/dialog_exportimagefile.cpp index e1f0efb4..be4d793a 100644 --- a/app/scanner/dialog_exportimagefile.cpp +++ b/app/scanner/dialog_exportimagefile.cpp @@ -31,7 +31,7 @@ Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destPath, const QS ui->progressBar->setValue(0); connect(this, SIGNAL(updateProgress(int)), this, SLOT(on_updateProgress(int)), Qt::QueuedConnection); - connect(this, SIGNAL(finish()), this, SLOT(on_finish()), Qt::QueuedConnection); + connect(this, SIGNAL(finish(HGResult)), this, SLOT(on_finish(HGResult)), Qt::QueuedConnection); m_stopThread = false; HGBase_OpenThread(ThreadFunc, this, &m_thread); @@ -279,7 +279,7 @@ void Dialog_ExportImageFile::on_updateProgress(int value) void Dialog_ExportImageFile::on_finish(HGResult ret) { - QString str = (ret == HGBASE_ERR_OK) ? tr("export succeed") : MainWindow::getLogInfo(ret); + QString str = (ret == HGBASE_ERR_OK) ? tr("export succeed") : tr("export failed: ") + MainWindow::getLogInfo(ret); QMessageBox msg(QMessageBox::Information, tr("tip"), str, QMessageBox::Ok, this); msg.setButtonText(QMessageBox::Ok, tr("ok")); msg.exec(); diff --git a/app/scanner/dialog_multirotateimagefile.cpp b/app/scanner/dialog_multirotateimagefile.cpp index 88d4cd24..c6d64195 100644 --- a/app/scanner/dialog_multirotateimagefile.cpp +++ b/app/scanner/dialog_multirotateimagefile.cpp @@ -19,7 +19,7 @@ Dialog_MultiRotateImageFile::Dialog_MultiRotateImageFile(const QStringList &file connect(this, SIGNAL(updateProgress(int)), this, SLOT(on_updateProgress(int)), Qt::QueuedConnection); connect(this, SIGNAL(updateImageFile(QString)), this, SLOT(on_updateImageFile(QString)), Qt::QueuedConnection); - connect(this, SIGNAL(finish()), this, SLOT(on_finish()), Qt::QueuedConnection); + connect(this, SIGNAL(finish(HGResult)), this, SLOT(on_finish(HGResult)), Qt::QueuedConnection); m_stopThread = false; HGBase_OpenThread(ThreadFunc, this, &m_thread); diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index 69d3d51d..f91a831c 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -893,6 +893,9 @@ void MainWindow::on_new_image(void *img, int statu) if (1 == m_scanType) { QString fileName = getCacheFileName(image); + if(!judgeDiskSpace(fileName)) + return; + HGResult ret = HGImgFmt_SaveImage(image, 0, nullptr, getStdString(fileName).c_str()); if(ret == HGBASE_ERR_OK) @@ -922,8 +925,8 @@ void MainWindow::on_new_image(void *img, int statu) } else { - m_dialogLog->addLog(getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true); + m_dialogLog->addLog(tr("save image failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("save image failed: ") + getLogInfo(ret), true); } } else if (2 == m_scanType) @@ -957,8 +960,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) { - m_dialogLog->addLog(getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true); + m_dialogLog->addLog(tr("create savepath failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("create savepath failed: ") + getLogInfo(ret), true); } QString scanFileName; @@ -979,11 +982,14 @@ void MainWindow::on_new_image(void *img, int statu) } } + if(!judgeDiskSpace(scanFileName)) + return; + 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); + m_dialogLog->addLog(tr("create image doc failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("create image doc failed: ") + getLogInfo(ret), true); } if (nullptr != m_scanImgFmtWriter) @@ -1017,8 +1023,8 @@ void MainWindow::on_new_image(void *img, int statu) 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_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); } ++m_aquireIntoMultiPageCount; @@ -1073,8 +1079,8 @@ void MainWindow::on_new_image(void *img, int statu) HGResult ret = HGBase_CreateDir(getStdString(savePath).c_str()); if(ret != HGBASE_ERR_OK) { - m_dialogLog->addLog(getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true); + m_dialogLog->addLog(tr("create savepath failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("create savepath failed: ") + getLogInfo(ret), true); } QString scanFileName; @@ -1095,6 +1101,9 @@ void MainWindow::on_new_image(void *img, int statu) } } + if(!judgeDiskSpace(scanFileName)) + return; + HGImgFmtSaveInfo saveInfo; saveInfo.jpegQuality = (HGUInt)m_aquireIntoSaveParam.m_jpegQuality; saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE; @@ -1125,8 +1134,8 @@ void MainWindow::on_new_image(void *img, int statu) } else { - m_dialogLog->addLog(getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true); + m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); } } } @@ -2064,9 +2073,9 @@ void MainWindow::on_act_save_triggered() } else { - QMessageBox::critical(this, tr("tips"), getLogInfo(ret)); - m_dialogLog->addLog(getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true); + QMessageBox::critical(this, tr("tips"), tr("save image doc failed: ") + getLogInfo(ret)); + m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); } } else @@ -2130,9 +2139,9 @@ void MainWindow::on_act_save_triggered() } else { - QMessageBox::critical(this, tr("tips"), getLogInfo(ret)); - m_dialogLog->addLog(getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true); + QMessageBox::critical(this, tr("tips"), tr("save image doc failed: ") + getLogInfo(ret)); + m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); } } @@ -2212,9 +2221,9 @@ void MainWindow::on_act_saveAs_triggered() } else { - QMessageBox::critical(this, tr("tips"), getLogInfo(ret)); - m_dialogLog->addLog(getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(getLogInfo(ret), true); + QMessageBox::critical(this, tr("tips"), tr("save image doc failed: ") + getLogInfo(ret)); + m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); + m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); } } else @@ -3532,8 +3541,11 @@ bool MainWindow::judgeDiskSpace(QString currentPath) available_size = storage.bytesAvailable()/1024/1024; if(available_size < 64) { + QString info = tr("the disk space in the current path is unsufficient, please select a new path or clear the disk space in time."); + m_wndStatusBar->setDeviceStatusInfo(info, true); + m_dialogLog->addLog(info, true); HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "disk space is unsufficient!"); - QMessageBox::warning(this, tr("warning"), tr("the disk space in the current path is unsufficient, please select a new path or clear the disk space in time.")); + QMessageBox::warning(this, tr("warning"), info); return false; } return true;