commit 35bb9cb4a63bbbd103306ec749f082faf318c56b
Author: Scott Kostyshak <[email protected]>
Date:   Fri Mar 20 09:39:51 2020 -0400

    Change a couple instances of QFontMetrics::width()
    
    Use QFontMetrics::boundingRect() instead. QFontMetrics::width() does
    not actually calculate the width of the bounding box and is mostly
    useful for knowing where to draw text after a string, taking into
    account bearings. Indeed, it has been renamed to
    QFontMetrics::horizontalAdvance().
    
    For the code touched in this commit, we want to center a string.
    Either method would likely be fine, but it is more easy to
    understand exactly what QFontMetrics::boundingRect() does.
    
    This commit does change functionality, although it should not be
    noticeable.
---
 src/frontends/qt/CategorizedCombo.cpp |    2 +-
 src/frontends/qt/LayoutBox.cpp        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/CategorizedCombo.cpp 
b/src/frontends/qt/CategorizedCombo.cpp
index 4acae5b..319bcb0 100644
--- a/src/frontends/qt/CategorizedCombo.cpp
+++ b/src/frontends/qt/CategorizedCombo.cpp
@@ -244,7 +244,7 @@ void CCItemDelegate::drawCategoryHeader(QPainter * painter, 
QStyleOptionViewItem
 
        // draw the centered text
        QFontMetrics fm(font);
-       int w = fm.width(category);
+       int w = fm.boundingRect(category).width();
        int x = opt.rect.x() + (opt.rect.width() - w) / 2;
        int y = opt.rect.y() + 3 * fm.ascent() / 2;
        int left = x;
diff --git a/src/frontends/qt/LayoutBox.cpp b/src/frontends/qt/LayoutBox.cpp
index 7167eba..01cb60e 100644
--- a/src/frontends/qt/LayoutBox.cpp
+++ b/src/frontends/qt/LayoutBox.cpp
@@ -275,7 +275,7 @@ void LayoutItemDelegate::drawCategoryHeader(QPainter * 
painter, QStyleOptionView
 
        // draw the centered text
        QFontMetrics fm(font);
-       int w = fm.width(category);
+       int w = fm.boundingRect(category).width();
        int x = opt.rect.x() + (opt.rect.width() - w) / 2;
        int y = opt.rect.y() + fm.ascent();
        int left = x;
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to