Qt: Fix some focus crashes
Jeffrey Pfau jeffrey@endrift.com
Mon, 18 Jan 2016 19:36:13 -0800
3 files changed,
11 insertions(+),
4 deletions(-)
M
src/platform/qt/SensorView.cpp
→
src/platform/qt/SensorView.cpp
@@ -81,9 +81,10 @@ button->installEventFilter(this);
} 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);
M
src/platform/qt/ShortcutView.cpp
→
src/platform/qt/ShortcutView.cpp
@@ -37,6 +37,10 @@ connect(m_ui.shortcutTable, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(load(const QModelIndex&)));
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 @@ }
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); } }
M
src/platform/qt/ShortcutView.h
→
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);