Prevent accidental edits of actions and conditions when scrolling

This commit is contained in:
WarmUpTill
2021-07-18 14:16:04 +02:00
committed by WarmUpTill
parent 95409dfa26
commit 84e4b740a8
6 changed files with 55 additions and 5 deletions

View File

@@ -649,3 +649,30 @@ void MacroRefAction::ResolveMacroRef()
{
_macro.UpdateRef();
}
MouseWheelWidgetAdjustmentGuard::MouseWheelWidgetAdjustmentGuard(QObject *parent)
: QObject(parent)
{
}
bool MouseWheelWidgetAdjustmentGuard::eventFilter(QObject *o, QEvent *e)
{
const QWidget *widget = static_cast<QWidget *>(o);
if (e->type() == QEvent::Wheel && widget && !widget->hasFocus()) {
e->ignore();
return true;
}
return QObject::eventFilter(o, e);
}
MacroSegmentEdit::MacroSegmentEdit(QWidget *parent) : QWidget(parent) {}
void MacroSegmentEdit::SetFocusPolicyOfWidgets()
{
QList<QWidget *> widgets = this->findChildren<QWidget *>();
for (auto w : widgets) {
w->setFocusPolicy(Qt::StrongFocus);
w->installEventFilter(new MouseWheelWidgetAdjustmentGuard(w));
}
}