Skip to content

Commit dae9b5d

Browse files
committedOct 4, 2013
[FEATURE] Holding ctrl while dragging a composer selection temporarily turns off snapping
1 parent bf076a0 commit dae9b5d

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
 

‎src/core/composer/qgscomposermousehandles.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void QgsComposerMouseHandles::mouseMoveEvent( QGraphicsSceneMouseEvent* event )
378378
if ( mIsDragging )
379379
{
380380
//currently dragging a selection
381-
dragMouseMove( event->lastScenePos(), shiftModifier );
381+
dragMouseMove( event->lastScenePos(), shiftModifier, controlModifier );
382382
}
383383
else if ( mIsResizing )
384384
{
@@ -499,7 +499,7 @@ void QgsComposerMouseHandles::mousePressEvent( QGraphicsSceneMouseEvent* event )
499499

500500
}
501501

502-
void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, bool lockMovement )
502+
void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, bool lockMovement, bool preventSnap )
503503
{
504504
if ( !mComposition )
505505
{
@@ -513,8 +513,18 @@ void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, boo
513513
//find target position before snapping (in scene coordinates)
514514
QPointF upperLeftPoint( mBeginHandlePos.x() + moveX, mBeginHandlePos.y() + moveY );
515515

516-
//snap to grid and guides
517-
QPointF snappedLeftPoint = snapPoint( upperLeftPoint, QgsComposerMouseHandles::Item );
516+
QPointF snappedLeftPoint;
517+
if ( !preventSnap )
518+
{
519+
//snap to grid and guides
520+
snappedLeftPoint = snapPoint( upperLeftPoint, QgsComposerMouseHandles::Item );
521+
}
522+
else
523+
{
524+
//no snapping
525+
snappedLeftPoint = upperLeftPoint;
526+
deleteAlignItems();
527+
}
518528

519529
//calculate total shift for item from beginning of drag operation to current position
520530
double moveRectX = snappedLeftPoint.x() - mBeginHandlePos.x();

‎src/core/composer/qgscomposermousehandles.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class CORE_EXPORT QgsComposerMouseHandles: public QObject, public QGraphicsRectI
140140
QgsComposerMouseHandles::MouseAction mouseActionForPosition( const QPointF& itemCoordPos );
141141

142142
/**Handles dragging of items during mouse move*/
143-
void dragMouseMove( const QPointF& currentPosition, bool lockMovement );
143+
void dragMouseMove( const QPointF& currentPosition, bool lockMovement, bool preventSnap );
144144
/**Handles resizing of items during mouse move*/
145145
void resizeMouseMove( const QPointF& currentPosition, bool lockAspect, bool fromCenter );
146146

0 commit comments

Comments
 (0)
Please sign in to comment.