mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-12-27 20:09:48 +01:00
c06fd88b3d
It also fixes the region button size and alignment fixes hyprwm#175
31 lines
No EOL
601 B
C++
31 lines
No EOL
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);
|
|
} |