aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-07-12 01:49:43 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-20 15:28:15 +0300
commit18282aa30e191e1af0dda7261a692c8bb82dc139 (patch)
tree70fc3fd75d93c5020f0c1fba99a00697fd06a6cb /qt-ui
parentd705cb34bb5a8d442b54784bb9105404bb304404 (diff)
downloadsubsurface-18282aa30e191e1af0dda7261a692c8bb82dc139.tar.gz
Printing: update preview on field changes
- Trigger re-rendering on the QPixmap if fields changed. - Change template selection to custom if template text changed. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/templateedit.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp
index bd4763107..8d216d998 100644
--- a/qt-ui/templateedit.cpp
+++ b/qt-ui/templateedit.cpp
@@ -43,7 +43,7 @@ void TemplateEdit::updatePreview()
int height = ui->label->height();
QPixmap map(width * 2, height * 2);
map.fill(QColor::fromRgb(255, 255, 255));
- Printer printer(&map, printOptions, templateOptions, Printer::PREVIEW);
+ Printer printer(&map, printOptions, &newTemplateOptions, Printer::PREVIEW);
printer.previewOnePage();
ui->label->setPixmap(map.scaled(width, height, Qt::IgnoreAspectRatio));
}
@@ -51,21 +51,25 @@ void TemplateEdit::updatePreview()
void TemplateEdit::on_fontsize_valueChanged(int font_size)
{
newTemplateOptions.font_size = font_size;
+ updatePreview();
}
void TemplateEdit::on_linespacing_valueChanged(double line_spacing)
{
newTemplateOptions.line_spacing = line_spacing;
+ updatePreview();
}
void TemplateEdit::on_fontSelection_currentIndexChanged(int index)
{
newTemplateOptions.font_index = index;
+ updatePreview();
}
void TemplateEdit::on_colorpalette_currentIndexChanged(int index)
{
newTemplateOptions.color_palette_index = index;
+ updatePreview();
}
void TemplateEdit::saveSettings()
@@ -77,8 +81,10 @@ void TemplateEdit::saveSettings()
msgBox.setDefaultButton(QMessageBox::Discard);
if (msgBox.exec() == QMessageBox::Save) {
memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options));
- printOptions->p_template = print_options::CUSTOM;
- TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText());
+ if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) {
+ printOptions->p_template = print_options::CUSTOM;
+ TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText());
+ }
}
}
}