Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Applied patch #2159 from ctimko
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13545 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 22, 2010
1 parent a875ca5 commit e4a2eff
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
24 changes: 17 additions & 7 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -52,9 +52,9 @@
#include <QMatrix>
#include <QMenuBar>
#include <QMessageBox>
#include <QPageSetupDialog>
#include <QPainter>

#include <QPrinter>
#include <QPrintDialog>
#include <QSettings>
#include <QIcon>
Expand Down Expand Up @@ -137,6 +137,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title ): QMainWindow(),
fileMenu->addAction( mActionExportAsPDF );
fileMenu->addAction( mActionExportAsSVG );
fileMenu->addSeparator();
fileMenu->addAction( mActionPageSetup );
fileMenu->addAction( mActionPrint );
fileMenu->addSeparator();
fileMenu->addAction( mActionQuit );
Expand Down Expand Up @@ -486,26 +487,26 @@ void QgsComposer::on_mActionExportAsPDF_triggered()

void QgsComposer::on_mActionPrint_triggered()
{
QPrinter printer;
//QPrinter printer;
if ( mComposition )
{
if ( mComposition->paperWidth() >= mComposition->paperHeight() )
{
printer.setOrientation( QPrinter::Landscape );
mPrinter.setOrientation( QPrinter::Landscape );
}
else
{
printer.setOrientation( QPrinter::Portrait );
mPrinter.setOrientation( QPrinter::Portrait );
}
}
printer.setPaperSize( QSizeF( mComposition->paperWidth(), mComposition->paperHeight() ), QPrinter::Millimeter );
QPrintDialog printDialog( &printer, 0 );
mPrinter.setPaperSize( QSizeF( mComposition->paperWidth(), mComposition->paperHeight() ), QPrinter::Millimeter );
QPrintDialog printDialog( &mPrinter, 0 );
if ( printDialog.exec() != QDialog::Accepted )
{
return;
}

print( printer );
print( mPrinter );
}

void QgsComposer::print( QPrinter &printer )
Expand Down Expand Up @@ -1498,4 +1499,13 @@ void QgsComposer::cleanupAfterTemplateRead()
}
}

void QgsComposer::on_mActionPageSetup_triggered()
{
if ( !mComposition )
{
return;
}

QPageSetupDialog pageSetupDialog( &mPrinter, this );
pageSetupDialog.exec();
}
9 changes: 8 additions & 1 deletion src/app/composer/qgscomposer.h
Expand Up @@ -20,6 +20,7 @@
#include "ui_qgscomposerbase.h"
#include "qgscomposeritem.h"
#include "qgscontexthelp.h"
#include <QPrinter>

class QgisApp;
class QgsComposerArrow;
Expand Down Expand Up @@ -118,6 +119,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! Print the composition
void on_mActionPrint_triggered();

//! Page Setup for composition
void on_mActionPageSetup_triggered();

//! Print as image
void on_mActionExportAsImage_triggered();

Expand Down Expand Up @@ -201,7 +205,7 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! Save window state
void saveWindowState();

/**Add a composer arrow to the item/widget map and crete a configuration widget for it*/
/**Add a composer arrow to the item/widget map and creates a configuration widget for it*/
void addComposerArrow( QgsComposerArrow* arrow );

/**Add a composer map to the item/widget map and creates a configuration widget for it*/
Expand Down Expand Up @@ -299,6 +303,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase

//! Window menu action to select this window
QAction *mWindowAction;

//! Page & Printer Setup
QPrinter mPrinter;
};

#endif
5 changes: 5 additions & 0 deletions src/ui/qgscomposerbase.ui
Expand Up @@ -474,6 +474,11 @@
<string>Adds attribute table</string>
</property>
</action>
<action name="mActionPageSetup">
<property name="text">
<string>Page Setup</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>mCompositionNameComboBox</tabstop>
Expand Down

0 comments on commit e4a2eff

Please sign in to comment.