添加Ctrl+左键快捷缩放,C+S+左键等比缩放
parent
f25f2d2a81
commit
6a1c64a426
|
@ -1,4 +1,5 @@
|
|||
#include "PreviewWindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue