Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
@@ -51,6 +51,7 @@ CaptureWidget::CaptureWidget(uint id,
|
||||
, m_mouseIsClicked(false)
|
||||
, m_newSelection(true)
|
||||
, m_grabbing(false)
|
||||
, m_movingSelection(false)
|
||||
, m_captureDone(false)
|
||||
, m_previewEnabled(true)
|
||||
, m_adjustmentButtonPressed(false)
|
||||
@@ -586,25 +587,7 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
m_buttonHandler->hide();
|
||||
}
|
||||
QRect inputRect;
|
||||
if (m_newSelection) {
|
||||
// Drawing a new selection
|
||||
inputRect = symmetryMod
|
||||
? QRect(m_dragStartPoint * 2 - m_context.mousePos,
|
||||
m_context.mousePos)
|
||||
: QRect(m_dragStartPoint, m_context.mousePos);
|
||||
|
||||
} else if (m_mouseOverHandle == SelectionWidget::NO_SIDE) {
|
||||
// Moving the whole selection
|
||||
if (m_adjustmentButtonPressed || activeToolObject().isNull()) {
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
QRect initialRect = m_selection->savedGeometry().normalized();
|
||||
QPoint newTopLeft =
|
||||
initialRect.topLeft() + (e->pos() - m_dragStartPoint);
|
||||
inputRect = QRect(newTopLeft, initialRect.size());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (m_mouseOverHandle != SelectionWidget::NO_SIDE) {
|
||||
// Dragging a handle
|
||||
inputRect = m_selection->savedGeometry();
|
||||
QPoint offset = e->pos() - m_dragStartPoint;
|
||||
@@ -647,6 +630,27 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
r.setLeft(r.left() - offset.x());
|
||||
}
|
||||
}
|
||||
} else if (!m_movingSelection &&
|
||||
(!m_selection->geometry().contains(e->pos()) ||
|
||||
m_newSelection)) {
|
||||
m_newSelection = true;
|
||||
// Drawing a new selection
|
||||
inputRect = symmetryMod
|
||||
? QRect(m_dragStartPoint * 2 - m_context.mousePos,
|
||||
m_context.mousePos)
|
||||
: QRect(m_dragStartPoint, m_context.mousePos);
|
||||
} else if (m_mouseOverHandle == SelectionWidget::NO_SIDE) {
|
||||
// Moving the whole selection
|
||||
m_movingSelection = true;
|
||||
if (m_adjustmentButtonPressed || activeToolObject().isNull()) {
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
QRect initialRect = m_selection->savedGeometry().normalized();
|
||||
QPoint newTopLeft =
|
||||
initialRect.topLeft() + (e->pos() - m_dragStartPoint);
|
||||
inputRect = QRect(newTopLeft, initialRect.size());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_selection->setGeometry(inputRect.intersected(rect()).normalized());
|
||||
update();
|
||||
@@ -744,6 +748,7 @@ void CaptureWidget::mouseReleaseEvent(QMouseEvent* e)
|
||||
m_mouseIsClicked = false;
|
||||
m_activeToolIsMoved = false;
|
||||
m_grabbing = false;
|
||||
m_movingSelection = false;
|
||||
if (m_selection->isVisible()) {
|
||||
m_newSelection = false;
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ private:
|
||||
bool m_mouseIsClicked;
|
||||
bool m_newSelection;
|
||||
bool m_grabbing;
|
||||
bool m_movingSelection;
|
||||
bool m_showInitialMsg;
|
||||
bool m_captureDone;
|
||||
bool m_previewEnabled;
|
||||
|
||||
Reference in New Issue
Block a user