summaryrefslogtreecommitdiffstats
path: root/qt-ui/printdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/printdialog.cpp')
-rw-r--r--qt-ui/printdialog.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp
index 6f30f89f5..9ff29e67b 100644
--- a/qt-ui/printdialog.cpp
+++ b/qt-ui/printdialog.cpp
@@ -8,6 +8,7 @@
#include <QPrintDialog>
#include <QShortcut>
#include <QSettings>
+#include <QMessageBox>
#define SETTINGS_GROUP "PrintDialog"
@@ -22,6 +23,10 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
printOptions.landscape = false;
printOptions.p_template = print_options::ONE_DIVE;
printOptions.type = print_options::DIVELIST;
+ templateOptions.font_index = 0;
+ templateOptions.font_size = 9;
+ templateOptions.color_palette_index = 0;
+ templateOptions.line_spacing = 1;
} else {
s.beginGroup(SETTINGS_GROUP);
printOptions.type = (print_options::print_type)s.value("type").toInt();
@@ -30,13 +35,17 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
printOptions.landscape = s.value("landscape").toBool();
printOptions.p_template = (print_options::print_template)s.value("template_selected").toInt();
qprinter.setOrientation((QPrinter::Orientation)printOptions.landscape);
+ templateOptions.font_index = s.value("font").toInt();
+ templateOptions.font_size = s.value("font_size").toDouble();
+ templateOptions.color_palette_index = s.value("color_palette").toInt();
+ templateOptions.line_spacing = s.value("line_spacing").toDouble();
}
// 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);
+ printer = new Printer(&qprinter, &printOptions, &templateOptions);
QVBoxLayout *layout = new QVBoxLayout(this);
setLayout(layout);
@@ -82,21 +91,47 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
void PrintDialog::onFinished()
{
- // save the settings
QSettings s;
s.beginGroup(SETTINGS_GROUP);
+
+ // save print paper settings
s.setValue("type", printOptions.type);
s.setValue("print_selected", printOptions.print_selected);
s.setValue("color_selected", printOptions.color_selected);
s.setValue("template_selected", printOptions.p_template);
+
+ // save template settings
+ s.setValue("font", templateOptions.font_index);
+ s.setValue("font_size", templateOptions.font_size);
+ s.setValue("color_palette", templateOptions.color_palette_index);
+ s.setValue("line_spacing", templateOptions.line_spacing);
}
void PrintDialog::previewClicked(void)
{
+ if (printOptions.type == print_options::TABLE || printOptions.type == print_options::STATISTICS) {
+ QMessageBox msgBox;
+ msgBox.setText("This feature is not implemented yet");
+ msgBox.exec();
+ return;
+ }
+
+ QPrintPreviewDialog previewDialog(&qprinter, this, Qt::Window
+ | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint
+ | Qt::WindowTitleHint);
+ connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *)));
+ previewDialog.exec();
}
void PrintDialog::printClicked(void)
{
+ if (printOptions.type == print_options::TABLE || printOptions.type == print_options::STATISTICS) {
+ QMessageBox msgBox;
+ msgBox.setText("This feature is not implemented yet");
+ msgBox.exec();
+ return;
+ }
+
QPrintDialog printDialog(&qprinter, this);
if (printDialog.exec() == QDialog::Accepted) {
switch (printOptions.type) {
@@ -115,5 +150,9 @@ void PrintDialog::printClicked(void)
void PrintDialog::onPaintRequested(QPrinter *printerPtr)
{
+ connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
+ printer->print();
+ progressBar->setValue(0);
+ disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
}
#endif