From 6a1c64a4267a84f958ea44eb8da6ab8bd47e6b6a Mon Sep 17 00:00:00 2001 From: karlis <2995621482@qq.com> Date: Mon, 20 Mar 2023 18:03:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Ctrl+=E5=B7=A6=E9=94=AE?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E7=BC=A9=E6=94=BE=EF=BC=8CC+S+=E5=B7=A6?= =?UTF-8?q?=E9=94=AE=E7=AD=89=E6=AF=94=E7=BC=A9=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Editor/PreviewWindow.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp index dbe317c..410b8af 100644 --- a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp +++ b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp @@ -1,4 +1,5 @@ #include "PreviewWindow.h" +#include PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent) { @@ -84,7 +85,17 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event) int dx = event->x() - m_lastPos.x(); int dy = event->y() - m_lastPos.y(); if (currentLayer != nullptr) { - if (event->buttons() & Qt::LeftButton) { + if (QApplication::keyboardModifiers() == Qt::ControlModifier && (event->buttons() & Qt::LeftButton)) + { + currentLayer->property.scale.setX(std::max(0.0, currentLayer->property.scale.x() + dx / 50.0)); + currentLayer->property.scale.setY(std::max(0.0, currentLayer->property.scale.y() + dy / 50.0)); + } + else if (QApplication::keyboardModifiers() == (Qt::ControlModifier | Qt::ShiftModifier) && (event->buttons() & Qt::LeftButton)) + { + currentLayer->property.scale.setX(std::max(0.0, currentLayer->property.scale.x() * (1.0 + dx / 50.0))); + currentLayer->property.scale.setY(std::max(0.0, currentLayer->property.scale.y() * (1.0 + dx / 50.0))); + } + else if (event->buttons() & Qt::LeftButton) { // 如果按下的是左键,那么平移图形 currentLayer->property.offset.setX(currentLayer->property.offset.x() + dx); currentLayer->property.offset.setY(currentLayer->property.offset.y() + dy);