diff --git a/src/platform/qt/SensorView.cpp b/src/platform/qt/SensorView.cpp index bf270e348..f6341e74c 100644 --- a/src/platform/qt/SensorView.cpp +++ b/src/platform/qt/SensorView.cpp @@ -81,9 +81,10 @@ void SensorView::jiggerer(QAbstractButton* button, void (InputController::*sette } bool SensorView::event(QEvent* event) { - if (event->type() == QEvent::WindowActivate) { + QEvent::Type type = event->type(); + if (type == QEvent::WindowActivate || type == QEvent::Show) { m_input->stealFocus(this); - } else if (event->type() == QEvent::WindowDeactivate) { + } else if (type == QEvent::WindowDeactivate || type == QEvent::Hide) { m_input->releaseFocus(this); } return QWidget::event(event); diff --git a/src/platform/qt/ShortcutView.cpp b/src/platform/qt/ShortcutView.cpp index 00d4385a6..9046f043c 100644 --- a/src/platform/qt/ShortcutView.cpp +++ b/src/platform/qt/ShortcutView.cpp @@ -37,6 +37,10 @@ ShortcutView::ShortcutView(QWidget* parent) connect(m_ui.clearButton, SIGNAL(clicked()), this, SLOT(clear())); } +ShortcutView::~ShortcutView() { + m_input->releaseFocus(this); +} + void ShortcutView::setController(ShortcutController* controller) { m_controller = controller; m_ui.shortcutTable->setModel(controller); @@ -117,9 +121,10 @@ void ShortcutView::closeEvent(QCloseEvent*) { bool ShortcutView::event(QEvent* event) { if (m_input) { - if (event->type() == QEvent::WindowActivate) { + QEvent::Type type = event->type(); + if (type == QEvent::WindowActivate || type == QEvent::Show) { m_input->stealFocus(this); - } else if (event->type() == QEvent::WindowDeactivate) { + } else if (type == QEvent::WindowDeactivate || type == QEvent::Hide) { m_input->releaseFocus(this); } } diff --git a/src/platform/qt/ShortcutView.h b/src/platform/qt/ShortcutView.h index 37c95c887..945f21d81 100644 --- a/src/platform/qt/ShortcutView.h +++ b/src/platform/qt/ShortcutView.h @@ -22,6 +22,7 @@ Q_OBJECT public: ShortcutView(QWidget* parent = nullptr); + ~ShortcutView(); void setController(ShortcutController* controller); void setInputController(InputController* input);