import QtQuick import QtQuick.Effects import "." // Search/filter input with an animated focus border + glow, shared by // CommandPalette and ClipboardManager. Navigation is exposed as signals // (rather than exposing the inner TextInput's Keys handlers directly) so // each caller can wire up its own list navigation. Rectangle { id: field property alias text: input.text property alias echoMode: input.echoMode property string placeholder: "" signal escapePressed() signal upPressed() signal downPressed() signal returnPressed() signal deleteRequested() function focusInput() { input.forceActiveFocus(); } // The layer-shell surface only gets real keyboard focus from the // compositor asynchronously after it's first mapped, so a single // forceActiveFocus() call right on visible-toggle can silently lose // input the first time a panel is shown in a session. There's no // reliable signal for "the compositor granted focus now" on a // wlr-layer-shell surface, so just retry until it actually sticks. Timer { interval: 30 repeat: true running: field.visible && !input.activeFocus onTriggered: input.forceActiveFocus() } height: 50 color: Theme.colors.surface radius: Theme.geometry.radiusSmall border.width: 1 border.color: input.activeFocus ? Theme.colors.primary : Theme.colors.border Behavior on border.color { ColorAnimation { duration: Theme.animation.durationFast } } layer.enabled: input.activeFocus layer.effect: MultiEffect { shadowEnabled: true shadowColor: Theme.colors.primary shadowOpacity: Theme.elevation.low.opacity shadowBlur: Theme.elevation.low.blur shadowHorizontalOffset: 0 shadowVerticalOffset: 0 } TextInput { id: input anchors.fill: parent anchors.margins: Theme.geometry.padding verticalAlignment: TextInput.AlignVCenter font.family: Theme.font.family font.pixelSize: 18 color: Theme.colors.text clip: true Text { text: field.placeholder color: Theme.colors.textMuted font.family: Theme.font.family font.pixelSize: 18 anchors.verticalCenter: parent.verticalCenter visible: input.text.length === 0 } Keys.onEscapePressed: (event) => { field.escapePressed(); event.accepted = true; } Keys.onUpPressed: (event) => { field.upPressed(); event.accepted = true; } Keys.onDownPressed: (event) => { field.downPressed(); event.accepted = true; } Keys.onReturnPressed: (event) => { field.returnPressed(); event.accepted = true; } Keys.onPressed: (event) => { if (event.key === Qt.Key_Delete || (event.key === Qt.Key_Backspace && input.text.length === 0)) { field.deleteRequested(); event.accepted = true; } } } }