From 558274fd80b0ac3351ccce9172f19646e304c8ed Mon Sep 17 00:00:00 2001 From: liuminghang Date: Wed, 23 Jun 2021 17:22:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3bug84933?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 增加了快捷键进行缩放 Log: 快捷键进行缩放 Bug: https://pms.uniontech.com/zentao/bug-view-84933.html Change-Id: I81231f31f94acbacf0ded7ccbe3965161d9bb9cf --- src/mainwidget.cpp | 24 ++++++++++++++++++++++++ src/mainwidget.h | 11 +++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/mainwidget.cpp b/src/mainwidget.cpp index 53a3310..0af882a 100644 --- a/src/mainwidget.cpp +++ b/src/mainwidget.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -193,6 +194,7 @@ void MainWidget::setupUi(QWidget *Widget) void MainWidget::setupConnect() { + initShortcut(); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::paletteTypeChanged, this, &MainWidget::setIcons); connect(m_exportBtn, &DIconButton::clicked, this, &MainWidget::slotExport); connect(m_copyBtn, &DIconButton::clicked, this, &MainWidget::slotCopy); @@ -258,6 +260,28 @@ void MainWidget::loadingUi() } } +void MainWidget::initShortcut() +{ + m_scAddView = new QShortcut(QKeySequence("Ctrl++"), this); + m_scAddView->setContext(Qt::WindowShortcut); + connect(m_scAddView, &QShortcut::activated, this, [ = ] { + if (m_imageview) + { + m_imageview->setScaleValue(1.1); + } + }); + + m_scReduceView = new QShortcut(QKeySequence("Ctrl+-"), this); + m_scReduceView->setContext(Qt::WindowShortcut); + connect(m_scReduceView, &QShortcut::activated, this, [ = ] { + if (m_imageview) + { + m_imageview->setScaleValue(0.9); + } + }); + +} + void MainWidget::openImage(const QString &path) { if (m_imageview) { diff --git a/src/mainwidget.h b/src/mainwidget.h index bb1f146..0ea2fef 100644 --- a/src/mainwidget.h +++ b/src/mainwidget.h @@ -21,7 +21,7 @@ class QGridLayout; class QHBoxLayout; class ImageView; class loadingWidget; - +class QShortcut; DWIDGET_USE_NAMESPACE class MainWidget : public DWidget @@ -39,10 +39,11 @@ public: void createLoadingUi(); void deleteLoadingUi(); void loadingUi(); + //初始化快捷键 + void initShortcut(); - - void openImage(const QString &path ); - void openImage(const QImage &img,const QString & name=""); + void openImage(const QString &path); + void openImage(const QImage &img, const QString &name = ""); void loadHtml(const QString &html); void loadString(const QString &string); @@ -84,6 +85,8 @@ private: DStackedWidget *m_resultWidget{nullptr}; DLabel *m_noResult{nullptr}; loadingWidget *m_loadingOcr{nullptr}; + QShortcut *m_scAddView = nullptr; + QShortcut *m_scReduceView = nullptr; signals: void sigResult(const QString &);