yolobs-studio/UI/media-slider.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
763 B
C++
Raw Permalink Normal View History

2020-10-01 20:15:25 +00:00
#include "slider-absoluteset-style.hpp"
#include "media-slider.hpp"
#include <QStyleFactory>
MediaSlider::MediaSlider(QWidget *parent) : SliderIgnoreScroll(parent)
{
setMouseTracking(true);
QString styleName = style()->objectName();
QStyle *style;
style = QStyleFactory::create(styleName);
if (!style) {
style = new SliderAbsoluteSetStyle();
} else {
style = new SliderAbsoluteSetStyle(style);
}
style->setParent(this);
this->setStyle(style);
}
void MediaSlider::mouseMoveEvent(QMouseEvent *event)
{
int val = minimum() + ((maximum() - minimum()) * event->x()) / width();
if (val > maximum())
val = maximum();
else if (val < minimum())
val = minimum();
emit mediaSliderHovered(val);
event->accept();
QSlider::mouseMoveEvent(event);
}