diff --git a/app/scanner/Scanner_zh_CN.qm b/app/scanner/Scanner_zh_CN.qm index d9d8d729..b8af3195 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 b1782b81..81d88145 100644 --- a/app/scanner/Scanner_zh_CN.ts +++ b/app/scanner/Scanner_zh_CN.ts @@ -2158,7 +2158,7 @@ bug description: - + act_acquireInto 扫描至... @@ -2383,49 +2383,49 @@ bug description: 文本增强 - + HuaGoScan 华高扫描软件 - + Grid 多列显示 - + Move To... 移动到... - + Insert files 插入文件 - + nodevice 没有发现扫描仪 - - - - - + + + + + Question 询问 - + modified, save it? 图像已被修改。 是否保存修改? - + file lost, remove it? 文件已丢失,是否删除? @@ -2434,7 +2434,7 @@ bug description: 已连接 - + disconnected 已断开连接 @@ -2451,17 +2451,17 @@ bug description: 扫描完成 - + Clear, then start scan 清空并启动扫描 - + Do NOT clear, then start scan 不清空并启动扫描 - + Already exist images in image list. Do you want to clear? 图像列表中已存在图像。 @@ -2476,12 +2476,12 @@ Do you want to clear? 磁盘空间不足,请删除不需要的文件,以保证有足够的空间 - + Open images 打开图片 - + Insert images 插入图片 @@ -2494,275 +2494,275 @@ Do you want to clear? 保存失败 - + binary 黑白 - + gray 256级灰度 - + rgb 24位彩色 - - - - - - - - - - - - + + + + + + + + + + + + Please wake up the device manually 请手动唤醒设备 - + UniScan 紫光扫描软件 - - + + default scheme 默认配置方案 - + thumbnailBar enabled 显示缩略图栏 - + thumbnailBar hidden 隐藏缩略图栏 - + cancel 取消 - - - + + + 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 彩色 - + Not supported 不支持 - + Warning 警告 - + Device is Running! Please finish scanning first. 设备正在运行! 请先结束扫描。 - + cache path folder limit:%1 无法访问当前缓存路径:%1 请尝试在【用户】菜单登录管理员账户,前往【缓存设置】更改缓存路径。 - + aquireinto folder limit:%1 无法访问当前缓存路径:%1 请尝试在【扫描到】更改缓存路径。 - + Image processing failed 图像处理失败 - + Ocr init failed OCR初始化错误 - + Ocr failed OCR错误 - + File does not exist 文件不存在 - + Failed to load dynamic library 加载动态库失败 - + File data error 文件数据错误 - + Image format processing error 图像格式处理错误 - + Out of memory 内存不足 - + Failed 错误 - - + + The language switch is successful and takes effect the next time the software is started! 语言切换成功,下次启动软件时生效! - + Are you sure to delete selected file? 您确定彻底删除选中项文件? - - - - - - - - - - - - + + + + + + + + + + + + already waked up device 已唤醒设备 - + be ready 就绪 @@ -2772,7 +2772,7 @@ Please finish scanning first. 请尝试在【用户】菜单登录管理员账户,前往【缓存设置】更改缓存路径 - + Insufficient access rights 文件访问权限不足 @@ -2785,46 +2785,46 @@ 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 错误 @@ -2839,17 +2839,17 @@ Continue to close? 是否继续关闭? - + Sure to sign out administrator account? 是否确定登出管理员账户? - + confirm the operation 确认操作 - + Are you sure to clear the rollor acount? 你确定要清除滚轴计数吗 @@ -2858,36 +2858,36 @@ Continue to close? 请重新进入关于界面以获取最新值 - - + + <p>%1: <a href='%2'>%3</a> - - + + <p>%1: %2 - + roller number 滚轴张数 - + open scanner 打开扫描仪 - - + + app name 华高扫描软件 - - + + success 成功 @@ -2904,22 +2904,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. 当前路径磁盘空间不足, 请重新选择路径或及时清理磁盘空间。 @@ -2929,64 +2929,64 @@ Continue to close? 配置丢失 - + apply setting 应用配置 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + + start failed 启动失败 - + HanvonScan 汉王扫描软件 - + LanxumScan 立思辰扫描软件 - + CumtennScan 沧田扫描软件 - + MicrotekScan Microtek DocWizard EX 扫描软件 - + menu_language 语言 - + act_simpCN 简体中文 - + act_English English @@ -3001,47 +3001,47 @@ Continue to close? 切换图片时,不提醒,直接保存编辑过的图片 - + statusBar displayed 显示状态栏 - + statusBar hidden 隐藏状态栏 - + toolBar displayed 显示工具栏 - + toolBar hidden 隐藏工具栏 - + colorInfo enabled 启用图像信息 - + colorInfo disenabled 关闭图像信息 - + enabling automatic saving 启用自动保存 - + cancel auto save 取消自动保存 - + Automatically save the edited the edited iamge when switching pictures. To cancel, uncheck the menu item: image-> automatically save 切换图片时,自动保存编辑过的图像。若想取消,请取消勾选菜单项:图像->自动保存 @@ -3062,26 +3062,26 @@ Continue to close? 发现设备 - + reconnected 重新连接 - + already connected, but open faild 已经连接,但打开失败 - - + + save image failed: 存图失败: - - - - + + + + create savepath failed: 创建文件夹失败: @@ -3090,102 +3090,102 @@ Continue to close? %1%2%3.%4 - - + + create image doc failed: 创建图片文件失败: - - - - - - - - - - - - - + + + + + + + + + + + + + save image doc failed: 保存图片文件失败: - + start failed! 启动安装程序失败! - + There are pictures that have not been saved. Are you sure to close? 有图像未保存,确定关闭? - + found device : %1 发现设备 : %1 - - - - - - - - - - - - - + + + + + + + + + + + + + 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. 文档丢失!文档可能已被删除或被重命名。 @@ -3226,21 +3226,21 @@ Are you sure to close? <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> @@ -3307,6 +3307,54 @@ Are you sure to close? Gamma校正 + + Widget_Imgproc_SideBar + + + Form + + + + + Ok + 确定 + + + + Cancel + 取消 + + + + Restore defaults + 恢复默认值 + + + + Enhance Text + 文本增强 + + + + Apply to image + 应用到图像 + + + + Brightness + 亮度 + + + + Gamma correction + Gamma校正 + + + + Contrast + 对比度 + + Widget_StatusBar diff --git a/app/scanner/Scanner_zh_EN.qm b/app/scanner/Scanner_zh_EN.qm index 92ff54b5..7a8106c4 100644 Binary files a/app/scanner/Scanner_zh_EN.qm and b/app/scanner/Scanner_zh_EN.qm differ diff --git a/app/scanner/Scanner_zh_EN.ts b/app/scanner/Scanner_zh_EN.ts index 6e86e597..4d8b482a 100644 --- a/app/scanner/Scanner_zh_EN.ts +++ b/app/scanner/Scanner_zh_EN.ts @@ -1993,7 +1993,7 @@ Please make sure the two passwords are the same. - + act_acquireInto Scan to... @@ -2218,64 +2218,64 @@ Please make sure the two passwords are the same. Enhance text - + HanvonScan Hanvon scanning software - + LanxumScan LANXUM scanning software - + CumtennScan CUMTENN scanning software - + MicrotekScan Microtek DocWizard EX V1.0 - + HuaGoScan HUAGOSCAN scanning software - + menu_language Language - + act_simpCN 简体中文 - + act_English English - + Grid Multi-column display - + Move To... Move to... - + Insert files Insert file - + nodevice No scanner detected @@ -2290,61 +2290,61 @@ Please make sure the two passwords are the same. Do not show prompt and save the edited images directly when switching images. - + statusBar displayed Show status bar - + statusBar hidden Hide status bar - + toolBar displayed Show toolbar - + toolBar hidden Hide toolbar - + colorInfo enabled Enable image information - + colorInfo disenabled Disable image information - + enabling automatic saving Enable auto save - + cancel auto save Cancel auto save - + Automatically save the edited the edited iamge when switching pictures. To cancel, uncheck the menu item: image-> automatically save Save edited images automatically when switching images. If you want to cancel, please deselect the menu item: Auto save images. - - - - - + + + + + Question Ask - + modified, save it? Image modified, save changes? @@ -2361,7 +2361,7 @@ Please make sure the two passwords are the same. No - + file lost, remove it? File lost; delete? @@ -2370,414 +2370,414 @@ Please make sure the two passwords are the same. Device discovered - + found device : %1 Device discovered: %1 - + reconnected reconnect - + already connected, but open faild connected, but failed to open - + disconnected disconnected - - - + + + the disk space in the current path is unsufficient, please select a new path or clear the disk space in time. Insufficient disk space for the current path. Please reselect a path or clear disk space immediately. - - - + + + warning Warning - - + + save image failed: Failed to save image: - - - - + + + + create savepath failed: Failed to create folder: - - + + create image doc failed: Failed to create image file: - - - - - - - - - - - - - + + + + + + + + + + + + + save image doc failed: Failed to save image: - + binary Black and white - + gray Grayscale - + rgb Color - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + + start failed Failed to start - + UniScan UNI scanning software - - + + default scheme Default scheme - - - - - - - - - - - - + + + + + + + + + + + + Please wake up the device manually Please wake up the device manually - - - - - - - - - - - - + + + + + + + + + + + + already waked up device Device is awake - + thumbnailBar enabled Show thumbnail bar - + thumbnailBar hidden Hide thumbnail bar - + Clear, then start scan Clear and start scan - + Do NOT clear, then start scan Do not clear and start scan - + cancel Cancel - + Already exist images in image list. Do you want to clear? Image already exists in the list of images. Clear? - + Open images Open image - + Insert images Insert image - - - - - - - - - - - - - + + + + + + + + + + + + + tips prompt - - - + + + save succeed Saved successfully - - + + find savePath in thumbnail Image name already exists in the list - + Please select at least one picture before export Please select at least one image and then export - + File name File name - + File path File path - + File size File size - + Creation date/time Creation time - + Modified date/time Modification time - + Accessed date/time Access time - + Format Format - + Width Width - + Height Height - + depth Depth - + Color model Color mode - + DPI Pixels per inch - + Print size Print size - + Frame Frame - + None None - + Mono Black and white - + Gray Gray scale - + Color Color - + Not supported Not supported - + Warning Warning - + Device is Running! Please finish scanning first. Device is currently running! Please stop scanning first. - + There are pictures that have not been saved. Are you sure to close? There are unsaved images; are you sure you want to close? - + Are you sure to close? Are you sure you want to close? - + Sure to sign out administrator account? Are you sure you want to log out of the administrator account? - + confirm operation Confirm operation - + are you sure to clear the roller count? Are you sure you want to clear the roller count? - - - + + + hint Prompt - - + + Roller scanned count has been set to 0. Roller count reset to zero. - - + + Roller scanned count reset failed. Failed to reset roller count. - + Error Error - + Document missing! It would be deleted or renamed. File lost! File may be deleted or renamed. - + confirm the operation Confirm operation - + Are you sure to clear the rollor acount? Are you sure you want to clear the roller count? - + cache path folder limit:%1 Unable to access the current path:%1 Please try to log in to the administrator account in the [User] menu and go to the [Cache settings] to change the cache path. - + aquireinto folder limit:%1 Unable to access the current path:%1 Please try to change the cache path in [Scan to]. @@ -2791,76 +2791,76 @@ Please try to change the cache path in [Scan to]. <p>%1</p><p>Version: %2<br>Copyright: &#169; %3</p><p>%4%5%6%7%8%9</p> - - + + about %1 About %1 - - + + <p>Version: %1</p> <p>Version: %1</p> - - + + <p>CopyRight: &#169; %1</p> <p>Copyright: &#169; %1</p> - - + + <p>%1: <a href='%2'>%3</a> <p>%1: <a href='%2'>%3</a> - - + + <p>%1: %2 <p>%1: %2 - + roller number Number of rollers - + open scanner Open scanner - - + + app name HUAGOSCAN scanning software - - + + success successfully - + be ready Ready - - + + failed failed - - + + error Error - + start failed! Failed to start! @@ -2870,106 +2870,106 @@ Please try to change the cache path in [Scan to]. Please go to “Scan to” and change the accessible scan folder and then perform the scan. - + Insufficient access rights Insufficient file access permissions - + Image processing failed Image processing failed - + Ocr init failed OCR initialization error - + Ocr failed OCR failed - + File does not exist File does not exist - + Failed to load dynamic library Failed to load dynamic library - + File data error File data error - + Image format processing error Image format processing error - + Out of memory Insufficient memory - + Failed Failed - + apply setting Apply configuration - + Are you sure to close Are you sure you want to disconnect device: - + ? ? - - + + close Close - + tip Prompt - + Other versions not available No other versions obtained - - + + The device does not support this operation Device does not support this operation - - + + IO error IO error - - + + The language switch is successful and takes effect the next time the software is started! The language switch is successful and takes effect the next time the software is started! - + Are you sure to delete selected file? Are you sure to delete the selected file completely? @@ -3023,6 +3023,54 @@ Please go to “Scan to” and change the accessible scan folder and then perfor Gamma correction + + Widget_Imgproc_SideBar + + + Form + + + + + Ok + OK + + + + Cancel + Cancel + + + + Restore defaults + Restore defaults + + + + Enhance Text + Enhance text + + + + Apply to image + Apply to image + + + + Brightness + Brightness + + + + Gamma correction + Gamma correction + + + + Contrast + Contrast + + Widget_StatusBar diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index 011d2620..20e482d3 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -82,6 +82,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent) , m_currDeviceName("") , m_cacheDirNotify(false) , m_AquirePathNotify(false) + , m_bSideflag(false) { ui->setupUi(this); @@ -333,6 +334,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent) m_menu_imageInsert->addAction(ui->act_insertFromScanner); ui->act_consume->setVisible(false); + ui->act_enhanceText->setVisible(false); connect(this, SIGNAL(sane_dev_arrive(QString, bool)), this, SLOT(on_sane_dev_arrive(QString, bool)), Qt::QueuedConnection); connect(this, SIGNAL(sane_dev_remove(QString)), this, SLOT(on_sane_dev_remove(QString)), Qt::QueuedConnection); @@ -371,7 +373,6 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent) m_dlgFullScreen = nullptr; m_dialogLog->updateStatus(!dev_que_.opened_scanner_name().empty() && 0 != m_scanType, m_isScanning); - updateActionStatus(); ui->act_autoSave->setChecked(getCfgValue("save", "autoSave", false)); #if defined(OEM_LISICHENG) @@ -389,6 +390,18 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent) m_vFwUpgradeAndDevLock.clear(); m_threadFwUpgradeAndDevLock = nullptr; + m_pbtn_push = new QPushButton(this); + m_pbtn_push->setText("<<"); + m_pbtn_push->setGeometry(0, 0, 25, 50); + m_widget_sideBar = new Widget_Imgproc_SideBar(this); + + connect(m_pbtn_push, SIGNAL(clicked()), this, SLOT(on_m_pbtn_push_clicked())); + connect(m_widget_sideBar, SIGNAL(applyToImage(HGImage,int,int,double)), this, SLOT(on_dialog_sideBar_applyToImage(HGImage,int,int,double))); + connect(m_widget_sideBar, SIGNAL(finish()), this, SLOT(on_dialog_sideBar_finish())); + + updateSideBar(); + updateActionStatus(); + SANE_Int v = 0; sane_init_ex(&v, sane_ex_callback, this); } @@ -848,6 +861,16 @@ void MainWindow::on_currItemChanged(int index) m_modify = false; } + if (m_widget_sideBar != nullptr) + { + HGImage curImage = nullptr; + m_view->getImage(&curImage); + if (curImage != nullptr) + { + m_widget_sideBar->getCurrentImg(curImage); + } + } + int count = 0; m_thumb->getItemCount(&count); m_wndStatusBar->setPageInfo(count, m_currIndex); @@ -1583,6 +1606,61 @@ void MainWindow::on_wrong_image_decide(dialog_wrong_img* dlg, bool save) delete dlg; } +void MainWindow::on_m_pbtn_push_clicked() +{ + int mainWndWidth = this->rect().width(); + int mainWndHeight = this->rect().height(); + int sideBarWidth = m_widget_sideBar->getWidth(); + int sideBarHeight = m_widget_sideBar->getHeight(); + + if(!m_bSideflag) + { + m_propertyAnimation->setStartValue(QRect(mainWndWidth, mainWndHeight/2 - sideBarHeight/2, sideBarWidth, sideBarHeight)); + m_propertyAnimation->setEndValue(QRect(mainWndWidth - sideBarWidth, mainWndHeight/2 - sideBarHeight/2, sideBarWidth, sideBarHeight)); + m_propertyAnimation->start(); + m_propertyAnimation2->setStartValue(QRect(mainWndWidth - m_pbtn_push->width(), mainWndHeight/2 - m_pbtn_push->height()/2, m_pbtn_push->width(), m_pbtn_push->height())); + m_propertyAnimation2->setEndValue(QRect(mainWndWidth - m_pbtn_push->width() - sideBarWidth, mainWndHeight/2 - m_pbtn_push->height()/2, m_pbtn_push->width(), m_pbtn_push->height())); + m_propertyAnimation2->start(); + m_pbtn_push->setText(">>"); + m_bSideflag = !m_bSideflag; + } + else + { + m_propertyAnimation->setStartValue(QRect(mainWndWidth - sideBarWidth, mainWndHeight/2 - sideBarHeight/2,sideBarWidth, sideBarHeight)); + m_propertyAnimation->setEndValue(QRect(mainWndWidth, mainWndHeight/2 - sideBarHeight/2, sideBarWidth, sideBarHeight)); + m_propertyAnimation->start(); + m_propertyAnimation2->setStartValue(QRect(mainWndWidth - m_pbtn_push->width() - sideBarWidth, mainWndHeight/2 - m_pbtn_push->height()/2, m_pbtn_push->width(), m_pbtn_push->height())); + m_propertyAnimation2->setEndValue(QRect(mainWndWidth - m_pbtn_push->width(), mainWndHeight/2 - m_pbtn_push->height()/2, m_pbtn_push->width(), m_pbtn_push->height())); + m_propertyAnimation2->start(); + m_pbtn_push->setText("<<"); + m_bSideflag = !m_bSideflag; + } +} + +void MainWindow::on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma) +{ + assert(nullptr != img); + + HGImageInfo imgInfo; + HGBase_GetImageInfo(img, &imgInfo); + + HGImage destImg = nullptr; + HGBase_CreateImage(imgInfo.width, imgInfo.height, imgInfo.type, imgInfo.origin, &destImg); + if (nullptr != destImg) + { + HGImgProc_ImageAdjustColors(img, destImg, brightness, contrast, (HGFloat)gamma); + m_view->addImage(destImg); + HGBase_DestroyImage(destImg); + updateStatusBarPixelInfo(); + } +} + +void MainWindow::on_dialog_sideBar_finish() +{ + emit m_pbtn_push->clicked(); + m_modify = true; +} + void MainWindow::on_act_thumbnailBar_triggered(bool checked) { ui->dockWidget->setVisible(checked); @@ -1847,6 +1925,11 @@ void MainWindow::updateActionStatus() m_dialogLog->pbtn_export->setEnabled(ui->act_Export->isEnabled()); m_moveToAction->setEnabled(!selectIndexs.empty() && (!dev_que_.is_online() || !m_isScanning)); + if (m_pbtn_push != nullptr && m_widget_sideBar!= nullptr) + { + m_pbtn_push->setVisible(nullptr != img); + m_widget_sideBar->setVisible(nullptr != img); + } } void MainWindow::startSaveMessageBox(QWidget* parent) @@ -2704,6 +2787,26 @@ void MainWindow::closeEvent(QCloseEvent *e) m_versionDll->PostUserCloseInfo(HGVERSION_APPNAME_SCANNER, m_oemName); } +void MainWindow::resizeEvent(QResizeEvent *e) +{ + (void)e; + + if (m_bSideflag) + { + int mainWndWidth = this->rect().width(); + int mainWndHeight = this->rect().height(); + int sideBarWidth = m_widget_sideBar->getWidth(); + int sideBarHeight = m_widget_sideBar->getHeight(); + + m_widget_sideBar->move(mainWndWidth - sideBarWidth, mainWndHeight/2 - sideBarHeight/2); + m_pbtn_push->move(mainWndWidth - m_pbtn_push->width() - sideBarWidth, mainWndHeight/2 - m_pbtn_push->height()/2); + } + else + { + updateSideBar(); + } +} + int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int* len, void *param) { (void)hdev; @@ -4404,6 +4507,23 @@ void MainWindow::initAcquireIntoComboBox() connect(m_cbtn_acquireIntoCfg, SIGNAL(currentTextChanged(QString)), this, SLOT(on_m_acquireIntoCfg_changed(QString))); } +void MainWindow::updateSideBar() +{ + int mainWndWidth = this->rect().width(); + int mainWndHeight = this->rect().height(); + int sideBarHeight = m_widget_sideBar->getHeight(); + + m_widget_sideBar->move(mainWndWidth, mainWndHeight/2 - sideBarHeight/2); + m_pbtn_push->move(mainWndWidth - m_pbtn_push->width(), mainWndHeight/2 - m_pbtn_push->height()/2); + + m_propertyAnimation = new QPropertyAnimation(m_widget_sideBar, "geometry"); + m_propertyAnimation->setEasingCurve(QEasingCurve::InOutSine); + m_propertyAnimation->setDuration(600); + m_propertyAnimation2 = new QPropertyAnimation(m_pbtn_push, "geometry"); + m_propertyAnimation2->setEasingCurve(QEasingCurve::InOutSine); + m_propertyAnimation2->setDuration(600); +} + void MainWindow::on_scanOptions_changed(const QString &device, const QString &option, bool checked_now) { QString title(tr("app name")); diff --git a/app/scanner/mainwindow.h b/app/scanner/mainwindow.h index 4497c43a..d1b133e0 100644 --- a/app/scanner/mainwindow.h +++ b/app/scanner/mainwindow.h @@ -6,10 +6,13 @@ #include #include #include +#include #include "HGImgView.h" #include "HGImgThumb.h" #include "sane/sane_ex.h" #include "dialog_aquireinto.h" +#include "widget_imgproc_base.h" +#include "widget_imgproc_sidebar.h" #include "imgfmt/HGImgFmt.h" #include "VersionDll.h" #include "device_menu.h" @@ -155,6 +158,9 @@ private slots: void on_stopScan(); void on_statusInfoDblClick(); void on_wrong_image_decide(dialog_wrong_img* dlg, bool save); + void on_m_pbtn_push_clicked(); + void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma); + void on_dialog_sideBar_finish(); void on_act_thumbnailBar_triggered(bool checked); @@ -255,6 +261,7 @@ public slots: protected: virtual void closeEvent(QCloseEvent *e) override; + virtual void resizeEvent(QResizeEvent *e) override; private: static int sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int* len, void *param); @@ -281,6 +288,7 @@ private: void deleteUpgradePkg(const QString& cfgFilePath); QString getDevPid(); void initAcquireIntoComboBox(); + void updateSideBar(); private: Ui::MainWindow *ui; @@ -300,6 +308,10 @@ private: QMenu *m_menu_language; QAction *m_act_simpCN; QAction *m_act_English; + QPushButton *m_pbtn_push; + Widget_Imgproc_SideBar *m_widget_sideBar; + QPropertyAnimation *m_propertyAnimation; + QPropertyAnimation *m_propertyAnimation2; dev_que dev_que_; @@ -352,6 +364,7 @@ private: const char* m_oemName; bool m_cacheDirNotify; bool m_AquirePathNotify; + bool m_bSideflag; // 固件升级和设备锁定 std::vector m_vFwUpgradeAndDevLock; diff --git a/app/scanner/widget_imgproc_sidebar.cpp b/app/scanner/widget_imgproc_sidebar.cpp new file mode 100644 index 00000000..fa6e6b1e --- /dev/null +++ b/app/scanner/widget_imgproc_sidebar.cpp @@ -0,0 +1,179 @@ +#include "widget_imgproc_sidebar.h" +#include "ui_widget_imgproc_sidebar.h" +#include +#include +#include "app_cfg.h" + +Widget_Imgproc_SideBar::Widget_Imgproc_SideBar(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget_Imgproc_SideBar) + , m_curImage(NULL) +{ + ui->setupUi(this); + updateUiStatus(); + + connect(ui->slider_brightness, SIGNAL(valueChanged(int)), ui->spin_brightness, SLOT(setValue(int))); + connect(ui->slider_contrast, SIGNAL(valueChanged(int)), ui->spin_contrast, SLOT(setValue(int))); +} + +Widget_Imgproc_SideBar::~Widget_Imgproc_SideBar() +{ + if (m_curImage != nullptr) + { + HGBase_DestroyImage(m_curImage); + } + delete ui; +} + +int Widget_Imgproc_SideBar::getWidth() +{ + return this->width(); +} + +int Widget_Imgproc_SideBar::getHeight() +{ + return this->height(); +} + +void Widget_Imgproc_SideBar::getCurrentImg(HGImage image) +{ + HGImageInfo imgInfo; + HGBase_GetImageInfo(image, &imgInfo); + HGBase_CloneImage(image, imgInfo.type, HGBASE_IMGORIGIN_TOP, &m_curImage); + if (NULL == m_curImage) + { + HGBase_DestroyImage(m_curImage); + return; + } +} + +void Widget_Imgproc_SideBar::setBrightness(int brightness) +{ + ui->spin_brightness->setValue(brightness); +} + +void Widget_Imgproc_SideBar::setContrast(int contrast) +{ + ui->spin_contrast->setValue(contrast); +} + +void Widget_Imgproc_SideBar::setGamma(double gamma) +{ + ui->dspin_gamma->setValue(gamma); +} + +void Widget_Imgproc_SideBar::paintEvent(QPaintEvent *e) +{ + (void)e; + QPainter p(this); + p.fillRect(0, 0, this->width(), this->height(), qRgb(240, 240, 240)); + p.setPen(QColor("gray")); + p.drawRect(0, 0, width() -1, height() -1); +} + +void Widget_Imgproc_SideBar::updateUiStatus() +{ + ui->checkBox_apply->setChecked(getCfgValue("sideBar", "applyImg", true)); + ui->checkBox_enhanceText->setChecked(getCfgValue("sideBar", "enhanceText", false)); + ui->spin_brightness->setValue(getCfgValue("sideBar", "brightness", 0)); + ui->spin_contrast->setValue(getCfgValue("sideBar", "contrast", 0)); + + QString strGamma = getCfgValue("sideBar", "gamma", QString("1.0")); + double gamma = atof(strGamma.toStdString().c_str()); + ui->dspin_gamma->setValue(gamma); +} + +void Widget_Imgproc_SideBar::on_spin_brightness_valueChanged(int arg1) +{ + ui->slider_brightness->setValue(arg1); + if(ui->checkBox_apply->isChecked()) + emit applyToImage(m_curImage, arg1, ui->spin_contrast->value(), ui->dspin_gamma->value()); +} + +void Widget_Imgproc_SideBar::on_spin_contrast_valueChanged(int arg1) +{ + ui->slider_contrast->setValue(arg1); + if(ui->checkBox_apply->isChecked()) + emit applyToImage(m_curImage, ui->spin_brightness->value(), arg1, ui->dspin_gamma->value()); +} + +void Widget_Imgproc_SideBar::on_dspin_gamma_valueChanged(double arg1) +{ + ui->slider_gamma->setValue(static_cast(arg1 * 100)); + if(ui->checkBox_apply->isChecked()) + emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), arg1); +} + +void Widget_Imgproc_SideBar::on_slider_gamma_valueChanged(int value) +{ + ui->dspin_gamma->setValue(static_cast(value / 100.0)); +} + +void Widget_Imgproc_SideBar::on_checkBox_apply_toggled(bool checked) +{ + if(checked) + emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), ui->dspin_gamma->value()); +} + +void Widget_Imgproc_SideBar::on_pbtn_restoreDefault_clicked() +{ + ui->spin_brightness->setValue(0); + ui->spin_contrast->setValue(0); + ui->dspin_gamma->setValue(1.0); + ui->checkBox_apply->setChecked(true); + ui->checkBox_enhanceText->setChecked(false); + if(ui->checkBox_apply->isChecked()) + emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), ui->dspin_gamma->value()); +} + +void Widget_Imgproc_SideBar::on_pbtn_ok_clicked() +{ + saveCfgValue("sideBar", "applyImg", ui->checkBox_apply->isChecked()); + saveCfgValue("sideBar", "enhanceText", ui->checkBox_enhanceText->isChecked()); + + saveCfgValue("sideBar", "brightness", ui->spin_brightness->value()); + saveCfgValue("sideBar", "contrast", ui->spin_contrast->value()); + char gamma[32]; + sprintf(gamma, "%f", ui->dspin_gamma->value()); + saveCfgValue("sideBar", "gamma", QString(gamma)); + + if (ui->checkBox_enhanceText->isChecked()) + { + HGUInt xDpi = 0; + HGUInt yDpi = 0; + HGBase_GetImageDpi(m_curImage, &xDpi, &yDpi); + + HGImageInfo imgInfo; + HGBase_GetImageInfo(m_curImage, &imgInfo); + HGUInt width = imgInfo.width; + HGUInt height = imgInfo.height; + + HGImage destImage = nullptr; + HGBase_CreateImage(width, height, imgInfo.type, HGBASE_IMGORIGIN_TOP, &destImage); + if (NULL == destImage) + { + HGBase_DestroyImage(destImage); + return; + } + + HGImgProc_ImageBinarization(m_curImage, destImage, HGIMGPROC_THRESHTYPE_BINARY, 40, 51, 41); + if (nullptr != destImage) + { + HGBase_SetImageDpi(destImage, xDpi, yDpi); + emit applyToImage(destImage, ui->spin_brightness->value(), ui->spin_contrast->value(), ui->dspin_gamma->value()); + HGBase_DestroyImage(destImage); + } + } + else + { + emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), ui->dspin_gamma->value()); + } + + emit finish(); +} + +void Widget_Imgproc_SideBar::on_pbtn_cancel_clicked() +{ + updateUiStatus(); + emit finish(); +} diff --git a/app/scanner/widget_imgproc_sidebar.h b/app/scanner/widget_imgproc_sidebar.h new file mode 100644 index 00000000..d01faafb --- /dev/null +++ b/app/scanner/widget_imgproc_sidebar.h @@ -0,0 +1,60 @@ +#ifndef WIDGET_IMGPROC_SIDEBAR_H +#define WIDGET_IMGPROC_SIDEBAR_H + +#include +#include "imgproc/HGImgProc.h" + +namespace Ui { +class Widget_Imgproc_SideBar; +} + +class Widget_Imgproc_SideBar : public QWidget +{ + Q_OBJECT + +public: + explicit Widget_Imgproc_SideBar(QWidget *parent = nullptr); + ~Widget_Imgproc_SideBar(); + + int getWidth(); + int getHeight(); + void getCurrentImg(HGImage image); + + void setBrightness(int brightness); + void setContrast(int contrast); + void setGamma(double gamma); + +protected: + void paintEvent(QPaintEvent *e) override; + +private: + void updateUiStatus(); + +signals: + void applyToImage(HGImage img, int brightness, int contrast, double gamma); + void finish(); + +private slots: + void on_spin_brightness_valueChanged(int arg1); + + void on_spin_contrast_valueChanged(int arg1); + + void on_dspin_gamma_valueChanged(double arg1); + + void on_slider_gamma_valueChanged(int value); + + void on_checkBox_apply_toggled(bool checked); + + void on_pbtn_restoreDefault_clicked(); + + void on_pbtn_ok_clicked(); + + void on_pbtn_cancel_clicked(); + +private: + Ui::Widget_Imgproc_SideBar *ui; + + HGImage m_curImage; +}; + +#endif // WIDGET_IMGPROC_SIDEBAR_H diff --git a/app/scanner/widget_imgproc_sidebar.ui b/app/scanner/widget_imgproc_sidebar.ui new file mode 100644 index 00000000..2ef88da3 --- /dev/null +++ b/app/scanner/widget_imgproc_sidebar.ui @@ -0,0 +1,390 @@ + + + Widget_Imgproc_SideBar + + + + 0 + 0 + 220 + 427 + + + + Form + + + + + 60 + 380 + 75 + 23 + + + + Ok + + + + + + 140 + 380 + 75 + 23 + + + + Cancel + + + + + + 10 + 330 + 152 + 25 + + + + + + + Restore defaults + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 10 + 250 + 143 + 22 + + + + + + + Enhance Text + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 10 + 290 + 155 + 22 + + + + + + + Apply to image + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 10 + 10 + 201 + 71 + + + + Brightness + + + + + 10 + 35 + 121 + 27 + + + + + 121 + 27 + + + + -255 + + + 255 + + + 0 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 32 + + + + + + 140 + 40 + 51 + 20 + + + + + 0 + 0 + + + + + 51 + 20 + + + + -255 + + + 255 + + + 0 + + + 10 + + + + + + + 10 + 170 + 201 + 71 + + + + Gamma correction + + + + + 10 + 35 + 121 + 27 + + + + + 121 + 27 + + + + 1 + + + 500 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 25 + + + + + + 140 + 40 + 51 + 20 + + + + + 0 + 0 + + + + + 51 + 20 + + + + 0.010000000000000 + + + 5.000000000000000 + + + 0.010000000000000 + + + 1.000000000000000 + + + + + + + 10 + 90 + 201 + 71 + + + + Contrast + + + + + 10 + 34 + 121 + 27 + + + + + 121 + 27 + + + + -127 + + + 127 + + + 0 + + + Qt::Horizontal + + + false + + + false + + + QSlider::TicksAbove + + + 16 + + + + + + 140 + 40 + 51 + 20 + + + + + 0 + 0 + + + + + 51 + 20 + + + + -127 + + + 127 + + + 0 + + + 10 + + + + + + + diff --git a/build2/qt/HGScanner/HGScanner.pro b/build2/qt/HGScanner/HGScanner.pro index f702ee6f..23ada6e0 100644 --- a/build2/qt/HGScanner/HGScanner.pro +++ b/build2/qt/HGScanner/HGScanner.pro @@ -246,6 +246,7 @@ SOURCES += \ ../../../app/scanner/widget.cpp \ ../../../app/scanner/widget_imgproc_base.cpp \ ../../../app/scanner/widget_statusbar.cpp \ + ../../../app/scanner/widget_imgproc_sidebar.cpp \ ../../../utility/HGString.cpp HEADERS += \ @@ -297,6 +298,7 @@ HEADERS += \ ../../../app/scanner/widget.h \ ../../../app/scanner/widget_imgproc_base.h \ ../../../app/scanner/widget_statusbar.h \ + ../../../app/scanner/widget_imgproc_sidebar.h \ ../../../utility/HGString.h FORMS += \ @@ -333,7 +335,8 @@ FORMS += \ ../../../app/scanner/setpicclrtool.ui \ ../../../app/scanner/widget.ui \ ../../../app/scanner/widget_imgproc_base.ui \ - ../../../app/scanner/widget_statusbar.ui + ../../../app/scanner/widget_statusbar.ui \ + ../../../app/scanner/widget_imgproc_sidebar.ui RESOURCES += \ ../../../app/scanner/Scanner_resource.qrc