mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-04 14:14:17 -04:00
Resize tab label height depending on the font in use. Fix #1922
Commit amended to fix icon getting cut off in certain cases by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "TabLabel.h"
|
||||
#include <QFontMetrics>
|
||||
|
||||
Ui::TabLabel::TabLabel(QString icon, QString name) :
|
||||
QWidget(nullptr),
|
||||
@@ -7,7 +8,14 @@ Ui::TabLabel::TabLabel(QString icon, QString name) :
|
||||
ui->setupUi(this);
|
||||
ui->icon->setText("<img src=':/" + icon + "' height='16' width='16' />");
|
||||
ui->name->setText(name);
|
||||
setMinimumHeight(ui->name->height());
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Make sure to properly set the tab label height depending |
|
||||
| on the font in use. |
|
||||
\*---------------------------------------------------------*/
|
||||
QFontMetrics fontMetrics(font());
|
||||
QRect rect = fontMetrics.boundingRect(0, 0, width(), height(), Qt::TextWordWrap | Qt::TextExpandTabs, name);
|
||||
setFixedHeight(std::max(rect.height(), ui->icon->height()));
|
||||
}
|
||||
|
||||
Ui::TabLabel::~TabLabel()
|
||||
|
||||
Reference in New Issue
Block a user