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

de-dupe scrollview

This commit is contained in:
bbedward
2025-07-27 20:56:09 -04:00
parent fae7f36a24
commit 77051d0d62
9 changed files with 333 additions and 122 deletions

View File

@@ -501,29 +501,46 @@ DankModal {
border.width: 1
clip: true
ScrollView {
ListView {
id: clipboardListView
anchors.fill: parent
anchors.margins: Theme.spacingS
clip: true
ScrollBar.vertical.policy: ScrollBar.AsNeeded
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
model: filteredClipboardModel
spacing: Theme.spacingXS
ListView {
id: clipboardListView
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
ScrollBar.horizontal: ScrollBar { policy: ScrollBar.AlwaysOff }
width: parent.availableWidth
model: filteredClipboardModel
spacing: Theme.spacingXS
property real wheelMultiplier: 1.8
property int wheelBaseStep: 160
StyledText {
text: "No clipboard entries found"
anchors.centerIn: parent
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceVariantText
visible: filteredClipboardModel.count === 0
WheelHandler {
target: null
onWheel: (ev) => {
let dy = ev.pixelDelta.y !== 0
? ev.pixelDelta.y
: (ev.angleDelta.y / 120) * clipboardListView.wheelBaseStep;
if (ev.inverted) dy = -dy;
const maxY = Math.max(0, clipboardListView.contentHeight - clipboardListView.height);
clipboardListView.contentY = Math.max(0, Math.min(maxY,
clipboardListView.contentY - dy * clipboardListView.wheelMultiplier));
ev.accepted = true;
}
}
delegate: Rectangle {
StyledText {
text: "No clipboard entries found"
anchors.centerIn: parent
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceVariantText
visible: filteredClipboardModel.count === 0
}
delegate: Rectangle {
property string entryType: getEntryType(model.entry)
property string entryPreview: getEntryPreview(model.entry)
property int entryIndex: index + 1
@@ -729,8 +746,6 @@ DankModal {
}
}
}
}

View File

@@ -198,21 +198,41 @@ DankModal {
}
// File grid
ScrollView {
GridView {
id: fileGrid
width: parent.width
height: parent.height - 80
clip: true
cellWidth: 150
cellHeight: 130
cacheBuffer: 260
model: folderModel
GridView {
id: fileGrid
cellWidth: 150
cellHeight: 130
cacheBuffer: 260 // Only cache ~2 rows worth of items
model: folderModel
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
ScrollBar.horizontal: ScrollBar { policy: ScrollBar.AlwaysOff }
delegate: StyledRect {
property real wheelMultiplier: 1.8
property int wheelBaseStep: 160
WheelHandler {
target: null
onWheel: (ev) => {
let dy = ev.pixelDelta.y !== 0
? ev.pixelDelta.y
: (ev.angleDelta.y / 120) * fileGrid.wheelBaseStep;
if (ev.inverted) dy = -dy;
const maxY = Math.max(0, fileGrid.contentHeight - fileGrid.height);
fileGrid.contentY = Math.max(0, Math.min(maxY,
fileGrid.contentY - dy * fileGrid.wheelMultiplier));
ev.accepted = true;
}
}
delegate: StyledRect {
id: delegateRoot
required property bool fileIsDir
@@ -292,7 +312,6 @@ DankModal {
}
}
}
}
}
}
}

View File

@@ -91,18 +91,36 @@ DankModal {
}
// Network Details
ScrollView {
Flickable {
width: parent.width
height: parent.height - 140
clip: true
ScrollBar.vertical.policy: ScrollBar.AsNeeded
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
contentWidth: width
contentHeight: detailsRect.height
Flickable {
contentWidth: parent.width
contentHeight: detailsRect.height
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
ScrollBar.horizontal: ScrollBar { policy: ScrollBar.AlwaysOff }
Rectangle {
property real wheelMultiplier: 1.8
property int wheelBaseStep: 160
WheelHandler {
target: null
onWheel: (ev) => {
let dy = ev.pixelDelta.y !== 0
? ev.pixelDelta.y
: (ev.angleDelta.y / 120) * parent.wheelBaseStep;
if (ev.inverted) dy = -dy;
const maxY = Math.max(0, parent.contentHeight - parent.height);
parent.contentY = Math.max(0, Math.min(maxY,
parent.contentY - dy * parent.wheelMultiplier));
ev.accepted = true;
}
}
Rectangle {
id: detailsRect
width: parent.width
@@ -124,8 +142,6 @@ DankModal {
lineHeight: 1.5
}
}
}
}