mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Beautify ToolTips in work area
* Justification and nicer line breaks.
* Much nicer tooltip for lists of bibliographical references.
* Removed unnecessary iterated copies of the string buffer in
InsetText::ToolTipText() which looked bad. This function used to be costly
(cf64064
), maybe it is quicker now.
This commit is contained in:
parent
d1dddde6d8
commit
4089ff1ec3
@ -1278,10 +1278,10 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
|
||||
if (!available) {
|
||||
docstring const output_type = (tc.outputType() == lyx::DOCBOOK) ? _("DocBook") : _("LaTeX");
|
||||
tooltip += '\n' + toqstr(wrap(bformat(_("Class not found by LyX. "
|
||||
tooltip += '\n' + toqstr(bformat(_("Class not found by LyX. "
|
||||
"Please check if you have the matching %1$s class "
|
||||
"and all required packages (%2$s) installed."),
|
||||
output_type, from_utf8(tc.prerequisites(", ")))));
|
||||
output_type, from_utf8(tc.prerequisites(", "))));
|
||||
}
|
||||
latexModule->classCO->addItemSort(toqstr(tc.name()),
|
||||
toqstr(guiname),
|
||||
|
@ -701,7 +701,7 @@ bool GuiWorkArea::event(QEvent * e)
|
||||
QPoint pos = helpEvent->pos();
|
||||
if (pos.x() < viewport()->width()) {
|
||||
QString s = toqstr(d->buffer_view_->toolTip(pos.x(), pos.y()));
|
||||
QToolTip::showText(helpEvent->globalPos(), s);
|
||||
QToolTip::showText(helpEvent->globalPos(), formatToolTip(s,35));
|
||||
}
|
||||
else
|
||||
QToolTip::hideText();
|
||||
|
@ -412,7 +412,9 @@ public:
|
||||
virtual bool producesOutput() const { return true; }
|
||||
|
||||
/// \return Tool tip for this inset.
|
||||
/// This default implementation returns an empty string.
|
||||
/// This default implementation returns an empty string. This can be
|
||||
/// either plain text or Qt html, and formatToolTip will be called
|
||||
/// on it before display in both cases.
|
||||
virtual docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||
|
||||
/// \return Context menu identifier. This function determines
|
||||
|
@ -173,21 +173,16 @@ docstring InsetBibtex::screenLabel() const
|
||||
|
||||
docstring InsetBibtex::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const
|
||||
{
|
||||
docstring item = from_ascii("* ");
|
||||
docstring tip = _("Databases:") + "\n";
|
||||
docstring tip = _("Databases:");
|
||||
vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
|
||||
|
||||
if (bibfilelist.empty()) {
|
||||
tip += item;
|
||||
tip += _("none");
|
||||
} else {
|
||||
vector<docstring>::const_iterator it = bibfilelist.begin();
|
||||
vector<docstring>::const_iterator en = bibfilelist.end();
|
||||
for (; it != en; ++it) {
|
||||
tip += item;
|
||||
tip += *it + "\n";
|
||||
}
|
||||
}
|
||||
tip += "<ul>";
|
||||
if (bibfilelist.empty())
|
||||
tip += "<li>" + _("none") + "</li>";
|
||||
else
|
||||
for (docstring const & bibfile : bibfilelist)
|
||||
tip += "<li>" + bibfile + "</li>";
|
||||
tip += "</ul>";
|
||||
|
||||
// Style-Options
|
||||
bool toc = false;
|
||||
@ -199,14 +194,10 @@ docstring InsetBibtex::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/)
|
||||
style = split(style, bibtotoc, char_type(','));
|
||||
}
|
||||
|
||||
tip += _("Style File:") +"\n";
|
||||
tip += item;
|
||||
if (!style.empty())
|
||||
tip += style;
|
||||
else
|
||||
tip += _("none");
|
||||
tip += _("Style File:");
|
||||
tip += "<ul><li>" + (style.empty() ? _("none") : style) + "</li></ul>";
|
||||
|
||||
tip += "\n" + _("Lists:") + " ";
|
||||
tip += _("Lists:") + " ";
|
||||
docstring btprint = getParam("btprint");
|
||||
if (btprint == "btPrintAll")
|
||||
tip += _("all references");
|
||||
|
@ -165,17 +165,18 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
|
||||
return _("No citations selected!");
|
||||
|
||||
vector<docstring> keys = getVectorFromString(key);
|
||||
vector<docstring>::const_iterator it = keys.begin();
|
||||
vector<docstring>::const_iterator en = keys.end();
|
||||
if (keys.size() == 1)
|
||||
return bi.getInfo(keys[0], buffer(), true);
|
||||
|
||||
docstring tip;
|
||||
for (; it != en; ++it) {
|
||||
docstring const key_info = bi.getInfo(*it, buffer());
|
||||
tip += "<ol>";
|
||||
for (docstring const & key : keys) {
|
||||
docstring const key_info = bi.getInfo(key, buffer(), true);
|
||||
if (key_info.empty())
|
||||
continue;
|
||||
if (!tip.empty())
|
||||
tip += "\n";
|
||||
tip += wrap(key_info, -4);
|
||||
tip += "<li>" + key_info + "</li>";
|
||||
}
|
||||
tip += "</ol>";
|
||||
return tip;
|
||||
}
|
||||
|
||||
|
@ -965,10 +965,8 @@ string InsetText::contextMenuName() const
|
||||
}
|
||||
|
||||
|
||||
docstring InsetText::toolTipText(docstring prefix,
|
||||
size_t numlines, size_t len) const
|
||||
docstring InsetText::toolTipText(docstring prefix, size_t const len) const
|
||||
{
|
||||
size_t const max_length = numlines * len;
|
||||
OutputParams rp(&buffer().params().encoding());
|
||||
rp.for_tooltip = true;
|
||||
odocstringstream oss;
|
||||
@ -978,17 +976,17 @@ docstring InsetText::toolTipText(docstring prefix,
|
||||
ParagraphList::const_iterator end = paragraphs().end();
|
||||
ParagraphList::const_iterator it = beg;
|
||||
bool ref_printed = false;
|
||||
docstring str;
|
||||
|
||||
for (; it != end; ++it) {
|
||||
if (it != beg)
|
||||
oss << '\n';
|
||||
writePlaintextParagraph(buffer(), *it, oss, rp, ref_printed, max_length);
|
||||
str = oss.str();
|
||||
if (str.length() >= max_length)
|
||||
writePlaintextParagraph(buffer(), *it, oss, rp, ref_printed, len);
|
||||
if (oss.tellp() >= 0 && size_t(oss.tellp()) > len)
|
||||
break;
|
||||
}
|
||||
return support::wrapParas(str, 4, len, numlines);
|
||||
docstring str = oss.str();
|
||||
support::truncateWithEllipsis(str, len);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,13 +201,14 @@ public:
|
||||
/// returns the text to be used as tooltip
|
||||
/// \param prefix: a string that will preced the tooltip,
|
||||
/// e.g., "Index: ".
|
||||
/// \param numlines: the number of lines in the tooltip
|
||||
/// \param len: length of those lines
|
||||
/// \param len: length of the resulting string
|
||||
/// NOTE This routine is kind of slow. It's fine to use it within the
|
||||
/// GUI, but definitely do not try to use it in updateBuffer or anything
|
||||
/// of that sort.
|
||||
/// of that sort. (Note: unnecessary internal copies have been removed
|
||||
/// since the previous note. The efficiency would have to be assessed
|
||||
/// again by profiling.)
|
||||
docstring toolTipText(docstring prefix = empty_docstring(),
|
||||
size_t numlines = 5, size_t len = 80) const;
|
||||
size_t len = 400) const;
|
||||
|
||||
///
|
||||
std::string contextMenu(BufferView const &, int, int) const;
|
||||
|
Loading…
Reference in New Issue
Block a user