1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Fixed SqueezeLabel

This commit is contained in:
nowrep 2011-05-25 14:30:43 +02:00
parent a71c0e073c
commit 41b992370b

View File

@ -8,7 +8,9 @@ SqueezeLabel::SqueezeLabel(QWidget *parent)
void SqueezeLabel::setText(const QString &txt) void SqueezeLabel::setText(const QString &txt)
{ {
m_originalText = txt; m_originalText = txt;
QLabel::setText(txt); QFontMetrics fm = fontMetrics();
QString elided = fm.elidedText(m_originalText, Qt::ElideMiddle, width());
QLabel::setText(elided);
} }
QString SqueezeLabel::originalText() QString SqueezeLabel::originalText()
@ -20,6 +22,6 @@ void SqueezeLabel::resizeEvent(QResizeEvent *event)
{ {
QLabel::resizeEvent(event); QLabel::resizeEvent(event);
QFontMetrics fm = fontMetrics(); QFontMetrics fm = fontMetrics();
QString elided = fm.elidedText(originalText(), Qt::ElideMiddle, width()); QString elided = fm.elidedText(m_originalText, Qt::ElideMiddle, width());
QLabel::setText(elided); QLabel::setText(elided);
} }