Skip to content

Commit 63c6950

Browse files
author
mhugent
committed
Applied patch #2159 from ctimko
git-svn-id: http://svn.osgeo.org/qgis/trunk@13545 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4e751ff commit 63c6950

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

src/app/composer/qgscomposer.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
#include <QMatrix>
5353
#include <QMenuBar>
5454
#include <QMessageBox>
55+
#include <QPageSetupDialog>
5556
#include <QPainter>
5657

57-
#include <QPrinter>
5858
#include <QPrintDialog>
5959
#include <QSettings>
6060
#include <QIcon>
@@ -137,6 +137,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title ): QMainWindow(),
137137
fileMenu->addAction( mActionExportAsPDF );
138138
fileMenu->addAction( mActionExportAsSVG );
139139
fileMenu->addSeparator();
140+
fileMenu->addAction( mActionPageSetup );
140141
fileMenu->addAction( mActionPrint );
141142
fileMenu->addSeparator();
142143
fileMenu->addAction( mActionQuit );
@@ -486,26 +487,26 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
486487

487488
void QgsComposer::on_mActionPrint_triggered()
488489
{
489-
QPrinter printer;
490+
//QPrinter printer;
490491
if ( mComposition )
491492
{
492493
if ( mComposition->paperWidth() >= mComposition->paperHeight() )
493494
{
494-
printer.setOrientation( QPrinter::Landscape );
495+
mPrinter.setOrientation( QPrinter::Landscape );
495496
}
496497
else
497498
{
498-
printer.setOrientation( QPrinter::Portrait );
499+
mPrinter.setOrientation( QPrinter::Portrait );
499500
}
500501
}
501-
printer.setPaperSize( QSizeF( mComposition->paperWidth(), mComposition->paperHeight() ), QPrinter::Millimeter );
502-
QPrintDialog printDialog( &printer, 0 );
502+
mPrinter.setPaperSize( QSizeF( mComposition->paperWidth(), mComposition->paperHeight() ), QPrinter::Millimeter );
503+
QPrintDialog printDialog( &mPrinter, 0 );
503504
if ( printDialog.exec() != QDialog::Accepted )
504505
{
505506
return;
506507
}
507508

508-
print( printer );
509+
print( mPrinter );
509510
}
510511

511512
void QgsComposer::print( QPrinter &printer )
@@ -1498,4 +1499,13 @@ void QgsComposer::cleanupAfterTemplateRead()
14981499
}
14991500
}
15001501

1502+
void QgsComposer::on_mActionPageSetup_triggered()
1503+
{
1504+
if ( !mComposition )
1505+
{
1506+
return;
1507+
}
15011508

1509+
QPageSetupDialog pageSetupDialog( &mPrinter, this );
1510+
pageSetupDialog.exec();
1511+
}

src/app/composer/qgscomposer.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "ui_qgscomposerbase.h"
2121
#include "qgscomposeritem.h"
2222
#include "qgscontexthelp.h"
23+
#include <QPrinter>
2324

2425
class QgisApp;
2526
class QgsComposerArrow;
@@ -118,6 +119,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
118119
//! Print the composition
119120
void on_mActionPrint_triggered();
120121

122+
//! Page Setup for composition
123+
void on_mActionPageSetup_triggered();
124+
121125
//! Print as image
122126
void on_mActionExportAsImage_triggered();
123127

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

204-
/**Add a composer arrow to the item/widget map and crete a configuration widget for it*/
208+
/**Add a composer arrow to the item/widget map and creates a configuration widget for it*/
205209
void addComposerArrow( QgsComposerArrow* arrow );
206210

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

300304
//! Window menu action to select this window
301305
QAction *mWindowAction;
306+
307+
//! Page & Printer Setup
308+
QPrinter mPrinter;
302309
};
303310

304311
#endif

src/ui/qgscomposerbase.ui

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,11 @@
474474
<string>Adds attribute table</string>
475475
</property>
476476
</action>
477+
<action name="mActionPageSetup">
478+
<property name="text">
479+
<string>Page Setup</string>
480+
</property>
481+
</action>
477482
</widget>
478483
<tabstops>
479484
<tabstop>mCompositionNameComboBox</tabstop>

0 commit comments

Comments
 (0)