diff --git a/src/widget/wbasewidget.cpp b/src/widget/wbasewidget.cpp index 2e7df4352e5..b374294a92a 100644 --- a/src/widget/wbasewidget.cpp +++ b/src/widget/wbasewidget.cpp @@ -139,63 +139,72 @@ void WBaseWidget::setControlParameterRightUp(double v) { } void WBaseWidget::updateTooltip() { - // If we are in developer mode, update the tooltip. + // Remove leading and trailing whitespace/line breaks from the tooltip. + QString base = baseTooltip().trimmed(); + + // If we are in developer mode, expand the tooltip. if (CmdlineArgs::Instance().getDeveloper()) { QStringList debug; fillDebugTooltip(&debug); - QString base = baseTooltip(); if (!base.isEmpty()) { - debug.append(QString("Tooltip: \"%1\"").arg(base)); + debug.append(QStringLiteral("Tooltip: \"%1\"").arg(base)); } - m_pWidget->setToolTip(debug.join("\n")); + m_pWidget->setToolTip(debug.join(QStringLiteral("\n"))); + } else { + m_pWidget->setToolTip(base); } } -template <> +template<> QString toDebugString(const QSizePolicy::Policy& policy) { switch (policy) { - case QSizePolicy::Fixed: - return "Fixed"; - case QSizePolicy::Minimum: - return "Minimum"; - case QSizePolicy::Maximum: - return "Maximum"; - case QSizePolicy::Preferred: - return "Preferred"; - case QSizePolicy::Expanding: - return "Expanding"; - case QSizePolicy::MinimumExpanding: - return "MinimumExpanding"; - case QSizePolicy::Ignored: - return "Ignored"; - default: - break; - } - return QString::number(static_cast(policy)); + case QSizePolicy::Fixed: + return QStringLiteral("Fixed"); + case QSizePolicy::Minimum: + return QStringLiteral("Minimum"); + case QSizePolicy::Maximum: + return QStringLiteral("Maximum"); + case QSizePolicy::Preferred: + return QStringLiteral("Preferred"); + case QSizePolicy::Expanding: + return QStringLiteral("Expanding"); + case QSizePolicy::MinimumExpanding: + return QStringLiteral("MinimumExpanding"); + case QSizePolicy::Ignored: + return QStringLiteral("Ignored"); + default: + return QString::number(static_cast(policy)); + } } void WBaseWidget::fillDebugTooltip(QStringList* debug) { QSizePolicy policy = m_pWidget->sizePolicy(); - *debug << QString("ClassName: %1").arg(m_pWidget->metaObject()->className()) - << QString("ObjectName: %1").arg(m_pWidget->objectName()) - << QString("Position: %1").arg(toDebugString(m_pWidget->pos())) - << QString("SizePolicy: %1,%2").arg(toDebugString(policy.horizontalPolicy()), - toDebugString(policy.verticalPolicy())) - << QString("Size: %1").arg(toDebugString(m_pWidget->size())) - << QString("SizeHint: %1").arg(toDebugString(m_pWidget->sizeHint())) - << QString("MinimumSizeHint: %1").arg(toDebugString(m_pWidget->minimumSizeHint())); - - for (const auto& pControlConnection : std::as_const(m_leftConnections)) { - *debug << QString("LeftConnection: %1").arg(pControlConnection->toDebugString()); - } - for (const auto& pControlConnection : std::as_const(m_rightConnections)) { - *debug << QString("RightConnection: %1").arg(pControlConnection->toDebugString()); - } - for (const auto& pControlConnection : std::as_const(m_connections)) { - *debug << QString("Connection: %1").arg(pControlConnection->toDebugString()); + *debug << QStringLiteral("ClassName: %1") + .arg(m_pWidget->metaObject()->className()) + << QStringLiteral("ObjectName: %1").arg(m_pWidget->objectName()) + << QStringLiteral("Position: %1") + .arg(toDebugString(m_pWidget->pos())) + << QStringLiteral("SizePolicy: %1,%2") + .arg(toDebugString(policy.horizontalPolicy()), + toDebugString(policy.verticalPolicy())) + << QStringLiteral("Size: %1").arg(toDebugString(m_pWidget->size())) + << QStringLiteral("SizeHint: %1") + .arg(toDebugString(m_pWidget->sizeHint())) + << QStringLiteral("MinimumSizeHint: %1") + .arg(toDebugString(m_pWidget->minimumSizeHint())); + + for (const auto& pControlConnection : m_leftConnections) { + *debug << QStringLiteral("LeftConnection: %1").arg(pControlConnection->toDebugString()); + } + for (const auto& pControlConnection : m_rightConnections) { + *debug << QStringLiteral("RightConnection: %1").arg(pControlConnection->toDebugString()); + } + for (const auto& pControlConnection : m_connections) { + *debug << QStringLiteral("Connection: %1").arg(pControlConnection->toDebugString()); } if (m_pDisplayConnection) { - *debug << QString("DisplayConnection: %1").arg(m_pDisplayConnection->toDebugString()); + *debug << QStringLiteral("DisplayConnection: %1") + .arg(m_pDisplayConnection->toDebugString()); } } diff --git a/src/widget/wbasewidget.h b/src/widget/wbasewidget.h index c9e0834551e..e5477462eae 100644 --- a/src/widget/wbasewidget.h +++ b/src/widget/wbasewidget.h @@ -21,7 +21,7 @@ class WBaseWidget { virtual void Init(); - QWidget* toQWidget() { + QWidget* toQWidget() const { return m_pWidget; }