Skip to content

Commit

Permalink
Do not use elided text for multiline string with fixed font size (#11610
Browse files Browse the repository at this point in the history
)

Fixes #8383
  • Loading branch information
adeas31 committed Nov 20, 2023
1 parent 5b94ed1 commit ad47153
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions OMEdit/OMEditLIB/Annotations/TextAnnotation.cpp
Expand Up @@ -434,10 +434,10 @@ void TextAnnotation::drawAnnotation(QPainter *painter)
painter->setFont(font);
}
/* Try to get the elided text if calculated font size <= Helper::minimumTextFontSize
* OR if font size is absolute.
* OR if font size is absolute and text is not multiline.
*/
QString textToDraw = textString;
if (absMappedBoundingRect.width() > 1 && ((mFontSize <= 0 && painter->font().pointSizeF() <= Helper::minimumTextFontSize) || mFontSize > 0)) {
if (absMappedBoundingRect.width() > 1 && ((mFontSize <= 0 && painter->font().pointSizeF() <= Helper::minimumTextFontSize) || (mFontSize > 0 && !Utilities::isMultiline(textString)))) {
QFontMetrics fontMetrics(painter->font());
textToDraw = fontMetrics.elidedText(textString, Qt::ElideRight, absMappedBoundingRect.width());
// if we get "..." i.e., QChar(0x2026) as textToDraw then don't draw anything
Expand Down
11 changes: 11 additions & 0 deletions OMEdit/OMEditLIB/Util/Utilities.cpp
Expand Up @@ -1333,3 +1333,14 @@ void Utilities::setToolTip(QComboBox *pComboBox, const QString &description, con
}
pComboBox->setToolTip(QString("<html><head/><body><p>%1</p><ul>%2</ul></body></html>").arg(description, itemsToolTip));
}

/*!
* \brief Utilities::isMultiline
* Returns true if the text containts \n.
* \param text
* \return
*/
bool Utilities::isMultiline(const QString &text)
{
return text.indexOf('\n') >= 0;
}
1 change: 1 addition & 0 deletions OMEdit/OMEditLIB/Util/Utilities.h
Expand Up @@ -523,6 +523,7 @@ namespace Utilities {
QString convertSymbolToUnit(const QString &symbol);
QRectF adjustSceneRectangle(const QRectF sceneRectangle, const qreal factor);
void setToolTip(QComboBox *pComboBox, const QString &description, const QStringList &optionsDescriptions);
bool isMultiline(const QString &text);
} // namespace Utilities

#endif // UTILITIES_H

0 comments on commit ad47153

Please sign in to comment.