From 5226a59edeae3e4973d5a3c38da2bed4a51b04d6 Mon Sep 17 00:00:00 2001 From: Dmytro Maslenko Date: Wed, 11 Jan 2023 22:53:41 -0800 Subject: [PATCH] Improve exported html layout [What] 1) The title was moved from dedicated column to a table caption. 2) The font size for notes was changed from medium to small. 3) The notes order was moved to the end. 4) The table margin and width were adjusted to fit into screen and print pages. [Why] To have more readable output and utilize more page space. --- src/gui/HtmlExporter.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/gui/HtmlExporter.cpp b/src/gui/HtmlExporter.cpp index 70249ed2..65490946 100644 --- a/src/gui/HtmlExporter.cpp +++ b/src/gui/HtmlExporter.cpp @@ -85,15 +85,6 @@ namespace item.append(""); } - const auto& n = entry.notes(); - if (!n.isEmpty()) { - item.append(""); - item.append(QObject::tr("Notes")); - item.append(""); - item.append(entry.notes().toHtmlEscaped().replace("\n", "
")); - item.append(""); - } - // Now add the attributes (if there are any) const auto* const attr = entry.attributes(); if (attr && !attr->customKeys().isEmpty()) { @@ -105,6 +96,15 @@ namespace item.append(""); } } + + const auto& n = entry.notes(); + if (!n.isEmpty()) { + item.append(""); + item.append(QObject::tr("Notes")); + item.append(""); + item.append(entry.notes().toHtmlEscaped().replace("\n", "
")); + item.append(""); + } return item; } } // namespace @@ -150,15 +150,18 @@ bool HtmlExporter::exportDatabase(QIODevice* device, "h3 " "{ margin-left: 2em; }" "table " - "{ margin-left: 4em; } " + "{ margin-left: 1em; } " + "caption " + "{ text-align: left; font-weight: bold; font-size: 150%; border-bottom: .15em solid " + "#4ca; margin-bottom: .5em;} " "th, td " "{ text-align: left; vertical-align: top; padding: 1px; }" "th " - "{ min-width: 5em; width: 20%; } " + "{ min-width: 7em; width: 15%; } " ".username, .password, .url, .attr " "{ font-size: larger; font-family: monospace; } " ".notes " - "{ font-size: medium; } " + "{ font-size: small; } " "" "\n" "" @@ -231,7 +234,7 @@ bool HtmlExporter::writeGroup(QIODevice& device, const Group& group, QString pat } // Begin the table for the entries in this group - auto table = QString(""); + auto table = QString("
"); auto entries = group.entries(); if (sorted) { @@ -252,10 +255,11 @@ bool HtmlExporter::writeGroup(QIODevice& device, const Group& group, QString pat // icon and entry title ... table += ""; table += ""; - table += ""; + auto caption = ""; // ... then the right side with the data fields - table += ""; + table += + ""; table += ""; }
" + PixmapToHTML(Icons::entryIconPixmap(entry, IconSize::Medium)) + "

" + entry->title().toHtmlEscaped() + "

" + entry->title().toHtmlEscaped() + "
" + formatted_entry + "
" + caption + formatted_entry + "