Skip to content

Commit

Permalink
Respect project bearing setting when showing pan direction in status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 9, 2020
1 parent c0ad430 commit 9fd3681
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -352,6 +352,9 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgsappcoordinateoperationhandlers.h"
#include "qgsprojectviewsettings.h"
#include "qgscoordinateformatter.h"
#include "qgslocaldefaultsettings.h"
#include "qgsbearingnumericformat.h"
#include "qgsprojectdisplaysettings.h"

#include "qgsuserprofilemanager.h"
#include "qgsuserprofile.h"
Expand Down Expand Up @@ -1546,6 +1549,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
std::sort( actions.begin(), actions.end(), cmpByText_ );
mPanelMenu->insertActions( nullptr, actions );

mBearingNumericFormat.reset( QgsLocalDefaultSettings::bearingFormat() );

// update windows
qApp->processEvents();

Expand Down Expand Up @@ -1585,6 +1590,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
connect( QgsProject::instance(), &QgsProject::isDirtyChanged, mActionRevertProject, toggleRevert );
connect( QgsProject::instance(), &QgsProject::fileNameChanged, mActionRevertProject, toggleRevert );

connect( QgsProject::instance()->displaySettings(), &QgsProjectDisplaySettings::bearingFormatChanged, this, [ = ]
{
mBearingNumericFormat.reset( QgsProject::instance()->displaySettings()->bearingFormat()->clone() );
} );
connect( mMapCanvas, &QgsMapCanvas::panDistanceBearingChanged, this, &QgisApp::showPanMessage );

// the most important part of the initialization: make sure that people can play puzzle if they need
Expand Down Expand Up @@ -1623,6 +1632,8 @@ QgisApp::QgisApp()
mPanelMenu = new QMenu( this );
mProgressBar = new QProgressBar( this );
mStatusBar = new QgsStatusBar( this );

mBearingNumericFormat.reset( QgsLocalDefaultSettings::bearingFormat() );
// More tests may need more members to be initialized
}

Expand Down Expand Up @@ -12910,7 +12921,7 @@ void QgisApp::showRotation()
void QgisApp::showPanMessage( double distance, QgsUnitTypes::DistanceUnit unit, double bearing )
{
mStatusBar->showMessage( tr( "Pan distance %1 (%2)" ).arg( QgsDistanceArea::formatDistance( distance, 1, unit ),
QgsCoordinateFormatter::formatX( bearing, QgsCoordinateFormatter::FormatDecimalDegrees, 1, QgsCoordinateFormatter::FlagDegreesUseStringSuffix ) ), 2000 );
mBearingNumericFormat->formatDouble( bearing, QgsNumericFormatContext() ) ), 2000 );
}

void QgisApp::selectionModeChanged( QgsMapToolSelect::Mode mode )
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -137,6 +137,7 @@ class QgsGeoCmsProviderRegistry;
class QgsLayoutCustomDropHandler;
class QgsProxyProgressTask;
class QgsNetworkRequestParameters;
class QgsBearingNumericFormat;

#include <QMainWindow>
#include <QToolBar>
Expand Down Expand Up @@ -2407,6 +2408,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsGeometryValidationDock *mGeometryValidationDock = nullptr;
QgsHandleBadLayersHandler *mAppBadLayersHandler = nullptr;

std::unique_ptr< QgsBearingNumericFormat > mBearingNumericFormat;

class QgsCanvasRefreshBlocker
{
public:
Expand Down

0 comments on commit 9fd3681

Please sign in to comment.