Merge pull request #5616 from ligfx/qtfocuseventtowindowactivation
DolphinQt2: FocusEventFilter -> WindowActivationEventFilter
This commit is contained in:
commit
f06e233d49
|
@ -50,7 +50,7 @@ set(SRCS
|
||||||
GameList/ListProxyModel.cpp
|
GameList/ListProxyModel.cpp
|
||||||
QtUtils/DoubleClickEventFilter.cpp
|
QtUtils/DoubleClickEventFilter.cpp
|
||||||
QtUtils/ElidedButton.cpp
|
QtUtils/ElidedButton.cpp
|
||||||
QtUtils/FocusEventFilter.cpp
|
QtUtils/WindowActivationEventFilter.cpp
|
||||||
Settings/GeneralPane.cpp
|
Settings/GeneralPane.cpp
|
||||||
Settings/InterfacePane.cpp
|
Settings/InterfacePane.cpp
|
||||||
Settings/PathPane.cpp
|
Settings/PathPane.cpp
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
<QtMoc Include="MainWindow.h" />
|
<QtMoc Include="MainWindow.h" />
|
||||||
<QtMoc Include="MenuBar.h" />
|
<QtMoc Include="MenuBar.h" />
|
||||||
<QtMoc Include="QtUtils\DoubleClickEventFilter.h" />
|
<QtMoc Include="QtUtils\DoubleClickEventFilter.h" />
|
||||||
<QtMoc Include="QtUtils\FocusEventFilter.h" />
|
<QtMoc Include="QtUtils\WindowActivationEventFilter.h" />
|
||||||
<QtMoc Include="RenderWidget.h" />
|
<QtMoc Include="RenderWidget.h" />
|
||||||
<QtMoc Include="Settings.h" />
|
<QtMoc Include="Settings.h" />
|
||||||
<QtMoc Include="Settings\GeneralPane.h" />
|
<QtMoc Include="Settings\GeneralPane.h" />
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
<ClCompile Include="$(QtMocOutPrefix)AboutDialog.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)AboutDialog.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)ControllersWindow.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)ControllersWindow.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)FilesystemWidget.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)FilesystemWidget.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)FocusEventFilter.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)WindowActivationEventFilter.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)GameFile.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)GameFile.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)GameList.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)GameList.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)GameListModel.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)GameListModel.cpp" />
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
<ClCompile Include="MenuBar.cpp" />
|
<ClCompile Include="MenuBar.cpp" />
|
||||||
<ClCompile Include="QtUtils\DoubleClickEventFilter.cpp" />
|
<ClCompile Include="QtUtils\DoubleClickEventFilter.cpp" />
|
||||||
<ClCompile Include="QtUtils\ElidedButton.cpp" />
|
<ClCompile Include="QtUtils\ElidedButton.cpp" />
|
||||||
<ClCompile Include="QtUtils\FocusEventFilter.cpp" />
|
<ClCompile Include="QtUtils\WindowActivationEventFilter.cpp" />
|
||||||
<ClCompile Include="RenderWidget.cpp" />
|
<ClCompile Include="RenderWidget.cpp" />
|
||||||
<ClCompile Include="Resources.cpp" />
|
<ClCompile Include="Resources.cpp" />
|
||||||
<ClCompile Include="Settings.cpp" />
|
<ClCompile Include="Settings.cpp" />
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "DolphinQt2/Host.h"
|
#include "DolphinQt2/Host.h"
|
||||||
#include "DolphinQt2/HotkeyScheduler.h"
|
#include "DolphinQt2/HotkeyScheduler.h"
|
||||||
#include "DolphinQt2/MainWindow.h"
|
#include "DolphinQt2/MainWindow.h"
|
||||||
#include "DolphinQt2/QtUtils/FocusEventFilter.h"
|
#include "DolphinQt2/QtUtils/WindowActivationEventFilter.h"
|
||||||
#include "DolphinQt2/Resources.h"
|
#include "DolphinQt2/Resources.h"
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
|
|
||||||
|
@ -88,13 +88,15 @@ void MainWindow::ShutdownControllers()
|
||||||
m_hotkey_scheduler->deleteLater();
|
m_hotkey_scheduler->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InstallHotkeyFilter(QDialog* dialog)
|
static void InstallHotkeyFilter(QWidget* dialog)
|
||||||
{
|
{
|
||||||
auto* filter = new FocusEventFilter();
|
auto* filter = new WindowActivationEventFilter();
|
||||||
dialog->installEventFilter(filter);
|
dialog->installEventFilter(filter);
|
||||||
|
|
||||||
filter->connect(filter, &FocusEventFilter::focusOutEvent, [] { HotkeyManagerEmu::Enable(true); });
|
filter->connect(filter, &WindowActivationEventFilter::windowDeactivated,
|
||||||
filter->connect(filter, &FocusEventFilter::focusInEvent, [] { HotkeyManagerEmu::Enable(false); });
|
[] { HotkeyManagerEmu::Enable(true); });
|
||||||
|
filter->connect(filter, &WindowActivationEventFilter::windowActivated,
|
||||||
|
[] { HotkeyManagerEmu::Enable(false); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CreateComponents()
|
void MainWindow::CreateComponents()
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
// Copyright 2017 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2+
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include <QEvent>
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "DolphinQt2/QtUtils/FocusEventFilter.h"
|
|
||||||
|
|
||||||
bool FocusEventFilter::eventFilter(QObject* object, QEvent* event)
|
|
||||||
{
|
|
||||||
if (event->type() == QEvent::FocusOut)
|
|
||||||
emit focusOutEvent();
|
|
||||||
|
|
||||||
if (event->type() == QEvent::FocusIn)
|
|
||||||
emit focusInEvent();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright 2017 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "DolphinQt2/QtUtils/WindowActivationEventFilter.h"
|
||||||
|
|
||||||
|
bool WindowActivationEventFilter::eventFilter(QObject* object, QEvent* event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::WindowDeactivate)
|
||||||
|
emit windowDeactivated();
|
||||||
|
|
||||||
|
if (event->type() == QEvent::WindowActivate)
|
||||||
|
emit windowActivated();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class FocusEventFilter : public QObject
|
class WindowActivationEventFilter : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
signals:
|
signals:
|
||||||
void focusInEvent();
|
void windowActivated();
|
||||||
void focusOutEvent();
|
void windowDeactivated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
Loading…
Reference in New Issue