diff --git a/app/scanner/Scanner_zh_CN.qm b/app/scanner/Scanner_zh_CN.qm index f027b2c9..bd4edd08 100644 Binary files a/app/scanner/Scanner_zh_CN.qm and b/app/scanner/Scanner_zh_CN.qm differ diff --git a/app/scanner/Scanner_zh_CN.ts b/app/scanner/Scanner_zh_CN.ts index 502d7d64..39a5de24 100644 --- a/app/scanner/Scanner_zh_CN.ts +++ b/app/scanner/Scanner_zh_CN.ts @@ -518,17 +518,17 @@ Page range will be 'Chosen Pages'. 停止导出 - + export failed: 导出失败: - + tip 提示 - + export succeed 导出完成 @@ -541,7 +541,7 @@ Page range will be 'Chosen Pages'. OCR功能处理失败 - + ok 确定 @@ -1080,22 +1080,22 @@ Page range will be 'Chosen Pages'. Dialog - + 输入: - + Ok - 确定 + 确定 Cancel - 取消 + 取消 @@ -1357,22 +1357,22 @@ This operation will NOT rotate the files that may contain multiple pages, such a 停止批量旋转 - + operation success 操作成功 - + multirotate operation failed: 多流旋转操作失败: - + tip 提示 - + ok 确定 @@ -1621,7 +1621,7 @@ Please make sure the two passwords are the same. 取消 - + upgrade online 检查更新 @@ -1654,17 +1654,17 @@ bug description: - + The current version is the latest! The current version number is : 当前为最新版本!版本号为: - + Discover the new version : 发现新版本: - + ,the current version is : ,当前版本为: @@ -2168,8 +2168,8 @@ bug description: - - + + Question 警告 @@ -2278,191 +2278,191 @@ Do you want to clear? - - + + save succeed 保存成功 - + find savePath in thumbnail 图片名在列表中已存在 - + Please select at least one picture before export 请至少选中一张图片再进行导出 - + File name 文件名 - + File path 文件路径 - + File size 文件大小 - + Creation date/time 创建时间 - + Modified date/time 修改时间 - + Accessed date/time 访问时间 - + Format 格式 - + Width 宽度 - + Height 高度 - + depth 深度 - + Color model 色彩模式 - + DPI 每英寸像素点 - + Print size 打印尺寸 - + Frame - + None - + Mono 黑白 - + Gray 灰度 - + Color 彩色 - + Warning 警告 - + Device is Running! Please finish scanning first. 设备正在运行! 请先结束扫描。 - + Image processing failed 图像处理失败 - + Ocr init failed OCR初始化错误 - + Ocr failed OCR错误 - + File does not exist 文件不存在 - + Failed to load dynamic library 加载动态库失败 - + File data error 文件数据错误 - + Failed 其他错误 + - + - + - + - already waked up device 已唤醒设备 - + be ready 就绪 + - + - folder limit 无法访问“我的文档”, 请前往“扫描至”更换可访问的扫描目录再进行扫描。 - + Insufficient access rights 文件访问权限不足 @@ -2475,47 +2475,47 @@ Please finish scanning first. 图像处理失败 - + Are you sure to close 您确定要关闭 - + ? 吗? + - close 关闭 - + tip 提示 - + Other versions not available 未获取到其他版本 - - + + The device does not support this operation 设备不支持该操作 - - + + IO error IO错误 - - - + + + error 错误 @@ -2530,17 +2530,17 @@ Continue to close? 是否继续关闭? - + Sure to sign out administrator account? 是否确定登出管理员账户? - + confirm the operation 确认操作 - + Are you sure to clear the rollor acount? 你确定要清除滚轴计数吗 @@ -2549,34 +2549,34 @@ Continue to close? 请重新进入关于界面以获取最新值 - + <p>%1: <a href='%2'>%3</a> - + <p>%1: %2 - + roller number 滚轴张数 - + open scanner 打开扫描仪 - - + + app name 华高扫描软件 - - + + success 成功 @@ -2593,22 +2593,22 @@ Continue to close? 失败 - - + + failed 失败 - + warning 警告 - + the disk space in the current path is unsufficient, please select a new path or clear the disk space in time. 当前路径磁盘空间不足, 请重新选择路径或及时清理磁盘空间。 @@ -2618,7 +2618,7 @@ Continue to close? 配置丢失 - + apply setting 应用配置 @@ -2626,18 +2626,18 @@ Continue to close? + - + - + - + - start failed 启动失败 @@ -2716,13 +2716,13 @@ Continue to close? - - - - - - - + + + + + + + yes 确定 @@ -2735,12 +2735,12 @@ Continue to close? - - - - - - + + + + + + no 取消 @@ -2771,7 +2771,7 @@ Continue to close? create savepath failed: - 创建文件夹失败: + 创建文件夹失败: @@ -2793,22 +2793,22 @@ Continue to close? + - + - save image doc failed: 保存图片文件失败: - + start failed! 启动安装程序失败! - + There are pictures that have not been saved. Are you sure to close? 有图像未保存,确定关闭? @@ -2817,57 +2817,57 @@ Are you sure to close? - - - - - - - + + + + + + + tips 提示 - + Are you sure to close? 确定关闭? - + confirm operation 确认操作 - + are you sure to clear the roller count? 您确定要清除滚轴计数吗 - - - + + + hint 提示 - - + + Roller scanned count has been set to 0. 辊轴计数已置零 - - + + Roller scanned count reset failed. 重置滚轴计数失败 - + Error 错误 - + Document missing! It would be deleted or renamed. 文档丢失!文档可能已被删除或被重命名。 @@ -2900,28 +2900,28 @@ Are you sure to close? <br>导航地址: <a href='https://j.map.baidu.com/7e/1TO'>百度地图访问</a> - + About %1 关于 %1 - + <p>%1</p><p>Version: %2<br>CopyRight: &#169; %3</p><p>%4%5%6%7%8%9</p> <p>%1</p><p>版本: %2<br>版权: &#169; %3</p><p>%4%5%6%7%8%9</p> - + about %1 关于 %1 - + <p>Version: %1</p> <p>版本: %1</p> <p>版本: %1</p> - + <p>CopyRight: &#169; %1</p> <p>版权: &#169; %1</p> <p>版权: &#169; %1</p> @@ -2947,7 +2947,7 @@ Are you sure to close? Widget - + @@ -3026,7 +3026,7 @@ Are you sure to close? cutDialog - + @@ -3160,6 +3160,7 @@ Are you sure to close? + ok 确定 @@ -3184,86 +3185,130 @@ Are you sure to close? 自定义色调曲线 - + + Please select to overwrite the original configuration: + 请选择覆盖原来的配置: + + + + ,or add a new configuration + ,或者新增配置 + + + save the configuration 保存配置 - The Settings you just set are in the original configuration " The Settings you just set are in the original configuration “ - 您刚才的设置是在原有配置 “ + 您刚才的设置是在原有配置 “ - " changed on the basis,Please select overwrite this configuration or add a new one? Yes: cover " ” changed on the basis,Please select overwrite this configuration or add a new one? Yes: cover “ - ” 基础上更改的,请选择是覆盖这个配置,还是增加新的配置? + ” 基础上更改的,请选择是覆盖这个配置,还是增加新的配置? 是: 覆盖 “ - " No: add new configuration ” No: add new configuration - + 否: 增加新的配置: - - - + + yes - - - + + no - + <h6><b> <h6><b> - + + cover original configuration: + 覆盖原来配置: + + + + add new configuration + 新增配置 + + + + rename: + 更名: + + + + + + tips + 提示 + + + + scheme name cannot be empty + 配置名不能为空 + + + + + scheme name: + 配置名: + + + + + already exists + 已存在 + + + :</b></h6> :</b></h6> - + <p> <p> - + </p> </p> - + configuration scheme name change 配置改名 - - + + be sure to delete the configuration 确认删除配置 - + Are you sure you want to delete the configuration " 您确认要删除配置 - + " ? @@ -3276,7 +3321,7 @@ No: add new configuration ’ 吗? - + Are you sure you want to delete the configuration? 您确认要删除所有配置吗? diff --git a/app/scanner/dialog_input.cpp b/app/scanner/dialog_input.cpp index c84f36f8..1692c79d 100644 --- a/app/scanner/dialog_input.cpp +++ b/app/scanner/dialog_input.cpp @@ -1,6 +1,7 @@ #include "dialog_input.h" #include "ui_dialog_input.h" #include +#include Dialog_Input::Dialog_Input(QWidget *parent) : QDialog(parent), @@ -16,7 +17,11 @@ Dialog_Input::~Dialog_Input() void Dialog_Input::on_pushButton_clicked() { - std::string str(ui->lineEdit->text().toStdString()); + QString text = ui->lineEdit->text(); + static QRegularExpression re("\\s"); + text.remove(re);//Remove space + + std::string str(text.toStdString()); int pos = 0; while(pos < str.length() && str[pos++] == ' '); if(--pos > 0) diff --git a/app/scanner/hg_settingdialog.cpp b/app/scanner/hg_settingdialog.cpp index 19bb2446..5dd919c3 100644 --- a/app/scanner/hg_settingdialog.cpp +++ b/app/scanner/hg_settingdialog.cpp @@ -18,7 +18,7 @@ hg_settingdialog::hg_settingdialog(void *handle, QWidget *parent : QDialog(parent) , dev_que_(dev), save_(false) , btn_cut_area_(nullptr), btn_gamma_(nullptr), clicked_gamma_(false) - , custom_area_lable_(nullptr), comb_(nullptr) + , custom_area_lable_(nullptr), comb_(nullptr),m_cover(true) { std::string n(dev->opened_scanner_name()); for(int i = 0; i < dev->scanners(); ++i) @@ -1500,6 +1500,158 @@ void hg_settingdialog::closeEvent(QCloseEvent* e) e->accept(); } + +bool hg_settingdialog::createMsgBoxUi(bool add, std::string &name) +{ + QString text(tr("Please select to overwrite the original configuration:")); + text += QString::fromStdString(name); + text += tr(",or add a new configuration"); + + QDialog *dlg = new QDialog(this); + dlg->setWindowTitle(tr("save the configuration")); + QLabel *label_question = new QLabel; + label_question->setText(text); + + QRadioButton *radioButtonCover = new QRadioButton; + radioButtonCover->setText(tr("cover original configuration:") + QString::fromStdString(name)); + radioButtonCover->setChecked(true); + add = false; + QRadioButton *radioButtonNew = new QRadioButton; + radioButtonNew->setText(tr("add new configuration")); + + QHBoxLayout *hLayoutName = new QHBoxLayout; + QLabel *label_name = new QLabel; + label_name->setText(tr("rename:")); + m_lineEdit_name = new QLineEdit; + std::string name2; + m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name2))); + + QSpacerItem *spacer1 = new QSpacerItem(20, 20, QSizePolicy::Expanding); + hLayoutName->addWidget(label_name); + hLayoutName->addWidget(m_lineEdit_name); + hLayoutName->addSpacerItem(spacer1); + label_name->setVisible(false); + m_lineEdit_name->setVisible(false); + + connect(radioButtonCover, &QRadioButton::clicked, this, [=, &add, this](){ + m_cover = true; + add = false; + label_name->setVisible(false); + m_lineEdit_name->setVisible(false); + }); + connect(radioButtonNew, &QRadioButton::clicked, this, [=, &add, this](){ + m_cover = false; + add = true; + label_name->setVisible(true); + m_lineEdit_name->setVisible(true); + + m_lineEdit_name->setFocus(); + QTimer::singleShot(0, m_lineEdit_name, &QLineEdit::selectAll); + }); + + QSpacerItem *spacer2 = new QSpacerItem(20, 20, QSizePolicy::Expanding); + QPushButton *pbtnOk = new QPushButton; + pbtnOk->setText(tr("ok")); + connect(pbtnOk, &QPushButton::clicked, this, [=, &name,this](){ + QString text = m_lineEdit_name->text(); + static QRegularExpression re("\\s"); + text.remove(re);//Remove space + + name = text.toStdString(); + + if(name.empty()) + { + QMessageBox::information(this, tr("tips"), tr("scheme name cannot be empty")); + m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name))); + return; + } + + if (!m_cover) + { + std::vector now; + cur_cfg_->get_all_schemes(now); + for(auto& v: now) + { + if(v == name) + { + + QMessageBox::information(this, tr("tips"), tr("scheme name: ") + QString::fromStdString(name) + tr(" already exists")); + m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name))); + return; + } + } + } + + dlg->close(); + }); + + QHBoxLayout *hLayout_pbtnOk = new QHBoxLayout; + hLayout_pbtnOk->addSpacerItem(spacer2); + hLayout_pbtnOk->addWidget(pbtnOk); + + QVBoxLayout *vLayout = new QVBoxLayout; + vLayout->addWidget(label_question); + vLayout->addWidget(radioButtonCover); + vLayout->addWidget(radioButtonNew); + vLayout->addLayout(hLayoutName); + vLayout->addLayout(hLayout_pbtnOk); + dlg->setLayout(vLayout); + + dlg->exec(); + + return add; +} + +std::string hg_settingdialog::getCurUiShemeName(std::string name) +{ + std::string k(""), val(""); + int id = 0; + const SANE_Option_Descriptor* opt = nullptr; + + if (cur_scheme_->first_config(k, val)) + { + int count = 0; + do + { + id = cur_scheme_->id_from_name(k.c_str()); + opt = sane_get_option_descriptor(m_handle, id); + if (opt) + { + if (count++) + name += " + "; + + if (opt->type == SANE_TYPE_STRING) + name += val; + else + { + name += opt->title; + if (opt->type == SANE_TYPE_BOOL) + { + name += std::string("("); + if (*(SANE_Bool*)&val[0] == SANE_TRUE) + name += "true)"; + else + name += "false)"; + } + else if (opt->type == SANE_TYPE_INT) + { + char buf[128] = { 0 }; + sprintf(buf, "(%d)", *(int*)&val[0]); + name += buf; + } + else if (opt->type == SANE_TYPE_FIXED) + { + char buf[128] = { 0 }; + sprintf(buf, "(%.4f)", SANE_UNFIX(*(SANE_Fixed*)&val[0])); + name += buf; + } + } + } + } while (count < 3 && cur_scheme_->next_config(k, val)); + } + return name; +} + void hg_settingdialog::save_scheme(void) { std::string name(cur_scheme_->get_scheme_name()); @@ -1507,68 +1659,14 @@ void hg_settingdialog::save_scheme(void) if(add) { - std::string k(""), val(""); - int id = 0; - const SANE_Option_Descriptor* opt = nullptr; - - if(cur_scheme_->first_config(k, val)) - { - int count = 0; - do - { - id = cur_scheme_->id_from_name(k.c_str()); - opt = sane_get_option_descriptor(m_handle, id); - if(opt) - { - if(count++) - name += " + "; - - if(opt->type == SANE_TYPE_STRING) - name += val; - else { - name += opt->title; - if(opt->type == SANE_TYPE_BOOL) - { - name += std::string("("); - if(*(SANE_Bool*)&val[0] == SANE_TRUE) - name += "true)"; - else - name += "false)"; - } - else if(opt->type == SANE_TYPE_INT) - { - char buf[128] = {0}; - sprintf(buf, "(%d)", *(int*)&val[0]); - name += buf; - } - else if(opt->type == SANE_TYPE_FIXED) - { - char buf[128] = {0}; - sprintf(buf, "(%.4f)", SANE_UNFIX(*(SANE_Fixed*)&val[0])); - name += buf; - } - } - } - }while(count < 3 && cur_scheme_->next_config(k, val)); - } + name = getCurUiShemeName(name); } else { add = cur_scheme_->has_changed(); if(add) { - QString title(tr("save the configuration")); - QString text(tr("The Settings you just set are in the original configuration \"")); - - text += QString::fromStdString(name); - text += tr("\" changed on the basis,Please select overwrite this configuration or add a new one?\nYes: cover \"") + QString::fromStdString(name); - text += tr("\"\nNo: add new configuration") + QString::fromStdString(""); - - QMessageBox msg(QMessageBox::Question, title, text, QMessageBox::Yes | QMessageBox::No, this); - msg.setButtonText(QMessageBox::Yes, tr("yes")); - msg.setButtonText(QMessageBox::No, tr("no")); - msg.exec(); - add = msg.clickedButton() != msg.button(QMessageBox::Yes); + add = createMsgBoxUi(add, name); } } if(add) @@ -1603,7 +1701,8 @@ void hg_settingdialog::save_scheme(void) sprintf(append, "-%d", ++ind); } } - else { + else + { cur_scheme_->end_setting(false); } cur_cfg_->select_scheme(cur_scheme_->get_scheme_name().c_str()); @@ -1739,9 +1838,7 @@ void hg_settingdialog::slot_pushButton_scheme_management(void) { if(v == str) { - str.insert(0, "\351\205\215\347\275\256\345\220\215\347\247\260 \342\200\230"); // 配置名称‘’ - str += "\342\200\231 \345\267\262\347\273\217\345\255\230\345\234\250"; // 已经存在 - QMessageBox(QMessageBox::Information, QString::fromStdString("\351\224\231\350\257\257")/*错误*/, QString::fromStdString(str)).exec(); + QMessageBox::information(this, tr("tips"), tr("scheme name: ") + QString::fromStdString(str) + tr(" already exists")); return; } } @@ -1827,8 +1924,8 @@ void hg_settingdialog::slot_pushButton_scheme_management(void) void hg_settingdialog::restore_2_default_settings(void) { cur_scheme_->end_setting(true); - cur_cfg_->select_scheme(nullptr); dev_que_->apply_scheme(nullptr); + cur_cfg_->select_scheme(nullptr); cur_cfg_->save(); gb::sane_config_schm *s = new gb::sane_config_schm(); diff --git a/app/scanner/hg_settingdialog.h b/app/scanner/hg_settingdialog.h index f114536f..230bd0cc 100644 --- a/app/scanner/hg_settingdialog.h +++ b/app/scanner/hg_settingdialog.h @@ -1,4 +1,4 @@ -#ifndef HG_SETTING_DIALOG_H +#ifndef HG_SETTING_DIALOG_H #define HG_SETTING_DIALOG_H #include @@ -33,6 +33,7 @@ class hg_settingdialog : public QDialog QPushButton *btn_cut_area_; QPushButton *btn_gamma_; QTextEdit *sketch_; + QLineEdit *m_lineEdit_name; void create_scheme_management_ui(QVBoxLayout* layout); QString find_current_scheme_menu(int *scheme_id = nullptr); @@ -72,9 +73,10 @@ private: QString md5(QString key); const void* find_option_description(int id); // return const SANE_Option_Descriptor* pointer const void* find_option_description(const std::string& title, int* id); // return const SANE_Option_Descriptor* pointer - QVariant find_default_value(int id); virtual void closeEvent(QCloseEvent* e); + bool createMsgBoxUi(bool add, std::string &name); + std::string getCurUiShemeName(std::string name); void save_scheme(void); void cancel_setting(void); void getAppVersion(); @@ -122,6 +124,7 @@ private: double m_cutBottomValue; // 单位是毫米 int m_colorModeId; + volatile bool m_cover = true; QString m_colorModeValue; SANE_Gamma m_gammaData; QComboBox *comb_; diff --git a/app/scanner/qt_zh_CN.ts b/app/scanner/qt_zh_CN.ts index 43bf5108..83dd5348 100644 --- a/app/scanner/qt_zh_CN.ts +++ b/app/scanner/qt_zh_CN.ts @@ -8279,20 +8279,6 @@ Please choose a different file name. save the configuration - - The Settings you just set are in the original configuration " - - - - " changed on the basis,Please select overwrite this configuration or add a new one? -Yes: cover " - - - - " -No: add new configuration - - yes @@ -8369,6 +8355,42 @@ No: add new configuration configuration scheme management + + Please select to overwrite the original configuration: + + + + ,or add a new configuration + + + + cover original configuration: + + + + add new configuration + + + + rename: + + + + tips + + + + scheme name cannot be empty + + + + scheme name: + + + + already exists + + setPicClrTool