QtUtils: Add BlockUserInputFilter

This commit is contained in:
Michael M 2017-06-26 22:44:10 -07:00
parent 10db1bcbca
commit 7d438da911
4 changed files with 43 additions and 0 deletions

View File

@ -64,6 +64,7 @@ set(SRCS
GameList/GameTracker.cpp
GameList/ListProxyModel.cpp
GameList/TableProxyModel.cpp
QtUtils/BlockUserInputFilter.cpp
QtUtils/DoubleClickEventFilter.cpp
QtUtils/ElidedButton.cpp
QtUtils/ListTabWidget.cpp

View File

@ -186,6 +186,7 @@
<ClCompile Include="Main.cpp" />
<ClCompile Include="MainWindow.cpp" />
<ClCompile Include="MenuBar.cpp" />
<ClCompile Include="QtUtils\BlockUserInputFilter.cpp" />
<ClCompile Include="QtUtils\DoubleClickEventFilter.cpp" />
<ClCompile Include="QtUtils\ElidedButton.cpp" />
<ClCompile Include="QtUtils\ListTabWidget.cpp" />
@ -217,6 +218,7 @@
<ClInclude Include="Config\Mapping\WiimoteEmuExtension.h" />
<ClInclude Include="Config\Mapping\WiimoteEmuGeneral.h" />
<ClInclude Include="Config\Mapping\WiimoteEmuMotionControl.h" />
<ClInclude Include="QtUtils\BlockUserInputFilter.h" />
<ClInclude Include="QtUtils\ElidedButton.h" />
<ClInclude Include="QtUtils\ListTabWidget.h" />
<ClInclude Include="Resources.h" />

View File

@ -0,0 +1,21 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt2/QtUtils/BlockUserInputFilter.h"
#include <QEvent>
BlockUserInputFilter* BlockUserInputFilter::Instance()
{
static BlockUserInputFilter s_block_user_input_filter;
return &s_block_user_input_filter;
}
bool BlockUserInputFilter::eventFilter(QObject* object, QEvent* event)
{
const QEvent::Type event_type = event->type();
return event_type == QEvent::KeyPress || event_type == QEvent::KeyRelease ||
event_type == QEvent::MouseButtonPress || event_type == QEvent::MouseButtonRelease ||
event_type == QEvent::MouseButtonDblClick;
}

View File

@ -0,0 +1,19 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QObject>
class QEvent;
class BlockUserInputFilter : public QObject
{
public:
static BlockUserInputFilter* Instance();
private:
BlockUserInputFilter() = default;
bool eventFilter(QObject* object, QEvent* event) override;
};