mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fix PR#536 revealing of bad factor management in StyledElidedLabel.
This commit is contained in:
parent
5f5b0d44bb
commit
32e54e53b7
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
StyledElidedLabel(const QString &text, QWidget *parent = NULL);
|
||||
|
||||
void setFontSizeFactor(int factor);
|
||||
|
||||
private:
|
||||
int _lastFactor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user