Skip to content

Commit 5e670ff

Browse files
committed
use custom widget for projection selection in options
1 parent f68cd5e commit 5e670ff

File tree

3 files changed

+329
-223
lines changed

3 files changed

+329
-223
lines changed

src/app/qgsoptions.cpp

+6-43
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
363363
}
364364
QString myLayerDefaultCrs = settings.value( "/Projections/layerDefaultCrs", GEO_EPSG_CRS_AUTHID ).toString();
365365
mLayerDefaultCrs.createFromOgcWmsCrs( myLayerDefaultCrs );
366-
//display the crs as friendly text rather than in wkt
367-
leLayerGlobalCrs->setText( mLayerDefaultCrs.authid() + " - " + mLayerDefaultCrs.description() );
366+
leLayerGlobalCrs->setCrs( mLayerDefaultCrs );
368367

369368
//on the fly CRS transformation settings
370369
//it would be logical to have single settings value but originaly the radio buttons were checkboxes
@@ -383,8 +382,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
383382

384383
QString myDefaultCrs = settings.value( "/Projections/projectDefaultCrs", GEO_EPSG_CRS_AUTHID ).toString();
385384
mDefaultCrs.createFromOgcWmsCrs( myDefaultCrs );
386-
//display the crs as friendly text rather than in wkt
387-
leProjectGlobalCrs->setText( mDefaultCrs.authid() + " - " + mDefaultCrs.description() );
385+
leProjectGlobalCrs->setCrs( mDefaultCrs );
388386

389387
//default datum transformations
390388
settings.beginGroup( "/Projections" );
@@ -1454,49 +1452,14 @@ void QgsOptions::on_mBoldGroupBoxTitleChkBx_clicked( bool chkd )
14541452
mStyleSheetBuilder->buildStyleSheet( mStyleSheetNewOpts );
14551453
}
14561454

1457-
void QgsOptions::on_pbnSelectProjection_clicked()
1455+
void QgsOptions::on_leProjectGlobalCrs_crsChanged(QgsCoordinateReferenceSystem crs)
14581456
{
1459-
QSettings settings;
1460-
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
1461-
1462-
//find out crs id of current proj4 string
1463-
mySelector->setSelectedCrsId( mLayerDefaultCrs.srsid() );
1464-
1465-
if ( mySelector->exec() )
1466-
{
1467-
mLayerDefaultCrs.createFromOgcWmsCrs( mySelector->selectedAuthId() );
1468-
QgsDebugMsg( QString( "Setting default project CRS to : %1" ).arg( mySelector->selectedAuthId() ) );
1469-
leLayerGlobalCrs->setText( mLayerDefaultCrs.authid() + " - " + mLayerDefaultCrs.description() );
1470-
QgsDebugMsg( QString( "------ Global Layer Default Projection Selection set to ----------\n%1" ).arg( leLayerGlobalCrs->text() ) );
1471-
}
1472-
else
1473-
{
1474-
QgsDebugMsg( "------ Global Layer Default Projection Selection change cancelled ----------" );
1475-
QApplication::restoreOverrideCursor();
1476-
}
1477-
1457+
mDefaultCrs = crs;
14781458
}
14791459

1480-
void QgsOptions::on_pbnSelectOtfProjection_clicked()
1460+
void QgsOptions::on_leLayerGlobalCrs_crsChanged(QgsCoordinateReferenceSystem crs)
14811461
{
1482-
QSettings settings;
1483-
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
1484-
1485-
//find out crs id of current proj4 string
1486-
mySelector->setSelectedCrsId( mDefaultCrs.srsid() );
1487-
1488-
if ( mySelector->exec() )
1489-
{
1490-
mDefaultCrs.createFromOgcWmsCrs( mySelector->selectedAuthId() );
1491-
QgsDebugMsg( QString( "Setting default project CRS to : %1" ).arg( mySelector->selectedAuthId() ) );
1492-
leProjectGlobalCrs->setText( mDefaultCrs.authid() + " - " + mDefaultCrs.description() );
1493-
QgsDebugMsg( QString( "------ Global OTF Projection Selection set to ----------\n%1" ).arg( leProjectGlobalCrs->text() ) );
1494-
}
1495-
else
1496-
{
1497-
QgsDebugMsg( "------ Global OTF Projection Selection change cancelled ----------" );
1498-
QApplication::restoreOverrideCursor();
1499-
}
1462+
mLayerDefaultCrs = crs;
15001463
}
15011464

15021465
void QgsOptions::on_lstGdalDrivers_itemDoubleClicked( QTreeWidgetItem * item, int column )

src/app/qgsoptions.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
6464
void on_pbnTemplateFolderBrowse_pressed();
6565
void on_pbnTemplateFolderReset_pressed();
6666
//! Slot called when user chooses to change the project wide projection.
67-
void on_pbnSelectProjection_clicked();
67+
void on_leProjectGlobalCrs_crsChanged(QgsCoordinateReferenceSystem crs);
6868
//! Slot called when user chooses to change the default 'on the fly' projection.
69-
void on_pbnSelectOtfProjection_clicked();
69+
void on_leLayerGlobalCrs_crsChanged(QgsCoordinateReferenceSystem crs);
7070
void on_lstGdalDrivers_itemDoubleClicked( QTreeWidgetItem * item, int column );
7171
void on_pbnEditCreateOptions_pressed();
7272
void on_pbnEditPyramidsOptions_pressed();

0 commit comments

Comments
 (0)