1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 17:42:10 +01:00
falkonOfficial/src/3rdparty/squeezelabel.cpp

28 lines
620 B
C++
Raw Normal View History

2011-03-02 16:57:41 +01:00
#include "squeezelabel.h"
SqueezeLabel::SqueezeLabel(QWidget *parent)
: QLabel(parent)
{
}
void SqueezeLabel::setText(const QString &txt)
2011-03-02 16:57:41 +01:00
{
m_originalText = txt;
2011-05-25 14:30:43 +02:00
QFontMetrics fm = fontMetrics();
QString elided = fm.elidedText(m_originalText, Qt::ElideMiddle, width());
QLabel::setText(elided);
}
QString SqueezeLabel::originalText()
{
return m_originalText;
}
void SqueezeLabel::resizeEvent(QResizeEvent *event)
{
QLabel::resizeEvent(event);
QFontMetrics fm = fontMetrics();
2011-05-25 14:30:43 +02:00
QString elided = fm.elidedText(m_originalText, Qt::ElideMiddle, width());
QLabel::setText(elided);
2011-03-02 16:57:41 +01:00
}