mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +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())));
|
QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
|
||||||
if (!available) {
|
if (!available) {
|
||||||
docstring const output_type = (tc.outputType() == lyx::DOCBOOK) ? _("DocBook") : _("LaTeX");
|
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 "
|
"Please check if you have the matching %1$s class "
|
||||||
"and all required packages (%2$s) installed."),
|
"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()),
|
latexModule->classCO->addItemSort(toqstr(tc.name()),
|
||||||
toqstr(guiname),
|
toqstr(guiname),
|
||||||
|
@ -701,7 +701,7 @@ bool GuiWorkArea::event(QEvent * e)
|
|||||||
QPoint pos = helpEvent->pos();
|
QPoint pos = helpEvent->pos();
|
||||||
if (pos.x() < viewport()->width()) {
|
if (pos.x() < viewport()->width()) {
|
||||||
QString s = toqstr(d->buffer_view_->toolTip(pos.x(), pos.y()));
|
QString s = toqstr(d->buffer_view_->toolTip(pos.x(), pos.y()));
|
||||||
QToolTip::showText(helpEvent->globalPos(), s);
|
QToolTip::showText(helpEvent->globalPos(), formatToolTip(s,35));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
QToolTip::hideText();
|
QToolTip::hideText();
|
||||||
|
@ -412,7 +412,9 @@ public:
|
|||||||
virtual bool producesOutput() const { return true; }
|
virtual bool producesOutput() const { return true; }
|
||||||
|
|
||||||
/// \return Tool tip for this inset.
|
/// \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;
|
virtual docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||||
|
|
||||||
/// \return Context menu identifier. This function determines
|
/// \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 InsetBibtex::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const
|
||||||
{
|
{
|
||||||
docstring item = from_ascii("* ");
|
docstring tip = _("Databases:");
|
||||||
docstring tip = _("Databases:") + "\n";
|
|
||||||
vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
|
vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
|
||||||
|
|
||||||
if (bibfilelist.empty()) {
|
tip += "<ul>";
|
||||||
tip += item;
|
if (bibfilelist.empty())
|
||||||
tip += _("none");
|
tip += "<li>" + _("none") + "</li>";
|
||||||
} else {
|
else
|
||||||
vector<docstring>::const_iterator it = bibfilelist.begin();
|
for (docstring const & bibfile : bibfilelist)
|
||||||
vector<docstring>::const_iterator en = bibfilelist.end();
|
tip += "<li>" + bibfile + "</li>";
|
||||||
for (; it != en; ++it) {
|
tip += "</ul>";
|
||||||
tip += item;
|
|
||||||
tip += *it + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Style-Options
|
// Style-Options
|
||||||
bool toc = false;
|
bool toc = false;
|
||||||
@ -199,14 +194,10 @@ docstring InsetBibtex::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/)
|
|||||||
style = split(style, bibtotoc, char_type(','));
|
style = split(style, bibtotoc, char_type(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
tip += _("Style File:") +"\n";
|
tip += _("Style File:");
|
||||||
tip += item;
|
tip += "<ul><li>" + (style.empty() ? _("none") : style) + "</li></ul>";
|
||||||
if (!style.empty())
|
|
||||||
tip += style;
|
|
||||||
else
|
|
||||||
tip += _("none");
|
|
||||||
|
|
||||||
tip += "\n" + _("Lists:") + " ";
|
tip += _("Lists:") + " ";
|
||||||
docstring btprint = getParam("btprint");
|
docstring btprint = getParam("btprint");
|
||||||
if (btprint == "btPrintAll")
|
if (btprint == "btPrintAll")
|
||||||
tip += _("all references");
|
tip += _("all references");
|
||||||
|
@ -165,17 +165,18 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
|
|||||||
return _("No citations selected!");
|
return _("No citations selected!");
|
||||||
|
|
||||||
vector<docstring> keys = getVectorFromString(key);
|
vector<docstring> keys = getVectorFromString(key);
|
||||||
vector<docstring>::const_iterator it = keys.begin();
|
if (keys.size() == 1)
|
||||||
vector<docstring>::const_iterator en = keys.end();
|
return bi.getInfo(keys[0], buffer(), true);
|
||||||
|
|
||||||
docstring tip;
|
docstring tip;
|
||||||
for (; it != en; ++it) {
|
tip += "<ol>";
|
||||||
docstring const key_info = bi.getInfo(*it, buffer());
|
for (docstring const & key : keys) {
|
||||||
|
docstring const key_info = bi.getInfo(key, buffer(), true);
|
||||||
if (key_info.empty())
|
if (key_info.empty())
|
||||||
continue;
|
continue;
|
||||||
if (!tip.empty())
|
tip += "<li>" + key_info + "</li>";
|
||||||
tip += "\n";
|
|
||||||
tip += wrap(key_info, -4);
|
|
||||||
}
|
}
|
||||||
|
tip += "</ol>";
|
||||||
return tip;
|
return tip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,10 +965,8 @@ string InsetText::contextMenuName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
docstring InsetText::toolTipText(docstring prefix,
|
docstring InsetText::toolTipText(docstring prefix, size_t const len) const
|
||||||
size_t numlines, size_t len) const
|
|
||||||
{
|
{
|
||||||
size_t const max_length = numlines * len;
|
|
||||||
OutputParams rp(&buffer().params().encoding());
|
OutputParams rp(&buffer().params().encoding());
|
||||||
rp.for_tooltip = true;
|
rp.for_tooltip = true;
|
||||||
odocstringstream oss;
|
odocstringstream oss;
|
||||||
@ -978,17 +976,17 @@ docstring InsetText::toolTipText(docstring prefix,
|
|||||||
ParagraphList::const_iterator end = paragraphs().end();
|
ParagraphList::const_iterator end = paragraphs().end();
|
||||||
ParagraphList::const_iterator it = beg;
|
ParagraphList::const_iterator it = beg;
|
||||||
bool ref_printed = false;
|
bool ref_printed = false;
|
||||||
docstring str;
|
|
||||||
|
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (it != beg)
|
if (it != beg)
|
||||||
oss << '\n';
|
oss << '\n';
|
||||||
writePlaintextParagraph(buffer(), *it, oss, rp, ref_printed, max_length);
|
writePlaintextParagraph(buffer(), *it, oss, rp, ref_printed, len);
|
||||||
str = oss.str();
|
if (oss.tellp() >= 0 && size_t(oss.tellp()) > len)
|
||||||
if (str.length() >= max_length)
|
|
||||||
break;
|
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
|
/// returns the text to be used as tooltip
|
||||||
/// \param prefix: a string that will preced the tooltip,
|
/// \param prefix: a string that will preced the tooltip,
|
||||||
/// e.g., "Index: ".
|
/// e.g., "Index: ".
|
||||||
/// \param numlines: the number of lines in the tooltip
|
/// \param len: length of the resulting string
|
||||||
/// \param len: length of those lines
|
|
||||||
/// NOTE This routine is kind of slow. It's fine to use it within the
|
/// 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
|
/// 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(),
|
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;
|
std::string contextMenu(BufferView const &, int, int) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user