]> Some of my projects - aniplayer2.git/commitdiff
Center the seek time vertically in the SeekSlider.
authorAPTX <marek321@gmail.com>
Sun, 16 Feb 2014 12:44:26 +0000 (13:44 +0100)
committerAPTX <marek321@gmail.com>
Sun, 16 Feb 2014 12:44:26 +0000 (13:44 +0100)
player/seekslider.cpp

index 919be600a8d25d83ffb7b69bf11c4e8a89bfcd07..f9130113c8104c390459672fdebcf687a4a92e69 100644 (file)
@@ -98,6 +98,7 @@ void SeekSlider::paintEvent(QPaintEvent *event)
        // unwatched part
        p.fillRect(markerPos + markerWidth / 2, seekerTop + 1, seekerWidth - markerPos, seekerHeight - 1, unwatchedPartColor);
 
+       // previous locations before seeking
        int i = 1;
        for (auto it = previuousPos.constBegin(); it != previuousPos.constEnd(); ++it)
        {
@@ -121,10 +122,11 @@ void SeekSlider::paintEvent(QPaintEvent *event)
                QRect r = p.fontMetrics().boundingRect(time);
 
                int xdelta = markerShadowPos + markerWidth / 2 + 1;
+               int ydelta = seekerHeight / 2 + r.height() / 2 - 1;
                if (xdelta + r.width() < width())
-                       r.translate(xdelta, r.height());
+                       r.translate(xdelta, ydelta);
                else
-                       r.translate(markerShadowPos - (markerWidth / 2 + 1) - r.width(), r.height());
+                       r.translate(markerShadowPos - (markerWidth / 2 + 1) - r.width(), ydelta);
 
                p.fillRect(r, toolTipBackgroundColor);
                p.setPen(QPen(toolTipForegroundColor));