From b7b2834564ec78f4ba78826ce4a7343ddff21565 Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Tue, 24 May 2022 13:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=90=8E=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scanner/HGImgView.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/app/scanner/HGImgView.cpp b/app/scanner/HGImgView.cpp index c34bf998..7f811e8b 100644 --- a/app/scanner/HGImgView.cpp +++ b/app/scanner/HGImgView.cpp @@ -8,6 +8,7 @@ #include "base/HGInc.h" #include "imgfmt/HGImgFmt.h" #include "HGUIGlobal.h" +#include HGImgView::HGImgView(QWidget* parent) : QWidget(parent) @@ -997,6 +998,21 @@ HGResult HGImgView::zoomIn(const HGPoint *pCenter) float fNewWidth = fCurWidth * 1.2f; float fNewHeight = fCurHeight * 1.2f; + // support 1% zoom-in when 'ctrl' pressed (added on 2022-05-24) + if(QApplication::queryKeyboardModifiers() == Qt::CTRL) + { + // 1% + fNewWidth = info.width * .01f; + if(fNewWidth < 1.0f) + fNewWidth = 1.0f; + fNewWidth += fCurWidth; + + fNewHeight = info.height * .01f; + if(fNewHeight < 1.0f) + fNewHeight = 1.0f; + fNewHeight += fCurHeight; + } + if (fabs(fMaxWidth - fCurWidth) > 1e-3 || fabs(fMaxHeight - fCurHeight) > 1e-3) { if (fNewWidth - fMaxWidth > -1e-3 || fNewHeight - fMaxHeight > -1e-3 @@ -1063,6 +1079,21 @@ HGResult HGImgView::zoomOut(const HGPoint *pCenter) float fNewWidth = fCurWidth * 1.0f / 1.2f; float fNewHeight = fCurHeight * 1.0f / 1.2f; + // support 1% zoom-out when 'ctrl' pressed (added on 2022-05-24) + if(QApplication::queryKeyboardModifiers() == Qt::CTRL) + { + // 1% + fNewWidth = info.width * .01f; + if(fNewWidth < 1.0f) + fNewWidth = 1.0f; + fNewWidth = fCurWidth - fNewWidth; + + fNewHeight = info.height * .01f; + if(fNewHeight < 1.0f) + fNewHeight = 1.0f; + fNewHeight = fCurHeight - fNewHeight; + } + if (fabs(fMinWidth - fCurWidth) > 1e-3 || fabs(fMinHeight - fCurHeight) > 1e-3) { if (fNewWidth - fMinWidth < 1e-3 || fNewHeight - fMinHeight < 1e-3