From c56b1c1114015c6b83852ecdcdb21b03f41e594b Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 7 Jul 2015 03:12:36 +0200 Subject: Printing: overwrite the old custom template file Change the new file size after inserting the new template to overwrite the old one. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- templatelayout.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'templatelayout.cpp') diff --git a/templatelayout.cpp b/templatelayout.cpp index 9a9dc9656..79508d6db 100644 --- a/templatelayout.cpp +++ b/templatelayout.cpp @@ -104,6 +104,7 @@ void TemplateLayout::writeTemplate(QString template_name, QString grantlee_templ QFile qfile(getSubsurfaceDataPath("printing_templates") + QDir::separator() + template_name); if (qfile.open(QFile::ReadWrite | QFile::Text)) { qfile.write(grantlee_template.toUtf8().data()); + qfile.resize(qfile.pos()); qfile.close(); } } -- cgit v1.2.3-70-g09d2 From 599920c6cfd87a213634097045e29f592390438b Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Thu, 16 Jul 2015 11:39:27 +0200 Subject: Printing: export grayscale filter value to template Export grayscale value to Grantlee template, So we must declare print_options as QMetatype. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- templatelayout.cpp | 2 ++ templatelayout.h | 11 +++++++++++ 2 files changed, 13 insertions(+) (limited to 'templatelayout.cpp') diff --git a/templatelayout.cpp b/templatelayout.cpp index 79508d6db..fec57cb2a 100644 --- a/templatelayout.cpp +++ b/templatelayout.cpp @@ -47,6 +47,7 @@ QString TemplateLayout::generate() Grantlee::registerMetaType(); Grantlee::registerMetaType(); + Grantlee::registerMetaType(); QVariantHash mapping; QVariantList diveList; @@ -64,6 +65,7 @@ QString TemplateLayout::generate() } mapping.insert("dives", diveList); mapping.insert("template_options", QVariant::fromValue(*templateOptions)); + mapping.insert("print_options", QVariant::fromValue(*PrintOptions)); Grantlee::Context c(mapping); diff --git a/templatelayout.h b/templatelayout.h index 85a4699da..e37e9e868 100644 --- a/templatelayout.h +++ b/templatelayout.h @@ -79,6 +79,7 @@ public: Q_DECLARE_METATYPE(Dive) Q_DECLARE_METATYPE(template_options) +Q_DECLARE_METATYPE(print_options) GRANTLEE_BEGIN_LOOKUP(Dive) if (property == "number") @@ -136,4 +137,14 @@ if (property == "font") { } GRANTLEE_END_LOOKUP +GRANTLEE_BEGIN_LOOKUP(print_options) +if (property == "grayscale") { + if (object.color_selected) { + return ""; + } else { + return "-webkit-filter: grayscale(100%)"; + } +} +GRANTLEE_END_LOOKUP + #endif -- cgit v1.2.3-70-g09d2