mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Print: add a setup() method to PrintLayout
The setup() method will be called each time to obtain the current printer settings. Also it calculates required scalling based on screen agains printer DPI. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
41bad7695e
commit
20804b16d3
3 changed files with 25 additions and 1 deletions
|
@ -43,6 +43,9 @@ void PrintDialog::runDialog()
|
||||||
|
|
||||||
void PrintDialog::printClicked(void)
|
void PrintDialog::printClicked(void)
|
||||||
{
|
{
|
||||||
// nop for now
|
// temporary
|
||||||
|
printer.setOutputFileName("print.pdf");
|
||||||
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||||
|
// ---------
|
||||||
printLayout->print();
|
printLayout->print();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QApplication>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "printlayout.h"
|
#include "printlayout.h"
|
||||||
|
|
||||||
|
@ -21,6 +23,8 @@ PrintLayout::PrintLayout(PrintDialog *dialogPtr, QPrinter *printerPtr, struct op
|
||||||
|
|
||||||
void PrintLayout::print()
|
void PrintLayout::print()
|
||||||
{
|
{
|
||||||
|
// we call setup each time to check if the printer properties have changed
|
||||||
|
setup();
|
||||||
switch (printOptions->type) {
|
switch (printOptions->type) {
|
||||||
case options::PRETTY:
|
case options::PRETTY:
|
||||||
printSixDives();
|
printSixDives();
|
||||||
|
@ -34,6 +38,19 @@ void PrintLayout::print()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintLayout::setup()
|
||||||
|
{
|
||||||
|
QDesktopWidget *desktop = QApplication::desktop();
|
||||||
|
screenDpiX = desktop->physicalDpiX();
|
||||||
|
screenDpiY = desktop->physicalDpiX();
|
||||||
|
|
||||||
|
printerDpi = printer->resolution();
|
||||||
|
pageRect = printer->pageRect();
|
||||||
|
|
||||||
|
scaleX = (qreal)printerDpi/(qreal)screenDpiX;
|
||||||
|
scaleY = (qreal)printerDpi/(qreal)screenDpiY;
|
||||||
|
}
|
||||||
|
|
||||||
void PrintLayout::printSixDives()
|
void PrintLayout::printSixDives()
|
||||||
{
|
{
|
||||||
// nop
|
// nop
|
||||||
|
|
|
@ -20,7 +20,11 @@ private:
|
||||||
struct options *printOptions;
|
struct options *printOptions;
|
||||||
|
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
|
int screenDpiX, screenDpiY, printerDpi;
|
||||||
|
qreal scaleX, scaleY;
|
||||||
|
QRect pageRect;
|
||||||
|
|
||||||
|
void setup();
|
||||||
void printSixDives();
|
void printSixDives();
|
||||||
void printTwoDives();
|
void printTwoDives();
|
||||||
void printTable();
|
void printTable();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue