Qt: Fix focus issues with LoadSaveState

This commit is contained in:
Vicki Pfau 2018-10-02 10:00:57 -07:00
parent 64b44efbf1
commit 18fc2cbdb2
3 changed files with 9 additions and 1 deletions

View File

@ -116,6 +116,7 @@ Bugfixes:
- Qt: Fix jumbled background when paused - Qt: Fix jumbled background when paused
- Qt: Fix FPS counter on Windows - Qt: Fix FPS counter on Windows
- GB, GBA Savedata: Fix leaks when loading masked save (fixes mgba.io/i/1197) - GB, GBA Savedata: Fix leaks when loading masked save (fixes mgba.io/i/1197)
- Qt: Fix focus issues with load/save state overlay
Misc: Misc:
- mGUI: Add SGB border configuration option - mGUI: Add SGB border configuration option
- mGUI: Add support for different settings types - mGUI: Add support for different settings types

View File

@ -27,8 +27,9 @@ LoadSaveState::LoadSaveState(std::shared_ptr<CoreController> controller, QWidget
, m_mode(LoadSave::LOAD) , m_mode(LoadSave::LOAD)
, m_currentFocus(controller->stateSlot() - 1) , m_currentFocus(controller->stateSlot() - 1)
{ {
setAttribute(Qt::WA_TranslucentBackground);
m_ui.setupUi(this); m_ui.setupUi(this);
m_ui.lsLabel->setFocusProxy(this);
setFocusPolicy(Qt::ClickFocus);
m_slots[0] = m_ui.state1; m_slots[0] = m_ui.state1;
m_slots[1] = m_ui.state2; m_slots[1] = m_ui.state2;
@ -56,6 +57,7 @@ LoadSaveState::LoadSaveState(std::shared_ptr<CoreController> controller, QWidget
if (m_currentFocus < 0) { if (m_currentFocus < 0) {
m_currentFocus = 0; m_currentFocus = 0;
} }
m_slots[m_currentFocus]->setFocus();
QAction* escape = new QAction(this); QAction* escape = new QAction(this);
connect(escape, &QAction::triggered, this, &QWidget::close); connect(escape, &QAction::triggered, this, &QWidget::close);
@ -242,6 +244,10 @@ void LoadSaveState::showEvent(QShowEvent* event) {
QWidget::showEvent(event); QWidget::showEvent(event);
} }
void LoadSaveState::focusInEvent(QFocusEvent*) {
m_slots[m_currentFocus]->setFocus();
}
void LoadSaveState::paintEvent(QPaintEvent*) { void LoadSaveState::paintEvent(QPaintEvent*) {
QPainter painter(this); QPainter painter(this);
QRect full(QPoint(), size()); QRect full(QPoint(), size());

View File

@ -41,6 +41,7 @@ protected:
virtual void closeEvent(QCloseEvent*) override; virtual void closeEvent(QCloseEvent*) override;
virtual void showEvent(QShowEvent*) override; virtual void showEvent(QShowEvent*) override;
virtual void paintEvent(QPaintEvent*) override; virtual void paintEvent(QPaintEvent*) override;
virtual void focusInEvent(QFocusEvent*) override;
private: private:
void loadState(int slot); void loadState(int slot);