summaryrefslogtreecommitdiff
path: root/src/timeslider.cpp
diff options
context:
space:
mode:
authorMateusz Łukasik <mati75@linuxmint.pl>2018-05-17 21:02:30 +0200
committerMateusz Łukasik <mati75@linuxmint.pl>2018-05-17 21:02:30 +0200
commitf32f79beb0288871bd88450df90e0f6e85e4a1cc (patch)
tree1a7af633202234147a53fb0f874026279ee0cba0 /src/timeslider.cpp
parent6c3f8733e9723de625a14670a948419235504e64 (diff)
New upstream version 18.4.0~ds0
Diffstat (limited to 'src/timeslider.cpp')
-rw-r--r--src/timeslider.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/timeslider.cpp b/src/timeslider.cpp
index 33ef3c8..6b26694 100644
--- a/src/timeslider.cpp
+++ b/src/timeslider.cpp
@@ -22,6 +22,7 @@
#include <QWheelEvent>
#include <QTimer>
#include <QToolTip>
+#include <QStyleOption>
#include <QDebug>
#define DEBUG 0
@@ -163,9 +164,17 @@ bool TimeSlider::event(QEvent *event) {
if (event->type() == QEvent::ToolTip) {
QHelpEvent * help_event = static_cast<QHelpEvent *>(event);
//qDebug() << "TimeSlider::event: x:" << help_event->x() << "maximum:" << maximum() << "width:" << width() << "total_time:" << total_time;
- qreal perc = help_event->x() * 100 / width();
- qreal time = perc * total_time / 100;
- //qDebug() << "TimeSlider::event: time:" << time;
+
+ QStyleOptionSlider opt;
+ initStyleOption(&opt);
+ const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
+ const QPoint center = sliderRect.center() - sliderRect.topLeft();
+
+ int value = pixelPosToRangeValue(help_event->x() - center.x());
+ int range = maximum() - minimum();
+ qreal time = value * total_time / range;
+ //qDebug() << "TimeSlider::event: value:" << value << "range:" << range << "time:" << time;
+
if (time >= 0 && time <= total_time) {
QToolTip::showText(help_event->globalPos(), Helper::formatTime(time), this);
} else {