Skip to content

Commit c4f0d31

Browse files
committedJun 17, 2015
[georef] Correctly restore paper size when opening settings dialog
1 parent 1d6086c commit c4f0d31

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed
 

‎src/plugins/georeferencer/qgsgeorefconfigdialog.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <QSizeF>
1818

1919
#include "qgsgeorefconfigdialog.h"
20+
#include "qgis.h"
2021

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

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

57-
mPaperSizeComboBox->setCurrentIndex( 2 ); //A3
58-
56+
readSettings();
5957
}
6058

6159
QgsGeorefConfigDialog::~QgsGeorefConfigDialog()
@@ -129,6 +127,22 @@ void QgsGeorefConfigDialog::readSettings()
129127

130128
mLeftMarginSpinBox->setValue( s.value( "/Plugin-GeoReferencer/Config/LeftMarginPDF", "2.0" ).toDouble() );
131129
mRightMarginSpinBox->setValue( s.value( "/Plugin-GeoReferencer/Config/RightMarginPDF", "2.0" ).toDouble() );
130+
131+
double currentWidth = s.value( "/Plugin-GeoReferencer/Config/WidthPDFMap", "297" ).toDouble();
132+
double currentHeight = s.value( "/Plugin-GeoReferencer/Config/HeightPDFMap", "420" ).toDouble();
133+
134+
int paperIndex = 2; //default to A3
135+
for ( int i = 0; i < mPaperSizeComboBox->count(); ++i )
136+
{
137+
double itemWidth = mPaperSizeComboBox->itemData( i ).toSizeF().width();
138+
double itemHeight = mPaperSizeComboBox->itemData( i ).toSizeF().height();
139+
if ( qgsDoubleNear( itemWidth, currentWidth ) && qgsDoubleNear( itemHeight, currentHeight ) )
140+
{
141+
paperIndex = i;
142+
break;
143+
}
144+
}
145+
mPaperSizeComboBox->setCurrentIndex( paperIndex );
132146
}
133147

134148
void QgsGeorefConfigDialog::writeSettings()

0 commit comments

Comments
 (0)
Please sign in to comment.