import QtQuick import "." // Search/filter input with a hard focus border + shadow, 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. Item { id: field property alias text: input.text property alias echoMode: input.echoMode property alias passwordCharacter: input.passwordCharacter property string placeholder: "" property string prefix: "" signal escapePressed() signal upPressed() signal downPressed() signal returnPressed() signal deleteRequested() function focusInput() { input.forceActiveFocus(); } readonly property bool focused: input.activeFocus readonly property color edgeColor: focused ? Theme.colors.primary : Theme.colors.crust readonly property int offset: focused ? Theme.elevation.high : Theme.elevation.low height: 50 // 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() } Rectangle { x: field.offset y: field.offset width: field.width height: field.height color: field.edgeColor } Rectangle { width: field.width height: field.height color: Theme.colors.surface border.width: Theme.geometry.borderWidth border.color: field.edgeColor Behavior on border.color { ColorAnimation { duration: Theme.animation.durationFast } } Text { id: prefixText text: field.prefix visible: field.prefix.length > 0 color: Theme.colors.secondary font.family: Theme.font.family font.bold: true font.pixelSize: 18 anchors.left: parent.left anchors.leftMargin: Theme.geometry.padding anchors.verticalCenter: parent.verticalCenter } TextInput { id: input anchors.fill: parent anchors.margins: Theme.geometry.padding anchors.leftMargin: field.prefix.length > 0 ? prefixText.width + Theme.geometry.padding + Theme.geometry.spacing / 2 : Theme.geometry.padding verticalAlignment: TextInput.AlignVCenter font.family: Theme.font.family font.pixelSize: 18 color: Theme.colors.text clip: true cursorDelegate: Rectangle { width: 9 color: Theme.colors.primary } 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; } } } } }