Qt: Better highlight active key in control binding

This commit is contained in:
Vicki Pfau 2017-06-25 16:04:56 -07:00
parent 7b543df002
commit b69cbd433d
2 changed files with 13 additions and 1 deletions

View File

@ -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:

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GBAKeyEditor.h"
#include <QApplication>
#include <QComboBox>
#include <QHBoxLayout>
#include <QPaintEvent>
@ -182,10 +183,20 @@ bool GBAKeyEditor::event(QEvent* event) {
}
bool GBAKeyEditor::eventFilter(QObject* obj, QEvent* event) {
KeyEditor* keyEditor = static_cast<KeyEditor*>(obj);
if (event->type() == QEvent::FocusOut) {
keyEditor->setPalette(QApplication::palette(keyEditor));
}
if (event->type() != QEvent::FocusIn) {
return false;
}
findFocus(static_cast<KeyEditor*>(obj));
QPalette palette = keyEditor->palette();
palette.setBrush(keyEditor->backgroundRole(), palette.highlight());
palette.setBrush(keyEditor->foregroundRole(), palette.highlightedText());
keyEditor->setPalette(palette);
findFocus(keyEditor);
return true;
}