Skip to content

Commit

Permalink
[georef] Correctly restore paper size when opening settings dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 17, 2015
1 parent 1d6086c commit c4f0d31
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/plugins/georeferencer/qgsgeorefconfigdialog.cpp
Expand Up @@ -17,6 +17,7 @@
#include <QSizeF>

#include "qgsgeorefconfigdialog.h"
#include "qgis.h"

QgsGeorefConfigDialog::QgsGeorefConfigDialog( QWidget *parent ) :
QDialog( parent )
Expand All @@ -26,8 +27,6 @@ QgsGeorefConfigDialog::QgsGeorefConfigDialog( QWidget *parent ) :
QSettings s;
restoreGeometry( s.value( "/Plugin-GeoReferencer/ConfigWindow/geometry" ).toByteArray() );

readSettings();

mPaperSizeComboBox->addItem( tr( "A5 (148x210 mm)" ), QSizeF( 148, 210 ) );
mPaperSizeComboBox->addItem( tr( "A4 (210x297 mm)" ), QSizeF( 210, 297 ) );
mPaperSizeComboBox->addItem( tr( "A3 (297x420 mm)" ), QSizeF( 297, 420 ) );
Expand All @@ -54,8 +53,7 @@ QgsGeorefConfigDialog::QgsGeorefConfigDialog( QWidget *parent ) :
mPaperSizeComboBox->addItem( tr( "Arch E (36x48 inches)" ), QSizeF( 914.4, 1219.2 ) );
mPaperSizeComboBox->addItem( tr( "Arch E1 (30x42 inches)" ), QSizeF( 762, 1066.8 ) );

mPaperSizeComboBox->setCurrentIndex( 2 ); //A3

readSettings();
}

QgsGeorefConfigDialog::~QgsGeorefConfigDialog()
Expand Down Expand Up @@ -129,6 +127,22 @@ void QgsGeorefConfigDialog::readSettings()

mLeftMarginSpinBox->setValue( s.value( "/Plugin-GeoReferencer/Config/LeftMarginPDF", "2.0" ).toDouble() );
mRightMarginSpinBox->setValue( s.value( "/Plugin-GeoReferencer/Config/RightMarginPDF", "2.0" ).toDouble() );

double currentWidth = s.value( "/Plugin-GeoReferencer/Config/WidthPDFMap", "297" ).toDouble();
double currentHeight = s.value( "/Plugin-GeoReferencer/Config/HeightPDFMap", "420" ).toDouble();

int paperIndex = 2; //default to A3
for ( int i = 0; i < mPaperSizeComboBox->count(); ++i )
{
double itemWidth = mPaperSizeComboBox->itemData( i ).toSizeF().width();
double itemHeight = mPaperSizeComboBox->itemData( i ).toSizeF().height();
if ( qgsDoubleNear( itemWidth, currentWidth ) && qgsDoubleNear( itemHeight, currentHeight ) )
{
paperIndex = i;
break;
}
}
mPaperSizeComboBox->setCurrentIndex( paperIndex );
}

void QgsGeorefConfigDialog::writeSettings()
Expand Down

0 comments on commit c4f0d31

Please sign in to comment.