From b4698ab638e172b18892d9c16f392ae08d223e09 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 22 Feb 2019 18:45:54 -0800 Subject: [PATCH] Qt: Kick focus back to main window when clicking a chip --- src/platform/qt/BattleChipView.cpp | 7 ++++++- src/platform/qt/BattleChipView.h | 5 ++++- src/platform/qt/Window.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/platform/qt/BattleChipView.cpp b/src/platform/qt/BattleChipView.cpp index 53c9a3024..2e00ac47b 100644 --- a/src/platform/qt/BattleChipView.cpp +++ b/src/platform/qt/BattleChipView.cpp @@ -8,6 +8,8 @@ #include "ConfigController.h" #include "CoreController.h" #include "GBAApp.h" +#include "ShortcutController.h" +#include "Window.h" #include #include @@ -18,9 +20,10 @@ using namespace QGBA; -BattleChipView::BattleChipView(std::shared_ptr controller, QWidget* parent) +BattleChipView::BattleChipView(std::shared_ptr controller, Window* window, QWidget* parent) : QDialog(parent) , m_controller(controller) + , m_window(window) { QResource::registerResource(GBAApp::dataDir() + "/chips.rcc"); QResource::registerResource(ConfigController::configDir() + "/chips.rcc"); @@ -126,6 +129,8 @@ void BattleChipView::reinsert() { } else { insertChip(true); } + m_window->setWindowState(m_window->windowState() & ~Qt::WindowActive); + m_window->setWindowState(m_window->windowState() | Qt::WindowActive); } void BattleChipView::addChip() { diff --git a/src/platform/qt/BattleChipView.h b/src/platform/qt/BattleChipView.h index 423c937c8..ca6dfb942 100644 --- a/src/platform/qt/BattleChipView.h +++ b/src/platform/qt/BattleChipView.h @@ -16,12 +16,13 @@ namespace QGBA { class CoreController; +class Window; class BattleChipView : public QDialog { Q_OBJECT public: - BattleChipView(std::shared_ptr controller, QWidget* parent = nullptr); + BattleChipView(std::shared_ptr controller, Window* window, QWidget* parent = nullptr); ~BattleChipView(); public slots: @@ -52,6 +53,8 @@ private: int m_frameCounter = -1; bool m_next = false; + + Window* m_window; }; } \ No newline at end of file diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 26c588d88..7d53ea420 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -1370,7 +1370,7 @@ void Window::setupMenu(QMenuBar* menubar) { #ifdef M_CORE_GBA QAction* bcGate = new QAction(tr("BattleChip Gate..."), emulationMenu); - connect(bcGate, &QAction::triggered, openControllerTView()); + connect(bcGate, &QAction::triggered, openControllerTView(this)); addControlledAction(emulationMenu, bcGate, "bcGate"); m_gbaActions.append(bcGate); m_gameActions.append(bcGate);