Skip to content
Permalink
Browse files

[georef] Correctly restore paper size when opening settings dialog

  • Loading branch information
nyalldawson committed Jun 17, 2015
1 parent 1d6086c commit c4f0d31fbbd7aa811c75e39489bf73e8419e767d
Showing with 18 additions and 4 deletions.
  1. +18 −4 src/plugins/georeferencer/qgsgeorefconfigdialog.cpp
@@ -17,6 +17,7 @@
#include <QSizeF>

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

QgsGeorefConfigDialog::QgsGeorefConfigDialog( QWidget *parent ) :
QDialog( parent )
@@ -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 ) );
@@ -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()
@@ -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()

0 comments on commit c4f0d31

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