# HG changeset patch # User Matti Hamalainen # Date 1505812259 -10800 # Node ID eeb3bb877b63c606f3099827aecdbfd5013e6328 # Parent 1c2f9d09e87b4e101c9c840757b85673afc2fedc More work on printing improvements, make certain hardcoded values #defines. diff -r 1c2f9d09e87b -r eeb3bb877b63 src/printing.cpp --- a/src/printing.cpp Tue Sep 19 11:27:38 2017 +0300 +++ b/src/printing.cpp Tue Sep 19 12:10:59 2017 +0300 @@ -10,6 +10,9 @@ #include #include "main.h" +#define APP_PRINT_WIDTH 1000 +#define APP_PRINT_HEIGHT 1300 + void SyntilistaMainWindow::on_button_Print_clicked() { @@ -25,7 +28,7 @@ pinfo.npages = 0; pinfo.nlinesPerPage = 0; - QPixmap tmpPixmap(1000, 1300); + QPixmap tmpPixmap(APP_PRINT_WIDTH, APP_PRINT_HEIGHT); QPainter tmpPainter; tmpPainter.begin(&tmpPixmap); bool ret = printDocumentPage(true, -1, &tmpPainter, &printer); @@ -132,8 +135,8 @@ pt->save(); pt->scale( - pt->device()->width() / 1000.0f, - pt->device()->height() / 1300.0f); + pt->device()->width() / (float) APP_PRINT_WIDTH, + pt->device()->height() / (float) APP_PRINT_HEIGHT); QFont font1; font1.setFamily("Arial"); @@ -149,7 +152,7 @@ // Check for end of page // KLUDGE for now - if (getPageInfo && ctx.lfq(10) >= 1300.0f - 50) + if (getPageInfo && ctx.lfq(10) >= APP_PRINT_HEIGHT - ctx.boundRect().height() * 1.5f) { if (nline > pinfo.nlinesPerPage) pinfo.nlinesPerPage = nline; @@ -172,7 +175,7 @@ ctx.drawText( 870, 120, tr("Tase")); ctx.lf(); - pt->drawLine(0, ctx.m_pos.y(), 1000, ctx.m_pos.y()); + pt->drawLine(0, ctx.m_pos.y(), APP_PRINT_WIDTH, ctx.m_pos.y()); ctx.move(0, 5); } @@ -183,7 +186,7 @@ pt->fillRect( 0, ctx.m_pos.y() - 1, - 1000, + APP_PRINT_WIDTH, ctx.boundRect().height() + 4, QColor(0, 0, 0, 40)); } @@ -209,8 +212,8 @@ } else { - ctx.setPos(0, 1240); - ctx.drawText(0, 1000, + ctx.setPos(0, APP_PRINT_HEIGHT - ctx.boundRect().height()); + ctx.drawText(0, APP_PRINT_WIDTH, tr("Sivu %1 / %2 (%3 / %4)"). arg(npage - printer->fromPage() + 1). arg(printer->toPage() - printer->fromPage() + 1).