@@ -54,7 +54,7 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, QL
54
54
mDpi = ms.outputDpi ();
55
55
mSize = ms.outputSize ();
56
56
57
- mResolutionSpinBox ->setValue ( qt_defaultDpiX () );
57
+ mResolutionSpinBox ->setValue ( mDpi );
58
58
59
59
mExtentGroupBox ->setOutputCrs ( ms.destinationCrs () );
60
60
mExtentGroupBox ->setCurrentExtent ( mExtent , ms.destinationCrs () );
@@ -176,16 +176,39 @@ void QgsMapSaveDialog::updateOutputHeight( int height )
176
176
177
177
void QgsMapSaveDialog::updateExtent ( const QgsRectangle &extent )
178
178
{
179
- mSize .setWidth ( mSize .width () * extent.width () / mExtent .width () );
180
- mSize .setHeight ( mSize .height () * extent.height () / mExtent .height () );
181
- mExtent = extent;
179
+ int currentDpi = 0 ;
180
+
181
+ // reset scale to properly sync output width and height when extent set using
182
+ // current map view, layer extent, or drawn on canvas buttons
183
+ if ( mExtentGroupBox ->extentState () != QgsExtentGroupBox::UserExtent )
184
+ {
185
+ currentDpi = mDpi ;
186
+
187
+ QgsMapSettings ms = mMapCanvas ->mapSettings ();
188
+ ms.setRotation ( 0 );
189
+ mDpi = ms.outputDpi ();
190
+ mSize .setWidth ( ms.outputSize ().width () * extent.width () / ms.visibleExtent ().width () );
191
+ mSize .setHeight ( ms.outputSize ().height () * extent.height () / ms.visibleExtent ().height () );
192
+
193
+ whileBlocking ( mScaleWidget )->setScale ( ms.scale () );
194
+
195
+ if ( currentDpi != mDpi )
196
+ {
197
+ updateDpi ( currentDpi );
198
+ }
199
+ }
200
+ else
201
+ {
202
+ mSize .setWidth ( mSize .width () * extent.width () / mExtent .width () );
203
+ mSize .setHeight ( mSize .height () * extent.height () / mExtent .height () );
204
+ }
205
+ updateOutputSize ();
182
206
207
+ mExtent = extent;
183
208
if ( mLockAspectRatio ->locked () )
184
209
{
185
210
mExtentGroupBox ->setRatio ( QSize ( mSize .width (), mSize .height () ) );
186
211
}
187
-
188
- updateOutputSize ();
189
212
}
190
213
191
214
void QgsMapSaveDialog::updateScale ( double scale )
0 commit comments