mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-24 07:05:58 +01:00
31 lines
601 B
C++
31 lines
601 B
C++
|
#include "elidedbutton.h"
|
||
|
|
||
|
ElidedButton::ElidedButton(QWidget *parent)
|
||
|
: QPushButton(parent)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
ElidedButton::ElidedButton( const QString& text, QWidget* parent )
|
||
|
: ElidedButton( parent )
|
||
|
{
|
||
|
setText(text);
|
||
|
}
|
||
|
|
||
|
void ElidedButton::setText(QString text)
|
||
|
{
|
||
|
og_text = text;
|
||
|
updateText();
|
||
|
}
|
||
|
|
||
|
void ElidedButton::resizeEvent(QResizeEvent *event)
|
||
|
{
|
||
|
QPushButton::resizeEvent(event);
|
||
|
updateText();
|
||
|
}
|
||
|
|
||
|
void ElidedButton::updateText()
|
||
|
{
|
||
|
QFontMetrics metrics(font());
|
||
|
QString elided = metrics.elidedText(og_text, Qt::ElideRight, width() - 15);
|
||
|
QPushButton::setText(elided);
|
||
|
}
|