diff --git a/CHANGES b/CHANGES index af13230da..5abb5d52e 100644 --- a/CHANGES +++ b/CHANGES @@ -116,6 +116,7 @@ Bugfixes: - Qt: Fix jumbled background when paused - Qt: Fix FPS counter on Windows - GB, GBA Savedata: Fix leaks when loading masked save (fixes mgba.io/i/1197) + - Qt: Fix focus issues with load/save state overlay Misc: - mGUI: Add SGB border configuration option - mGUI: Add support for different settings types diff --git a/src/platform/qt/LoadSaveState.cpp b/src/platform/qt/LoadSaveState.cpp index d9db6a7d3..93cbfee66 100644 --- a/src/platform/qt/LoadSaveState.cpp +++ b/src/platform/qt/LoadSaveState.cpp @@ -27,8 +27,9 @@ LoadSaveState::LoadSaveState(std::shared_ptr controller, QWidget , m_mode(LoadSave::LOAD) , m_currentFocus(controller->stateSlot() - 1) { - setAttribute(Qt::WA_TranslucentBackground); m_ui.setupUi(this); + m_ui.lsLabel->setFocusProxy(this); + setFocusPolicy(Qt::ClickFocus); m_slots[0] = m_ui.state1; m_slots[1] = m_ui.state2; @@ -56,6 +57,7 @@ LoadSaveState::LoadSaveState(std::shared_ptr controller, QWidget if (m_currentFocus < 0) { m_currentFocus = 0; } + m_slots[m_currentFocus]->setFocus(); QAction* escape = new QAction(this); connect(escape, &QAction::triggered, this, &QWidget::close); @@ -242,6 +244,10 @@ void LoadSaveState::showEvent(QShowEvent* event) { QWidget::showEvent(event); } +void LoadSaveState::focusInEvent(QFocusEvent*) { + m_slots[m_currentFocus]->setFocus(); +} + void LoadSaveState::paintEvent(QPaintEvent*) { QPainter painter(this); QRect full(QPoint(), size()); diff --git a/src/platform/qt/LoadSaveState.h b/src/platform/qt/LoadSaveState.h index b762a00e1..5596c1b10 100644 --- a/src/platform/qt/LoadSaveState.h +++ b/src/platform/qt/LoadSaveState.h @@ -41,6 +41,7 @@ protected: virtual void closeEvent(QCloseEvent*) override; virtual void showEvent(QShowEvent*) override; virtual void paintEvent(QPaintEvent*) override; + virtual void focusInEvent(QFocusEvent*) override; private: void loadState(int slot);