fix: 解决bug84933

Description: 增加了快捷键进行缩放

Log: 快捷键进行缩放
Bug: https://pms.uniontech.com/zentao/bug-view-84933.html
Change-Id: I81231f31f94acbacf0ded7ccbe3965161d9bb9cf
This commit is contained in:
liuminghang 2021-06-23 17:22:48 +08:00
parent 2036239a4f
commit 558274fd80
2 changed files with 31 additions and 4 deletions

View File

@ -14,6 +14,7 @@
#include <QMutexLocker>
#include <QSplitter>
#include <QTimer>
#include <QShortcut>
#include <DGuiApplicationHelper>
#include <DMainWindow>
@ -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) {

View File

@ -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 &);