From 4bad76d8762726ea5c6302c6d511971b9c99fe2b Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sun, 18 May 2025 13:00:43 +0700 Subject: [PATCH] Where did my pre-commit hook go? --- python/PyQt6/core/auto_additions/qgis.py | 8 ++++ python/PyQt6/core/auto_generated/qgis.sip.in | 4 ++ python/core/auto_additions/qgis.py | 8 ++++ python/core/auto_generated/qgis.sip.in | 4 ++ src/gui/layout/qgslayoutmousehandles.cpp | 2 +- src/gui/qgsgraphicsviewmousehandles.cpp | 46 ++++++++++---------- src/gui/qgsgraphicsviewmousehandles.h | 6 +-- 7 files changed, 51 insertions(+), 27 deletions(-) diff --git a/python/PyQt6/core/auto_additions/qgis.py b/python/PyQt6/core/auto_additions/qgis.py index 1fab43f0c58..d04002e5503 100644 --- a/python/PyQt6/core/auto_additions/qgis.py +++ b/python/PyQt6/core/auto_additions/qgis.py @@ -11505,6 +11505,10 @@ Qgis.MouseHandlesAction.ResizeLeftUp.__doc__ = "Resize left up (Top left handle) Qgis.MouseHandlesAction.ResizeRightUp.__doc__ = "Resize right up (Top right handle)" Qgis.MouseHandlesAction.ResizeLeftDown.__doc__ = "Resize left down (Bottom left handle)" Qgis.MouseHandlesAction.ResizeRightDown.__doc__ = "Resize right down (Bottom right handle)" +Qgis.MouseHandlesAction.RotateLeftUp.__doc__ = "Rotate left up (Top left handle)" +Qgis.MouseHandlesAction.RotateRightUp.__doc__ = "Rotate right up (Top right handle)" +Qgis.MouseHandlesAction.RotateLeftDown.__doc__ = "Rotate left up (Bottom left handle)" +Qgis.MouseHandlesAction.RotateRightDown.__doc__ = "Rotate right up (Bottom right handle)" Qgis.MouseHandlesAction.SelectItem.__doc__ = "Select item" Qgis.MouseHandlesAction.NoAction.__doc__ = "No action" Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles @@ -11520,6 +11524,10 @@ Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles * ``ResizeRightUp``: Resize right up (Top right handle) * ``ResizeLeftDown``: Resize left down (Bottom left handle) * ``ResizeRightDown``: Resize right down (Bottom right handle) +* ``RotateLeftUp``: Rotate left up (Top left handle) +* ``RotateRightUp``: Rotate right up (Top right handle) +* ``RotateLeftDown``: Rotate left up (Bottom left handle) +* ``RotateRightDown``: Rotate right up (Bottom right handle) * ``SelectItem``: Select item * ``NoAction``: No action diff --git a/python/PyQt6/core/auto_generated/qgis.sip.in b/python/PyQt6/core/auto_generated/qgis.sip.in index a7748c6625d..c0e04078dae 100644 --- a/python/PyQt6/core/auto_generated/qgis.sip.in +++ b/python/PyQt6/core/auto_generated/qgis.sip.in @@ -3347,6 +3347,10 @@ The development version ResizeRightUp, ResizeLeftDown, ResizeRightDown, + RotateLeftUp, + RotateRightUp, + RotateLeftDown, + RotateRightDown, SelectItem, NoAction }; diff --git a/python/core/auto_additions/qgis.py b/python/core/auto_additions/qgis.py index 2e5f1b35e9e..7a3e596cb88 100644 --- a/python/core/auto_additions/qgis.py +++ b/python/core/auto_additions/qgis.py @@ -11411,6 +11411,10 @@ Qgis.MouseHandlesAction.ResizeLeftUp.__doc__ = "Resize left up (Top left handle) Qgis.MouseHandlesAction.ResizeRightUp.__doc__ = "Resize right up (Top right handle)" Qgis.MouseHandlesAction.ResizeLeftDown.__doc__ = "Resize left down (Bottom left handle)" Qgis.MouseHandlesAction.ResizeRightDown.__doc__ = "Resize right down (Bottom right handle)" +Qgis.MouseHandlesAction.RotateLeftUp.__doc__ = "Rotate left up (Top left handle)" +Qgis.MouseHandlesAction.RotateRightUp.__doc__ = "Rotate right up (Top right handle)" +Qgis.MouseHandlesAction.RotateLeftDown.__doc__ = "Rotate left up (Bottom left handle)" +Qgis.MouseHandlesAction.RotateRightDown.__doc__ = "Rotate right up (Bottom right handle)" Qgis.MouseHandlesAction.SelectItem.__doc__ = "Select item" Qgis.MouseHandlesAction.NoAction.__doc__ = "No action" Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles @@ -11426,6 +11430,10 @@ Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles * ``ResizeRightUp``: Resize right up (Top right handle) * ``ResizeLeftDown``: Resize left down (Bottom left handle) * ``ResizeRightDown``: Resize right down (Bottom right handle) +* ``RotateLeftUp``: Rotate left up (Top left handle) +* ``RotateRightUp``: Rotate right up (Top right handle) +* ``RotateLeftDown``: Rotate left up (Bottom left handle) +* ``RotateRightDown``: Rotate right up (Bottom right handle) * ``SelectItem``: Select item * ``NoAction``: No action diff --git a/python/core/auto_generated/qgis.sip.in b/python/core/auto_generated/qgis.sip.in index d7abbcdf3e7..6db1a88f6c1 100644 --- a/python/core/auto_generated/qgis.sip.in +++ b/python/core/auto_generated/qgis.sip.in @@ -3347,6 +3347,10 @@ The development version ResizeRightUp, ResizeLeftDown, ResizeRightDown, + RotateLeftUp, + RotateRightUp, + RotateLeftDown, + RotateRightDown, SelectItem, NoAction }; diff --git a/src/gui/layout/qgslayoutmousehandles.cpp b/src/gui/layout/qgslayoutmousehandles.cpp index 4024ee6bbec..2d1293adc94 100644 --- a/src/gui/layout/qgslayoutmousehandles.cpp +++ b/src/gui/layout/qgslayoutmousehandles.cpp @@ -45,7 +45,7 @@ QgsLayoutMouseHandles::QgsLayoutMouseHandles( QgsLayout *layout, QgsLayoutView * , mView( view ) { setRotationEnabled( true ); - + //listen for selection changes, and update handles accordingly connect( mLayout, &QGraphicsScene::selectionChanged, this, &QgsLayoutMouseHandles::selectionChanged ); diff --git a/src/gui/qgsgraphicsviewmousehandles.cpp b/src/gui/qgsgraphicsviewmousehandles.cpp index e87ad80473b..053c87c828f 100644 --- a/src/gui/qgsgraphicsviewmousehandles.cpp +++ b/src/gui/qgsgraphicsviewmousehandles.cpp @@ -34,7 +34,7 @@ QgsGraphicsViewMouseHandles::QgsGraphicsViewMouseHandles( QGraphicsView *view ) { //accept hover events, required for changing cursor to resize cursors setAcceptHoverEvents( true ); - + //prepare rotation handle path mRotationHandlePath.moveTo( 0, 14 ); mRotationHandlePath.lineTo( 6, 20 ); @@ -53,7 +53,7 @@ void QgsGraphicsViewMouseHandles::setRotationEnabled( bool enable ) { return; } - + mRotationEnabled = enable; update(); } @@ -152,7 +152,7 @@ void QgsGraphicsViewMouseHandles::drawHandles( QPainter *painter, double rectHan painter->drawRect( QRectF( ( rect().width() - rectHandlerSize ) / 2, rect().height() - rectHandlerSize, rectHandlerSize, rectHandlerSize ) ); //bottom right painter->drawRect( QRectF( rect().width() - rectHandlerSize, rect().height() - rectHandlerSize, rectHandlerSize, rectHandlerSize ) ); - + if ( isRotationEnabled() ) { //draw rotate handles @@ -160,7 +160,7 @@ void QgsGraphicsViewMouseHandles::drawHandles( QPainter *painter, double rectHan const bool drawBottomRotationHandles = ( rectHandlerSize * 2 ) + ( mRotationHandleSize * scale * 2 ) < rect().height(); const bool drawRightRotationHandles = ( rectHandlerSize * 2 ) + ( mRotationHandleSize * scale * 2 ) < rect().width(); QTransform transform; - + //top left transform.reset(); transform.translate( rectHandlerSize, rectHandlerSize ); @@ -169,7 +169,7 @@ void QgsGraphicsViewMouseHandles::drawHandles( QPainter *painter, double rectHan painter->setTransform( transform, true ); painter->drawPath( mRotationHandlePath ); painter->restore(); - + //top right if ( drawRightRotationHandles ) { @@ -182,7 +182,7 @@ void QgsGraphicsViewMouseHandles::drawHandles( QPainter *painter, double rectHan painter->drawPath( mRotationHandlePath ); painter->restore(); } - + if ( drawBottomRotationHandles ) { //bottom left @@ -195,7 +195,7 @@ void QgsGraphicsViewMouseHandles::drawHandles( QPainter *painter, double rectHan painter->drawPath( mRotationHandlePath ); painter->restore(); } - + if ( drawBottomRotationHandles && drawRightRotationHandles ) { //bottom right @@ -268,7 +268,7 @@ void QgsGraphicsViewMouseHandles::drawSelectedItemBounds( QPainter *painter ) { const QPolygonF itemSceneBounds = item->mapToScene( itemRect( item ) ); const QPointF rotationCenter = sceneTransform().map( rect().center() ); - + QTransform transform; transform.translate( rotationCenter.x(), rotationCenter.y() ); transform.rotate( mRotationDelta ); @@ -406,7 +406,7 @@ Qt::CursorShape QgsGraphicsViewMouseHandles::cursorForPosition( QPointF itemCoor } case Qgis::MouseHandlesAction::SelectItem: return Qt::ArrowCursor; - + case Qgis::MouseHandlesAction::RotateLeftUp: case Qgis::MouseHandlesAction::RotateRightUp: case Qgis::MouseHandlesAction::RotateLeftDown: @@ -428,10 +428,10 @@ Qgis::MouseHandlesAction QgsGraphicsViewMouseHandles::mouseActionForPosition( QP bool nearRightInner = false; bool nearLowerInner = false; bool nearUpperInner = false; - + bool withinWidth = false; bool withinHeight = false; - + if ( itemCoordPos.x() >= 0 && itemCoordPos.x() <= rect().width() ) { withinWidth = true; @@ -650,7 +650,7 @@ void QgsGraphicsViewMouseHandles::mousePressEvent( QGraphicsSceneMouseEvent *eve mResizeMoveY = 0; mCursorOffset = calcCursorEdgeOffset( mMouseMoveStartPos ); break; - + case Qgis::MouseHandlesAction::RotateLeftUp: case Qgis::MouseHandlesAction::RotateRightUp: case Qgis::MouseHandlesAction::RotateLeftDown: @@ -660,7 +660,7 @@ void QgsGraphicsViewMouseHandles::mousePressEvent( QGraphicsSceneMouseEvent *eve mRotationBegin = std::atan2( mMouseMoveStartPos.y() - mRotationCenter.y(), mMouseMoveStartPos.x() - mRotationCenter.x() ) * 180 / M_PI; mRotationCurrent = 0.0; break; - + case Qgis::MouseHandlesAction::SelectItem: case Qgis::MouseHandlesAction::NoAction: break; @@ -766,7 +766,7 @@ void QgsGraphicsViewMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *e endItemCommand( item ); } endMacroCommand(); - + mIsDragging = false; } else if ( mIsResizing ) @@ -806,13 +806,13 @@ void QgsGraphicsViewMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *e endItemCommand( item ); } endMacroCommand(); - + mIsResizing = false; } else if ( mIsRotating ) { const QPointF itemRotationCenter = sceneTransform().map( rect().center() ); - + //move selected items startMacroCommand( tr( "Rotate Items" ) ); @@ -827,19 +827,19 @@ void QgsGraphicsViewMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *e } const QPointF itemCenter = item->mapToScene( itemRect( item ) ).boundingRect().center(); - + QTransform transform; transform.translate( itemRotationCenter.x(), itemRotationCenter.y() ); transform.rotate( mRotationDelta ); transform.translate( -itemRotationCenter.x(), -itemRotationCenter.y() ); const QPointF rotatedItemCenter = transform.map( itemCenter ); - + createItemCommand( item ); rotateItem( item, mRotationDelta, rotatedItemCenter.x() - itemCenter.x(), rotatedItemCenter.y() - itemCenter.y() ); endItemCommand( item ); } endMacroCommand(); - + mIsRotating = false; } @@ -925,7 +925,7 @@ void QgsGraphicsViewMouseHandles::rotateMouseMove( QPointF currentPosition, bool { return; } - + mRotationCurrent = std::atan2( currentPosition.y() - mRotationCenter.y(), currentPosition.x() - mRotationCenter.x() ) * 180 / M_PI; mRotationDelta = mRotationCurrent - mRotationBegin; if ( snapToCommonAngles ) @@ -938,17 +938,17 @@ void QgsGraphicsViewMouseHandles::rotateMouseMove( QPointF currentPosition, bool } mRotationDelta = mRotationDelta >= 0 ? snappedRotationDelta : -snappedRotationDelta; } - + const double itemRotationRadian = rotation() * M_PI / 180; const double deltaX = ( rect().width() / 2 ) * cos( itemRotationRadian ) - ( rect().height() / 2 ) * sin( itemRotationRadian ); const double deltaY = ( rect().width() / 2 ) * sin( itemRotationRadian ) + ( rect().height() / 2 ) * cos( itemRotationRadian ); - + QTransform rotateTransform; rotateTransform.translate( deltaX, deltaY ); rotateTransform.rotate( mRotationDelta ); rotateTransform.translate( -deltaX, -deltaY ); setTransform( rotateTransform ); - + //show current selection rotation in status bar showStatusMessage( tr( "rotation: %1°" ).arg( QString::number( mRotationDelta, 'f', 2 ) ) ); diff --git a/src/gui/qgsgraphicsviewmousehandles.h b/src/gui/qgsgraphicsviewmousehandles.h index 861aa175363..af844f456af 100644 --- a/src/gui/qgsgraphicsviewmousehandles.h +++ b/src/gui/qgsgraphicsviewmousehandles.h @@ -79,15 +79,15 @@ class GUI_EXPORT QgsGraphicsViewMouseHandles : public QObject, public QGraphicsR //! Returns TRUE is user is currently rotating with the handles bool isRotating() const { return mIsRotating; } - + bool shouldBlockEvent( QInputEvent *event ) const; //! Initializes a drag operation \since QGIS 3.34 void startMove( QPointF sceneCoordPos ); - + //! Returns TRUE if rotation functionality is enabled bool isRotationEnabled() const { return mRotationEnabled; } - + //! Sets whether rotation functionality is enabled void setRotationEnabled( bool enable );