Skip to content

Commit

Permalink
Disable cad perpendicular/parallel buttons when snapping is disabled
Browse files Browse the repository at this point in the history
And use tooltips to advise users that snapping must be enabled
before this functionality can be used.

Hopefully helps make the behaviour of these features a bit more
predictable for users
  • Loading branch information
nyalldawson committed Apr 19, 2017
1 parent 58ded28 commit 3e2d60e
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/gui/qgsadvanceddigitizingdockwidget.cpp
Expand Up @@ -30,6 +30,7 @@
#include "qgslinestring.h"
#include "qgsfocuswatcher.h"
#include "qgssettings.h"
#include "qgsproject.h"

struct EdgesOnlyFilter : public QgsPointLocator::MatchFilter
{
Expand Down Expand Up @@ -199,9 +200,6 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *

// set tooltips
mConstructionModeButton->setToolTip( "<b>" + tr( "Construction mode" ) + "</b><br>(" + tr( "press c to toggle on/off" ) + ")" );
mPerpendicularButton->setToolTip( "<b>" + tr( "Perpendicular" ) + "</b><br>(" + tr( "press p to switch between perpendicular, parallel and normal mode" ) + ")" );
mParallelButton->setToolTip( "<b>" + tr( "Parallel" ) + "</b><br>(" + tr( "press p to switch between perpendicular, parallel and normal mode" ) + ")" );

mDistanceLineEdit->setToolTip( "<b>" + tr( "Distance" ) + "</b><br>(" + tr( "press d for quick access" ) + ")" );
mLockDistanceButton->setToolTip( "<b>" + tr( "Lock distance" ) + "</b><br>(" + tr( "press Ctrl + d for quick access" ) + ")" );
mRepeatingLockDistanceButton->setToolTip( "<b>" + tr( "Continuously lock distance" ) + "</b>" );
Expand All @@ -223,6 +221,8 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *


updateCapacity( true );
connect( QgsProject::instance(), &QgsProject::snappingConfigChanged, this, [ = ] { updateCapacity( true ); } );

disable();
}

Expand Down Expand Up @@ -525,15 +525,31 @@ void QgsAdvancedDigitizingDockWidget::updateCapacity( bool updateUIwithoutChange
return;
}

bool snappingEnabled = QgsProject::instance()->snappingConfig().enabled();

// update the UI according to new capacities
// still keep the old to compare

bool relativeAngle = mCadEnabled && newCapacities.testFlag( RelativeAngle );
bool absoluteAngle = mCadEnabled && newCapacities.testFlag( AbsoluteAngle );
bool relativeCoordinates = mCadEnabled && newCapacities.testFlag( RelativeCoordinates );

mPerpendicularButton->setEnabled( absoluteAngle );
mParallelButton->setEnabled( absoluteAngle );
mPerpendicularButton->setEnabled( absoluteAngle && snappingEnabled );
mParallelButton->setEnabled( absoluteAngle && snappingEnabled );

//update tooltips on buttons
if ( !snappingEnabled )
{
mPerpendicularButton->setToolTip( tr( "Snapping must be enabled to utilize perpendicular mode" ) );
mParallelButton->setToolTip( tr( "Snapping must be enabled to utilize parallel mode" ) );
}
else
{
mPerpendicularButton->setToolTip( "<b>" + tr( "Perpendicular" ) + "</b><br>(" + tr( "press p to switch between perpendicular, parallel and normal mode" ) + ")" );
mParallelButton->setToolTip( "<b>" + tr( "Parallel" ) + "</b><br>(" + tr( "press p to switch between perpendicular, parallel and normal mode" ) + ")" );
}


if ( !absoluteAngle )
{
lockAdditionalConstraint( NoConstraint );
Expand Down

0 comments on commit 3e2d60e

Please sign in to comment.