Qt: Fix shortcuts conflicting between views

This commit is contained in:
Jeffrey Pfau 2015-04-03 21:13:24 -07:00
parent 5da7198d07
commit 36af5fba87
2 changed files with 7 additions and 3 deletions

View File

@ -43,6 +43,12 @@ LoadSaveState::LoadSaveState(GameController* controller, QWidget* parent)
m_slots[i]->installEventFilter(this);
connect(m_slots[i], &QAbstractButton::clicked, this, [this, i]() { triggerState(i + 1); });
}
QAction* escape = new QAction(this);
escape->connect(escape, SIGNAL(triggered()), this, SLOT(close()));
escape->setShortcut(QKeySequence("Esc"));
escape->setShortcutContext(Qt::WidgetWithChildrenShortcut);
addAction(escape);
}
void LoadSaveState::setMode(LoadSave mode) {
@ -80,9 +86,6 @@ bool LoadSaveState::eventFilter(QObject* object, QEvent* event) {
case Qt::Key_9:
triggerState(static_cast<QKeyEvent*>(event)->key() - Qt::Key_1 + 1);
break;
case Qt::Key_Escape:
close();
break;
case Qt::Key_Enter:
case Qt::Key_Return:
triggerState(m_currentFocus + 1);

View File

@ -922,6 +922,7 @@ void Window::updateMRU() {
QAction* Window::addControlledAction(QMenu* menu, QAction* action, const QString& name) {
m_shortcutController->addAction(menu, action, name);
menu->addAction(action);
action->setShortcutContext(Qt::WidgetShortcut);
addAction(action);
return action;
}