mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
app search qol: enter first item, entry always respond to char keys
This commit is contained in:
parent
72ccce04c6
commit
ebb831d345
2 changed files with 31 additions and 6 deletions
|
|
@ -50,7 +50,7 @@ Button {
|
|||
anchors.fill: parent
|
||||
anchors.leftMargin: root.horizontalMargin
|
||||
anchors.rightMargin: root.horizontalMargin
|
||||
radius: Appearance.rounding.small
|
||||
radius: Appearance.rounding.normal
|
||||
color: (root.down || root.keyboardDown) ? Appearance.colors.colLayer1Active : ((root.hovered || root.focus) ? Appearance.colors.colLayer1Hover : Appearance.transparentize(Appearance.m3colors.m3surfaceContainerHigh, 1))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,21 @@ Item { // Wrapper
|
|||
implicitWidth: searchWidgetContent.implicitWidth + Appearance.sizes.elevationMargin * 2
|
||||
implicitHeight: searchWidgetContent.implicitHeight + Appearance.sizes.elevationMargin * 2
|
||||
|
||||
Keys.onPressed: {
|
||||
// Only handle printable characters (ignore modifiers, arrows, etc.)
|
||||
if (event.text && event.text.length === 1 && event.key !== Qt.Key_Enter && event.key !== Qt.Key_Return) {
|
||||
if (!searchInput.activeFocus) {
|
||||
searchInput.forceActiveFocus();
|
||||
// Insert the character at the cursor position
|
||||
searchInput.text = searchInput.text.slice(0, searchInput.cursorPosition) +
|
||||
event.text +
|
||||
searchInput.text.slice(searchInput.cursorPosition);
|
||||
searchInput.cursorPosition += 1;
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle { // Background
|
||||
id: searchWidgetContent
|
||||
anchors.centerIn: parent
|
||||
|
|
@ -53,16 +68,16 @@ Item { // Wrapper
|
|||
TextField { // Search box
|
||||
id: searchInput
|
||||
|
||||
padding: 15
|
||||
focus: root.panelWindow.visible || GlobalStates.overviewOpen
|
||||
Layout.rightMargin: 15
|
||||
padding: 15
|
||||
color: activeFocus ? Appearance.m3colors.m3onSurface : Appearance.m3colors.m3onSurfaceVariant
|
||||
selectedTextColor: Appearance.m3colors.m3onSurface
|
||||
placeholderText: qsTr("Search")
|
||||
placeholderTextColor: Appearance.m3colors.m3outline
|
||||
focus: root.panelWindow.visible || GlobalStates.overviewOpen
|
||||
|
||||
implicitWidth: Appearance.sizes.searchWidth
|
||||
|
||||
|
||||
onTextChanged: root.searchingText = text
|
||||
Connections {
|
||||
target: root
|
||||
|
|
@ -72,6 +87,16 @@ Item { // Wrapper
|
|||
}
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
if (appResults.count > 0) {
|
||||
// Get the first visible delegate and trigger its click
|
||||
let firstItem = appResults.itemAtIndex(0);
|
||||
if (firstItem && firstItem.clicked) {
|
||||
firstItem.clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
background: Item {}
|
||||
|
||||
cursorDelegate: Rectangle {
|
||||
|
|
@ -93,7 +118,7 @@ Item { // Wrapper
|
|||
id: appResults
|
||||
visible: root.showResults
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 600
|
||||
implicitHeight: Math.min(600, appResults.contentHeight + topMargin + bottomMargin)
|
||||
clip: true
|
||||
topMargin: 10
|
||||
bottomMargin: 10
|
||||
|
|
@ -101,7 +126,7 @@ Item { // Wrapper
|
|||
KeyNavigation.up: searchBar
|
||||
|
||||
model: ScriptModel {
|
||||
id: model;
|
||||
id: model
|
||||
values: DesktopEntries.applications.values
|
||||
.filter((entry) => {
|
||||
if (root.searchingText == "") return false
|
||||
|
|
|
|||
Loading…
Reference in a new issue