MappingButton: use BlockUserInputFilter

This commit is contained in:
Michael M 2017-06-26 22:46:54 -07:00
parent 7d438da911
commit c624ef43f0
2 changed files with 3 additions and 22 deletions

View File

@ -15,6 +15,7 @@
#include "DolphinQt2/Config/Mapping/MappingCommon.h" #include "DolphinQt2/Config/Mapping/MappingCommon.h"
#include "DolphinQt2/Config/Mapping/MappingWidget.h" #include "DolphinQt2/Config/Mapping/MappingWidget.h"
#include "DolphinQt2/Config/Mapping/MappingWindow.h" #include "DolphinQt2/Config/Mapping/MappingWindow.h"
#include "DolphinQt2/QtUtils/BlockUserInputFilter.h"
#include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h" #include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/ControllerInterface.h"
@ -42,9 +43,7 @@ void MappingButton::OnButtonPressed()
if (m_parent->GetDevice() == nullptr || !m_reference->IsInput()) if (m_parent->GetDevice() == nullptr || !m_reference->IsInput())
return; return;
if (!m_block.TestAndSet()) installEventFilter(BlockUserInputFilter::Instance());
return;
grabKeyboard(); grabKeyboard();
grabMouse(); grabMouse();
@ -63,7 +62,7 @@ void MappingButton::OnButtonPressed()
releaseMouse(); releaseMouse();
releaseKeyboard(); releaseKeyboard();
m_block.Clear(); removeEventFilter(BlockUserInputFilter::Instance());
if (!expr.isEmpty()) if (!expr.isEmpty())
{ {
@ -97,22 +96,6 @@ void MappingButton::Update()
m_parent->SaveSettings(); m_parent->SaveSettings();
} }
bool MappingButton::event(QEvent* event)
{
const QEvent::Type event_type = event->type();
// Returning 'true' means "yes, this event has been handled, don't propagate it to parent
// widgets".
if (m_block.IsSet() &&
(event_type == QEvent::KeyPress || event_type == QEvent::KeyRelease ||
event_type == QEvent::MouseButtonPress || event_type == QEvent::MouseButtonRelease ||
event_type == QEvent::MouseButtonDblClick))
{
return true;
}
return QPushButton::event(event);
}
void MappingButton::mouseReleaseEvent(QMouseEvent* event) void MappingButton::mouseReleaseEvent(QMouseEvent* event)
{ {
switch (event->button()) switch (event->button())

View File

@ -25,7 +25,6 @@ signals:
void AdvancedPressed(); void AdvancedPressed();
private: private:
bool event(QEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override;
void OnButtonPressed(); void OnButtonPressed();
@ -34,5 +33,4 @@ private:
MappingWidget* m_parent; MappingWidget* m_parent;
ControlReference* m_reference; ControlReference* m_reference;
Common::Flag m_block;
}; };