Skip to content

Commit 97c937f

Browse files
lbartolettinyalldawson
authored andcommittedJul 16, 2018
replace "Snap to 30° angles" by ""30, 60, 90, 120°..." etc.
improve readability
1 parent 2205ea6 commit 97c937f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed
 

‎src/gui/qgsadvanceddigitizingdockwidget.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,16 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *
110110
QActionGroup *angleButtonGroup = new QActionGroup( menu ); // actions are exclusive for common angles
111111
mCommonAngleActions = QMap<QAction *, double>();
112112
QList< QPair< double, QString > > commonAngles;
113-
commonAngles << QPair<double, QString>( 0, tr( "Do not snap to common angles" ) );
114-
commonAngles << QPair<double, QString>( 5, tr( "Snap to 5° angles" ) );
115-
commonAngles << QPair<double, QString>( 10, tr( "Snap to 10° angles" ) );
116-
commonAngles << QPair<double, QString>( 15, tr( "Snap to 15° angles" ) );
117-
commonAngles << QPair<double, QString>( 18, tr( "Snap to 18° angles" ) );
118-
commonAngles << QPair<double, QString>( 22.5, tr( "Snap to 22.5° angles" ) );
119-
commonAngles << QPair<double, QString>( 30, tr( "Snap to 30° angles" ) );
120-
commonAngles << QPair<double, QString>( 45, tr( "Snap to 45° angles" ) );
121-
commonAngles << QPair<double, QString>( 90, tr( "Snap to 90° angles" ) );
113+
QString menuText;
114+
QList<double> anglesDouble( { 0.0, 5.0, 10.0, 15.0, 18.0, 22.5, 30.0, 45.0, 90.0} );
115+
for ( QList<double>::const_iterator it = anglesDouble.constBegin(); it != anglesDouble.constEnd(); ++it )
116+
{
117+
if ( *it == 0 )
118+
menuText = tr( "Do not snap to common angles" );
119+
else
120+
menuText = QString( tr( "%1, %2, %3, %4°..." ) ).arg( *it, 0, 'f', 1 ).arg( *it * 2, 0, 'f', 1 ).arg( *it * 3, 0, 'f', 1 ).arg( *it * 4, 0, 'f', 1 );
121+
commonAngles << QPair<double, QString>( *it, menuText );
122+
}
122123
for ( QList< QPair<double, QString > >::const_iterator it = commonAngles.constBegin(); it != commonAngles.constEnd(); ++it )
123124
{
124125
QAction *action = new QAction( it->second, menu );

0 commit comments

Comments
 (0)
Please sign in to comment.