forked from qt-creator/qt-creator
Improve various HTML-based tooltips
A couple of tooltips in Qt Creator, contain rich text (HTML). These tooltips tend to have line breaks in unfavorable places, making the content sometimes hard to read. This is fixed in this change by using: style="white-space:pre" Another issue with some tooltips is that they show key/value definitions in a <table>, which, especially with longer keys makes looking up the value quite hard. Also the length of the key column is dependent on the (translated) content. This change implements an alternative: using "description lists" <dl>, which indent the values nicely independent from the key length. Fixes: QTCREATORBUG-27553 Change-Id: If047627193413f23d868c52f005f22aa9a0752a9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -173,7 +173,8 @@ void ProxyAction::updateToolTipWithKeySequence()
|
|||||||
QString ProxyAction::stringWithAppendedShortcut(const QString &str, const QKeySequence &shortcut)
|
QString ProxyAction::stringWithAppendedShortcut(const QString &str, const QKeySequence &shortcut)
|
||||||
{
|
{
|
||||||
const QString s = stripAccelerator(str);
|
const QString s = stripAccelerator(str);
|
||||||
return QString::fromLatin1("%1 <span style=\"color: gray; font-size: small\">%2</span>")
|
return QString::fromLatin1("<div style=\"white-space:pre\">%1 "
|
||||||
|
"<span style=\"color: gray; font-size: small\">%2</span></div>")
|
||||||
.arg(s, shortcut.toString(QKeySequence::NativeText));
|
.arg(s, shortcut.toString(QKeySequence::NativeText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -687,7 +687,7 @@ QString ConfigModelTreeItem::toolTip() const
|
|||||||
if (!dataItem->description.isEmpty())
|
if (!dataItem->description.isEmpty())
|
||||||
tooltip << dataItem->description;
|
tooltip << dataItem->description;
|
||||||
|
|
||||||
const QString pattern = "<p><b>%1</b> %2</p>";
|
const QString pattern = "<dt style=\"font-weight:bold\">%1</dt><dd>%2</dd>";
|
||||||
if (dataItem->isInitial) {
|
if (dataItem->isInitial) {
|
||||||
if (!dataItem->kitValue.isEmpty())
|
if (!dataItem->kitValue.isEmpty())
|
||||||
tooltip << pattern.arg(ConfigModel::tr("Kit:")).arg(dataItem->kitValue);
|
tooltip << pattern.arg(ConfigModel::tr("Kit:")).arg(dataItem->kitValue);
|
||||||
@@ -708,7 +708,7 @@ QString ConfigModelTreeItem::toolTip() const
|
|||||||
}
|
}
|
||||||
tooltip << pattern.arg(ConfigModel::tr("Type:")).arg(dataItem->typeDisplay());
|
tooltip << pattern.arg(ConfigModel::tr("Type:")).arg(dataItem->typeDisplay());
|
||||||
|
|
||||||
return tooltip.join(QString());
|
return "<dl style=\"white-space:pre\">" + tooltip.join(QString()) + "</dl>";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigModelTreeItem::currentValue() const
|
QString ConfigModelTreeItem::currentValue() const
|
||||||
|
@@ -608,7 +608,7 @@ QString Kit::toHtml(const Tasks &additional, const QString &extraText) const
|
|||||||
if (!isValid() || hasWarning() || !additional.isEmpty())
|
if (!isValid() || hasWarning() || !additional.isEmpty())
|
||||||
str << "<p>" << ProjectExplorer::toHtml(additional + validate()) << "</p>";
|
str << "<p>" << ProjectExplorer::toHtml(additional + validate()) << "</p>";
|
||||||
|
|
||||||
str << "<table>";
|
str << "<dl style=\"white-space:pre\">";
|
||||||
for (KitAspect *aspect : KitManager::kitAspects()) {
|
for (KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
const KitAspect::ItemList list = aspect->toUserOutput(this);
|
const KitAspect::ItemList list = aspect->toUserOutput(this);
|
||||||
for (const KitAspect::Item &j : list) {
|
for (const KitAspect::Item &j : list) {
|
||||||
@@ -620,10 +620,11 @@ QString Kit::toHtml(const Tasks &additional, const QString &extraText) const
|
|||||||
contents = contents.mid(0, pos);
|
contents = contents.mid(0, pos);
|
||||||
contents += "<...>";
|
contents += "<...>";
|
||||||
}
|
}
|
||||||
str << "<tr><td><b>" << j.first << ":</b></td><td>" << contents << "</td></tr>";
|
str << "<dt style=\"font-weight:bold\">" << j.first
|
||||||
|
<< ":</dt><dd>" << contents << "</dd>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str << "</table></body></html>";
|
str << "</dl></body></html>";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -124,11 +124,12 @@ public:
|
|||||||
return m_icon;
|
return m_icon;
|
||||||
|
|
||||||
if (role == Qt::ToolTipRole) {
|
if (role == Qt::ToolTipRole) {
|
||||||
const QString row = "<tr><td>%1:</td><td>%2</td></tr>";
|
const QString row = "<dt style=\"font-weight:bold\">%1:</dt>"
|
||||||
return QString("<table>"
|
"<dd>%2</dd>";
|
||||||
|
return QString("<dl style=\"white-space:pre\">"
|
||||||
+ row.arg(tr("Qt Version"), m_version->qtVersionString())
|
+ row.arg(tr("Qt Version"), m_version->qtVersionString())
|
||||||
+ row.arg(tr("Location of qmake"), m_version->qmakeFilePath().toUserOutput())
|
+ row.arg(tr("Location of qmake"), m_version->qmakeFilePath().toUserOutput())
|
||||||
+ "</table>");
|
+ "</dl>");
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
Reference in New Issue
Block a user