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') 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