From 1139e209a88e4e3c5f94fd6cd8be5e9e836d9450 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 10 Nov 2022 23:52:29 +0100 Subject: [PATCH] Gui: [skip ci] fix several warnings reported by GH actions --- src/Gui/Action.cpp | 15 ++++++++------- src/Gui/Action.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index a808d3b886..9969a68f66 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -30,6 +30,7 @@ # include # include # include +# include # include # include # include @@ -38,8 +39,6 @@ # include #endif -#include - #include #include #include @@ -60,6 +59,7 @@ #include "Widgets.h" #include "Workbench.h" #include "ShortcutManager.h" +#include "Tools.h" using namespace Gui; @@ -318,11 +318,11 @@ QString Action::createToolTip(QString _tooltip, if (auto act = pcCmd->getAction()) { int idx = act->property("defaultAction").toInt(); auto cmd = groupcmd->getCommand(idx); - if (cmd && cmd->getName()) + if (cmd && cmd->getName()) { cmdName = QStringLiteral("%1 (%2:%3)") - .arg(QString::fromLatin1(cmd->getName())) - .arg(cmdName) + .arg(QString::fromLatin1(cmd->getName()), cmdName) .arg(idx); + } } } cmdName = QStringLiteral("

%1

") @@ -354,9 +354,10 @@ QString Action::createToolTip(QString _tooltip, // width, so that the following text can wrap at that width. float tipWidth = 400; QFontMetrics fm(font); - int width = fm.width(_tooltip); - if (width <= tipWidth) + int width = QtTools::horizontalAdvance(fm, _tooltip); + if (width <= tipWidth) { tooltip += _tooltip.toHtmlEscaped() + QString::fromLatin1("

") ; + } else { int index = tipWidth / width * _tooltip.size(); // Try to only break at white space diff --git a/src/Gui/Action.h b/src/Gui/Action.h index e1a4ae1141..d068a9bf5e 100644 --- a/src/Gui/Action.h +++ b/src/Gui/Action.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace Gui {