From 9c0ba8b6a8f6b2c5919f4043923b6420af3bf75a Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 20 Jan 2025 10:45:20 +0100 Subject: [PATCH] Pref Effects: left/right key in effect lists trigger hide/unhide --- src/preferences/dialog/dlgprefeffects.cpp | 20 ++++++++++++++------ src/preferences/dialog/dlgprefeffects.h | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 12916498b1e..d065a7b2496 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -402,8 +402,8 @@ void DlgPrefEffects::slotDeletePreset() { } } -bool DlgPrefEffects::eventFilter(QObject* object, QEvent* event) { - if (event->type() == QEvent::FocusIn) { +bool DlgPrefEffects::eventFilter(QObject* pObj, QEvent* pEvent) { + if (pEvent->type() == QEvent::FocusIn) { // Allow selection only in either of the effects/chains lists at a time // to clarify which effect/chain the info below refers to. // The method to update the info box for the new selection is the same @@ -411,11 +411,11 @@ bool DlgPrefEffects::eventFilter(QObject* object, QEvent* event) { // * clear selection in adjacent view // * restore previous selection (select first item if none was selected) // which updates the info box via 'currentRowChanged' signals - auto* pChainList = qobject_cast(object); - auto* pEffectList = qobject_cast(object); + auto* pChainList = qobject_cast(pObj); + auto* pEffectList = qobject_cast(pObj); // Restore previous selection only if focus was changed with keyboard. // For mouse clicks, that procedure would select the wrong index. - QFocusEvent* focEv = static_cast(event); + QFocusEvent* focEv = static_cast(pEvent); bool keyboardFocusIn = false; if (focEv->reason() == Qt::TabFocusReason || focEv->reason() == Qt::BacktabFocusReason) { @@ -447,8 +447,16 @@ bool DlgPrefEffects::eventFilter(QObject* object, QEvent* event) { pEffectList->selectRow(currIndex.row()); } } + } else if (pEvent->type() == QEvent::KeyPress && + m_pFocusedEffectList && + pObj == m_pFocusedEffectList) { + // Left/Right key in focused effect list trigger Hide/Unhide + QKeyEvent* pKE = static_cast(pEvent); + if (pKE->key() == Qt::Key_Left || pKE->key() == Qt::Key_Right) { + slotHideUnhideEffect(); + } } - return DlgPreferencePage::eventFilter(object, event); + return DlgPreferencePage::eventFilter(pObj, pEvent); } QListView* DlgPrefEffects::unfocusedChainList() { diff --git a/src/preferences/dialog/dlgprefeffects.h b/src/preferences/dialog/dlgprefeffects.h index 379e3bdec45..1396e0f0792 100644 --- a/src/preferences/dialog/dlgprefeffects.h +++ b/src/preferences/dialog/dlgprefeffects.h @@ -41,7 +41,8 @@ class DlgPrefEffects : public DlgPreferencePage, public Ui::DlgPrefEffectsDlg { void loadChainPresetLists(); void saveChainPresetLists(); - bool eventFilter(QObject* pChainList, QEvent* event) override; + /// Handles FocusIn and KeyPress events in chain preset lists + bool eventFilter(QObject* pObj, QEvent* pEvent) override; QListView* m_pFocusedChainList; QListView* unfocusedChainList(); QTableView* m_pFocusedEffectList;