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:
parent
eac2066ad5
commit
f08736eab8
1 changed files with 9 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue