Fixx Launcher warning

This commit is contained in:
Ly-sec 2025-08-25 06:22:31 +02:00
parent bf16a6ee16
commit 4fcc6b8455

View file

@ -26,15 +26,13 @@ NPanel {
// Properties // Properties
property string searchText: "" property string searchText: ""
property bool shouldResetCursor: false
// Add function to set search text programmatically // Add function to set search text programmatically
function setSearchText(text) { function setSearchText(text) {
searchText = text searchText = text
if (searchInput) { // The searchInput will automatically update via the text binding
searchInput.text = text // Focus and cursor position will be handled by the TextField's Component.onCompleted
searchInput.cursorPosition = text.length
searchInput.forceActiveFocus()
}
} }
onOpened: { onOpened: {
@ -43,19 +41,13 @@ NPanel {
searchText = "" searchText = ""
selectedIndex = 0 selectedIndex = 0
} }
if (searchInput) {
searchInput.forceActiveFocus()
}
} }
onClosed: { onClosed: {
// Reset search bar when launcher is closed // Reset search bar when launcher is closed
searchText = "" searchText = ""
selectedIndex = 0 selectedIndex = 0
if (searchInput) { shouldResetCursor = true
searchInput.text = ""
searchInput.cursorPosition = 0
}
} }
// Import modular components // Import modular components
@ -283,6 +275,12 @@ NPanel {
} }
// Defer selectedIndex reset to avoid binding loops // Defer selectedIndex reset to avoid binding loops
Qt.callLater(() => selectedIndex = 0) Qt.callLater(() => selectedIndex = 0)
// Reset cursor position if needed
if (shouldResetCursor && text === "") {
cursorPosition = 0
shouldResetCursor = false
}
} }
selectedTextColor: Color.mOnSurface selectedTextColor: Color.mOnSurface
selectionColor: Color.mPrimary selectionColor: Color.mPrimary
@ -293,10 +291,14 @@ NPanel {
topPadding: 0 topPadding: 0
bottomPadding: 0 bottomPadding: 0
Component.onCompleted: { Component.onCompleted: {
// Focus the search bar by default // Focus the search bar by default and set cursor position
Qt.callLater(() => { Qt.callLater(() => {
selectedIndex = 0 selectedIndex = 0
searchInput.forceActiveFocus() searchInput.forceActiveFocus()
// Set cursor to end if there's already text
if (searchText && searchText.length > 0) {
searchInput.cursorPosition = searchText.length
}
}) })
} }
Keys.onDownPressed: selectNext() Keys.onDownPressed: selectNext()