mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix a handful of UX issues with gamepad mapping
This commit is contained in:
parent
e263467f13
commit
3854c7e401
|
@ -20,7 +20,11 @@ KeyEditor::KeyEditor(QWidget* parent)
|
|||
|
||||
void KeyEditor::setValue(int key) {
|
||||
if (m_button) {
|
||||
setText(QString::number(key));
|
||||
if (key < 0) {
|
||||
clear();
|
||||
} else {
|
||||
setText(QString::number(key));
|
||||
}
|
||||
} else {
|
||||
setText(QKeySequence(key).toString(QKeySequence::NativeText));
|
||||
}
|
||||
|
|
|
@ -171,6 +171,14 @@ const QAction* ShortcutController::actionAt(const QModelIndex& index) const {
|
|||
return item->action();
|
||||
}
|
||||
|
||||
bool ShortcutController::isMenuAt(const QModelIndex& index) const {
|
||||
const ShortcutItem* item = itemAt(index);
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
return item->menu();
|
||||
}
|
||||
|
||||
void ShortcutController::updateKey(const QModelIndex& index, const QKeySequence& keySequence) {
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
|
|
|
@ -86,9 +86,8 @@ 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);
|
||||
|
||||
ShortcutItem* itemAt(const QModelIndex& index);
|
||||
const ShortcutItem* itemAt(const QModelIndex& index) const;
|
||||
const QAction* actionAt(const QModelIndex& index) const;
|
||||
bool isMenuAt(const QModelIndex& index) const;
|
||||
|
||||
void updateKey(const QModelIndex& index, const QKeySequence& keySequence);
|
||||
void updateButton(const QModelIndex& index, int button);
|
||||
|
@ -99,6 +98,8 @@ protected:
|
|||
private:
|
||||
static QKeySequence keyEventToSequence(const QKeyEvent*);
|
||||
|
||||
ShortcutItem* itemAt(const QModelIndex& index);
|
||||
const ShortcutItem* itemAt(const QModelIndex& index) const;
|
||||
void loadShortcuts(ShortcutItem*);
|
||||
|
||||
ShortcutItem m_rootMenu;
|
||||
|
|
|
@ -47,7 +47,7 @@ void ShortcutView::load(const QModelIndex& index) {
|
|||
return;
|
||||
}
|
||||
const QAction* action = m_controller->actionAt(index);
|
||||
if (!action) {
|
||||
if (!action || m_controller->isMenuAt(index)) {
|
||||
return;
|
||||
}
|
||||
if (m_ui.gamepadButton->isChecked()) {
|
||||
|
@ -58,7 +58,7 @@ void ShortcutView::load(const QModelIndex& index) {
|
|||
}
|
||||
|
||||
void ShortcutView::updateKey() {
|
||||
if (!m_controller) {
|
||||
if (!m_controller || m_controller->isMenuAt(m_ui.shortcutTable->selectionModel()->currentIndex())) {
|
||||
return;
|
||||
}
|
||||
m_ui.keySequenceEdit->clearFocus();
|
||||
|
@ -66,7 +66,7 @@ void ShortcutView::updateKey() {
|
|||
}
|
||||
|
||||
void ShortcutView::updateButton(int button) {
|
||||
if (!m_controller) {
|
||||
if (!m_controller || m_controller->isMenuAt(m_ui.shortcutTable->selectionModel()->currentIndex())) {
|
||||
return;
|
||||
}
|
||||
m_controller->updateButton(m_ui.shortcutTable->selectionModel()->currentIndex(), button);
|
||||
|
@ -79,5 +79,5 @@ void ShortcutView::loadKey(const QAction* action) {
|
|||
|
||||
void ShortcutView::loadButton() {
|
||||
m_ui.keyEdit->setFocus();
|
||||
m_ui.keyEdit->setValueButton(-1); // TODO: Real value
|
||||
m_ui.keyEdit->setValueButton(-1); // There are no default bindings
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue