Skip to content

Commit

Permalink
Avoid missing line under toolbar when GPS toolbar is docked
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 11, 2023
1 parent 31dda41 commit a30bf17
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/app/gps/qgsgpstoolbar.cpp
Expand Up @@ -178,8 +178,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can
mAddTrackVertexAction->setEnabled( mEnableAddVertexButton );
break;
}
// this is necessary to ensure that the toolbar in floating mode correctly resizes to fit the label!
setFixedWidth( sizeHint().width() );
adjustSize();
} );

connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::destinationLayerChanged,
Expand All @@ -188,8 +187,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can
connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::automaticallyAddTrackVerticesChanged, this, [ = ]( bool enabled ) { setAddVertexButtonEnabled( !enabled ); } );
setAddVertexButtonEnabled( !QgsProject::instance()->gpsSettings()->automaticallyAddTrackVertices() );

// this is necessary to ensure that the toolbar in floating mode correctly resizes to fit the label!
setFixedWidth( sizeHint().width() );
adjustSize();
}

void QgsGpsToolBar::setGpsDigitizing( QgsAppGpsDigitizing *digitizing )
Expand Down Expand Up @@ -305,8 +303,7 @@ void QgsGpsToolBar::updateLocationLabel()
mInformationButton->setText( parts.join( ' ' ) );
}

// this is necessary to ensure that the toolbar in floating mode correctly resizes to fit the label!
setFixedWidth( sizeHint().width() );
adjustSize();
}

void QgsGpsToolBar::destinationLayerChanged( QgsVectorLayer *vlayer )
Expand Down Expand Up @@ -475,3 +472,12 @@ void QgsGpsToolBar::createLocationWidget()
insertWidget( mSettingsMenuAction, mInformationButton );
}

void QgsGpsToolBar::adjustSize()
{
// this is necessary to ensure that the toolbar in floating mode correctly resizes to fit the label!
if ( isFloating() )
setFixedWidth( sizeHint().width() );
else
setFixedWidth( QWIDGETSIZE_MAX );
}

1 change: 1 addition & 0 deletions src/app/gps/qgsgpstoolbar.h
Expand Up @@ -65,6 +65,7 @@ class QgsGpsToolBar : public QToolBar
private:

void createLocationWidget();
void adjustSize();

QgsAppGpsConnection *mConnection = nullptr;
QgsMapCanvas *mCanvas = nullptr;
Expand Down

0 comments on commit a30bf17

Please sign in to comment.