mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 11:49:06 +00:00
DolphinQt: Fix ElidedButton (MappingButton) from growing with long text.
This commit is contained in:
parent
2a3c075330
commit
1cae9b9b39
3 changed files with 17 additions and 12 deletions
|
@ -27,6 +27,14 @@ void ElidedButton::setElideMode(Qt::TextElideMode elide_mode)
|
|||
repaint();
|
||||
}
|
||||
|
||||
QSize ElidedButton::sizeHint() const
|
||||
{
|
||||
// Long text produces big sizeHints which is throwing layouts off
|
||||
// even when setting fixed sizes. This seems like a Qt layout bug.
|
||||
// Let's always return the sizeHint of an empty button to work around this.
|
||||
return QPushButton(parentWidget()).sizeHint();
|
||||
}
|
||||
|
||||
void ElidedButton::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QStyleOptionButton option;
|
||||
|
|
|
@ -12,10 +12,13 @@ class ElidedButton : public QPushButton
|
|||
public:
|
||||
explicit ElidedButton(const QString& text = QStringLiteral(""),
|
||||
Qt::TextElideMode elide_mode = Qt::ElideRight);
|
||||
|
||||
Qt::TextElideMode elideMode() const;
|
||||
void setElideMode(Qt::TextElideMode elide_mode);
|
||||
|
||||
QSize sizeHint() const final override;
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void paintEvent(QPaintEvent* event) final override;
|
||||
Qt::TextElideMode m_elide_mode;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue