From 86708dbddea29ee9bc4ae2d0a1f174cffbf92793 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 16 May 2022 08:03:56 +0200 Subject: [PATCH] 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 , 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"
, which indent the values nicely independent from the key length. Fixes: QTCREATORBUG-27553 Change-Id: If047627193413f23d868c52f005f22aa9a0752a9 Reviewed-by: Eike Ziller --- src/libs/utils/proxyaction.cpp | 3 ++- src/plugins/cmakeprojectmanager/configmodel.cpp | 4 ++-- src/plugins/projectexplorer/kit.cpp | 7 ++++--- src/plugins/qtsupport/qtoptionspage.cpp | 7 ++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/libs/utils/proxyaction.cpp b/src/libs/utils/proxyaction.cpp index d8d9cf86971..b0360f5c355 100644 --- a/src/libs/utils/proxyaction.cpp +++ b/src/libs/utils/proxyaction.cpp @@ -173,7 +173,8 @@ void ProxyAction::updateToolTipWithKeySequence() QString ProxyAction::stringWithAppendedShortcut(const QString &str, const QKeySequence &shortcut) { const QString s = stripAccelerator(str); - return QString::fromLatin1("%1 %2") + return QString::fromLatin1("
%1 " + "%2
") .arg(s, shortcut.toString(QKeySequence::NativeText)); } diff --git a/src/plugins/cmakeprojectmanager/configmodel.cpp b/src/plugins/cmakeprojectmanager/configmodel.cpp index e170fc49179..4dfbbef4a54 100644 --- a/src/plugins/cmakeprojectmanager/configmodel.cpp +++ b/src/plugins/cmakeprojectmanager/configmodel.cpp @@ -687,7 +687,7 @@ QString ConfigModelTreeItem::toolTip() const if (!dataItem->description.isEmpty()) tooltip << dataItem->description; - const QString pattern = "

%1 %2

"; + const QString pattern = "
%1
%2
"; if (dataItem->isInitial) { if (!dataItem->kitValue.isEmpty()) 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()); - return tooltip.join(QString()); + return "
" + tooltip.join(QString()) + "
"; } QString ConfigModelTreeItem::currentValue() const diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index 70aba302b2d..41941b9d208 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -608,7 +608,7 @@ QString Kit::toHtml(const Tasks &additional, const QString &extraText) const if (!isValid() || hasWarning() || !additional.isEmpty()) str << "

" << ProjectExplorer::toHtml(additional + validate()) << "

"; - str << "
"; + str << "
"; for (KitAspect *aspect : KitManager::kitAspects()) { const KitAspect::ItemList list = aspect->toUserOutput(this); 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 += "<...>"; } - str << "
"; + str << "
" << j.first + << ":
" << contents << "
"; } } - str << "
" << j.first << ":" << contents << "
"; + str << ""; return result; } diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index ab8643f535f..c0049058abd 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -124,11 +124,12 @@ public: return m_icon; if (role == Qt::ToolTipRole) { - const QString row = "%1:%2"; - return QString("" + const QString row = "
%1:
" + "
%2
"; + return QString("
" + row.arg(tr("Qt Version"), m_version->qtVersionString()) + row.arg(tr("Location of qmake"), m_version->qmakeFilePath().toUserOutput()) - + "
"); + + ""); } return QVariant();