Qt: Fix a few more UX grievances

This commit is contained in:
Jeffrey Pfau 2015-01-05 02:06:37 -08:00
parent c90d105e34
commit 851d942cdd
3 changed files with 13 additions and 9 deletions

View File

@ -163,12 +163,12 @@ const ShortcutController::ShortcutItem* ShortcutController::itemAt(const QModelI
return static_cast<const ShortcutItem*>(index.internalPointer());
}
const QAction* ShortcutController::actionAt(const QModelIndex& index) const {
QKeySequence ShortcutController::shortcutAt(const QModelIndex& index) const {
const ShortcutItem* item = itemAt(index);
if (!item) {
return nullptr;
return QKeySequence();
}
return item->action();
return item->shortcut();
}
bool ShortcutController::isMenuAt(const QModelIndex& index) const {

View File

@ -86,7 +86,7 @@ public:
void addFunctions(QMenu* menu, std::function<void ()> press, std::function<void()> release, const QKeySequence& shortcut, const QString& visibleName, const QString& name);
void addMenu(QMenu* menu, QMenu* parent = nullptr);
const QAction* actionAt(const QModelIndex& index) const;
QKeySequence shortcutAt(const QModelIndex& index) const;
bool isMenuAt(const QModelIndex& index) const;
void updateKey(const QModelIndex& index, const QKeySequence& keySequence);

View File

@ -47,16 +47,21 @@ void ShortcutView::load(const QModelIndex& index) {
if (!m_controller) {
return;
}
const QAction* action = m_controller->actionAt(index);
if (!action || m_controller->isMenuAt(index)) {
if (m_controller->isMenuAt(index)) {
return;
}
QKeySequence sequence = m_controller->shortcutAt(index);
if (index.column() == 1) {
m_ui.keyboardButton->click();
} else if (index.column() == 2) {
m_ui.gamepadButton->click();
}
if (m_ui.gamepadButton->isChecked()) {
m_ui.keyEdit->setFocus();
m_ui.keyEdit->setValueButton(-1); // There are no default bindings
} else {
m_ui.keySequenceEdit->setFocus();
m_ui.keySequenceEdit->setKeySequence(action->shortcut());
m_ui.keySequenceEdit->setKeySequence(sequence);
}
}
@ -65,8 +70,7 @@ void ShortcutView::clear() {
return;
}
QModelIndex index = m_ui.shortcutTable->selectionModel()->currentIndex();
const QAction* action = m_controller->actionAt(index);
if (!action || m_controller->isMenuAt(index)) {
if (m_controller->isMenuAt(index)) {
return;
}
if (m_ui.gamepadButton->isChecked()) {