summaryrefslogtreecommitdiffstats
path: root/printer.cpp
AgeCommit message (Collapse)Author
2015-08-15Printing: remove silly white line at end of each pageGravatar Gehad elrobey
QPrinter::pageRect() doesn't always return the correct value of the printable area, which results in white horizontal lines of un-rendered area at the bottom of each page, Use QPrinter::pageLayout() instead which fixes the issue. QPrinter::pageLayout() is added in QT 5.3, So use pageRect for previous versions. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15Printing: fill the QPainter background color before renderingGravatar Gehad elrobey
While rendering a dynamically sized view port, it may not fit the full page size, But the background color should be the same for the whole page, So fill the page background color with the template background color before rendering. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15Printing: don't break dives into successive pagesGravatar Gehad elrobey
While rendering a template with "0" dives per page value, try to fit as many dives per page but don't break a dive into 2 pages. Use a dynamically sized view port to fit the rendered area only, and don't render the full page. All the Template elements that shouldn't be broken should have the CSS class "dontbreak". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15Printing: export border to templatesGravatar Gehad elrobey
As there is a problem with sizing the borders in QWebView, "vw" sizing is not working as supposed with border-width, As a workaround we export border-width dynamically, so that border-width is relatively the same for all page sizes. The border-width is equal to the page width / 1000 which gives a nice range for borders for A0 - A5 papers, Also prevent drawing zero pixel borders and use 1 px borders as the minimum border. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15Printing: fix scrolling bug by adding extra paddingGravatar Gehad elrobey
This bug occurs in "table" and "flowlayout" templates, it takes place when the size of the full web view to be rendered is not divisible by the size of the view port (Page size), This issue is fixed by adding extra padding to the bottom of the body so that the total body height is divisable by the view port size. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15Printing: hide scrollbar from QWebview to fix padding issueGravatar Gehad elrobey
The vertical scrollbar was causing a default margin at the right most of the page which corrupted the page layout calculations. By hidding the vertical scrollbar the issue is fixed. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15Printing: add statistics printGravatar Gehad elrobey
Add statistics table print option. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-08-15Printing: use pageRect() to support old QT versionsGravatar Gehad elrobey
While calculating the page size use QPrinter::pageRect instead of QPrinter::pageLayout which is added in QT 5.3 and is not supported in earlier versions. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
2015-07-29Printing: calculate a much more accurate font scale valueGravatar Dirk Hohndel
This simply uses the relative size of the profile. This can result in truly tiny text in print, but at least it's consistent and logical. We could add some minimum value there but I'm not sure that's the right answer, either. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-28Printing: fix dive lookup for profile generationGravatar Dirk Hohndel
The existing code (and templates) looked up dives by number and then used that as index into the dive table. This worked exactly in one case: if all dives were numbered consecutively starting with 1. While that is not an entirely unreasonable case, it's of course not an acceptable assumption to make. This commit adds the necessary changes to instead look up dives by their unique id. That's what it's there fore, after all. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-28Printing: get the number of pages from the full resolutionGravatar Gehad elrobey
When we calculate the number of pages to print we need to check if the template doesn't define the number of dives per one page, then render as much dives as we can fit in one page. A dive can be broken into many pages. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-20Printing: transfer profile to QImage if grayscaleGravatar Gehad elrobey
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-20Printing: add preview to TemplateEdit dialogGravatar Gehad elrobey
Show QPixmap in QLabel, Use Printer class to render the Preview on the QPixmap. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-20Printing: check for different printing modesGravatar Gehad elrobey
Add PRINT/PREVIEW print modes, check for printing modes before casting. We must pass a QPaintDevice with type QPixmap for previewing and with type QPrinter for actual printing. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-20Printing: change QPrinter to parent class QPaintDeviceGravatar Gehad elrobey
Use general class QPaintDevice to be used for printing and previewing instances, printing uses a QPrinter object while previewing uses a QPixmap instance. We use static_cast to use the needed object. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-20Printing: refactoring printer classGravatar Gehad elrobey
- Render specific number of pages only. - Move printer related code to print(). Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-20Printing: handle memory leak in printer classGravatar Gehad elrobey
Don't initialize new webview each time we print. Delete the QWebView object in the destructor. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05Printing: retrieve number of dives per page from the template fileGravatar Gehad elrobey
Add special data attribute 'data-numberofdives' in the template <body> with the number of dives per page. This is standard HTML5 specification so it won't corrupt the template file. Any template that will be used for printing must contain this attribute to assure correct output. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05Printing: pass the template_options struct to TemplateLayoutGravatar Gehad elrobey
The template_options struct needs to be passed to TemplateLayout constructor. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05Printing: choose printing color mode 'color/greyscale'Gravatar Gehad elrobey
We can have color printouts only if the printer supports color prints, the user selected 'print in colors' from the print dialog and the default printer settings (Operating system wise) is to print in colors, Otherwise the prints will be in greyscale. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05Printing: make dive profile scale dependant on the page size and DPIGravatar Gehad elrobey
Use setFontPrintScale() to change the font scale of the dive profile as a ratio of the full resolution, font = (pageWidth * dpi) / fontvalue Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05Printing: print all dives if 'print selected' is uncheckedGravatar Gehad elrobey
User can choose either to print all dives or print selected dives only. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-22Address uninitialized member warningsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-19Printing: add support for printing on any page sizeGravatar Gehad elrobey
Make page size and orientation customizable. The user can select any page size and orientation and then the rendering resolution will be calculated based on the selected preferences and the printer DPI. The HTML templates must be responsive, also the font-size must be based on the viewport width so that we don't lose quality. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-19Printing: use selected print preferences while printingGravatar Gehad elrobey
Having a pointer to the printing_options struct, it should be used to privide the selected options while printing. Print options used ATM: - number of dives per page - template file name - print in colors Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-19Printing: pass the print_options struct to TemplateLayout and PrinterGravatar Gehad elrobey
As the print_options struct is needed by both TemplateLayout and Printer class, it can be passed to their constructor. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-19Printing: render the dive profile on top of QWebViewGravatar Gehad elrobey
We render the dive profile over the QWebView to the QPainter. This helps us not to save the SVG images to disk and then render them again to the webview. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-19Printing: fix rendering bug for odd number of divesGravatar Gehad elrobey
Odd number of dives needs extra space from the buttom, so that when we scroll to the last page extra whitespace is shown under the last dive frame, this is fixed by adding a default footer to the base template. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-06-04Printing: Add progress updating ability to print dialogGravatar Gehad elrobey
The progress bar shows the progress of both the rendering part and the templating part, unfortunately we can't check the progress of Grantlee templating engine so the progess bar doesn't have a constant pace it stops a little around 20%. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04Printing: Add Printer class that holds the rendering logic.Gravatar Gehad elrobey
Render Html pages into a QWebView then print it using QPainter. the Printer::print() is called that prepare the HTML file to be rendered by the QWebView. Printer::render() will do the rendering task. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>