Printing: add template_options struct that contains template

The template_options struct holds the settings variables in the code.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Gehad elrobey 2015-06-29 03:16:19 +02:00 committed by Lubomir I. Ivanov
parent ff594c65e3
commit a600ea5201
6 changed files with 18 additions and 7 deletions

View file

@ -34,7 +34,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
}
// create a print options object and pass our options struct
optionsWidget = new PrintOptions(this, &printOptions);
optionsWidget = new PrintOptions(this, &printOptions, &templateOptions);
// create a new printer object
printer = new Printer(&qprinter, &printOptions);

View file

@ -6,6 +6,7 @@
#include <QPrinter>
#include "printoptions.h"
#include "printer.h"
#include "templateedit.h"
class QProgressBar;
class PrintOptions;
@ -24,6 +25,7 @@ private:
Printer *printer;
QPrinter qprinter;
struct print_options printOptions;
struct template_options templateOptions;
private
slots:

View file

@ -2,7 +2,7 @@
#include "templateedit.h"
#include <QDebug>
PrintOptions::PrintOptions(QWidget *parent, struct print_options *printOpt)
PrintOptions::PrintOptions(QWidget *parent, struct print_options *printOpt, struct template_options *templateOpt)
{
hasSetupSlots = false;
ui.setupUi(this);
@ -11,6 +11,7 @@ PrintOptions::PrintOptions(QWidget *parent, struct print_options *printOpt)
if (!printOpt)
return;
setup(printOpt);
templateOptions = templateOpt;
}
void PrintOptions::setup(struct print_options *printOpt)
@ -101,6 +102,6 @@ void PrintOptions::on_printTemplate_currentIndexChanged(int index)
void PrintOptions::on_editButton_clicked()
{
TemplateEdit te;
TemplateEdit te(this, templateOptions);
te.exec();
}

View file

@ -25,12 +25,13 @@ class PrintOptions : public QWidget {
Q_OBJECT
public:
explicit PrintOptions(QWidget *parent = 0, struct print_options *printOpt = 0);
explicit PrintOptions(QWidget *parent, struct print_options *printOpt, struct template_options *templateOpt);
void setup(struct print_options *printOpt);
private:
Ui::PrintOptions ui;
struct print_options *printOptions;
struct template_options *templateOptions;
bool hasSetupSlots;
private

View file

@ -1,7 +1,7 @@
#include "templateedit.h"
#include "ui_templateedit.h"
TemplateEdit::TemplateEdit(QWidget *parent) :
TemplateEdit::TemplateEdit(QWidget *parent, struct template_options *templateOptions) :
QDialog(parent),
ui(new Ui::TemplateEdit)
{

View file

@ -3,6 +3,13 @@
#include <QDialog>
struct template_options {
int font_index;
int color_palette_index;
double font_size;
double line_spacing;
};
namespace Ui {
class TemplateEdit;
}
@ -12,11 +19,11 @@ class TemplateEdit : public QDialog
Q_OBJECT
public:
explicit TemplateEdit(QWidget *parent = 0);
explicit TemplateEdit(QWidget *parent, struct template_options *templateOptions);
~TemplateEdit();
private:
Ui::TemplateEdit *ui;
struct template_options *templateOptions;
};
#endif // TEMPLATEEDIT_H