Skip to content

Commit

Permalink
More naming clarification
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 4, 2022
1 parent 1c89fe3 commit e7bdae9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions src/app/gps/qgsgpstoolbar.cpp
Expand Up @@ -78,11 +78,12 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can

addSeparator();

mAddTrackPointAction = new QAction( tr( "Add Track Point" ), this );
mAddTrackPointAction->setEnabled( false );
mAddTrackPointAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/gpsicons/mActionAddTrackPoint.svg" ) ) );
connect( mAddTrackPointAction, &QAction::triggered, this, &QgsGpsToolBar::addVertexClicked );
addAction( mAddTrackPointAction );
mAddTrackVertexAction = new QAction( tr( "Add Track Vertex" ), this );
mAddTrackVertexAction->setToolTip( tr( "Add vertex to GPS track using current GPS location" ) );
mAddTrackVertexAction->setEnabled( false );
mAddTrackVertexAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/gpsicons/mActionAddTrackPoint.svg" ) ) );
connect( mAddTrackVertexAction, &QAction::triggered, this, &QgsGpsToolBar::addVertexClicked );
addAction( mAddTrackVertexAction );

mAddFeatureAction = new QAction( tr( "Create Feature from Track" ), this );
mAddFeatureAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionCaptureLine.svg" ) ) );
Expand Down Expand Up @@ -118,7 +119,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can

mRecenterAction->setEnabled( false );
mAddFeatureAction->setEnabled( false );
mAddTrackPointAction->setEnabled( false );
mAddTrackVertexAction->setEnabled( false );
connect( mConnection, &QgsAppGpsConnection::statusChanged, this, [ = ]( Qgis::GpsConnectionStatus status )
{
switch ( status )
Expand All @@ -131,7 +132,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can
mConnectAction->setEnabled( true );
mRecenterAction->setEnabled( false );
mAddFeatureAction->setEnabled( false );
mAddTrackPointAction->setEnabled( false );
mAddTrackVertexAction->setEnabled( false );
break;
case Qgis::GpsConnectionStatus::Connecting:
whileBlocking( mConnectAction )->setChecked( true );
Expand All @@ -140,7 +141,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can
mConnectAction->setEnabled( false );
mRecenterAction->setEnabled( false );
mAddFeatureAction->setEnabled( false );
mAddTrackPointAction->setEnabled( false );
mAddTrackVertexAction->setEnabled( false );
break;
case Qgis::GpsConnectionStatus::Connected:
whileBlocking( mConnectAction )->setChecked( true );
Expand All @@ -150,7 +151,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can
mConnectAction->setEnabled( true );
mRecenterAction->setEnabled( true );
mAddFeatureAction->setEnabled( true );
mAddTrackPointAction->setEnabled( mEnableAddVertexButton );
mAddTrackVertexAction->setEnabled( mEnableAddVertexButton );
break;
}
} );
Expand All @@ -162,7 +163,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can
void QgsGpsToolBar::setAddVertexButtonEnabled( bool enabled )
{
mEnableAddVertexButton = enabled;
mAddTrackPointAction->setEnabled( mEnableAddVertexButton && mConnection->isConnected() );
mAddTrackVertexAction->setEnabled( mEnableAddVertexButton && mConnection->isConnected() );
}

void QgsGpsToolBar::updateLocationLabel( const QgsPoint &point )
Expand Down Expand Up @@ -206,6 +207,7 @@ void QgsGpsToolBar::updateCloseFeatureButton( QgsMapLayer *lyr )
}

QString buttonLabel = tr( "Create Feature" );
QString buttonToolTip = tr( "Create Feature" );
QString icon = QStringLiteral( "mActionCaptureLine.svg" );;
if ( vlayer )
{
Expand All @@ -219,16 +221,19 @@ void QgsGpsToolBar::updateCloseFeatureButton( QgsMapLayer *lyr )
{
case QgsWkbTypes::PointGeometry:
buttonLabel = tr( "Create Point Feature at Location" );
buttonToolTip = tr( "Create a new point feature at the current GPS location" );
icon = QStringLiteral( "mActionCapturePoint.svg" );
break;

case QgsWkbTypes::LineGeometry:
buttonLabel = tr( "Create Line Feature from Track" );
buttonToolTip = tr( "Create a new line feature using the current GPS track" );
icon = QStringLiteral( "mActionCaptureLine.svg" );
break;

case QgsWkbTypes::PolygonGeometry:
buttonLabel = tr( "Create Polygon Feature from Track" );
buttonToolTip = tr( "Create a new polygon feature using the current GPS track" );
icon = QStringLiteral( "mActionCapturePolygon.svg" );
break;

Expand All @@ -246,7 +251,7 @@ void QgsGpsToolBar::updateCloseFeatureButton( QgsMapLayer *lyr )
}
mAddFeatureAction->setText( buttonLabel );
mAddFeatureAction->setIcon( QgsApplication::getThemeIcon( icon ) );
mAddFeatureAction->setToolTip( buttonLabel );
mAddFeatureAction->setToolTip( buttonToolTip );
}

void QgsGpsToolBar::layerEditStateChanged()
Expand Down
2 changes: 1 addition & 1 deletion src/app/gps/qgsgpstoolbar.h
Expand Up @@ -59,7 +59,7 @@ class QgsGpsToolBar : public QToolBar
QAction *mConnectAction = nullptr;
QAction *mRecenterAction = nullptr;
QAction *mShowInfoAction = nullptr;
QAction *mAddTrackPointAction = nullptr;
QAction *mAddTrackVertexAction = nullptr;
QAction *mAddFeatureAction = nullptr;
QAction *mResetFeatureAction = nullptr;

Expand Down

0 comments on commit e7bdae9

Please sign in to comment.