1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-14 11:02:19 +01:00
falkonOfficial/src/3rdparty/squeezelabelv2.cpp

34 lines
727 B
C++
Raw Normal View History

2011-05-31 21:11:46 +02:00
#include "squeezelabelv2.h"
2011-03-02 16:57:41 +01:00
SqueezeLabelV2::SqueezeLabelV2(QWidget* parent)
2011-03-02 16:57:41 +01:00
: QLabel(parent)
{
}
SqueezeLabelV2::SqueezeLabelV2(const QString &string)
: QLabel()
{
setText(string);
}
2011-05-31 21:11:46 +02:00
void SqueezeLabelV2::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);
}
2011-05-31 21:11:46 +02:00
QString SqueezeLabelV2::originalText()
{
return m_originalText;
}
void SqueezeLabelV2::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
}