diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-07-10 16:04:00 +0300 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-07-10 16:18:16 +0300 |
commit | 20804b16d333f0a9d8b9f5e6eba05eddd60cc68e (patch) | |
tree | 283106304ecc3c434fba10cba3279e623492b9d2 /qt-ui/printlayout.cpp | |
parent | 41bad7695ee40571062a370610e6ca518295e3c7 (diff) | |
download | subsurface-20804b16d333f0a9d8b9f5e6eba05eddd60cc68e.tar.gz |
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>
Diffstat (limited to 'qt-ui/printlayout.cpp')
-rw-r--r-- | qt-ui/printlayout.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index 7716883e8..be5d955ea 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -1,4 +1,6 @@ #include <QPainter> +#include <QDesktopWidget> +#include <QApplication> #include "mainwindow.h" #include "printlayout.h" @@ -21,6 +23,8 @@ PrintLayout::PrintLayout(PrintDialog *dialogPtr, QPrinter *printerPtr, struct op void PrintLayout::print() { + // we call setup each time to check if the printer properties have changed + setup(); switch (printOptions->type) { case options::PRETTY: 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() { // nop |