1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00

refactor: perf improvement stopping singletons with ref

Also switch to scale+opacity anims with custom curve
This commit is contained in:
bbedward
2025-07-23 16:54:19 -04:00
parent 2c57487046
commit 4f63d5899b
21 changed files with 677 additions and 672 deletions

View File

@@ -15,10 +15,32 @@ ScrollView {
property bool showDescription: true
property int itemSpacing: Theme.spacingS
property bool hoverUpdatesSelection: true
property bool keyboardNavigationActive: false
signal keyboardNavigationReset()
signal itemClicked(int index, var modelData)
signal itemHovered(int index)
// Ensure the current item is visible
function ensureVisible(index) {
if (index < 0 || index >= list.count) return;
var itemY = index * (itemHeight + itemSpacing);
var itemBottom = itemY + itemHeight;
if (itemY < list.contentY) {
list.contentY = itemY;
} else if (itemBottom > list.contentY + list.height) {
list.contentY = itemBottom - list.height;
}
}
onCurrentIndexChanged: {
if (keyboardNavigationActive) {
ensureVisible(currentIndex);
}
}
clip: true
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
@@ -134,11 +156,15 @@ ScrollView {
cursorShape: Qt.PointingHandCursor
z: 10
onEntered: {
if (hoverUpdatesSelection)
if (hoverUpdatesSelection && !keyboardNavigationActive) {
listView.currentIndex = index;
}
itemHovered(index);
}
onPositionChanged: {
// Signal parent to reset keyboard navigation flag when mouse moves
keyboardNavigationReset();
}
onClicked: {
itemClicked(index, model);
}