4141
4242
4343QgsProjectProperties::QgsProjectProperties ( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl )
44- : QDialog( parent, fl ), mMapCanvas( mapCanvas )
44+ : QDialog( parent, fl )
45+ , mMapCanvas( mapCanvas )
4546{
4647 setupUi ( this );
4748 connect ( buttonBox, SIGNAL ( accepted () ), this , SLOT ( accept () ) );
@@ -63,9 +64,9 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
6364 cbxProjectionEnabled->setChecked ( myProjectionEnabled );
6465 btnGrpMapUnits->setEnabled ( !myProjectionEnabled );
6566
66- long myCRSID = myRenderer->destinationCrs ().srsid ();
67- QgsDebugMsg ( " Read project CRSID: " + QString::number ( myCRSID ) );
68- projectionSelector->setSelectedCrsId ( myCRSID );
67+ mProjectSrsId = myRenderer->destinationCrs ().srsid ();
68+ QgsDebugMsg ( " Read project CRSID: " + QString::number ( mProjectSrsId ) );
69+ projectionSelector->setSelectedCrsId ( mProjectSrsId );
6970
7071 // /////////////////////////////////////////////////////////
7172 // Properties stored in QgsProject
@@ -112,6 +113,19 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
112113
113114 const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance ()->mapLayers ();
114115
116+ if ( mMapCanvas ->currentLayer () )
117+ {
118+ mLayerSrsId = mMapCanvas ->currentLayer ()->crs ().srsid ();
119+ }
120+ else if ( mapLayers.size () > 0 )
121+ {
122+ mLayerSrsId = mapLayers.begin ().value ()->crs ().srsid ();
123+ }
124+ else
125+ {
126+ mLayerSrsId = mProjectSrsId ;
127+ }
128+
115129 twIdentifyLayers->setColumnCount ( 3 );
116130 twIdentifyLayers->horizontalHeader ()->setVisible ( true );
117131 twIdentifyLayers->setHorizontalHeaderItem ( 0 , new QTableWidgetItem ( tr ( " Layer" ) ) );
@@ -454,6 +468,17 @@ void QgsProjectProperties::on_pbnCanvasColor_clicked()
454468void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged ( int state )
455469{
456470 btnGrpMapUnits->setEnabled ( state == Qt::Unchecked );
471+
472+ if ( state != Qt::Checked )
473+ {
474+ mProjectSrsId = projectionSelector->selectedCrsId ();
475+ projectionSelector->setSelectedCrsId ( mLayerSrsId );
476+ }
477+ else
478+ {
479+ mLayerSrsId = projectionSelector->selectedCrsId ();
480+ projectionSelector->setSelectedCrsId ( mProjectSrsId );
481+ }
457482}
458483
459484void QgsProjectProperties::setMapUnitsToCurrentProjection ()
@@ -541,7 +566,9 @@ void QgsProjectProperties::on_pbnWMSAddSRS_clicked()
541566void QgsProjectProperties::on_pbnWMSRemoveSRS_clicked ()
542567{
543568 foreach ( QListWidgetItem *item, mWMSList ->selectedItems () )
544- delete item;
569+ {
570+ delete item;
571+ }
545572}
546573
547574void QgsProjectProperties::on_pbnWMSSetUsedSRS_clicked ()
0 commit comments