From b69cbd433d8a93d0679d9623118dfc4adff37aad Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 25 Jun 2017 16:04:56 -0700 Subject: [PATCH] Qt: Better highlight active key in control binding --- CHANGES | 1 + src/platform/qt/GBAKeyEditor.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 6c721fe05..55ce1fd69 100644 --- a/CHANGES +++ b/CHANGES @@ -141,6 +141,7 @@ Misc: - Core: Config values can now be hexadecimal - GB: Reset with initial state of DIV register - GB MBC: New MBC7 implementation + - Qt: Better highlight active key in control binding 0.5.2: (2016-12-31) Bugfixes: diff --git a/src/platform/qt/GBAKeyEditor.cpp b/src/platform/qt/GBAKeyEditor.cpp index 0b58760eb..064bd0f58 100644 --- a/src/platform/qt/GBAKeyEditor.cpp +++ b/src/platform/qt/GBAKeyEditor.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GBAKeyEditor.h" +#include #include #include #include @@ -182,10 +183,20 @@ bool GBAKeyEditor::event(QEvent* event) { } bool GBAKeyEditor::eventFilter(QObject* obj, QEvent* event) { + KeyEditor* keyEditor = static_cast(obj); + if (event->type() == QEvent::FocusOut) { + keyEditor->setPalette(QApplication::palette(keyEditor)); + } if (event->type() != QEvent::FocusIn) { return false; } - findFocus(static_cast(obj)); + + QPalette palette = keyEditor->palette(); + palette.setBrush(keyEditor->backgroundRole(), palette.highlight()); + palette.setBrush(keyEditor->foregroundRole(), palette.highlightedText()); + keyEditor->setPalette(palette); + + findFocus(keyEditor); return true; }