36 changes: 36 additions & 0 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
QgsCompositionWidget* compositionWidget = new QgsCompositionWidget( mGeneralDock, mComposition );
connect( mComposition, SIGNAL( paperSizeChanged() ), compositionWidget, SLOT( displayCompositionWidthHeight() ) );
connect( this, SIGNAL( printAsRasterChanged( bool ) ), compositionWidget, SLOT( setPrintAsRasterCheckBox( bool ) ) );
connect( compositionWidget, SIGNAL( pageOrientationChanged( QString ) ), this, SLOT( setPrinterPageOrientation( QString ) ) );
mGeneralDock->setWidget( compositionWidget );

//undo widget
Expand Down Expand Up @@ -514,6 +515,9 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
connect( atlasMap, SIGNAL( toggled( bool ) ), this, SLOT( toggleAtlasControls( bool ) ) );
connect( atlasMap, SIGNAL( coverageLayerChanged( QgsVectorLayer* ) ), this, SLOT( updateAtlasMapLayerAction( QgsVectorLayer * ) ) );

//default printer page setup
setPrinterPageDefaults();

// Create size grip (needed by Mac OS X for QMainWindow if QStatusBar is not visible)
//should not be needed now that composer has a status bar?
#if 0
Expand Down Expand Up @@ -2599,6 +2603,7 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
QgsCompositionWidget* compositionWidget = new QgsCompositionWidget( mGeneralDock, mComposition );
QObject::connect( mComposition, SIGNAL( paperSizeChanged() ), compositionWidget, SLOT( displayCompositionWidthHeight() ) );
QObject::connect( this, SIGNAL( printAsRasterChanged( bool ) ), compositionWidget, SLOT( setPrintAsRasterCheckBox( bool ) ) );
QObject::connect( compositionWidget, SIGNAL( pageOrientationChanged( QString ) ), this, SLOT( setPrinterPageOrientation( QString ) ) );
mGeneralDock->setWidget( compositionWidget );

//read and restore all the items
Expand Down Expand Up @@ -2672,6 +2677,9 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
connect( atlasMap, SIGNAL( coverageLayerChanged( QgsVectorLayer* ) ), this, SLOT( updateAtlasMapLayerAction( QgsVectorLayer * ) ) );
updateAtlasMapLayerAction( atlasMap->enabled() );

//default printer page setup
setPrinterPageDefaults();

setSelectionTool();
}

Expand Down Expand Up @@ -3137,6 +3145,34 @@ void QgsComposer::updateAtlasMapLayerAction( QgsVectorLayer *coverageLayer )
}
}

void QgsComposer::setPrinterPageOrientation( QString orientation )
{
if ( orientation == tr( "Landscape" ) )
{
mPrinter.setOrientation( QPrinter::Landscape );
}
else
{
mPrinter.setOrientation( QPrinter::Portrait );
}
}

void QgsComposer::setPrinterPageDefaults()
{
double paperWidth = mComposition->paperWidth();
double paperHeight = mComposition->paperHeight();

//set printer page orientation
if ( paperWidth > paperHeight )
{
mPrinter.setOrientation( QPrinter::Landscape );
}
else
{
mPrinter.setOrientation( QPrinter::Portrait );
}
}

void QgsComposer::updateAtlasMapLayerAction( bool atlasEnabled )
{
if ( mAtlasFeatureAction )
Expand Down
8 changes: 8 additions & 0 deletions src/app/composer/qgscomposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! Updates the "set as atlas feature" map layer action, removing it if atlas is disabled
void updateAtlasMapLayerAction( bool atlasEnabled );

//! Set default settings for printer page settings based on composition paper size
void setPrinterPageDefaults();

/**Composer title*/
QString mTitle;

Expand Down Expand Up @@ -557,6 +560,7 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase

QgsMapLayerAction* mAtlasFeatureAction;


signals:
void printAsRasterChanged( bool state );

Expand Down Expand Up @@ -592,6 +596,10 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase

//! Updates the "set as atlas feature" map layer action when atlas coverage layer changes
void updateAtlasMapLayerAction( QgsVectorLayer* coverageLayer );

//! Sets the printer page orientation when the page orientation changes
void setPrinterPageOrientation( QString orientation );

};

#endif
Expand Down
3 changes: 0 additions & 3 deletions src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mFrameGroupBox->blockSignals( true );
mBackgroundGroupBox->blockSignals( true );
mItemIdLineEdit->blockSignals( true );
mItemUuidLineEdit->blockSignals( true );
mBlendModeCombo->blockSignals( true );
mTransparencySlider->blockSignals( true );
mTransparencySpnBx->blockSignals( true );
Expand All @@ -351,7 +350,6 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mOutlineWidthSpinBox->setValue( mItem->pen().widthF() );
mItemIdLineEdit->setText( mItem->id() );
mItemUuidLineEdit->setText( mItem->uuid() );
mFrameGroupBox->setChecked( mItem->hasFrame() );
mBackgroundGroupBox->setChecked( mItem->hasBackground() );
mBlendModeCombo->setBlendMode( mItem->blendMode() );
Expand All @@ -365,7 +363,6 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mFrameGroupBox->blockSignals( false );
mBackgroundGroupBox->blockSignals( false );
mItemIdLineEdit->blockSignals( false );
mItemUuidLineEdit->blockSignals( false );
mBlendModeCombo->blockSignals( false );
mTransparencySlider->blockSignals( false );
mTransparencySpnBx->blockSignals( false );
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,11 @@ void QgsCompositionWidget::adjustOrientation()
setSize( mPaperWidthDoubleSpinBox, height );
setSize( mPaperHeightDoubleSpinBox, width );
}

mPaperWidthDoubleSpinBox->setEnabled( lineEditsEnabled );
mPaperHeightDoubleSpinBox->setEnabled( lineEditsEnabled );

emit pageOrientationChanged( mPaperOrientationComboBox->currentText() );
}

void QgsCompositionWidget::setSize( QDoubleSpinBox *spin, double v )
Expand Down
4 changes: 4 additions & 0 deletions src/app/composer/qgscompositionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase
/**Sets Print as raster checkbox value*/
void setPrintAsRasterCheckBox( bool state );

signals:
/**Is emitted when page orientation changes*/
void pageOrientationChanged( QString orientation );

private slots:
/* when a new map is added */
void onComposerMapAdded( QgsComposerMap* );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgisgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace QgisGui
#endif

// Add the file type suffix to the fileName if required
if ( !ext.isNull() && !outputFileName.endsWith( "." + ext ) )
if ( !ext.isNull() && !outputFileName.toLower().endsWith( "." + ext.toLower() ) )
{
outputFileName += "." + ext;
}
Expand Down
20 changes: 3 additions & 17 deletions src/ui/qgscomposeritemwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -342,30 +342,16 @@
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<item row="1" column="0">
<widget class="QLabel" name="mItemUuidLabel">
<property name="text">
<string>Uuid (read-only)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mItemUuidLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mItemIdLineEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mItemIdLabel">
<property name="text">
<string>Id</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mItemIdLineEdit"/>
</item>
</layout>
</widget>
</item>
Expand Down