UI: Add eventFilter to media slider
When pressing the up and down arrows or moving the mouse wheel for the media slider, the slider would move.
This commit is contained in:
parent
8a41c7298f
commit
fca727c191
@ -4,6 +4,7 @@
|
||||
|
||||
MediaSlider::MediaSlider(QWidget *parent) : SliderIgnoreScroll(parent)
|
||||
{
|
||||
installEventFilter(this);
|
||||
setMouseTracking(true);
|
||||
|
||||
QString styleName = style()->objectName();
|
||||
@ -32,3 +33,20 @@ void MediaSlider::mouseMoveEvent(QMouseEvent *event)
|
||||
event->accept();
|
||||
QSlider::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
bool MediaSlider::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
|
||||
if (keyEvent->key() == Qt::Key_Up ||
|
||||
keyEvent->key() == Qt::Key_Down) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (event->type() == QEvent::Wheel)
|
||||
return true;
|
||||
|
||||
return QSlider::eventFilter(obj, event);
|
||||
}
|
||||
|
@ -14,4 +14,5 @@ signals:
|
||||
|
||||
protected:
|
||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user