From 2b2c506cb7e5e1659ad68818eca46d14d7840ecd Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 24 Jul 2015 09:53:07 +0200 Subject: Printing: use grantlee templates from the current existing template list We use templates from the grantlee templates list created and dynamically. So we don't need static templates anymore. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/printdialog.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'qt-ui/printdialog.cpp') diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 31ec354c8..bb6643b31 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -30,7 +30,6 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.print_selected = true; printOptions.color_selected = true; printOptions.landscape = false; - printOptions.p_template = print_options::ONE_DIVE; printOptions.type = print_options::DIVELIST; templateOptions.font_index = 0; templateOptions.font_size = 9; @@ -43,7 +42,6 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.print_selected = s.value("print_selected").toBool(); printOptions.color_selected = s.value("color_selected").toBool(); 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(); -- cgit v1.2.3-70-g09d2 From 2a85be91b1bc3ae80a75e5508ffdfc7b7e4c1daa Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 24 Jul 2015 14:27:33 +0200 Subject: Printing: save/load selected template by QSettings We save the selected template name on closing the printDialog, We also load the last selected template from QSettings when initializing the dialog. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/printdialog.cpp | 2 ++ qt-ui/printoptions.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'qt-ui/printdialog.cpp') diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index bb6643b31..c7ce327f5 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -30,6 +30,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.print_selected = true; printOptions.color_selected = true; printOptions.landscape = false; + printOptions.p_template = "one_dive.html"; printOptions.type = print_options::DIVELIST; templateOptions.font_index = 0; templateOptions.font_size = 9; @@ -42,6 +43,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.print_selected = s.value("print_selected").toBool(); printOptions.color_selected = s.value("color_selected").toBool(); printOptions.landscape = s.value("landscape").toBool(); + printOptions.p_template = s.value("template_selected").toString(); qprinter.setOrientation((QPrinter::Orientation)printOptions.landscape); templateOptions.font_index = s.value("font").toInt(); templateOptions.font_size = s.value("font_size").toDouble(); diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp index 3ed3edf11..df49694ee 100644 --- a/qt-ui/printoptions.cpp +++ b/qt-ui/printoptions.cpp @@ -30,12 +30,20 @@ void PrintOptions::setup() break; } - // insert existing templates in the UI - ui.printTemplate->clear(); + // insert existing templates in the UI and select the current template qSort(grantlee_templates); + int current_index = 0; + for (QList::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { + if ((*i).compare(printOptions->p_template) == 0) { + break; + } + current_index++; + } + ui.printTemplate->clear(); for (QList::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i)); } + ui.printTemplate->setCurrentIndex(current_index); // general print option checkboxes if (printOptions->color_selected) -- cgit v1.2.3-70-g09d2 From 7f8d20c09d531a65dd8864e86b33766d49c0b04b Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 24 Jul 2015 16:23:50 +0200 Subject: Printing: fix issue with old QSettings group As I am using the same old QSettings group name, some variables may not be correctly initialized, so we need to check for incorrect values before we start. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/printdialog.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'qt-ui/printdialog.cpp') diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index c7ce327f5..c42ec6fb9 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -56,6 +56,14 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f custom_colors.color5 = QColor(s.value("custom_color_5").toString()); } + // handle cases from old QSettings group + if (templateOptions.font_size < 9) { + templateOptions.font_size = 9; + } + if (templateOptions.line_spacing < 1) { + templateOptions.line_spacing = 1; + } + switch (templateOptions.color_palette_index) { case 0: // almond templateOptions.color_palette = almond_colors; -- cgit v1.2.3-70-g09d2 From e8ad4b0c97c011f9cc89943252a69a8008bbb749 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 26 Jul 2015 00:31:37 +0200 Subject: Printing: remove "Table" option from print options radio group "Table" print is now a template, so remove the radio button. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/printdialog.cpp | 6 ++---- qt-ui/printoptions.cpp | 10 ---------- qt-ui/printoptions.h | 2 -- qt-ui/printoptions.ui | 27 --------------------------- 4 files changed, 2 insertions(+), 43 deletions(-) (limited to 'qt-ui/printdialog.cpp') diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index c42ec6fb9..8717766a1 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -148,7 +148,7 @@ void PrintDialog::onFinished() void PrintDialog::previewClicked(void) { - if (printOptions.type == print_options::TABLE || printOptions.type == print_options::STATISTICS) { + if (printOptions.type == print_options::STATISTICS) { QMessageBox msgBox; msgBox.setText("This feature is not implemented yet"); msgBox.exec(); @@ -164,7 +164,7 @@ void PrintDialog::previewClicked(void) void PrintDialog::printClicked(void) { - if (printOptions.type == print_options::TABLE || printOptions.type == print_options::STATISTICS) { + if (printOptions.type == print_options::STATISTICS) { QMessageBox msgBox; msgBox.setText("This feature is not implemented yet"); msgBox.exec(); @@ -178,8 +178,6 @@ void PrintDialog::printClicked(void) connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); printer->print(); break; - case print_options::TABLE: - break; case print_options::STATISTICS: break; } diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp index df49694ee..223dfab93 100644 --- a/qt-ui/printoptions.cpp +++ b/qt-ui/printoptions.cpp @@ -22,9 +22,6 @@ void PrintOptions::setup() case print_options::DIVELIST: ui.radioDiveListPrint->setChecked(true); break; - case print_options::TABLE: - ui.radioTablePrint->setChecked(true); - break; case print_options::STATISTICS: ui.radioStatisticsPrint->setChecked(true); break; @@ -69,13 +66,6 @@ void PrintOptions::on_radioDiveListPrint_clicked(bool check) } } -void PrintOptions::on_radioTablePrint_clicked(bool check) -{ - if (check) { - printOptions->type = print_options::TABLE; - } -} - void PrintOptions::on_radioStatisticsPrint_clicked(bool check) { if (check) { diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 3ece6b64c..326935b8c 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -8,7 +8,6 @@ struct print_options { enum print_type { DIVELIST, - TABLE, STATISTICS } type; QString p_template; @@ -66,7 +65,6 @@ slots: void printInColorClicked(bool check); void printSelectedClicked(bool check); void on_radioStatisticsPrint_clicked(bool check); - void on_radioTablePrint_clicked(bool check); void on_radioDiveListPrint_clicked(bool check); void on_printTemplate_currentIndexChanged(int index); void on_editButton_clicked(); diff --git a/qt-ui/printoptions.ui b/qt-ui/printoptions.ui index 6bd271bbe..b2daefd0b 100644 --- a/qt-ui/printoptions.ui +++ b/qt-ui/printoptions.ui @@ -46,19 +46,6 @@ - - - - 0 - 0 - - - - &Table print - - - - @@ -71,19 +58,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -151,7 +125,6 @@ radioDiveListPrint - radioStatisticsPrint printSelected printInColor -- cgit v1.2.3-70-g09d2 From d41d79b549cdfb0ff3c785eae09a504a46fb4b96 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 26 Jul 2015 19:13:23 +0200 Subject: Printing: add the "Shades of blue" color theme Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/printdialog.cpp | 12 ++++++++++-- qt-ui/printoptions.h | 2 +- qt-ui/templateedit.cpp | 13 ++++++++++--- qt-ui/templateedit.ui | 5 +++++ 4 files changed, 26 insertions(+), 6 deletions(-) (limited to 'qt-ui/printdialog.cpp') diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 8717766a1..d5a16df11 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -12,7 +12,7 @@ #define SETTINGS_GROUP "PrintDialog" -template_options::color_palette_struct almond_colors, custom_colors; +template_options::color_palette_struct almond_colors, blueshades_colors, custom_colors; PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { @@ -22,6 +22,11 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f almond_colors.color3 = QColor::fromRgb(136, 160, 150); almond_colors.color4 = QColor::fromRgb(187, 171, 139); almond_colors.color5 = QColor::fromRgb(239, 130, 117); + blueshades_colors.color1 = QColor::fromRgb(182, 192, 206); + blueshades_colors.color2 = QColor::fromRgb(142, 152, 166); + blueshades_colors.color3 = QColor::fromRgb(31, 49, 75); + blueshades_colors.color4 = QColor::fromRgb(21, 45, 84); + blueshades_colors.color5 = QColor::fromRgb(5, 25, 56); // check if the options were previously stored in the settings; if not use some defaults. QSettings s; @@ -68,7 +73,10 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f case 0: // almond templateOptions.color_palette = almond_colors; break; - case 1: // custom + case 1: // blueshades + templateOptions.color_palette = blueshades_colors; + break; + case 2: // custom templateOptions.color_palette = custom_colors; break; } diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 528c5ed4d..5a4ca3504 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -44,7 +44,7 @@ struct template_options { } }; -extern template_options::color_palette_struct almond_colors, custom_colors; +extern template_options::color_palette_struct almond_colors, blueshades_colors, custom_colors; // should be based on a custom QPrintDialog class class PrintOptions : public QWidget { diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index de280f7a8..c26740506 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -95,7 +95,10 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index) case 0: // almond newTemplateOptions.color_palette = almond_colors; break; - case 1: // custom + case 1: // blueshades + newTemplateOptions.color_palette = blueshades_colors; + break; + case 2: // custom newTemplateOptions.color_palette = custom_colors; break; } @@ -115,7 +118,7 @@ void TemplateEdit::saveSettings() printOptions->p_template = "custom.html"; TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); } - if (templateOptions->color_palette_index == 1) { + if (templateOptions->color_palette_index == 2) { custom_colors = templateOptions->color_palette; } } @@ -148,6 +151,10 @@ void TemplateEdit::colorSelect(QAbstractButton *button) newTemplateOptions.color_palette = almond_colors; custom_colors = newTemplateOptions.color_palette; break; + case 1: // blueshades + newTemplateOptions.color_palette = blueshades_colors; + custom_colors = newTemplateOptions.color_palette; + break; } //change selected color @@ -174,6 +181,6 @@ void TemplateEdit::colorSelect(QAbstractButton *button) newTemplateOptions.color_palette.color5 = color; break; } - newTemplateOptions.color_palette_index = 1; + newTemplateOptions.color_palette_index = 2; updatePreview(); } diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui index 073db237b..1442954cf 100644 --- a/qt-ui/templateedit.ui +++ b/qt-ui/templateedit.ui @@ -173,6 +173,11 @@ Almond + + + Shades of blue + + Custom -- cgit v1.2.3-70-g09d2 From ed5afc510ed4d0756aadbadd57d8b58f37857ef1 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 26 Jul 2015 19:57:57 +0200 Subject: Printing: don't name color templates with confusing numbers Use the color_palette enum instead. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/printdialog.cpp | 8 ++++---- qt-ui/printoptions.h | 6 ++++++ qt-ui/templateedit.cpp | 12 ++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'qt-ui/printdialog.cpp') diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index d5a16df11..25c102201 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -39,7 +39,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f printOptions.type = print_options::DIVELIST; templateOptions.font_index = 0; templateOptions.font_size = 9; - templateOptions.color_palette_index = 0; + templateOptions.color_palette_index = ALMOND; templateOptions.line_spacing = 1; custom_colors = almond_colors; } else { @@ -70,13 +70,13 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f } switch (templateOptions.color_palette_index) { - case 0: // almond + case ALMOND: // almond templateOptions.color_palette = almond_colors; break; - case 1: // blueshades + case BLUESHADES: // blueshades templateOptions.color_palette = blueshades_colors; break; - case 2: // custom + case CUSTOM: // custom templateOptions.color_palette = custom_colors; break; } diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 5a4ca3504..2e2e2a9f4 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -46,6 +46,12 @@ struct template_options { extern template_options::color_palette_struct almond_colors, blueshades_colors, custom_colors; +enum color_palette { + ALMOND, + BLUESHADES, + CUSTOM +}; + // should be based on a custom QPrintDialog class class PrintOptions : public QWidget { Q_OBJECT diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index c26740506..6df11ea79 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -92,13 +92,13 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index) { newTemplateOptions.color_palette_index = index; switch (newTemplateOptions.color_palette_index) { - case 0: // almond + case ALMOND: // almond newTemplateOptions.color_palette = almond_colors; break; - case 1: // blueshades + case BLUESHADES: // blueshades newTemplateOptions.color_palette = blueshades_colors; break; - case 2: // custom + case CUSTOM: // custom newTemplateOptions.color_palette = custom_colors; break; } @@ -147,11 +147,11 @@ void TemplateEdit::colorSelect(QAbstractButton *button) { // reset custom colors palette switch (newTemplateOptions.color_palette_index) { - case 0: // almond + case ALMOND: // almond newTemplateOptions.color_palette = almond_colors; custom_colors = newTemplateOptions.color_palette; break; - case 1: // blueshades + case BLUESHADES: // blueshades newTemplateOptions.color_palette = blueshades_colors; custom_colors = newTemplateOptions.color_palette; break; @@ -181,6 +181,6 @@ void TemplateEdit::colorSelect(QAbstractButton *button) newTemplateOptions.color_palette.color5 = color; break; } - newTemplateOptions.color_palette_index = 2; + newTemplateOptions.color_palette_index = CUSTOM; updatePreview(); } -- cgit v1.2.3-70-g09d2