mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
20804b16d3
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>
67 lines
1.2 KiB
C++
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
|
|
}
|