From d4382c7c4b802b030bab5e64de4b1641f603d543 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Fri, 10 Jul 2015 21:45:27 +0200 Subject: Printing: add preview to TemplateEdit dialog Show QPixmap in QLabel, Use Printer class to render the Preview on the QPixmap. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/templateedit.ui | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'qt-ui/templateedit.ui') diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui index 26fe15926..fa27eb324 100644 --- a/qt-ui/templateedit.ui +++ b/qt-ui/templateedit.ui @@ -188,21 +188,6 @@ - - - - 20 - 60 - 251 - 311 - - - - - about:blank - - - @@ -216,14 +201,20 @@ Preview + + + + 50 + 70 + 211 + 291 + + + + + + - - - QWebView - QWidget -
QtWebKitWidgets/QWebView
-
-
-- cgit v1.2.3-70-g09d2 From f1615e725c7a5562b5fcaac2cd0701dae61b89ca Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sat, 11 Jul 2015 01:37:27 +0200 Subject: Printing: add apply button to TemplateEdit class Add apply button to the dialog, Update the preview after applying the new settings. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/templateedit.cpp | 17 ++++++++++++++++- qt-ui/templateedit.h | 3 ++- qt-ui/templateedit.ui | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'qt-ui/templateedit.ui') diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 0354131ef..2d09cb947 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -64,7 +64,7 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index) newTemplateOptions.color_palette_index = index; } -void TemplateEdit::on_TemplateEdit_finished(int result) +void TemplateEdit::saveSettings() { if ((*templateOptions) != newTemplateOptions || grantlee_template.compare(ui->plainTextEdit->toPlainText())) { QMessageBox msgBox; @@ -78,3 +78,18 @@ void TemplateEdit::on_TemplateEdit_finished(int result) } } } + +void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button) +{ + QDialogButtonBox::StandardButton standardButton = ui->buttonBox->standardButton(button); + switch (standardButton) { + case QDialogButtonBox::Ok: + saveSettings(); + break; + case QDialogButtonBox::Cancel: + break; + case QDialogButtonBox::Apply: + saveSettings(); + break; + } +} diff --git a/qt-ui/templateedit.h b/qt-ui/templateedit.h index 325d7eef3..9b6d9167f 100644 --- a/qt-ui/templateedit.h +++ b/qt-ui/templateedit.h @@ -24,7 +24,7 @@ private slots: void on_colorpalette_currentIndexChanged(int index); - void on_TemplateEdit_finished(int result); + void on_buttonBox_clicked(QAbstractButton *button); private: Ui::TemplateEdit *ui; @@ -32,6 +32,7 @@ private: struct template_options newTemplateOptions; struct print_options *printOptions; QString grantlee_template; + void saveSettings(); }; #endif // TEMPLATEEDIT_H diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui index fa27eb324..de007c9b7 100644 --- a/qt-ui/templateedit.ui +++ b/qt-ui/templateedit.ui @@ -26,7 +26,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok -- cgit v1.2.3-70-g09d2 From dcedc8ebea5a686f87d51daefa83728696d26b1a Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 12 Jul 2015 04:49:16 +0200 Subject: Printing: add colors tab to edit window Select custom colors for print templates, by default there are five colors that can be used dynamically in prints. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/templateedit.ui | 219 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 218 insertions(+), 1 deletion(-) (limited to 'qt-ui/templateedit.ui') diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui index de007c9b7..771fa90f8 100644 --- a/qt-ui/templateedit.ui +++ b/qt-ui/templateedit.ui @@ -39,7 +39,7 @@ - 0 + 2 @@ -187,6 +187,223 @@ + + + Colors + + + + + 10 + 30 + 411 + 171 + + + + + + + + + + 0 + 0 + + + + Background + + + + + + + + 0 + 0 + + + + color1 + + + Qt::AlignCenter + + + + + + + Edit + + + + + + + + + + + + 0 + 0 + + + + Table cells + + + + + + + + 0 + 0 + + + + color2 + + + Qt::AlignCenter + + + + + + + Edit + + + + + + + + + + + + 0 + 0 + + + + Text 1 + + + + + + + + 0 + 0 + + + + color3 + + + Qt::AlignCenter + + + + + + + Edit + + + + + + + + + + + + 0 + 0 + + + + Text 2 + + + + + + + + 0 + 0 + + + + color4 + + + Qt::AlignCenter + + + + + + + Edit + + + + + + + + + + + + 0 + 0 + + + + Borders + + + + + + + + 0 + 0 + + + + color5 + + + Qt::AlignCenter + + + + + + + Edit + + + + + + + + -- cgit v1.2.3-70-g09d2 From f8f645398857ca7cfb3c9496259e2ab638065642 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Mon, 13 Jul 2015 11:23:35 +0200 Subject: Printing: add custom color palette We can use custom color palette to edit current color palette. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/templateedit.cpp | 24 ++++++++++++++++++++++++ qt-ui/templateedit.ui | 5 +++++ 2 files changed, 29 insertions(+) (limited to 'qt-ui/templateedit.ui') diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index 3d84dd63b..ff1c1b7ea 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -71,6 +71,9 @@ void TemplateEdit::updatePreview() ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name()); ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name()); ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name()); + + // update critical UI elements + ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index); } void TemplateEdit::on_fontsize_valueChanged(int font_size) @@ -94,6 +97,14 @@ void TemplateEdit::on_fontSelection_currentIndexChanged(int index) void TemplateEdit::on_colorpalette_currentIndexChanged(int index) { newTemplateOptions.color_palette_index = index; + switch (newTemplateOptions.color_palette_index) { + case 0: // almond + newTemplateOptions.color_palette = almond_colors; + break; + case 1: // custom + newTemplateOptions.color_palette = custom_colors; + break; + } updatePreview(); } @@ -110,6 +121,9 @@ void TemplateEdit::saveSettings() printOptions->p_template = print_options::CUSTOM; TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); } + if (templateOptions->color_palette_index == 1) { + custom_colors = templateOptions->color_palette; + } } } } @@ -132,6 +146,15 @@ void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button) void TemplateEdit::colorSelect(QAbstractButton *button) { + // reset custom colors palette + switch (newTemplateOptions.color_palette_index) { + case 0: // almond + newTemplateOptions.color_palette = almond_colors; + custom_colors = newTemplateOptions.color_palette; + break; + } + + //change selected color QColor color; switch (btnGroup->id(button)) { case 1: @@ -155,5 +178,6 @@ void TemplateEdit::colorSelect(QAbstractButton *button) newTemplateOptions.color_palette.color5 = color; break; } + newTemplateOptions.color_palette_index = 1; updatePreview(); } diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui index 771fa90f8..4f9c9c2ed 100644 --- a/qt-ui/templateedit.ui +++ b/qt-ui/templateedit.ui @@ -132,6 +132,11 @@ Almond + + + Custom + + -- cgit v1.2.3-70-g09d2