Fix PR#536 revealing of bad factor management in StyledElidedLabel.
This commit is contained in:
Cyril Soler 2016-10-26 11:35:30 +02:00 committed by GitHub
commit 7e536efe66
2 changed files with 14 additions and 6 deletions

View File

@ -25,19 +25,24 @@
/** Constructor */ /** Constructor */
StyledElidedLabel::StyledElidedLabel(QWidget *parent) StyledElidedLabel::StyledElidedLabel(QWidget *parent)
: ElidedLabel(parent) : ElidedLabel(parent), _lastFactor(-1)
{ {
} }
StyledElidedLabel::StyledElidedLabel(const QString &text, QWidget *parent) StyledElidedLabel::StyledElidedLabel(const QString &text, QWidget *parent)
: ElidedLabel(text, parent) : ElidedLabel(text, parent), _lastFactor(-1)
{ {
} }
void StyledElidedLabel::setFontSizeFactor(int factor) void StyledElidedLabel::setFontSizeFactor(int factor)
{ {
QFont f = font(); int newFactor = factor;
qreal fontSize = factor * f.pointSizeF() / 100; if (factor > 0) {
f.setPointSizeF(fontSize); if (_lastFactor > 0) newFactor = 100 + factor - _lastFactor;
setFont(f); _lastFactor = factor;
QFont f = font();
qreal fontSize = newFactor * f.pointSizeF() / 100;
f.setPointSizeF(fontSize);
setFont(f);
}
} }

View File

@ -34,6 +34,9 @@ public:
StyledElidedLabel(const QString &text, QWidget *parent = NULL); StyledElidedLabel(const QString &text, QWidget *parent = NULL);
void setFontSizeFactor(int factor); void setFontSizeFactor(int factor);
private:
int _lastFactor;
}; };
#endif #endif