Fix PR#536 revealing of bad factor management in StyledElidedLabel.

This commit is contained in:
Phenom 2016-10-25 14:58:06 +02:00
parent 5f5b0d44bb
commit 32e54e53b7
2 changed files with 14 additions and 6 deletions

View File

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