@@ -473,6 +473,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
473
473
QgsCompositionWidget* compositionWidget = new QgsCompositionWidget ( mGeneralDock , mComposition );
474
474
connect ( mComposition , SIGNAL ( paperSizeChanged () ), compositionWidget, SLOT ( displayCompositionWidthHeight () ) );
475
475
connect ( this , SIGNAL ( printAsRasterChanged ( bool ) ), compositionWidget, SLOT ( setPrintAsRasterCheckBox ( bool ) ) );
476
+ connect ( compositionWidget, SIGNAL ( pageOrientationChanged ( QString ) ), this , SLOT ( setPrinterPageOrientation ( QString ) ) );
476
477
mGeneralDock ->setWidget ( compositionWidget );
477
478
478
479
// undo widget
@@ -514,6 +515,9 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
514
515
connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
515
516
connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
516
517
518
+ // default printer page setup
519
+ setPrinterPageDefaults ();
520
+
517
521
// Create size grip (needed by Mac OS X for QMainWindow if QStatusBar is not visible)
518
522
// should not be needed now that composer has a status bar?
519
523
#if 0
@@ -2599,6 +2603,7 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
2599
2603
QgsCompositionWidget* compositionWidget = new QgsCompositionWidget ( mGeneralDock , mComposition );
2600
2604
QObject::connect ( mComposition , SIGNAL ( paperSizeChanged () ), compositionWidget, SLOT ( displayCompositionWidthHeight () ) );
2601
2605
QObject::connect ( this , SIGNAL ( printAsRasterChanged ( bool ) ), compositionWidget, SLOT ( setPrintAsRasterCheckBox ( bool ) ) );
2606
+ QObject::connect ( compositionWidget, SIGNAL ( pageOrientationChanged ( QString ) ), this , SLOT ( setPrinterPageOrientation ( QString ) ) );
2602
2607
mGeneralDock ->setWidget ( compositionWidget );
2603
2608
2604
2609
// read and restore all the items
@@ -2672,6 +2677,9 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
2672
2677
connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
2673
2678
updateAtlasMapLayerAction ( atlasMap->enabled () );
2674
2679
2680
+ // default printer page setup
2681
+ setPrinterPageDefaults ();
2682
+
2675
2683
setSelectionTool ();
2676
2684
}
2677
2685
@@ -3137,6 +3145,34 @@ void QgsComposer::updateAtlasMapLayerAction( QgsVectorLayer *coverageLayer )
3137
3145
}
3138
3146
}
3139
3147
3148
+ void QgsComposer::setPrinterPageOrientation ( QString orientation )
3149
+ {
3150
+ if ( orientation == tr ( " Landscape" ) )
3151
+ {
3152
+ mPrinter .setOrientation ( QPrinter::Landscape );
3153
+ }
3154
+ else
3155
+ {
3156
+ mPrinter .setOrientation ( QPrinter::Portrait );
3157
+ }
3158
+ }
3159
+
3160
+ void QgsComposer::setPrinterPageDefaults ()
3161
+ {
3162
+ double paperWidth = mComposition ->paperWidth ();
3163
+ double paperHeight = mComposition ->paperHeight ();
3164
+
3165
+ // set printer page orientation
3166
+ if ( paperWidth > paperHeight )
3167
+ {
3168
+ mPrinter .setOrientation ( QPrinter::Landscape );
3169
+ }
3170
+ else
3171
+ {
3172
+ mPrinter .setOrientation ( QPrinter::Portrait );
3173
+ }
3174
+ }
3175
+
3140
3176
void QgsComposer::updateAtlasMapLayerAction ( bool atlasEnabled )
3141
3177
{
3142
3178
if ( mAtlasFeatureAction )
0 commit comments