From 7607cd0c85ee16f342e346aa422258e38d780a00 Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Sat, 20 Dec 2025 13:40:16 +0530 Subject: [PATCH] feat: add vim bindings shortcuts and plugins panel keyboard navigation --- Modules/MainScreen/MainScreen.qml | 25 +++++++++++++++++++++ Modules/Panels/Plugins/PluginPanelSlot.qml | 26 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/Modules/MainScreen/MainScreen.qml b/Modules/MainScreen/MainScreen.qml index 534a9d5ab..c4580cbb1 100644 --- a/Modules/MainScreen/MainScreen.qml +++ b/Modules/MainScreen/MainScreen.qml @@ -515,4 +515,29 @@ PanelWindow { enabled: root.isPanelOpen && (PanelService.openedPanel.onCtrlPPressed !== undefined) onActivated: PanelService.openedPanel.onCtrlPPressed() } + + // ===== VIM BINDINGS ===== + Shortcut { + sequence: "H" + enabled: root.isPanelOpen && (PanelService.openedPanel.onHPressed !== undefined) + onActivated: PanelService.openedPanel.onHPressed() + } + + Shortcut { + sequence: "J" + enabled: root.isPanelOpen && (PanelService.openedPanel.onJPressed !== undefined) + onActivated: PanelService.openedPanel.onJPressed() + } + + Shortcut { + sequence: "K" + enabled: root.isPanelOpen && (PanelService.openedPanel.onKPressed !== undefined) + onActivated: PanelService.openedPanel.onKPressed() + } + + Shortcut { + sequence: "L" + enabled: root.isPanelOpen && (PanelService.openedPanel.onLPressed !== undefined) + onActivated: PanelService.openedPanel.onLPressed() + } } diff --git a/Modules/Panels/Plugins/PluginPanelSlot.qml b/Modules/Panels/Plugins/PluginPanelSlot.qml index 177686f6d..c53353639 100644 --- a/Modules/Panels/Plugins/PluginPanelSlot.qml +++ b/Modules/Panels/Plugins/PluginPanelSlot.qml @@ -31,6 +31,32 @@ SmartPanel { panelAnchorLeft: pluginInstance?.panelAnchorLeft ?? false panelAnchorRight: pluginInstance?.panelAnchorRight ?? false + // ===== KEYBOARD EVENT FORWARDING ===== + // Helper function to safely retrieve a handler function from the plugin instance + function getHandler(funcName) { + // Check if instance exists and has the function + if (root.pluginInstance && typeof root.pluginInstance[funcName] === "function") { + // Return a wrapper that calls the function on the instance + return function() { root.pluginInstance[funcName]() } + } + return undefined; + } + + // Standard Navigation + property var onTabPressed: root.pluginInstance ? getHandler("onTabPressed") : undefined + property var onBackTabPressed: root.pluginInstance ? getHandler("onBackTabPressed") : undefined + property var onUpPressed: root.pluginInstance ? getHandler("onUpPressed") : undefined + property var onDownPressed: root.pluginInstance ? getHandler("onDownPressed") : undefined + property var onLeftPressed: root.pluginInstance ? getHandler("onLeftPressed") : undefined + property var onRightPressed: root.pluginInstance ? getHandler("onRightPressed") : undefined + property var onReturnPressed: root.pluginInstance ? getHandler("onReturnPressed") : undefined + + // Vim Navigation + property var onHPressed: root.pluginInstance ? getHandler("onHPressed") : undefined + property var onJPressed: root.pluginInstance ? getHandler("onJPressed") : undefined + property var onKPressed: root.pluginInstance ? getHandler("onKPressed") : undefined + property var onLPressed: root.pluginInstance ? getHandler("onLPressed") : undefined + // Panel content is dynamically loaded panelContent: Component { Item {