diff --git a/Source/Core/DolphinQt2/CMakeLists.txt b/Source/Core/DolphinQt2/CMakeLists.txt index 104ca2ffd3..bc1b2c226c 100644 --- a/Source/Core/DolphinQt2/CMakeLists.txt +++ b/Source/Core/DolphinQt2/CMakeLists.txt @@ -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 diff --git a/Source/Core/DolphinQt2/DolphinQt2.vcxproj b/Source/Core/DolphinQt2/DolphinQt2.vcxproj index 18af6e387d..4e45358b4a 100644 --- a/Source/Core/DolphinQt2/DolphinQt2.vcxproj +++ b/Source/Core/DolphinQt2/DolphinQt2.vcxproj @@ -186,6 +186,7 @@ + @@ -217,6 +218,7 @@ + diff --git a/Source/Core/DolphinQt2/QtUtils/BlockUserInputFilter.cpp b/Source/Core/DolphinQt2/QtUtils/BlockUserInputFilter.cpp new file mode 100644 index 0000000000..6368ae072a --- /dev/null +++ b/Source/Core/DolphinQt2/QtUtils/BlockUserInputFilter.cpp @@ -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 + +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; +} diff --git a/Source/Core/DolphinQt2/QtUtils/BlockUserInputFilter.h b/Source/Core/DolphinQt2/QtUtils/BlockUserInputFilter.h new file mode 100644 index 0000000000..112c3eea8f --- /dev/null +++ b/Source/Core/DolphinQt2/QtUtils/BlockUserInputFilter.h @@ -0,0 +1,19 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +class QEvent; + +class BlockUserInputFilter : public QObject +{ +public: + static BlockUserInputFilter* Instance(); + +private: + BlockUserInputFilter() = default; + bool eventFilter(QObject* object, QEvent* event) override; +};