Skip to content
Permalink
Browse files

fix disabled map unit widgets when opening project prop. dialog

(fixes #17208)
  • Loading branch information
nirvn committed Feb 19, 2018
1 parent ae956d7 commit a303ef5ab738bc065122583302369a5005ef7bf9
Showing with 39 additions and 27 deletions.
  1. +36 −26 src/app/qgsprojectproperties.cpp
  2. +3 −1 src/app/qgsprojectproperties.h
@@ -152,7 +152,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
// Properties stored in map canvas's QgsMapRenderer
// these ones are propagated to QgsProject by a signal

updateGuiForMapUnits( QgsProject::instance()->crs().mapUnits() );
mCrs = QgsProject::instance()->crs();
updateGuiForMapUnits();
projectionSelector->setCrs( QgsProject::instance()->crs() );

// Datum transforms
@@ -235,12 +236,25 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
// selection of the ellipsoid from settings is defferred to a later point, because it would
// be overridden in the meanwhile by the projection selector
populateEllipsoidList();

if ( !QgsProject::instance()->crs().isValid() )
{
cmbEllipsoid->setCurrentIndex( 0 );
cmbEllipsoid->setEnabled( false );
}
else
{
// attempt to reset the projection ellipsoid according to the srs
int index = 0;
for ( int i = 0; i < mEllipsoidList.length(); i++ )
{
if ( mEllipsoidList[ i ].acronym == QgsProject::instance()->crs().ellipsoidAcronym() )
{
index = i;
break;
}
}
updateEllipsoidUI( index );
}

QString format = QgsProject::instance()->readEntry( QStringLiteral( "PositionPrecision" ), QStringLiteral( "/DegreeFormat" ), QStringLiteral( "MU" ) );
if ( format == QLatin1String( "MU" ) )
@@ -1260,9 +1274,9 @@ void QgsProjectProperties::cbxWCSPubliedStateChanged( int aIdx )
}
}

void QgsProjectProperties::updateGuiForMapUnits( QgsUnitTypes::DistanceUnit units )
void QgsProjectProperties::updateGuiForMapUnits()
{
if ( !projectionSelector->crs().isValid() )
if ( !mCrs.isValid() )
{
// no projection set - disable everything!
int idx = mDistanceUnitsCombo->findData( QgsUnitTypes::DistanceUnknownUnit );
@@ -1289,6 +1303,8 @@ void QgsProjectProperties::updateGuiForMapUnits( QgsUnitTypes::DistanceUnit unit
}
else
{
QgsUnitTypes::DistanceUnit units = mCrs.mapUnits();

mDistanceUnitsCombo->setEnabled( true );
mAreaUnitsCombo->setEnabled( true );
mCoordinateDisplayComboBox->setEnabled( true );
@@ -1319,27 +1335,23 @@ void QgsProjectProperties::srIdUpdated()
if ( !projectionSelector->hasValidSelection() )
return;

QgsCoordinateReferenceSystem srs = projectionSelector->crs();
mCrs = projectionSelector->crs();
updateGuiForMapUnits();

//set radio button to crs map unit type
QgsUnitTypes::DistanceUnit units = srs.mapUnits();

updateGuiForMapUnits( units );

if ( srs.isValid() )
if ( mCrs.isValid() )
{
cmbEllipsoid->setEnabled( true );
// attempt to reset the projection ellipsoid according to the srs
int myIndex = 0;
int index = 0;
for ( int i = 0; i < mEllipsoidList.length(); i++ )
{
if ( mEllipsoidList[ i ].acronym == srs.ellipsoidAcronym() )
if ( mEllipsoidList[ i ].acronym == mCrs.ellipsoidAcronym() )
{
myIndex = i;
index = i;
break;
}
}
updateEllipsoidUI( myIndex );
updateEllipsoidUI( index );
}
else
{
@@ -1410,10 +1422,8 @@ void QgsProjectProperties::pbnWMSSetUsedSRS_clicked()
}

QSet<QString> crsList;

QgsCoordinateReferenceSystem srs = projectionSelector->crs();
if ( srs.isValid() )
crsList << srs.authid();
if ( mCrs.isValid() )
crsList << mCrs.authid();

const QMap<QString, QgsMapLayer *> &mapLayers = QgsProject::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer *>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); ++it )
@@ -1927,7 +1937,7 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex )
leSemiMajor->clear();
leSemiMinor->clear();

cmbEllipsoid->setEnabled( projectionSelector->crs().isValid() );
cmbEllipsoid->setEnabled( mCrs.isValid() );
cmbEllipsoid->setToolTip( QLatin1String( "" ) );
if ( mEllipsoidList.at( mEllipsoidIndex ).acronym.startsWith( QLatin1String( "PARAMETER:" ) ) )
{
@@ -1945,7 +1955,7 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex )
leSemiMinor->setText( QLocale::system().toString( myMinor, 'f', 3 ) );
}

if ( projectionSelector->crs().isValid() )
if ( mCrs.isValid() )
cmbEllipsoid->setCurrentIndex( mEllipsoidIndex ); // Not always necessary
}

@@ -1956,24 +1966,24 @@ void QgsProjectProperties::projectionSelectorInitialized()
// Reading ellipsoid from settings
QStringList mySplitEllipsoid = QgsProject::instance()->ellipsoid().split( ':' );

int myIndex = 0;
int index = 0;
for ( int i = 0; i < mEllipsoidList.length(); i++ )
{
if ( mEllipsoidList.at( i ).acronym.startsWith( mySplitEllipsoid[ 0 ] ) )
{
myIndex = i;
index = i;
break;
}
}

// Update parameters if present.
if ( mySplitEllipsoid.length() >= 3 )
{
mEllipsoidList[ myIndex ].semiMajor = mySplitEllipsoid[ 1 ].toDouble();
mEllipsoidList[ myIndex ].semiMinor = mySplitEllipsoid[ 2 ].toDouble();
mEllipsoidList[ index ].semiMajor = mySplitEllipsoid[ 1 ].toDouble();
mEllipsoidList[ index ].semiMinor = mySplitEllipsoid[ 2 ].toDouble();
}

updateEllipsoidUI( myIndex );
updateEllipsoidUI( index );
}

void QgsProjectProperties::mButtonAddColor_clicked()
@@ -174,6 +174,8 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
QgsMapCanvas *mMapCanvas = nullptr;
QgsStyle *mStyle = nullptr;

QgsCoordinateReferenceSystem mCrs;

void populateStyles();
void editSymbol( QComboBox *cbo );

@@ -217,7 +219,7 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:

static const char *GEO_NONE_DESC;

void updateGuiForMapUnits( QgsUnitTypes::DistanceUnit units );
void updateGuiForMapUnits();

void showHelp();
};

0 comments on commit a303ef5

Please sign in to comment.
You can’t perform that action at this time.