From 2f50821db4d4ad9ffd5a6ce08c382efd20ffaf62 Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 22 Jul 2025 21:16:00 -0400 Subject: [PATCH] Focus text inputs by default --- Modules/AppLauncher.qml | 3 +++ Modules/ClipboardHistory.qml | 31 ++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Modules/AppLauncher.qml b/Modules/AppLauncher.qml index 2ac9dfdf..a66d6813 100644 --- a/Modules/AppLauncher.qml +++ b/Modules/AppLauncher.qml @@ -149,6 +149,9 @@ PanelWindow { searchField.enabled = true; searchDebounceTimer.stop(); // Stop any pending search updateFilteredModel(); + Qt.callLater(function() { + searchField.forceActiveFocus(); + }); } function hide() { diff --git a/Modules/ClipboardHistory.qml b/Modules/ClipboardHistory.qml index 471cea44..fb723e85 100644 --- a/Modules/ClipboardHistory.qml +++ b/Modules/ClipboardHistory.qml @@ -14,6 +14,7 @@ DankModal { property var clipboardEntries: [] property string searchText: "" + property bool shouldFocusSearch: false function updateFilteredModel() { filteredClipboardModel.clear(); @@ -118,6 +119,7 @@ DankModal { onVisibleChanged: { if (visible) { refreshClipboard(); + shouldFocusSearch = true; } } @@ -194,12 +196,24 @@ DankModal { clipboardHistory.searchText = text; updateFilteredModel(); } + + Connections { + target: clipboardHistory + function onShouldFocusSearchChanged() { + if (shouldFocusSearch) { + Qt.callLater(function() { + searchField.forceActiveFocus(); + shouldFocusSearch = false; + }); + } + } + } } // Clipboard entries list Rectangle { width: parent.width - height: parent.height - 100 + height: parent.height - 110 radius: Theme.cornerRadius color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.1) clip: true @@ -280,14 +294,13 @@ DankModal { onClicked: copyEntry(model.entry) } } - } - - Text { - text: "No clipboard entries found" - anchors.centerIn: parent - font.pixelSize: Theme.fontSizeMedium - color: Theme.surfaceVariantText - visible: filteredClipboardModel.count === 0 + Text { + text: "No clipboard entries found" + anchors.centerIn: parent + font.pixelSize: Theme.fontSizeMedium + color: Theme.surfaceVariantText + visible: filteredClipboardModel.count === 0 + } } } }