mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: pass the print_options struct to TemplateLayout and Printer
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>
This commit is contained in:
parent
42b9d0d047
commit
60c5e3cf25
5 changed files with 12 additions and 6 deletions
|
@ -9,9 +9,10 @@
|
||||||
#define A4_300DPI_WIDTH 2480
|
#define A4_300DPI_WIDTH 2480
|
||||||
#define A4_300DPI_HIGHT 3508
|
#define A4_300DPI_HIGHT 3508
|
||||||
|
|
||||||
Printer::Printer(QPrinter *printer)
|
Printer::Printer(QPrinter *printer, print_options *printOptions)
|
||||||
{
|
{
|
||||||
this->printer = printer;
|
this->printer = printer;
|
||||||
|
this->printOptions = printOptions;
|
||||||
|
|
||||||
//override these settings for now.
|
//override these settings for now.
|
||||||
printer->setFullPage(true);
|
printer->setFullPage(true);
|
||||||
|
@ -112,7 +113,7 @@ void Printer::templateProgessUpdated(int value)
|
||||||
|
|
||||||
void Printer::print()
|
void Printer::print()
|
||||||
{
|
{
|
||||||
TemplateLayout t;
|
TemplateLayout t(printOptions);
|
||||||
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
|
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
|
||||||
webView = new QWebView();
|
webView = new QWebView();
|
||||||
webView->setHtml(t.generate());
|
webView->setHtml(t.generate());
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include "profile/profilewidget2.h"
|
#include "profile/profilewidget2.h"
|
||||||
|
#include "printoptions.h"
|
||||||
|
|
||||||
class Printer : public QObject {
|
class Printer : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -14,6 +15,7 @@ class Printer : public QObject {
|
||||||
private:
|
private:
|
||||||
QPrinter *printer;
|
QPrinter *printer;
|
||||||
QWebView *webView;
|
QWebView *webView;
|
||||||
|
print_options *printOptions;
|
||||||
void render();
|
void render();
|
||||||
void putProfileImage(QRect box, QRect viewPort, QPainter *painter, struct dive *dive, QPointer<ProfileWidget2> profile);
|
void putProfileImage(QRect box, QRect viewPort, QPainter *painter, struct dive *dive, QPointer<ProfileWidget2> profile);
|
||||||
int done;
|
int done;
|
||||||
|
@ -22,7 +24,7 @@ private slots:
|
||||||
void templateProgessUpdated(int value);
|
void templateProgessUpdated(int value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Printer(QPrinter *printer);
|
Printer(QPrinter *printer, print_options *printOptions);
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -35,7 +35,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
|
||||||
optionsWidget = new PrintOptions(this, &printOptions);
|
optionsWidget = new PrintOptions(this, &printOptions);
|
||||||
|
|
||||||
// create a new printer object
|
// create a new printer object
|
||||||
printer = new Printer(&qprinter);
|
printer = new Printer(&qprinter, &printOptions);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
|
@ -16,8 +16,9 @@ int getTotalWork()
|
||||||
return dives;
|
return dives;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateLayout::TemplateLayout()
|
TemplateLayout::TemplateLayout(print_options *PrintOptions)
|
||||||
{
|
{
|
||||||
|
this->PrintOptions = PrintOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateLayout::~TemplateLayout()
|
TemplateLayout::~TemplateLayout()
|
||||||
|
|
|
@ -3,18 +3,20 @@
|
||||||
|
|
||||||
#include <grantlee_templates.h>
|
#include <grantlee_templates.h>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "printoptions.h"
|
||||||
|
|
||||||
int getTotalWork();
|
int getTotalWork();
|
||||||
|
|
||||||
class TemplateLayout : public QObject {
|
class TemplateLayout : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TemplateLayout();
|
TemplateLayout(print_options *PrintOptions);
|
||||||
~TemplateLayout();
|
~TemplateLayout();
|
||||||
QString generate();
|
QString generate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Grantlee::Engine *m_engine;
|
Grantlee::Engine *m_engine;
|
||||||
|
print_options *PrintOptions;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void progressUpdated(int value);
|
void progressUpdated(int value);
|
||||||
|
|
Loading…
Add table
Reference in a new issue