Merge pull request #5215

93a3f0e Qt: Network-Traffic-Graph: make some distance between line and text (Jonas Schnelli)
This commit is contained in:
Wladimir J. van der Laan 2014-11-05 16:02:06 +01:00
commit d064f7f3ee
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
1 changed files with 5 additions and 3 deletions

View File

@ -76,10 +76,12 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *)
int base = floor(log10(fMax)); int base = floor(log10(fMax));
float val = pow(10.0f, base); float val = pow(10.0f, base);
const QString units = tr("KB/s"); const QString units = tr("KB/s");
const float yMarginText = 2.0;
// draw lines // draw lines
painter.setPen(axisCol); painter.setPen(axisCol);
painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax, QString("%1 %2").arg(val).arg(units)); painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax-yMarginText, QString("%1 %2").arg(val).arg(units));
for(float y = val; y < fMax; y += val) { for(float y = val; y < fMax; y += val) {
int yy = YMARGIN + h - h * y / fMax; int yy = YMARGIN + h - h * y / fMax;
painter.drawLine(XMARGIN, yy, width() - XMARGIN, yy); painter.drawLine(XMARGIN, yy, width() - XMARGIN, yy);
@ -89,7 +91,7 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *)
axisCol = axisCol.darker(); axisCol = axisCol.darker();
val = pow(10.0f, base - 1); val = pow(10.0f, base - 1);
painter.setPen(axisCol); painter.setPen(axisCol);
painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax, QString("%1 %2").arg(val).arg(units)); painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax-yMarginText, QString("%1 %2").arg(val).arg(units));
int count = 1; int count = 1;
for(float y = val; y < fMax; y += val, count++) { for(float y = val; y < fMax; y += val, count++) {
// don't overwrite lines drawn above // don't overwrite lines drawn above