From a0b6220cfefe7da1835a9e717fee82f5bd6e2935 Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Wed, 24 Apr 2024 11:57:56 +0800 Subject: [PATCH] =?UTF-8?q?scantool=E9=9B=86=E6=88=90=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E5=88=B0=E8=AE=BE=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scantool/HGUIGlobal.cpp | 20 ++ app/scantool/HGUIGlobal.h | 10 + app/scantool/app_cfg.cpp | 70 +++++ app/scantool/app_cfg.h | 14 + app/scantool/dialog_add.cpp | 31 +- app/scantool/dialog_add.h | 6 +- app/scantool/dialog_add.ui | 209 +++++++------- app/scantool/dialog_aquireinto.cpp | 27 -- app/scantool/dialog_aquireinto.h | 46 --- app/scantool/dialog_aquireinto.ui | 68 ----- app/scantool/dialog_button.ui | 96 +++---- app/scantool/dialog_param.cpp | 21 -- app/scantool/dialog_param.h | 32 --- app/scantool/dialog_param.ui | 68 ----- app/scantool/dialog_scan.ui | 102 +++++-- app/scantool/dialog_writesettings.cpp | 73 +++++ app/scantool/dialog_writesettings.h | 42 +++ app/scantool/dialog_writesettings.ui | 335 ++++++++++++++++++++++ app/scantool/form_deviceconfig.cpp | 29 ++ app/scantool/form_deviceconfig.h | 33 +++ app/scantool/form_deviceconfig.ui | 21 ++ app/scantool/form_saveparam.cpp | 276 ++++++++++++++++++ app/scantool/form_saveparam.h | 70 +++++ app/scantool/form_saveparam.ui | 395 ++++++++++++++++++++++++++ build2/qt/HGScanTool/HGScanTool.pro | 28 +- 25 files changed, 1662 insertions(+), 460 deletions(-) create mode 100644 app/scantool/HGUIGlobal.cpp create mode 100644 app/scantool/HGUIGlobal.h create mode 100644 app/scantool/app_cfg.cpp create mode 100644 app/scantool/app_cfg.h delete mode 100644 app/scantool/dialog_aquireinto.cpp delete mode 100644 app/scantool/dialog_aquireinto.h delete mode 100644 app/scantool/dialog_aquireinto.ui delete mode 100644 app/scantool/dialog_param.cpp delete mode 100644 app/scantool/dialog_param.h delete mode 100644 app/scantool/dialog_param.ui create mode 100644 app/scantool/dialog_writesettings.cpp create mode 100644 app/scantool/dialog_writesettings.h create mode 100644 app/scantool/dialog_writesettings.ui create mode 100644 app/scantool/form_deviceconfig.cpp create mode 100644 app/scantool/form_deviceconfig.h create mode 100644 app/scantool/form_deviceconfig.ui create mode 100644 app/scantool/form_saveparam.cpp create mode 100644 app/scantool/form_saveparam.h create mode 100644 app/scantool/form_saveparam.ui diff --git a/app/scantool/HGUIGlobal.cpp b/app/scantool/HGUIGlobal.cpp new file mode 100644 index 00000000..fd3dbbf1 --- /dev/null +++ b/app/scantool/HGUIGlobal.cpp @@ -0,0 +1,20 @@ +#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 +} diff --git a/app/scantool/HGUIGlobal.h b/app/scantool/HGUIGlobal.h new file mode 100644 index 00000000..d1da4d16 --- /dev/null +++ b/app/scantool/HGUIGlobal.h @@ -0,0 +1,10 @@ +#ifndef __HGUIGLOBAL_H__ +#define __HGUIGLOBAL_H__ + +#include + +QString getStdFileName(const QString &fileName); + +std::string getStdString(const QString &str); + +#endif /* __HGUIGLOBAL_H__ */ diff --git a/app/scantool/app_cfg.cpp b/app/scantool/app_cfg.cpp new file mode 100644 index 00000000..10b4d3cd --- /dev/null +++ b/app/scantool/app_cfg.cpp @@ -0,0 +1,70 @@ +#include "app_cfg.h" +#include "base/HGDef.h" +#include "base/HGInc.h" +#include "base/HGUtility.h" +#include "base/HGIni.h" +#include "HGUIGlobal.h" +#include "HGString.h" + +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); +} diff --git a/app/scantool/app_cfg.h b/app/scantool/app_cfg.h new file mode 100644 index 00000000..0b5d1228 --- /dev/null +++ b/app/scantool/app_cfg.h @@ -0,0 +1,14 @@ +#ifndef __APP_CFG_H__ +#define __APP_CFG_H__ + +#include + +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); + +#endif /* __APP_CFG_H__ */ diff --git a/app/scantool/dialog_add.cpp b/app/scantool/dialog_add.cpp index 1ac1606f..f75d831c 100644 --- a/app/scantool/dialog_add.cpp +++ b/app/scantool/dialog_add.cpp @@ -25,7 +25,13 @@ Dialog_Add::Dialog_Add(class Dialog_Button *btnDlg) m_scanParam.deviceType = DeviceType(ui->comboBoxDeviceType->currentIndex() + 1); m_scanParam.buttonType = ButtonType(ui->comboBoxButtonType->currentIndex() + 1); m_scanParam.deviceConfig.clear(); - m_scanParam.saveParam = Dialog_AquireInto::GetDefSaveParam(); + m_scanParam.saveParam = Form_SaveParam::GetDefSaveParam(); + + m_formDeviceConfig = new Form_DeviceConfig(m_scanParam.deviceType, m_scanParam.deviceConfig, this); + m_formSaveParam = new Form_SaveParam(m_scanParam.saveParam, this); + ui->stackedWidget->addWidget(m_formDeviceConfig); + ui->stackedWidget->addWidget(m_formSaveParam); + ui->stackedWidget->setCurrentIndex(0); } Dialog_Add::Dialog_Add(class Dialog_Button *btnDlg, const ScanParam &scanParam, int index) @@ -50,10 +56,18 @@ Dialog_Add::Dialog_Add(class Dialog_Button *btnDlg, const ScanParam &scanParam, m_scanParam = scanParam; ui->comboBoxDeviceType->setCurrentIndex(m_scanParam.deviceType - 1); ui->comboBoxButtonType->setCurrentIndex(m_scanParam.buttonType - 1); + + m_formDeviceConfig = new Form_DeviceConfig(m_scanParam.deviceType, m_scanParam.deviceConfig, this); + m_formSaveParam = new Form_SaveParam(m_scanParam.saveParam, this); + ui->stackedWidget->addWidget(m_formDeviceConfig); + ui->stackedWidget->addWidget(m_formSaveParam); + ui->stackedWidget->setCurrentIndex(0); } Dialog_Add::~Dialog_Add() { + delete m_formSaveParam; + delete m_formDeviceConfig; delete ui; } @@ -64,26 +78,19 @@ ScanParam Dialog_Add::GetScanParam() void Dialog_Add::on_pushButtonDeviceConfig_clicked() { - Dialog_Param dlg(m_scanParam.deviceType, m_scanParam.deviceConfig, this); - if (dlg.exec()) - { - m_scanParam.deviceConfig = dlg.GetDeviceConfig(); - } + ui->stackedWidget->setCurrentIndex(0); } void Dialog_Add::on_pushButtonSaveParam_clicked() { - Dialog_AquireInto dlg(m_scanParam.saveParam, this); - if (dlg.exec()) - { - m_scanParam.saveParam = dlg.GetSaveParam(); - } + ui->stackedWidget->setCurrentIndex(1); } void Dialog_Add::on_comboBoxDeviceType_currentIndexChanged(int index) { m_scanParam.deviceType = DeviceType(index + 1); m_scanParam.deviceConfig.clear(); + m_formDeviceConfig->Update(m_scanParam.deviceType, m_scanParam.deviceConfig); } void Dialog_Add::on_comboBoxButtonType_currentIndexChanged(int index) @@ -99,6 +106,8 @@ void Dialog_Add::on_pushButtonOK_clicked() return; } + m_scanParam.deviceConfig = m_formDeviceConfig->GetDeviceConfig(); + m_scanParam.saveParam = m_formSaveParam->GetSaveParam(); accept(); } diff --git a/app/scantool/dialog_add.h b/app/scantool/dialog_add.h index e07ed796..89e8eaad 100644 --- a/app/scantool/dialog_add.h +++ b/app/scantool/dialog_add.h @@ -2,8 +2,8 @@ #define DIALOG_ADD_H #include -#include "dialog_param.h" -#include "dialog_aquireinto.h" +#include "form_deviceconfig.h" +#include "form_saveparam.h" namespace Ui { class Dialog_Add; @@ -53,6 +53,8 @@ private: class Dialog_Button *m_btnDlg; ScanParam m_scanParam; int m_index; + Form_DeviceConfig *m_formDeviceConfig; + Form_SaveParam *m_formSaveParam; }; #endif // DIALOG_ADD_H diff --git a/app/scantool/dialog_add.ui b/app/scantool/dialog_add.ui index b804e32f..085e2da4 100644 --- a/app/scantool/dialog_add.ui +++ b/app/scantool/dialog_add.ui @@ -6,111 +6,120 @@ 0 0 - 411 - 310 + 752 + 492 Dialog - - - - 80 - 110 - 81 - 21 - - - - 扫描按钮: - - - - - - 80 - 70 - 81 - 21 - - - - 设备类型: - - - - - - 160 - 70 - 171 - 22 - - - - - - - 160 - 110 - 171 - 22 - - - - - - - 80 - 160 - 111 - 31 - - - - 设备配置 - - - - - - 220 - 160 - 111 - 31 - - - - 保存设置 - - - - - - 230 - 270 - 75 - 23 - - - - OK - - - - - - 320 - 270 - 75 - 23 - - - - Cancel - - + + + + + + + + + + + 设备类型: + + + + + + + + + + + + + + 扫描按钮: + + + + + + + + + + + + 设备配置 + + + + + + + 保存设置 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + -1 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + OK + + + + + + + Cancel + + + + + + + + diff --git a/app/scantool/dialog_aquireinto.cpp b/app/scantool/dialog_aquireinto.cpp deleted file mode 100644 index 7f02af56..00000000 --- a/app/scantool/dialog_aquireinto.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "dialog_aquireinto.h" -#include "ui_dialog_aquireinto.h" - -Dialog_AquireInto::Dialog_AquireInto(const SaveParam &saveParam, QWidget *parent) - : QDialog(parent) - , ui(new Ui::Dialog_AquireInto) -{ - ui->setupUi(this); - setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); -} - -Dialog_AquireInto::~Dialog_AquireInto() -{ - delete ui; -} - -SaveParam Dialog_AquireInto::GetSaveParam() -{ - SaveParam saveParam; - return saveParam; -} - -SaveParam Dialog_AquireInto::GetDefSaveParam() -{ - SaveParam saveParam; - return saveParam; -} diff --git a/app/scantool/dialog_aquireinto.h b/app/scantool/dialog_aquireinto.h deleted file mode 100644 index b19fd42e..00000000 --- a/app/scantool/dialog_aquireinto.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef DIALOG_AQUIREINTO_H -#define DIALOG_AQUIREINTO_H - -#include - -namespace Ui { -class Dialog_AquireInto; -} - -struct SaveParam -{ - QString m_savePath; - bool m_isUseSubfolderByTime; - bool m_isUseSubfolderByBlankPages; - bool m_isUseSubfolderByColor; - int m_jpegQuality; - int m_tiffCompressionBW; - int m_tiffCompression; - int m_tiffQuality; - QString m_fileNamePrefix; - int m_fileNameStartIndex; - int m_fileNameDigits; - int m_fileNameOddEventType; - QString m_fileNameExt; - bool m_isOcr; - bool m_isSaveAsMultiPage; - int m_multiPagesType; - int m_customMultiPages; -}; - -class Dialog_AquireInto : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog_AquireInto(const SaveParam &saveParam, QWidget *parent = nullptr); - ~Dialog_AquireInto(); - - SaveParam GetSaveParam(); - static SaveParam GetDefSaveParam(); - -private: - Ui::Dialog_AquireInto *ui; -}; - -#endif // DIALOG_AQUIREINTO_H diff --git a/app/scantool/dialog_aquireinto.ui b/app/scantool/dialog_aquireinto.ui deleted file mode 100644 index 64d1e625..00000000 --- a/app/scantool/dialog_aquireinto.ui +++ /dev/null @@ -1,68 +0,0 @@ - - - Dialog_AquireInto - - - - 0 - 0 - 644 - 510 - - - - Save Param - - - - - 290 - 470 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - buttonBox - accepted() - Dialog_AquireInto - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_AquireInto - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scantool/dialog_button.ui b/app/scantool/dialog_button.ui index 28d7829a..decbc136 100644 --- a/app/scantool/dialog_button.ui +++ b/app/scantool/dialog_button.ui @@ -6,62 +6,56 @@ 0 0 - 751 - 542 + 1023 + 677 Button Setting - - - - 10 - 50 - 731 - 481 - - - - - - - 450 - 10 - 91 - 31 - - - - Add - - - - - - 550 - 10 - 91 - 31 - - - - Modify - - - - - - 650 - 10 - 91 - 31 - - - - Remove - - + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Add + + + + + + + Modify + + + + + + + Remove + + + + + + + + + diff --git a/app/scantool/dialog_param.cpp b/app/scantool/dialog_param.cpp deleted file mode 100644 index da84cd2a..00000000 --- a/app/scantool/dialog_param.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "dialog_param.h" -#include "ui_dialog_param.h" - -Dialog_Param::Dialog_Param(DeviceType deviceType, const std::string &deviceConfig, QWidget *parent) - : QDialog(parent) - , ui(new Ui::Dialog_Param) -{ - ui->setupUi(this); - setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); -} - -Dialog_Param::~Dialog_Param() -{ - delete ui; -} - -std::string Dialog_Param::GetDeviceConfig() -{ - std::string deviceConfig; - return deviceConfig; -} diff --git a/app/scantool/dialog_param.h b/app/scantool/dialog_param.h deleted file mode 100644 index 73c362f5..00000000 --- a/app/scantool/dialog_param.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef DIALOG_PARAM_H -#define DIALOG_PARAM_H - -#include - -namespace Ui { -class Dialog_Param; -} - -enum DeviceType -{ - DeviceType_G100 = 1, - DeviceType_G200, - DeviceType_G300, - DeviceType_G400 -}; - -class Dialog_Param : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog_Param(DeviceType deviceType, const std::string &deviceConfig, QWidget *parent = nullptr); - ~Dialog_Param(); - - std::string GetDeviceConfig(); - -private: - Ui::Dialog_Param *ui; -}; - -#endif // DIALOG_PARAM_H diff --git a/app/scantool/dialog_param.ui b/app/scantool/dialog_param.ui deleted file mode 100644 index f1ca4ab0..00000000 --- a/app/scantool/dialog_param.ui +++ /dev/null @@ -1,68 +0,0 @@ - - - Dialog_Param - - - - 0 - 0 - 708 - 542 - - - - Device Config - - - - - 350 - 500 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - buttonBox - accepted() - Dialog_Param - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_Param - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scantool/dialog_scan.ui b/app/scantool/dialog_scan.ui index 86a8ca89..f36cff35 100644 --- a/app/scantool/dialog_scan.ui +++ b/app/scantool/dialog_scan.ui @@ -6,36 +6,88 @@ 0 0 - 403 - 239 + 316 + 181 Scan Setting - - - - 80 - 110 - 71 - 16 - - - - 设备列表: - - - - - - 160 - 100 - 161 - 31 - - - + + + + + Qt::Vertical + + + + 20 + 62 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 设备列表: + + + + + + + + 171 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 61 + + + + + diff --git a/app/scantool/dialog_writesettings.cpp b/app/scantool/dialog_writesettings.cpp new file mode 100644 index 00000000..c8b9786b --- /dev/null +++ b/app/scantool/dialog_writesettings.cpp @@ -0,0 +1,73 @@ +#include "dialog_writesettings.h" +#include "ui_dialog_writesettings.h" +#include "app_cfg.h" + +Dialog_WriteSettings::Dialog_WriteSettings(int suffix_type, const WriteParam &writeParam, QWidget *parent) + : QDialog(parent) + , ui(new Ui::Dialog_WriteSettings) +{ + ui->setupUi(this); + setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); + //set visible + bool jpg_enable = (suffix_type == 0 || suffix_type == 7 || suffix_type == 8); + bool tif_enable = (suffix_type == 6); + ui->lab_tif_bw->setVisible(tif_enable); + ui->cbox_tif_bw->setVisible(tif_enable); + ui->lab_tif_color->setVisible(tif_enable); + ui->cbox_tif_color->setVisible(tif_enable); + ui->lab_spin_tif_jpgQuality->setVisible(tif_enable); + ui->spin_tif_quality->setVisible(tif_enable); + ui->lab_slider_jpg_low->setVisible(jpg_enable); + ui->lab_slider_jpg_high->setVisible(jpg_enable); + ui->slider_jpg_quality->setVisible(jpg_enable); + ui->lab_spin_jpgQuality->setVisible(jpg_enable); + ui->spin_jpg_quality->setVisible(jpg_enable); + //set value + + ui->slider_jpg_quality->setValue(writeParam.m_jpegQuality); + ui->spin_jpg_quality->setValue(writeParam.m_jpegQuality); + ui->cbox_tif_bw->setCurrentIndex(writeParam.m_tiffCompressionBW); + ui->cbox_tif_color->setCurrentIndex(writeParam.m_tiffCompression); + ui->spin_tif_quality->setValue(writeParam.m_tiffQuality); + //set enable + ui->spin_tif_quality->setEnabled(ui->cbox_tif_color->currentIndex() == 2); + + ui->spin_jpg_quality->setMinimumWidth(160); + ui->spin_tif_quality->setMinimumWidth(160); +} + +Dialog_WriteSettings::~Dialog_WriteSettings() +{ + delete ui; +} + +WriteParam Dialog_WriteSettings::GetWriteParam() +{ + WriteParam writeParam; + writeParam.m_jpegQuality = ui->spin_jpg_quality->value(); + writeParam.m_tiffCompressionBW = ui->cbox_tif_bw->currentIndex(); + writeParam.m_tiffCompression = ui->cbox_tif_color->currentIndex(); + writeParam.m_tiffQuality = ui->spin_tif_quality->value(); + + return writeParam; +} + +void Dialog_WriteSettings::on_cbox_tif_color_currentIndexChanged(int index) +{ + ui->spin_tif_quality->setEnabled(index == 2); +} + +void Dialog_WriteSettings::on_slider_jpg_quality_valueChanged(int value) +{ + ui->spin_jpg_quality->setValue(value); +} + +void Dialog_WriteSettings::on_spin_jpg_quality_valueChanged(int arg1) +{ + ui->slider_jpg_quality->setValue(arg1); +} + +void Dialog_WriteSettings::on_buttonBox_accepted() +{ + +} diff --git a/app/scantool/dialog_writesettings.h b/app/scantool/dialog_writesettings.h new file mode 100644 index 00000000..a27d4ca0 --- /dev/null +++ b/app/scantool/dialog_writesettings.h @@ -0,0 +1,42 @@ +#ifndef DIALOG_WRITESETTINGS_H +#define DIALOG_WRITESETTINGS_H + +#include + +class QSettings; +namespace Ui { +class Dialog_WriteSettings; +} + +struct WriteParam +{ + int m_jpegQuality; + int m_tiffCompressionBW; + int m_tiffCompression; + int m_tiffQuality; +}; + +class Dialog_WriteSettings : public QDialog +{ + Q_OBJECT + +public: + explicit Dialog_WriteSettings(int suffix_type, const WriteParam &writeParam, QWidget *parent = nullptr); + ~Dialog_WriteSettings(); + + WriteParam GetWriteParam(); + +private slots: + void on_cbox_tif_color_currentIndexChanged(int index); + + void on_slider_jpg_quality_valueChanged(int value); + + void on_spin_jpg_quality_valueChanged(int arg1); + + void on_buttonBox_accepted(); + +private: + Ui::Dialog_WriteSettings *ui; +}; + +#endif // DIALOG_WRITESETTINGS_H diff --git a/app/scantool/dialog_writesettings.ui b/app/scantool/dialog_writesettings.ui new file mode 100644 index 00000000..dbbe55bc --- /dev/null +++ b/app/scantool/dialog_writesettings.ui @@ -0,0 +1,335 @@ + + + Dialog_WriteSettings + + + + 0 + 0 + 454 + 178 + + + + Write Settings + + + + + + + + + 115 + 0 + + + + Compression for black&white picture + + + true + + + + + + + + 80 + 0 + + + + + None + + + + + LZW + + + + + CCITT G4 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 115 + 0 + + + + Compression for color picture + + + true + + + + + + + + 80 + 0 + + + + + None + + + + + LZW + + + + + JPEG + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 2 + + + + + + + + + + + + + + Quality + + + + + + + + + + + + + Lowest + + + + + + + Qt::LeftToRight + + + Best + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + 100 + + + 80 + + + Qt::Horizontal + + + false + + + QSlider::TicksAbove + + + 10 + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + 100 + + + 80 + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + 100 + + + 80 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Dialog_WriteSettings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog_WriteSettings + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/app/scantool/form_deviceconfig.cpp b/app/scantool/form_deviceconfig.cpp new file mode 100644 index 00000000..42034748 --- /dev/null +++ b/app/scantool/form_deviceconfig.cpp @@ -0,0 +1,29 @@ +#include "form_deviceconfig.h" +#include "ui_form_deviceconfig.h" + +Form_DeviceConfig::Form_DeviceConfig(DeviceType deviceType, const std::string &deviceConfig, QWidget *parent) + : QWidget(parent) + , ui(new Ui::Form_DeviceConfig) +{ + ui->setupUi(this); + Update(deviceType, deviceConfig); +} + +Form_DeviceConfig::~Form_DeviceConfig() +{ + delete ui; +} + +void Form_DeviceConfig::Update(DeviceType deviceType, const std::string &deviceConfig) +{ + // TODO 展示界面 +} + +std::string Form_DeviceConfig::GetDeviceConfig() +{ + std::string deviceConfig; + + // 从界面获取配置 + + return deviceConfig; +} diff --git a/app/scantool/form_deviceconfig.h b/app/scantool/form_deviceconfig.h new file mode 100644 index 00000000..2024d288 --- /dev/null +++ b/app/scantool/form_deviceconfig.h @@ -0,0 +1,33 @@ +#ifndef FORM_DEVICECONFIG_H +#define FORM_DEVICECONFIG_H + +#include + +namespace Ui { +class Form_DeviceConfig; +} + +enum DeviceType +{ + DeviceType_G100 = 1, + DeviceType_G200, + DeviceType_G300, + DeviceType_G400 +}; + +class Form_DeviceConfig : public QWidget +{ + Q_OBJECT + +public: + explicit Form_DeviceConfig(DeviceType deviceType, const std::string &deviceConfig, QWidget *parent = nullptr); + ~Form_DeviceConfig(); + + void Update(DeviceType deviceType, const std::string &deviceConfig); + std::string GetDeviceConfig(); + +private: + Ui::Form_DeviceConfig *ui; +}; + +#endif // FORM_DEVICECONFIG_H diff --git a/app/scantool/form_deviceconfig.ui b/app/scantool/form_deviceconfig.ui new file mode 100644 index 00000000..03bfb403 --- /dev/null +++ b/app/scantool/form_deviceconfig.ui @@ -0,0 +1,21 @@ + + + + + Form_DeviceConfig + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/app/scantool/form_saveparam.cpp b/app/scantool/form_saveparam.cpp new file mode 100644 index 00000000..f70d0052 --- /dev/null +++ b/app/scantool/form_saveparam.cpp @@ -0,0 +1,276 @@ +#include "form_saveparam.h" +#include "ui_form_saveparam.h" +#include +#include "base/HGDef.h" +#include "base/HGInc.h" +#include "base/HGUtility.h" +#include "base/HGIni.h" +#include "HGUIGlobal.h" +#include "HGString.h" +#include "app_cfg.h" + +Form_SaveParam::Form_SaveParam(const SaveParam &saveParam, QWidget *parent) + : QWidget(parent) + , ui(new Ui::Form_SaveParam) +{ + ui->setupUi(this); + + QRegExp rx("[^\\\\/:*?\"<>|]+$"); + ui->lineEdit_fileName->setValidator(new QRegExpValidator(rx, this)); + + ui->lineEdit_directory->setText(saveParam.m_savePath); + ui->cbtn_subFolder->setChecked(saveParam.m_isUseSubfolderByTime); + ui->cbtn_subFolderByBlank->setChecked(saveParam.m_isUseSubfolderByBlankPages); + ui->cbtn_subFolderByColor->setChecked(saveParam.m_isUseSubfolderByColor); + ui->lineEdit_fileName->setText(saveParam.m_fileNamePrefix); + + ui->spin_index->setValue(saveParam.m_fileNameStartIndex); + ui->cbox_digit->setCurrentIndex(saveParam.m_fileNameDigits - 1); + ui->cbox_evenOdd->setCurrentIndex(saveParam.m_fileNameOddEventType); + int format = getFormatIndex(saveParam.m_fileNameExt, saveParam.m_isOcr); + ui->cbox_format->setCurrentIndex(format); + ui->cbtn_multiFile->setChecked(saveParam.m_isSaveAsMultiPage); + ui->radio_multiAll->setChecked(0 == saveParam.m_multiPagesType); + ui->radio_multiCustom->setChecked(0 != saveParam.m_multiPagesType); + ui->spinBox_multiPages->setValue(saveParam.m_customMultiPages); + + 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'))); + 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->radio_multiAll->setEnabled(ui->cbtn_multiFile->isChecked()); + ui->radio_multiCustom->setEnabled(ui->cbtn_multiFile->isChecked()); + ui->spinBox_multiPages->setEnabled(ui->cbtn_multiFile->isChecked() ? ui->radio_multiCustom->isChecked() : false); + + ui->spin_index->setFixedWidth(160); + ui->cbox_digit->setFixedWidth(80); + +#if defined (x86_64) || defined (loongarch64) + ui->cbox_format->removeItem(11); + ui->cbox_format->removeItem(10); +#endif + + m_writeParam.m_jpegQuality = saveParam.m_jpegQuality; + m_writeParam.m_tiffCompressionBW = saveParam.m_tiffCompressionBW; + m_writeParam.m_tiffCompression = saveParam.m_tiffCompression; + m_writeParam.m_tiffQuality = saveParam.m_tiffQuality; +} + +Form_SaveParam::~Form_SaveParam() +{ + delete ui; +} + +SaveParam Form_SaveParam::GetSaveParam() +{ + SaveParam saveParam; + saveParam.m_savePath = ui->lineEdit_directory->text(); + saveParam.m_isUseSubfolderByTime = ui->cbtn_subFolder->isChecked(); + saveParam.m_isUseSubfolderByBlankPages = ui->cbtn_subFolderByBlank->isChecked(); + saveParam.m_isUseSubfolderByColor = ui->cbtn_subFolderByColor->isChecked(); + saveParam.m_jpegQuality = m_writeParam.m_jpegQuality; + saveParam.m_tiffCompressionBW = m_writeParam.m_tiffCompressionBW; + saveParam.m_tiffCompression = m_writeParam.m_tiffCompression; + saveParam.m_tiffQuality = m_writeParam.m_tiffQuality; + saveParam.m_fileNamePrefix = ui->lineEdit_fileName->text(); + saveParam.m_fileNameStartIndex = ui->spin_index->value(); + saveParam.m_fileNameDigits = ui->cbox_digit->currentIndex() + 1; + saveParam.m_fileNameOddEventType = ui->cbox_evenOdd->currentIndex(); + + QString format = "jpg"; + switch (ui->cbox_format->currentIndex()) + { + case 1: + format = "bmp"; + break; + case 2: + format = "png"; + break; + case 3: + format = "ppm"; + break; + case 4: + format = "pgm"; + break; + case 5: + format = "pbm"; + break; + case 6: + format = "tif"; + break; + case 7: + format = "pdf"; + break; + case 8: + format = "ofd"; + break; + case 9: + format = "gif"; + break; + case 10: + format = "pdf"; + break; + case 11: + format = "ofd"; + break; + default: + break; + } + saveParam.m_fileNameExt = format; + saveParam.m_isOcr = (ui->cbox_format->currentIndex() >= 10); + + saveParam.m_isSaveAsMultiPage = ui->cbtn_multiFile->isChecked(); + saveParam.m_multiPagesType = (ui->radio_multiAll->isChecked()) ? 0 : 1; + saveParam.m_customMultiPages = ui->spinBox_multiPages->value(); + + return saveParam; +} + +SaveParam Form_SaveParam::GetDefSaveParam() +{ + HGChar aquireIntoPath[512]; + HGBase_GetDocumentsPath(aquireIntoPath, 512); + HGChar procName[512]; + HGBase_GetProcessName(procName, 512); + strcat(aquireIntoPath, procName); + strcat(aquireIntoPath, "/AquireInto/"); + QString filePath = getStdFileName(StdStringToUtf8(aquireIntoPath).c_str()); + + SaveParam saveParam; + saveParam.m_savePath = filePath; + saveParam.m_isUseSubfolderByTime = false; + saveParam.m_isUseSubfolderByBlankPages = false; + saveParam.m_isUseSubfolderByColor = false; + saveParam.m_jpegQuality = 80; + saveParam.m_tiffCompressionBW = 1; + saveParam.m_tiffCompression = 1; + saveParam.m_tiffQuality = 80; + +#if defined(OEM_HANWANG) + saveParam.m_fileNamePrefix = QString("HWScan"); +#elif defined(OEM_LISICHENG) + saveParam.m_fileNamePrefix = QString("LXScan"); +#elif defined(OEM_CANGTIAN) + saveParam.m_fileNamePrefix = QString("CTSScan"); +#elif defined(OEM_ZHONGJING) + saveParam.m_fileNamePrefix = QString("ZJScan"); +#elif defined(OEM_ZIGUANG) + saveParam.m_fileNamePrefix = QString("ZGScan"); +#elif defined(OEM_NEUTRAL) + saveParam.m_fileNamePrefix = QString("Scan"); +#elif defined(OEM_DELI) + saveParam.m_fileNamePrefix = QString("DLScan"); +#else + saveParam.m_fileNamePrefix = QString("HGScan"); +#endif + + saveParam.m_fileNameStartIndex = 1; + saveParam.m_fileNameDigits = 3; + saveParam.m_fileNameOddEventType = 0; + saveParam.m_fileNameExt = QString("jpg"); + saveParam.m_isOcr = false; + saveParam.m_isSaveAsMultiPage = false; + saveParam.m_multiPagesType = 0; + saveParam.m_customMultiPages = 1; + + return saveParam; +} + +int Form_SaveParam::getFormatIndex(const QString &ext, bool ocr) +{ + if (ext == "bmp") + return 1; + else if (ext == "png") + return 2; + else if (ext == "ppm") + return 3; + else if (ext == "pgm") + return 4; + else if (ext == "pbm") + return 5; + else if (ext == "tif") + return 6; + else if (ext == "pdf") + return !ocr ? 7 : 10; + else if (ext == "ofd") + return !ocr ? 8 : 11; + else if (ext == "gif") + return 9; + return 0; +} + +void Form_SaveParam::on_btn_directory_clicked() +{ + QString save_dir = QFileDialog::getExistingDirectory(this, tr("Browse directory"), ""); + if (!save_dir.isEmpty()) + { + if (save_dir[save_dir.size() - 1] != '/') + save_dir += "/"; + ui->lineEdit_directory->setText(getStdFileName(save_dir)); + } +} + +void Form_SaveParam::on_btn_option_clicked() +{ + Dialog_WriteSettings dlg(ui->cbox_format->currentIndex(), m_writeParam, this); + if (dlg.exec()) + { + m_writeParam = dlg.GetWriteParam(); + } +} + +void Form_SaveParam::on_cbox_format_currentIndexChanged(int index) +{ + ui->cbtn_multiFile->setEnabled(index > 5 && index < 12); + if (index < 6 || index >= 10 ) + ui->cbtn_multiFile->setChecked(false); + + ui->btn_option->setEnabled(0 == index || 6 == index || 7 == index || 8 == index); +} + +void Form_SaveParam::on_lineEdit_directory_textChanged(const QString& arg1) +{ + +} + +void Form_SaveParam::on_cbox_digit_currentIndexChanged(int index) +{ + (void)index; + 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'))); +} + +void Form_SaveParam::on_cbtn_multiFile_toggled(bool checked) +{ + if (checked) + { + ui->spinBox_multiPages->setEnabled(ui->radio_multiCustom->isChecked()); + } + else + { + ui->spinBox_multiPages->setEnabled(false); + } + + ui->radio_multiAll->setEnabled(checked); + ui->radio_multiCustom->setEnabled(checked); +} + +void Form_SaveParam::on_radio_multiCustom_toggled(bool checked) +{ + ui->spinBox_multiPages->setEnabled(checked && ui->cbtn_multiFile->isEnabled()); +} + +void Form_SaveParam::on_lineEdit_fileName_textChanged(const QString &arg1) +{ + (void)arg1; + 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'))); +} + +void Form_SaveParam::on_spin_index_valueChanged(int arg1) +{ + (void)arg1; + 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'))); +} diff --git a/app/scantool/form_saveparam.h b/app/scantool/form_saveparam.h new file mode 100644 index 00000000..2faa3337 --- /dev/null +++ b/app/scantool/form_saveparam.h @@ -0,0 +1,70 @@ +#ifndef FORM_SAVEPARAM_H +#define FORM_SAVEPARAM_H + +#include +#include "dialog_writesettings.h" + +namespace Ui { +class Form_SaveParam; +} + +struct SaveParam +{ + QString m_savePath; + bool m_isUseSubfolderByTime; + bool m_isUseSubfolderByBlankPages; + bool m_isUseSubfolderByColor; + int m_jpegQuality; + int m_tiffCompressionBW; + int m_tiffCompression; + int m_tiffQuality; + QString m_fileNamePrefix; + int m_fileNameStartIndex; + int m_fileNameDigits; + int m_fileNameOddEventType; + QString m_fileNameExt; + bool m_isOcr; + bool m_isSaveAsMultiPage; + int m_multiPagesType; + int m_customMultiPages; +}; + +class Form_SaveParam : public QWidget +{ + Q_OBJECT + +public: + explicit Form_SaveParam(const SaveParam &saveParam, QWidget *parent = nullptr); + ~Form_SaveParam(); + + SaveParam GetSaveParam(); + static SaveParam GetDefSaveParam(); + +private: + int getFormatIndex(const QString &ext, bool ocr); + +private slots: + void on_btn_directory_clicked(); + + void on_btn_option_clicked(); + + void on_cbox_format_currentIndexChanged(int index); + + void on_lineEdit_directory_textChanged(const QString& arg1); + + void on_cbox_digit_currentIndexChanged(int index); + + void on_cbtn_multiFile_toggled(bool checked); + + void on_radio_multiCustom_toggled(bool checked); + + void on_lineEdit_fileName_textChanged(const QString &arg1); + + void on_spin_index_valueChanged(int arg1); + +private: + Ui::Form_SaveParam *ui; + WriteParam m_writeParam; +}; + +#endif // FORM_SAVEPARAM_H diff --git a/app/scantool/form_saveparam.ui b/app/scantool/form_saveparam.ui new file mode 100644 index 00000000..0da2fcbe --- /dev/null +++ b/app/scantool/form_saveparam.ui @@ -0,0 +1,395 @@ + + + Form_SaveParam + + + + 0 + 0 + 736 + 380 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Batch scanning + + + + + + + + + + + Directory + + + + + + + true + + + + + + + ... + + + + + + + + + Use subfolder based on current date + + + + + + + Use subfolder based on blank pages + + + + + + + Use subfolder based on image color type + + + + + + + + + File name + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + File name index + + + + + + + + Start index + + + + + + + + 0 + 0 + + + + 99999 + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Digit(s) + + + + + + + 2 + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + + + + e.g. 'HGScan001' + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Even and odd pages + + + + + Odd pages + + + + + Even pages + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Format + + + + + + + + JPG - JPG / JFIF(*.jpg) + + + + + BMP - Windows Bitmap(*.bmp) + + + + + PNG - Portable Network Graphics(*.png) + + + + + PPM - Portable Pixmap(*.ppm) + + + + + PGM - Portable Greymap(*.pgm) + + + + + PBM - Portable Bitmap(*.pbm) + + + + + TIF - TIFF Revision 6(*.tif) + + + + + PDF - Portable Document Format(*.pdf) + + + + + OFD - Open Fixed-layout Document(*.ofd) + + + + + GIF - Graphics Interchange Format(*.gif) + + + + + OCR->PDF - Portable Document Format(*.pdf) + + + + + OCR->OFD - Open Fixed-layout Document(*.ofd) + + + + + + + + Compression option + + + + + + + + + + + Save as multipages (TIFF/PDF/OFD/GIF) + + + + + + + true + + + 所有页 + + + true + + + + + + + true + + + 用户自定义页数 + + + + + + + true + + + + 0 + 0 + + + + 1 + + + 1000 + + + + + + + + + + + + + diff --git a/build2/qt/HGScanTool/HGScanTool.pro b/build2/qt/HGScanTool/HGScanTool.pro index abca94cd..488e9ac3 100644 --- a/build2/qt/HGScanTool/HGScanTool.pro +++ b/build2/qt/HGScanTool/HGScanTool.pro @@ -52,7 +52,8 @@ win32 { LIBS += -L$$PWD/../../../../release/win/$${MY_ARCH}/OEM/$${OEM_NAME} } -INCLUDEPATH += $$PWD/../../../modules/base +INCLUDEPATH += $$PWD/../../../modules +INCLUDEPATH += $$PWD/../../../utility INCLUDEPATH += $$PWD/../../../third_party/sqlite INCLUDEPATH += $$PWD/../../../third_party/json @@ -94,33 +95,42 @@ win32 { } SOURCES += \ + ../../../app/scantool/HGUIGlobal.cpp \ + ../../../app/scantool/app_cfg.cpp \ ../../../app/scantool/dialog_add.cpp \ - ../../../app/scantool/dialog_aquireinto.cpp \ ../../../app/scantool/dialog_button.cpp \ - ../../../app/scantool/dialog_param.cpp \ ../../../app/scantool/dialog_scan.cpp \ + ../../../app/scantool/dialog_writesettings.cpp \ + ../../../app/scantool/form_deviceconfig.cpp \ + ../../../app/scantool/form_saveparam.cpp \ ../../../app/scantool/main.cpp \ ../../../app/scantool/mainwindow.cpp \ ../../../third_party/json/cJSON.c \ - ../../../third_party/sqlite/sqlite3.c + ../../../third_party/sqlite/sqlite3.c \ + ../../../utility/HGString.cpp HEADERS += \ + ../../../app/scantool/HGUIGlobal.h \ + ../../../app/scantool/app_cfg.h \ ../../../app/scantool/dialog_add.h \ - ../../../app/scantool/dialog_aquireinto.h \ ../../../app/scantool/dialog_button.h \ - ../../../app/scantool/dialog_param.h \ ../../../app/scantool/dialog_scan.h \ + ../../../app/scantool/dialog_writesettings.h \ + ../../../app/scantool/form_deviceconfig.h \ + ../../../app/scantool/form_saveparam.h \ ../../../app/scantool/mainwindow.h \ \ ../../../third_party/json/cJSON.h \ - ../../../third_party/sqlite/sqlite3.h + ../../../third_party/sqlite/sqlite3.h \ + ../../../utility/HGString.h FORMS += \ ../../../app/scantool/dialog_add.ui \ - ../../../app/scantool/dialog_aquireinto.ui \ ../../../app/scantool/dialog_button.ui \ - ../../../app/scantool/dialog_param.ui \ ../../../app/scantool/dialog_scan.ui \ + ../../../app/scantool/dialog_writesettings.ui \ + ../../../app/scantool/form_deviceconfig.ui \ + ../../../app/scantool/form_saveparam.ui \ ../../../app/scantool/mainwindow.ui RESOURCES += \