mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
fix(nsearchcombobox): cleanup
This commit is contained in:
@@ -241,58 +241,47 @@ RowLayout {
|
||||
onTextChanged: root.searchText = text
|
||||
fontSize: Style.fontSizeS
|
||||
|
||||
Keys.onPressed: (event) => {
|
||||
if (Keybinds.checkKey(event, 'enter', Settings)) {
|
||||
selectHighlighted()
|
||||
combo.popup.close();
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
Keys.onPressed: event => {
|
||||
if (Keybinds.checkKey(event, 'enter', Settings)) {
|
||||
selectHighlighted();
|
||||
combo.popup.close();
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Keybinds.checkKey(event, 'escape', Settings)) {
|
||||
combo.popup.close()
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
if (Keybinds.checkKey(event, 'escape', Settings)) {
|
||||
combo.popup.close();
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Keybinds.checkKey(event, 'up', Settings)) {
|
||||
if (listView.currentIndex > 0) {
|
||||
listView.currentIndex--;
|
||||
listView.positionViewAtIndex(listView.currentIndex, ListView.Contain);
|
||||
if (root.selectOnNavigation)
|
||||
selectHighlighted();
|
||||
}
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
if (Keybinds.checkKey(event, 'up', Settings)) {
|
||||
if (listView.currentIndex > 0) {
|
||||
listView.currentIndex--;
|
||||
if (root.selectOnNavigation)
|
||||
selectHighlighted();
|
||||
}
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Keybinds.checkKey(event, 'down', Settings)) {
|
||||
if (listView.currentIndex < listView.count - 1) {
|
||||
listView.currentIndex++;
|
||||
listView.positionViewAtIndex(listView.currentIndex, ListView.Contain);
|
||||
if (root.selectOnNavigation)
|
||||
selectHighlighted();
|
||||
}
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Keybinds.checkKey(event, 'down', Settings)) {
|
||||
if (listView.currentIndex < listView.count - 1) {
|
||||
listView.currentIndex++;
|
||||
if (root.selectOnNavigation)
|
||||
selectHighlighted();
|
||||
}
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function selectHighlighted() {
|
||||
if (listView.currentIndex >= 0
|
||||
&& listView.model
|
||||
&& listView.currentIndex < listView.model.count) {
|
||||
if (listView.currentIndex >= 0 && listView.model && listView.currentIndex < listView.model.count) {
|
||||
var selectedKey = listView.model.get(listView.currentIndex).key;
|
||||
root.selected(selectedKey);
|
||||
}
|
||||
}
|
||||
|
||||
function pageStep() {
|
||||
if (listView.count === 0 || listView.contentHeight === 0)
|
||||
return 1;
|
||||
var rowHeight = listView.contentHeight / listView.count;
|
||||
return Math.max(1, Math.floor(listView.height / rowHeight));
|
||||
}
|
||||
}
|
||||
|
||||
NListView {
|
||||
|
||||
Reference in New Issue
Block a user