mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
keybinds: preserve scroll position of expanded item on list change
fixes #1766
This commit is contained in:
@@ -107,6 +107,22 @@ Item {
|
|||||||
flickable.contentY = 0;
|
flickable.contentY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _scrollToExpandedItem() {
|
||||||
|
for (let i = 0; i < bindsRepeater.count; i++) {
|
||||||
|
const item = bindsRepeater.itemAt(i);
|
||||||
|
if (item && item.modelData.action === expandedKey) {
|
||||||
|
const itemY = item.mapToItem(flickable.contentItem, 0, 0).y;
|
||||||
|
const itemH = item.height;
|
||||||
|
const viewH = flickable.height;
|
||||||
|
if (itemY >= flickable.contentY && itemY + itemH <= flickable.contentY + viewH)
|
||||||
|
return;
|
||||||
|
flickable.contentY = Math.max(0, Math.min(itemY - viewH / 4, flickable.contentHeight - viewH));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flickable.contentY = _savedScrollY;
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: searchDebounce
|
id: searchDebounce
|
||||||
interval: 150
|
interval: 150
|
||||||
@@ -122,8 +138,12 @@ Item {
|
|||||||
keybindsTab._updateCategories();
|
keybindsTab._updateCategories();
|
||||||
keybindsTab._updateFiltered();
|
keybindsTab._updateFiltered();
|
||||||
keybindsTab._preserveScroll = false;
|
keybindsTab._preserveScroll = false;
|
||||||
if (wasPreserving)
|
if (wasPreserving) {
|
||||||
Qt.callLater(() => flickable.contentY = savedY);
|
if (keybindsTab.expandedKey)
|
||||||
|
Qt.callLater(keybindsTab._scrollToExpandedItem);
|
||||||
|
else
|
||||||
|
Qt.callLater(() => flickable.contentY = savedY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function onBindSaved(key) {
|
function onBindSaved(key) {
|
||||||
keybindsTab._savedScrollY = flickable.contentY;
|
keybindsTab._savedScrollY = flickable.contentY;
|
||||||
@@ -569,6 +589,7 @@ Item {
|
|||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
|
id: bindsRepeater
|
||||||
model: ScriptModel {
|
model: ScriptModel {
|
||||||
values: keybindsTab._filteredBinds
|
values: keybindsTab._filteredBinds
|
||||||
objectProp: "action"
|
objectProp: "action"
|
||||||
|
|||||||
Reference in New Issue
Block a user