forked from qt-creator/qt-creator
ScreenRecorder: Make Selection not movable if fully selected
Change-Id: I0f2737fdaef44a649a3e1576554f0abcd304c272 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -59,6 +59,15 @@ void CropScene::initMouseInteraction(const QPoint &imagePos)
|
||||
return inRange;
|
||||
};
|
||||
|
||||
static const auto inMoveArea = [this, &imagePos] {
|
||||
const qreal minRatio = 0.25; // 25% width / height of selection
|
||||
const int minAbsoluteSize = 40;
|
||||
QRect result(0, 0, qMax(int(m_cropRect.width() * minRatio), minAbsoluteSize),
|
||||
qMax(int(m_cropRect.height() * minRatio), minAbsoluteSize));
|
||||
result.moveCenter(m_cropRect.center());
|
||||
return result.contains(imagePos);
|
||||
};
|
||||
|
||||
m_mouse.clickOffset = {};
|
||||
if (inGripRange(imagePos.x(), m_cropRect.left(), m_mouse.clickOffset.rx())) {
|
||||
m_mouse.margin = EdgeLeft;
|
||||
@@ -72,7 +81,7 @@ void CropScene::initMouseInteraction(const QPoint &imagePos)
|
||||
} else if (inGripRange(imagePos.y(), m_cropRect.bottom(), m_mouse.clickOffset.ry())) {
|
||||
m_mouse.margin = EdgeBottom;
|
||||
m_mouse.cursorShape = Qt::SizeVerCursor;
|
||||
} else if (const QRect hoverArea = moveHoverArea(); hoverArea.contains(imagePos)) {
|
||||
} else if (!fullySelected() && inMoveArea()) {
|
||||
m_mouse.margin = Move;
|
||||
m_mouse.cursorShape = Qt::SizeAllCursor;
|
||||
m_mouse.clickOffset = imagePos - m_cropRect.topLeft();
|
||||
@@ -129,16 +138,6 @@ QPoint CropScene::toImagePos(const QPoint &widgetPos) const
|
||||
return {(widgetPos.x() - lineWidth) * dpr, (widgetPos.y() - lineWidth) * dpr};
|
||||
}
|
||||
|
||||
QRect CropScene::moveHoverArea() const
|
||||
{
|
||||
const qreal minRatio = 0.3; // 30% width / height of selection
|
||||
const int minAbsoluteSize = 40;
|
||||
QRect result(0, 0, qMax(int(m_cropRect.width() * minRatio), minAbsoluteSize),
|
||||
qMax(int(m_cropRect.height() * minRatio), minAbsoluteSize));
|
||||
result.moveCenter(m_cropRect.center());
|
||||
return result;
|
||||
}
|
||||
|
||||
QRect CropScene::cropRect() const
|
||||
{
|
||||
return m_cropRect;
|
||||
|
||||
@@ -52,7 +52,6 @@ private:
|
||||
void initMouseInteraction(const QPoint &pos);
|
||||
void updateBuffer();
|
||||
QPoint toImagePos(const QPoint &widgetCoordinate) const;
|
||||
QRect moveHoverArea() const;
|
||||
|
||||
const static int m_gripWidth = 8;
|
||||
QRect m_cropRect;
|
||||
|
||||
Reference in New Issue
Block a user