subsurface/qt-ui/printlayout.cpp
Lubomir I. Ivanov 20804b16d3 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>
2013-07-10 16:18:16 +03:00

67 lines
1.2 KiB
C++

#include <QPainter>
#include <QDesktopWidget>
#include <QApplication>
#include "mainwindow.h"
#include "printlayout.h"
/*
struct options {
enum { PRETTY, TABLE, TWOPERPAGE } type;
int print_selected;
int color_selected;
bool notes_up;
int profile_height, notes_height, tanks_height;
};
*/
PrintLayout::PrintLayout(PrintDialog *dialogPtr, QPrinter *printerPtr, struct options *optionsPtr)
{
dialog = dialogPtr;
printer = printerPtr;
printOptions = optionsPtr;
}
void PrintLayout::print()
{
// we call setup each time to check if the printer properties have changed
setup();
switch (printOptions->type) {
case options::PRETTY:
printSixDives();
break;
case options::TWOPERPAGE:
printTwoDives();
break;
case options::TABLE:
printTable();
break;
}
}
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
}
void PrintLayout::printTwoDives()
{
// nop
}
void PrintLayout::printTable()
{
// nop
}