summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-23 07:38:11 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-23 07:38:11 -0700
commit2f540b56a8e42c8a0722dec3676297024f31eb74 (patch)
treed5c34830520481fccef873a3cbc5b9f60aae8d07 /qt-ui
parentfbce8a0378f5ebcd36dbc08b3b5771ccf5cad830 (diff)
parentcc864794753eb586e89470d87196e13568cb9031 (diff)
downloadsubsurface-2f540b56a8e42c8a0722dec3676297024f31eb74.tar.gz
Merge branch 'custom-print' of github.com:neolit123/subsurface
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/printdialog.cpp20
-rw-r--r--qt-ui/printoptions.cpp63
-rw-r--r--qt-ui/printoptions.h1
-rw-r--r--qt-ui/templateedit.cpp7
4 files changed, 51 insertions, 40 deletions
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp
index 002f9b9f4..cf08062d2 100644
--- a/qt-ui/printdialog.cpp
+++ b/qt-ui/printdialog.cpp
@@ -178,15 +178,8 @@ void PrintDialog::printClicked(void)
{
QPrintDialog printDialog(&qprinter, this);
if (printDialog.exec() == QDialog::Accepted) {
- switch (printOptions.type) {
- case print_options::DIVELIST:
- connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
- printer->print();
- break;
- case print_options::STATISTICS:
- printer->print_statistics();
- break;
- }
+ connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
+ printer->print();
close();
}
}
@@ -194,14 +187,7 @@ void PrintDialog::printClicked(void)
void PrintDialog::onPaintRequested(QPrinter *printerPtr)
{
connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
- switch (printOptions.type) {
- case print_options::DIVELIST:
- printer->print();
- break;
- case print_options::STATISTICS:
- printer->print_statistics();
- break;
- }
+ printer->print();
progressBar->setValue(0);
disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
}
diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp
index 419098cf8..cb944f9d7 100644
--- a/qt-ui/printoptions.cpp
+++ b/qt-ui/printoptions.cpp
@@ -31,21 +31,7 @@ void PrintOptions::setup()
break;
}
- // insert existing templates in the UI and select the current template
- qSort(grantlee_templates);
- int current_index = 0, index = 0;
- for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) {
- if ((*i).compare(printOptions->p_template) == 0) {
- current_index = index;
- break;
- }
- index++;
- }
- ui.printTemplate->clear();
- for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) {
- ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i));
- }
- ui.printTemplate->setCurrentIndex(current_index);
+ setupTemplates();
// general print option checkboxes
if (printOptions->color_selected)
@@ -63,6 +49,43 @@ void PrintOptions::setup()
hasSetupSlots = true;
}
+void PrintOptions::setupTemplates()
+{
+ if (printOptions->type == print_options::DIVELIST) {
+ // insert dive list templates in the UI and select the current template
+ qSort(grantlee_templates);
+ int current_index = 0, index = 0;
+ for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) {
+ if ((*i).compare(printOptions->p_template) == 0) {
+ current_index = index;
+ break;
+ }
+ index++;
+ }
+ ui.printTemplate->clear();
+ for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) {
+ ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i));
+ }
+ ui.printTemplate->setCurrentIndex(current_index);
+ } else if (printOptions->type == print_options::STATISTICS) {
+ // insert statistics templates in the UI and select the current template
+ qSort(grantlee_statistics_templates);
+ int current_index = 0, index = 0;
+ for (QList<QString>::iterator i = grantlee_statistics_templates.begin(); i != grantlee_statistics_templates.end(); ++i) {
+ if ((*i).compare(printOptions->p_template) == 0) {
+ current_index = index;
+ break;
+ }
+ index++;
+ }
+ ui.printTemplate->clear();
+ for (QList<QString>::iterator i = grantlee_statistics_templates.begin(); i != grantlee_statistics_templates.end(); ++i) {
+ ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i));
+ }
+ ui.printTemplate->setCurrentIndex(current_index);
+ }
+}
+
// print type radio buttons
void PrintOptions::on_radioDiveListPrint_toggled(bool check)
{
@@ -70,15 +93,14 @@ void PrintOptions::on_radioDiveListPrint_toggled(bool check)
printOptions->type = print_options::DIVELIST;
// print options
- ui.printInColor->setEnabled(true);
ui.printSelected->setEnabled(true);
// print template
ui.deleteButton->setEnabled(true);
- ui.editButton->setEnabled(true);
ui.exportButton->setEnabled(true);
ui.importButton->setEnabled(true);
- ui.printTemplate->setEnabled(true);
+
+ setupTemplates();
}
}
@@ -88,15 +110,14 @@ void PrintOptions::on_radioStatisticsPrint_toggled(bool check)
printOptions->type = print_options::STATISTICS;
// print options
- ui.printInColor->setEnabled(false);
ui.printSelected->setEnabled(false);
// print template
ui.deleteButton->setEnabled(false);
- ui.editButton->setEnabled(false);
ui.exportButton->setEnabled(false);
ui.importButton->setEnabled(false);
- ui.printTemplate->setEnabled(false);
+
+ setupTemplates();
}
}
diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h
index 6d7ffffee..9c50b10f3 100644
--- a/qt-ui/printoptions.h
+++ b/qt-ui/printoptions.h
@@ -70,6 +70,7 @@ private:
struct print_options *printOptions;
struct template_options *templateOptions;
bool hasSetupSlots;
+ void setupTemplates();
private
slots:
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp
index e4e6453ac..b50338090 100644
--- a/qt-ui/templateedit.cpp
+++ b/qt-ui/templateedit.cpp
@@ -35,6 +35,9 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
ui->plainTextEdit->setPlainText(grantlee_template);
editingCustomColors = false;
+ if (printOptions->type == print_options::STATISTICS) {
+ ui->plainTextEdit->setEnabled(false);
+ }
updatePreview();
}
@@ -125,8 +128,8 @@ void TemplateEdit::saveSettings()
if (msgBox.exec() == QMessageBox::Save) {
memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options));
if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) {
- printOptions->p_template = "custom.html";
- TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText());
+ printOptions->p_template = "Custom.html";
+ TemplateLayout::writeTemplate("Custom.html", ui->plainTextEdit->toPlainText());
}
if (templateOptions->color_palette_index == CUSTOM) {
custom_colors = templateOptions->color_palette;