mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 16:32:50 -05:00
workaround for all the terrible default QT scrolling behavior
- DankGridView, DankFlickable, DankListView\ - Touchpad behavior greatly improved by preserving momentum - Fixed janky nested scrollers in control center
This commit is contained in:
@@ -429,7 +429,7 @@ DankModal {
|
||||
border.width: 1
|
||||
clip: true
|
||||
|
||||
ListView {
|
||||
DankListView {
|
||||
id: clipboardListView
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
@@ -283,8 +283,9 @@ DankModal {
|
||||
border.color: Theme.outlineLight
|
||||
border.width: 1
|
||||
|
||||
GoodScrollingListView {
|
||||
DankListView {
|
||||
id: resultsList
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
property int itemHeight: 60
|
||||
property int iconSize: 40
|
||||
@@ -448,7 +449,7 @@ DankModal {
|
||||
}
|
||||
}
|
||||
|
||||
GoodScrollingGridView {
|
||||
DankGridView {
|
||||
id: resultsGrid
|
||||
|
||||
property int currentIndex: appLauncher.selectedIndex
|
||||
|
||||
@@ -368,8 +368,9 @@ PanelWindow {
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
|
||||
border.width: 1
|
||||
|
||||
GoodScrollingListView {
|
||||
DankListView {
|
||||
id: appList
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
property int itemHeight: 72
|
||||
property int iconSize: 56
|
||||
@@ -533,7 +534,7 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
GoodScrollingGridView {
|
||||
DankGridView {
|
||||
id: appGrid
|
||||
|
||||
property int currentIndex: appLauncher.selectedIndex
|
||||
|
||||
@@ -101,7 +101,7 @@ Rectangle {
|
||||
|
||||
}
|
||||
|
||||
ListView {
|
||||
DankListView {
|
||||
id: eventsList
|
||||
|
||||
anchors.top: headerRow.bottom
|
||||
|
||||
@@ -33,46 +33,90 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
// Output Tab - DankFlickable
|
||||
DankFlickable {
|
||||
width: parent.width
|
||||
height: parent.height - 48
|
||||
visible: audioTab.audioSubTab === 0
|
||||
clip: true
|
||||
contentHeight: outputColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: outputColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingL
|
||||
|
||||
VolumeControl {
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: volumeComponent
|
||||
}
|
||||
|
||||
AudioDevicesList {
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: outputDevicesComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
// Input Tab - DankFlickable
|
||||
DankFlickable {
|
||||
width: parent.width
|
||||
height: parent.height - 48
|
||||
visible: audioTab.audioSubTab === 1
|
||||
clip: true
|
||||
contentHeight: inputColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: inputColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingL
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: microphoneComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: inputDevicesComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Volume Control Component
|
||||
Component {
|
||||
id: volumeComponent
|
||||
VolumeControl {
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
// Microphone Control Component
|
||||
Component {
|
||||
id: microphoneComponent
|
||||
MicrophoneControl {
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
// Output Devices Component
|
||||
Component {
|
||||
id: outputDevicesComponent
|
||||
AudioDevicesList {
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
// Input Devices Component
|
||||
Component {
|
||||
id: inputDevicesComponent
|
||||
AudioInputDevicesList {
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,15 @@ import qs.Widgets
|
||||
Column {
|
||||
id: root
|
||||
|
||||
property var bluetoothContextMenuWindow
|
||||
function findBluetoothContextMenu() {
|
||||
var p = parent;
|
||||
while (p) {
|
||||
if (p.bluetoothContextMenuWindow)
|
||||
return p.bluetoothContextMenuWindow;
|
||||
p = p.parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
@@ -117,10 +125,11 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (bluetoothContextMenuWindow) {
|
||||
bluetoothContextMenuWindow.deviceData = modelData;
|
||||
let localPos = btMenuButtonArea.mapToItem(bluetoothContextMenuWindow.parentItem, btMenuButtonArea.width / 2, btMenuButtonArea.height);
|
||||
bluetoothContextMenuWindow.show(localPos.x, localPos.y);
|
||||
var contextMenu = root.findBluetoothContextMenu();
|
||||
if (contextMenu) {
|
||||
contextMenu.deviceData = modelData;
|
||||
let localPos = btMenuButtonArea.mapToItem(contextMenu.parentItem, btMenuButtonArea.width / 2, btMenuButtonArea.height);
|
||||
contextMenu.show(localPos.x, localPos.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,33 +12,39 @@ import qs.Widgets
|
||||
Item {
|
||||
id: bluetoothTab
|
||||
|
||||
ScrollView {
|
||||
property alias bluetoothContextMenuWindow: bluetoothContextMenuWindow
|
||||
|
||||
DankFlickable {
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
ScrollBar.vertical.policy: ScrollBar.AsNeeded
|
||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||
contentHeight: mainColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: mainColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingL
|
||||
|
||||
BluetoothToggle {
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: toggleComponent
|
||||
}
|
||||
|
||||
PairedDevicesList {
|
||||
bluetoothContextMenuWindow: bluetoothContextMenuWindow
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: pairedComponent
|
||||
}
|
||||
|
||||
AvailableDevicesList {
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: availableComponent
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BluetoothContextMenu {
|
||||
id: bluetoothContextMenuWindow
|
||||
|
||||
parentItem: bluetoothTab
|
||||
}
|
||||
|
||||
@@ -57,7 +63,26 @@ Item {
|
||||
onClicked: {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Component {
|
||||
id: toggleComponent
|
||||
BluetoothToggle {
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: pairedComponent
|
||||
PairedDevicesList {
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: availableComponent
|
||||
AvailableDevicesList {
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import qs.Modules
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
ScrollView {
|
||||
Item {
|
||||
id: displayTab
|
||||
|
||||
property var brightnessDebounceTimer
|
||||
@@ -16,19 +16,61 @@ ScrollView {
|
||||
brightnessDebounceTimer: Timer {
|
||||
property int pendingValue: 0
|
||||
|
||||
interval: BrightnessService.ddcAvailable ? 500 : 50 // 500ms for slow DDC (i2c), 50ms for fast laptop backlight
|
||||
interval: BrightnessService.ddcAvailable ? 500 : 50
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
|
||||
BrightnessService.setBrightnessInternal(pendingValue);
|
||||
}
|
||||
}
|
||||
|
||||
DankFlickable {
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
contentHeight: mainColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: mainColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingL
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: brightnessComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: settingsComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: nightModeEnableProcess
|
||||
command: ["bash", "-c", "if command -v wlsunset > /dev/null; then pkill wlsunset; wlsunset -t 3000 & elif command -v redshift > /dev/null; then pkill redshift; redshift -P -O 3000 & else echo 'No night mode tool available'; fi"]
|
||||
running: false
|
||||
onExited: (exitCode) => {
|
||||
if (exitCode !== 0) {
|
||||
SettingsData.setNightModeEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: nightModeDisableProcess
|
||||
command: ["bash", "-c", "pkill wlsunset; pkill redshift; if command -v wlsunset > /dev/null; then wlsunset -t 6500 -T 6500 & sleep 1; pkill wlsunset; elif command -v redshift > /dev/null; then redshift -P -O 6500; redshift -x; fi"]
|
||||
running: false
|
||||
onExited: (exitCode) => {
|
||||
if (exitCode !== 0) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: brightnessComponent
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
@@ -48,12 +90,10 @@ ScrollView {
|
||||
rightIcon: "brightness_high"
|
||||
enabled: BrightnessService.brightnessAvailable
|
||||
onSliderValueChanged: function(newValue) {
|
||||
|
||||
brightnessDebounceTimer.pendingValue = newValue;
|
||||
brightnessDebounceTimer.restart();
|
||||
}
|
||||
onSliderDragFinished: function(finalValue) {
|
||||
|
||||
brightnessDebounceTimer.stop();
|
||||
BrightnessService.setBrightnessInternal(finalValue);
|
||||
}
|
||||
@@ -66,9 +106,11 @@ ScrollView {
|
||||
visible: BrightnessService.ddcAvailable && !BrightnessService.laptopBacklightAvailable
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: settingsComponent
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
@@ -110,12 +152,10 @@ ScrollView {
|
||||
font.weight: Font.Medium
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: nightModeToggle
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
@@ -129,7 +169,6 @@ ScrollView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -158,12 +197,10 @@ ScrollView {
|
||||
font.weight: Font.Medium
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: lightModeToggle
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
@@ -177,40 +214,9 @@ ScrollView {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Process {
|
||||
id: nightModeEnableProcess
|
||||
|
||||
command: ["bash", "-c", "if command -v wlsunset > /dev/null; then pkill wlsunset; wlsunset -t 3000 & elif command -v redshift > /dev/null; then pkill redshift; redshift -P -O 3000 & else echo 'No night mode tool available'; fi"]
|
||||
running: false
|
||||
onExited: (exitCode) => {
|
||||
if (exitCode !== 0) {
|
||||
|
||||
SettingsData.setNightModeEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: nightModeDisableProcess
|
||||
|
||||
command: ["bash", "-c", "pkill wlsunset; pkill redshift; if command -v wlsunset > /dev/null; then wlsunset -t 6500 -T 6500 & sleep 1; pkill wlsunset; elif command -v redshift > /dev/null; then redshift -P -O 6500; redshift -x; fi"]
|
||||
running: false
|
||||
onExited: (exitCode) => {
|
||||
if (exitCode !== 0)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,144 +2,27 @@ import QtQuick
|
||||
import QtQuick.Controls
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
ListView {
|
||||
DankListView {
|
||||
id: root
|
||||
|
||||
property alias count: root.count
|
||||
readonly property real listContentHeight: root.contentHeight
|
||||
readonly property bool atYBeginning: root.contentY === 0
|
||||
property real stableY: 0
|
||||
property bool isUserScrolling: false
|
||||
property alias listContentHeight: root.contentHeight
|
||||
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
clip: true
|
||||
model: NotificationService.groupedNotifications
|
||||
spacing: Theme.spacingL
|
||||
interactive: true
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
// Qt 6.9+ scrolling: flickDeceleration/maximumFlickVelocity only affect touch now
|
||||
flickDeceleration: 1500
|
||||
maximumFlickVelocity: 2000
|
||||
boundsMovement: Flickable.FollowBoundsBehavior
|
||||
pressDelay: 0
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
cacheBuffer: 1000
|
||||
|
||||
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
|
||||
WheelHandler {
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
property real momentum: 0
|
||||
onWheel: (event) => {
|
||||
if (event.pixelDelta.y !== 0) {
|
||||
// Touchpad with pixel delta
|
||||
momentum = event.pixelDelta.y * 1.8
|
||||
} else {
|
||||
// Mouse wheel with angle delta
|
||||
momentum = (event.angleDelta.y / 120) * (parent.spacing * 2.5) // ~2.5 items per wheel step
|
||||
}
|
||||
|
||||
let newY = parent.contentY - momentum
|
||||
newY = Math.max(0, Math.min(parent.contentHeight - parent.height, newY))
|
||||
parent.contentY = newY
|
||||
momentum *= 0.92 // Decay for smooth momentum
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
onMovementStarted: isUserScrolling = true
|
||||
onMovementEnded: {
|
||||
isUserScrolling = false;
|
||||
if (contentY > 40)
|
||||
stableY = contentY;
|
||||
|
||||
}
|
||||
onContentYChanged: {
|
||||
if (!isUserScrolling && visible && parent.visible && stableY > 40 && Math.abs(contentY - stableY) > 10)
|
||||
contentY = stableY;
|
||||
|
||||
}
|
||||
|
||||
NotificationEmptyState {
|
||||
visible: root.count === 0
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
add: Transition {
|
||||
enabled: !root.isUserScrolling
|
||||
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
properties: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: root.isUserScrolling ? 0 : Theme.mediumDuration
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
properties: "height"
|
||||
from: 0
|
||||
duration: root.isUserScrolling ? 0 : Theme.mediumDuration
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
remove: Transition {
|
||||
SequentialAnimation {
|
||||
PauseAnimation {
|
||||
duration: 50
|
||||
}
|
||||
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
properties: "opacity"
|
||||
to: 0
|
||||
duration: Theme.mediumDuration
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
properties: "height,anchors.topMargin,anchors.bottomMargin"
|
||||
to: 0
|
||||
duration: Theme.mediumDuration
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
displaced: Transition {
|
||||
enabled: false
|
||||
|
||||
NumberAnimation {
|
||||
properties: "y"
|
||||
duration: 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
move: Transition {
|
||||
enabled: false
|
||||
|
||||
NumberAnimation {
|
||||
properties: "y"
|
||||
duration: 0
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
delegate: NotificationCard {
|
||||
notificationGroup: modelData
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,9 +49,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
processListView.captureAnchor();
|
||||
SysMonitorService.setSortBy("name");
|
||||
processListView.restoreAnchor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +88,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
processListView.captureAnchor();
|
||||
SysMonitorService.setSortBy("cpu");
|
||||
processListView.restoreAnchor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,9 +127,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
processListView.captureAnchor();
|
||||
SysMonitorService.setSortBy("memory");
|
||||
processListView.restoreAnchor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,9 +167,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
processListView.captureAnchor();
|
||||
SysMonitorService.setSortBy("pid");
|
||||
processListView.restoreAnchor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,9 +203,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
processListView.captureAnchor();
|
||||
SysMonitorService.toggleSortOrder();
|
||||
processListView.restoreAnchor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,101 +218,21 @@ Column {
|
||||
|
||||
}
|
||||
|
||||
ListView {
|
||||
DankListView {
|
||||
id: processListView
|
||||
|
||||
property real stableY: 0
|
||||
property bool isUserScrolling: false
|
||||
property bool isScrollBarDragging: false
|
||||
property string keyRoleName: "pid"
|
||||
property var _anchorKey: undefined
|
||||
property real _anchorOffset: 0
|
||||
|
||||
function captureAnchor() {
|
||||
const y = contentY + 1;
|
||||
const idx = indexAt(0, y);
|
||||
if (idx < 0 || !model || idx >= model.length)
|
||||
return ;
|
||||
|
||||
_anchorKey = model[idx][keyRoleName];
|
||||
const it = itemAtIndex(idx);
|
||||
_anchorOffset = it ? (y - it.y) : 0;
|
||||
}
|
||||
|
||||
function restoreAnchor() {
|
||||
Qt.callLater(function() {
|
||||
if (_anchorKey === undefined || !model)
|
||||
return ;
|
||||
|
||||
var i = -1;
|
||||
for (var j = 0; j < model.length; ++j) {
|
||||
if (model[j][keyRoleName] === _anchorKey) {
|
||||
i = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < 0)
|
||||
return ;
|
||||
|
||||
positionViewAtIndex(i, ListView.Beginning);
|
||||
const maxY = Math.max(0, contentHeight - height);
|
||||
contentY = Math.max(0, Math.min(maxY, contentY + _anchorOffset - 1));
|
||||
});
|
||||
}
|
||||
|
||||
width: parent.width
|
||||
height: parent.height - columnHeaders.height
|
||||
clip: true
|
||||
spacing: 4
|
||||
model: SysMonitorService.processes
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
// Qt 6.9+ scrolling: flickDeceleration/maximumFlickVelocity only affect touch now
|
||||
interactive: true
|
||||
flickDeceleration: 1500 // Touch only in Qt 6.9+ // Lower = more momentum, longer scrolling
|
||||
maximumFlickVelocity: 2000 // Touch only in Qt 6.9+ // Higher = faster maximum scroll speed
|
||||
boundsMovement: Flickable.FollowBoundsBehavior
|
||||
pressDelay: 0
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
|
||||
onMovementStarted: isUserScrolling = true
|
||||
onMovementEnded: {
|
||||
isUserScrolling = false;
|
||||
if (contentY > 40)
|
||||
stableY = contentY;
|
||||
}
|
||||
onContentYChanged: {
|
||||
if (!isUserScrolling && !isScrollBarDragging && visible && stableY > 40 && Math.abs(contentY - stableY) > 10)
|
||||
contentY = stableY;
|
||||
}
|
||||
onModelChanged: {
|
||||
if (model && model.length > 0 && !isUserScrolling && stableY > 40)
|
||||
Qt.callLater(function() {
|
||||
contentY = stableY;
|
||||
});
|
||||
}
|
||||
|
||||
delegate: ProcessListItem {
|
||||
process: modelData
|
||||
contextMenu: root.contextMenu
|
||||
}
|
||||
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
id: verticalScrollBar
|
||||
|
||||
policy: ScrollBar.AsNeeded
|
||||
onPressedChanged: {
|
||||
processListView.isScrollBarDragging = pressed;
|
||||
if (!pressed && processListView.contentY > 40)
|
||||
processListView.stableY = processListView.contentY;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ScrollBar.horizontal: ScrollBar {
|
||||
policy: ScrollBar.AlwaysOff
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,34 +5,48 @@ import qs.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
ScrollView {
|
||||
Item {
|
||||
id: appearanceTab
|
||||
|
||||
// Qt 6.9+ scrolling: Enhanced mouse wheel and touchpad responsiveness
|
||||
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
|
||||
WheelHandler {
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
onWheel: (event) => {
|
||||
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * 1.8 : event.angleDelta.y / 120 * 80
|
||||
let flickable = appearanceTab.contentItem
|
||||
let newY = flickable.contentY - delta
|
||||
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
|
||||
flickable.contentY = newY
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
contentWidth: availableWidth
|
||||
contentHeight: column.implicitHeight + Theme.spacingXL
|
||||
DankFlickable {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: Theme.spacingL
|
||||
anchors.bottomMargin: Theme.spacingXL
|
||||
clip: true
|
||||
contentHeight: mainColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: column
|
||||
|
||||
id: mainColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXL
|
||||
topPadding: Theme.spacingL
|
||||
bottomPadding: Theme.spacingXL
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: displayComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: transparencyComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: themeComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: systemThemingComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Display Settings Component
|
||||
Component {
|
||||
id: displayComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -273,8 +287,12 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Transparency Settings Component
|
||||
Component {
|
||||
id: transparencyComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -391,8 +409,12 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Theme Color Component
|
||||
Component {
|
||||
id: themeComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -759,8 +781,12 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// System App Theming Component
|
||||
Component {
|
||||
id: systemThemingComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -828,9 +854,7 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Process {
|
||||
|
||||
@@ -4,33 +4,43 @@ import Quickshell.Widgets
|
||||
import qs.Common
|
||||
import qs.Widgets
|
||||
|
||||
ScrollView {
|
||||
Item {
|
||||
id: launcherTab
|
||||
|
||||
// Qt 6.9+ scrolling: Enhanced mouse wheel and touchpad responsiveness
|
||||
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
|
||||
WheelHandler {
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
onWheel: (event) => {
|
||||
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * 1.8 : event.angleDelta.y / 120 * 80
|
||||
let flickable = launcherTab.contentItem
|
||||
let newY = flickable.contentY - delta
|
||||
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
|
||||
flickable.contentY = newY
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
contentHeight: column.implicitHeight + Theme.spacingXL
|
||||
DankFlickable {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: Theme.spacingL
|
||||
anchors.bottomMargin: Theme.spacingXL
|
||||
clip: true
|
||||
contentHeight: mainColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: column
|
||||
|
||||
id: mainColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXL
|
||||
topPadding: Theme.spacingL
|
||||
bottomPadding: Theme.spacingXL
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: appLauncherComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: dockComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: recentlyUsedComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// App Launcher Component
|
||||
Component {
|
||||
id: appLauncherComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -159,8 +169,12 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Dock Component
|
||||
Component {
|
||||
id: dockComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -262,6 +276,11 @@ ScrollView {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recently Used Apps Component
|
||||
Component {
|
||||
id: recentlyUsedComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -474,9 +493,6 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,35 +7,47 @@ import qs.Modals
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
ScrollView {
|
||||
Item {
|
||||
id: personalizationTab
|
||||
|
||||
// Qt 6.9+ scrolling: Enhanced mouse wheel and touchpad responsiveness
|
||||
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
|
||||
WheelHandler {
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
onWheel: (event) => {
|
||||
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * 1.8 : event.angleDelta.y / 120 * 80
|
||||
let flickable = personalizationTab.contentItem
|
||||
let newY = flickable.contentY - delta
|
||||
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
|
||||
flickable.contentY = newY
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
property alias profileBrowser: profileBrowserLoader.item
|
||||
property alias wallpaperBrowser: wallpaperBrowserLoader.item
|
||||
|
||||
contentHeight: column.implicitHeight
|
||||
DankFlickable {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: Theme.spacingL
|
||||
anchors.bottomMargin: Theme.spacingXL
|
||||
clip: true
|
||||
contentHeight: mainColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: column
|
||||
|
||||
id: mainColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXL
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: profileComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: wallpaperComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: dynamicThemeComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Profile Image Component
|
||||
Component {
|
||||
id: profileComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
height: profileSection.implicitHeight + Theme.spacingL * 2
|
||||
@@ -294,8 +306,12 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Wallpaper Component
|
||||
Component {
|
||||
id: wallpaperComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -491,8 +507,12 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Dynamic Theme Component
|
||||
Component {
|
||||
id: dynamicThemeComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -568,9 +588,7 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
|
||||
@@ -3,32 +3,39 @@ import QtQuick.Controls
|
||||
import qs.Common
|
||||
import qs.Widgets
|
||||
|
||||
ScrollView {
|
||||
Item {
|
||||
id: timeWeatherTab
|
||||
|
||||
// Qt 6.9+ scrolling: Enhanced mouse wheel and touchpad responsiveness
|
||||
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
|
||||
WheelHandler {
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
onWheel: (event) => {
|
||||
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * 1.8 : event.angleDelta.y / 120 * 80
|
||||
let flickable = timeWeatherTab.contentItem
|
||||
let newY = flickable.contentY - delta
|
||||
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
|
||||
flickable.contentY = newY
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
contentHeight: column.implicitHeight
|
||||
DankFlickable {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: Theme.spacingL
|
||||
anchors.bottomMargin: Theme.spacingXL
|
||||
clip: true
|
||||
contentHeight: mainColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: column
|
||||
|
||||
id: mainColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXL
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: timeComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: weatherComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Time Format Component
|
||||
Component {
|
||||
id: timeComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
height: timeSection.implicitHeight + Theme.spacingL * 2
|
||||
@@ -76,8 +83,12 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Weather Component
|
||||
Component {
|
||||
id: weatherComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -171,9 +182,6 @@ ScrollView {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,23 +3,9 @@ import QtQuick.Controls
|
||||
import qs.Common
|
||||
import qs.Widgets
|
||||
|
||||
ScrollView {
|
||||
Item {
|
||||
id: widgetsTab
|
||||
|
||||
// Qt 6.9+ scrolling: Enhanced mouse wheel and touchpad responsiveness
|
||||
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
|
||||
WheelHandler {
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
onWheel: (event) => {
|
||||
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * 1.8 : event.angleDelta.y / 120 * 80
|
||||
let flickable = widgetsTab.contentItem
|
||||
let newY = flickable.contentY - delta
|
||||
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
|
||||
flickable.contentY = newY
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
property var baseWidgetDefinitions: [{
|
||||
"id": "launcherButton",
|
||||
"text": "App Launcher",
|
||||
@@ -305,8 +291,6 @@ ScrollView {
|
||||
return widgets;
|
||||
}
|
||||
|
||||
contentHeight: column.implicitHeight + Theme.spacingXL
|
||||
clip: true
|
||||
Component.onCompleted: {
|
||||
if (!SettingsData.topBarLeftWidgets || SettingsData.topBarLeftWidgets.length === 0)
|
||||
SettingsData.setTopBarLeftWidgets(defaultLeftWidgets);
|
||||
@@ -347,13 +331,45 @@ ScrollView {
|
||||
});
|
||||
}
|
||||
|
||||
Column {
|
||||
id: column
|
||||
DankFlickable {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: Theme.spacingL
|
||||
anchors.bottomMargin: Theme.spacingXL
|
||||
clip: true
|
||||
contentHeight: mainColumn.height
|
||||
contentWidth: width
|
||||
mouseWheelSpeed: 20
|
||||
|
||||
Column {
|
||||
id: mainColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXL
|
||||
topPadding: Theme.spacingL
|
||||
bottomPadding: Theme.spacingXL
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: headerComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: messageComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: sectionsComponent
|
||||
}
|
||||
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: workspaceComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Header Component
|
||||
Component {
|
||||
id: headerComponent
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -406,7 +422,6 @@ ScrollView {
|
||||
color: Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -427,7 +442,6 @@ ScrollView {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Behavior on border.color {
|
||||
@@ -435,12 +449,14 @@ ScrollView {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// Message Component
|
||||
Component {
|
||||
id: messageComponent
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
@@ -449,9 +465,6 @@ ScrollView {
|
||||
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||
border.width: 1
|
||||
visible: true
|
||||
opacity: 1
|
||||
z: 1
|
||||
|
||||
StyledText {
|
||||
id: messageText
|
||||
@@ -463,8 +476,12 @@ ScrollView {
|
||||
width: parent.width - Theme.spacingM * 2
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Sections Component
|
||||
Component {
|
||||
id: sectionsComponent
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
@@ -568,8 +585,12 @@ ScrollView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Workspace Settings Component
|
||||
Component {
|
||||
id: workspaceComponent
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
@@ -604,7 +625,6 @@ ScrollView {
|
||||
color: Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
@@ -626,44 +646,10 @@ ScrollView {
|
||||
return SettingsData.setShowWorkspacePadding(checked);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: tooltipText.contentWidth + Theme.spacingM * 2
|
||||
height: tooltipText.contentHeight + Theme.spacingS * 2
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.surfaceContainer
|
||||
border.color: Theme.outline
|
||||
border.width: 1
|
||||
visible: resetArea.containsMouse
|
||||
opacity: resetArea.containsMouse ? 1 : 0
|
||||
y: column.y + 48
|
||||
x: parent.width - width - Theme.spacingM
|
||||
z: 100
|
||||
|
||||
StyledText {
|
||||
id: tooltipText
|
||||
|
||||
anchors.centerIn: parent
|
||||
text: "Reset widget layout to defaults"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DankWidgetSelectionPopup {
|
||||
id: widgetSelectionPopup
|
||||
|
||||
@@ -63,7 +63,7 @@ PanelWindow {
|
||||
menu: currentTrayItem && currentTrayItem.hasMenu ? currentTrayItem.menu : null
|
||||
}
|
||||
|
||||
ListView {
|
||||
DankListView {
|
||||
id: menuList
|
||||
|
||||
property real maxTextWidth: {
|
||||
|
||||
@@ -269,7 +269,7 @@ Rectangle {
|
||||
visible: root.enableFuzzySearch
|
||||
}
|
||||
|
||||
ListView {
|
||||
DankListView {
|
||||
id: listView
|
||||
|
||||
width: parent.width
|
||||
|
||||
163
Widgets/DankFlickable.qml
Normal file
163
Widgets/DankFlickable.qml
Normal file
@@ -0,0 +1,163 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Flickable {
|
||||
id: flickable
|
||||
|
||||
property real mouseWheelSpeed: 12
|
||||
property real momentumVelocity: 0
|
||||
property bool isMomentumActive: false
|
||||
property real friction: 0.95
|
||||
property real minMomentumVelocity: 50
|
||||
property real maxMomentumVelocity: 2500
|
||||
|
||||
flickDeceleration: 1500
|
||||
maximumFlickVelocity: 2000
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
boundsMovement: Flickable.FollowBoundsBehavior
|
||||
pressDelay: 0
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
|
||||
WheelHandler {
|
||||
id: wheelHandler
|
||||
|
||||
property real touchpadSpeed: 1.8
|
||||
property real momentumRetention: 0.92
|
||||
property real lastWheelTime: 0
|
||||
property real momentum: 0
|
||||
property var velocitySamples: []
|
||||
|
||||
function startMomentum() {
|
||||
flickable.isMomentumActive = true;
|
||||
momentumTimer.start();
|
||||
}
|
||||
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
|
||||
onWheel: (event) => {
|
||||
let currentTime = Date.now();
|
||||
let timeDelta = currentTime - lastWheelTime;
|
||||
lastWheelTime = currentTime;
|
||||
|
||||
const deltaY = event.angleDelta.y;
|
||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0;
|
||||
|
||||
if (isMouseWheel) {
|
||||
momentumTimer.stop();
|
||||
flickable.isMomentumActive = false;
|
||||
velocitySamples = [];
|
||||
momentum = 0;
|
||||
|
||||
const lines = Math.floor(Math.abs(deltaY) / 120);
|
||||
const scrollAmount = (deltaY > 0 ? -lines : lines) * flickable.mouseWheelSpeed;
|
||||
let newY = flickable.contentY + scrollAmount;
|
||||
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY));
|
||||
|
||||
if (flickable.flicking)
|
||||
flickable.cancelFlick();
|
||||
|
||||
flickable.contentY = newY;
|
||||
} else {
|
||||
momentumTimer.stop();
|
||||
flickable.isMomentumActive = false;
|
||||
|
||||
let delta = 0;
|
||||
if (event.pixelDelta.y !== 0) {
|
||||
delta = event.pixelDelta.y * touchpadSpeed;
|
||||
} else {
|
||||
delta = event.angleDelta.y / 8 * touchpadSpeed;
|
||||
}
|
||||
|
||||
velocitySamples.push({
|
||||
"delta": delta,
|
||||
"time": currentTime
|
||||
});
|
||||
velocitySamples = velocitySamples.filter((s) => {
|
||||
return currentTime - s.time < 100;
|
||||
});
|
||||
|
||||
if (velocitySamples.length > 1) {
|
||||
let totalDelta = velocitySamples.reduce((sum, s) => {
|
||||
return sum + s.delta;
|
||||
}, 0);
|
||||
let timeSpan = currentTime - velocitySamples[0].time;
|
||||
if (timeSpan > 0)
|
||||
flickable.momentumVelocity = Math.max(-flickable.maxMomentumVelocity,
|
||||
Math.min(flickable.maxMomentumVelocity,
|
||||
totalDelta / timeSpan * 1000));
|
||||
}
|
||||
|
||||
if (event.pixelDelta.y !== 0 && timeDelta < 50) {
|
||||
momentum = momentum * momentumRetention + delta * 0.15;
|
||||
delta += momentum;
|
||||
} else {
|
||||
momentum = 0;
|
||||
}
|
||||
|
||||
let newY = flickable.contentY - delta;
|
||||
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY));
|
||||
|
||||
if (flickable.flicking)
|
||||
flickable.cancelFlick();
|
||||
|
||||
flickable.contentY = newY;
|
||||
}
|
||||
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
onActiveChanged: {
|
||||
if (!active) {
|
||||
if (Math.abs(flickable.momentumVelocity) >= flickable.minMomentumVelocity) {
|
||||
startMomentum();
|
||||
} else {
|
||||
velocitySamples = [];
|
||||
flickable.momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: momentumTimer
|
||||
interval: 16
|
||||
repeat: true
|
||||
|
||||
onTriggered: {
|
||||
let newY = flickable.contentY - flickable.momentumVelocity * 0.016;
|
||||
let maxY = Math.max(0, flickable.contentHeight - flickable.height);
|
||||
|
||||
if (newY < 0) {
|
||||
flickable.contentY = 0;
|
||||
stop();
|
||||
flickable.isMomentumActive = false;
|
||||
flickable.momentumVelocity = 0;
|
||||
return;
|
||||
} else if (newY > maxY) {
|
||||
flickable.contentY = maxY;
|
||||
stop();
|
||||
flickable.isMomentumActive = false;
|
||||
flickable.momentumVelocity = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
flickable.contentY = newY;
|
||||
|
||||
flickable.momentumVelocity *= flickable.friction;
|
||||
|
||||
if (Math.abs(flickable.momentumVelocity) < 5) {
|
||||
stop();
|
||||
flickable.isMomentumActive = false;
|
||||
flickable.momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: returnToBoundsAnimation
|
||||
target: flickable
|
||||
property: "contentY"
|
||||
duration: 300
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
179
Widgets/DankGridView.qml
Normal file
179
Widgets/DankGridView.qml
Normal file
@@ -0,0 +1,179 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
GridView {
|
||||
id: gridView
|
||||
|
||||
// Kinetic scrolling momentum properties
|
||||
property real momentumVelocity: 0
|
||||
property bool isMomentumActive: false
|
||||
property real friction: 0.95
|
||||
property real minMomentumVelocity: 50
|
||||
property real maxMomentumVelocity: 2500
|
||||
|
||||
flickDeceleration: 1500
|
||||
maximumFlickVelocity: 2000
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
boundsMovement: Flickable.FollowBoundsBehavior
|
||||
pressDelay: 0
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
|
||||
WheelHandler {
|
||||
id: wheelHandler
|
||||
|
||||
// Tunable parameters for responsive scrolling
|
||||
property real mouseWheelSpeed: 20
|
||||
// Higher = faster mouse wheel
|
||||
property real touchpadSpeed: 1.8
|
||||
// Touchpad sensitivity
|
||||
property real momentumRetention: 0.92
|
||||
property real lastWheelTime: 0
|
||||
property real momentum: 0
|
||||
property var velocitySamples: []
|
||||
|
||||
function startMomentum() {
|
||||
isMomentumActive = true;
|
||||
momentumTimer.start();
|
||||
}
|
||||
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
onWheel: (event) => {
|
||||
let currentTime = Date.now();
|
||||
let timeDelta = currentTime - lastWheelTime;
|
||||
lastWheelTime = currentTime;
|
||||
|
||||
// Detect mouse wheel vs touchpad
|
||||
const deltaY = event.angleDelta.y;
|
||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0;
|
||||
|
||||
if (isMouseWheel) {
|
||||
// Fixed scrolling for mouse wheel - 2 cells per click
|
||||
momentumTimer.stop();
|
||||
isMomentumActive = false;
|
||||
velocitySamples = [];
|
||||
momentum = 0;
|
||||
|
||||
const lines = Math.floor(Math.abs(deltaY) / 120);
|
||||
const scrollAmount = (deltaY > 0 ? -lines : lines) * cellHeight * 0.15; // 0.15 cells per wheel click
|
||||
let newY = contentY + scrollAmount;
|
||||
newY = Math.max(0, Math.min(contentHeight - height, newY));
|
||||
|
||||
if (flicking)
|
||||
cancelFlick();
|
||||
|
||||
contentY = newY;
|
||||
} else {
|
||||
// Touchpad - existing smooth kinetic scrolling
|
||||
// Stop any existing momentum
|
||||
momentumTimer.stop();
|
||||
isMomentumActive = false;
|
||||
|
||||
// Calculate scroll delta based on input type
|
||||
let delta = 0;
|
||||
if (event.pixelDelta.y !== 0)
|
||||
// Touchpad with pixel precision
|
||||
delta = event.pixelDelta.y * touchpadSpeed;
|
||||
else
|
||||
// Fallback for touchpad without pixel delta
|
||||
delta = event.angleDelta.y / 120 * cellHeight * 1.2;
|
||||
|
||||
// Track velocity for momentum
|
||||
velocitySamples.push({
|
||||
"delta": delta,
|
||||
"time": currentTime
|
||||
});
|
||||
velocitySamples = velocitySamples.filter((s) => {
|
||||
return currentTime - s.time < 100;
|
||||
});
|
||||
|
||||
// Calculate momentum velocity from samples
|
||||
if (velocitySamples.length > 1) {
|
||||
let totalDelta = velocitySamples.reduce((sum, s) => {
|
||||
return sum + s.delta;
|
||||
}, 0);
|
||||
let timeSpan = currentTime - velocitySamples[0].time;
|
||||
if (timeSpan > 0)
|
||||
momentumVelocity = Math.max(-maxMomentumVelocity, Math.min(maxMomentumVelocity, totalDelta / timeSpan * 1000));
|
||||
}
|
||||
|
||||
// Apply momentum for touchpad (smooth continuous scrolling)
|
||||
if (event.pixelDelta.y !== 0 && timeDelta < 50) {
|
||||
momentum = momentum * momentumRetention + delta * 0.15;
|
||||
delta += momentum;
|
||||
} else {
|
||||
momentum = 0;
|
||||
}
|
||||
|
||||
// Apply scrolling with proper bounds checking
|
||||
let newY = contentY - delta;
|
||||
newY = Math.max(0, Math.min(contentHeight - height, newY));
|
||||
|
||||
// Cancel any conflicting flicks and apply new position
|
||||
if (flicking)
|
||||
cancelFlick();
|
||||
|
||||
contentY = newY;
|
||||
}
|
||||
|
||||
event.accepted = true;
|
||||
}
|
||||
onActiveChanged: {
|
||||
if (!active && Math.abs(momentumVelocity) >= minMomentumVelocity) {
|
||||
startMomentum();
|
||||
} else if (!active) {
|
||||
velocitySamples = [];
|
||||
momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Physics-based momentum timer for kinetic scrolling
|
||||
Timer {
|
||||
id: momentumTimer
|
||||
|
||||
interval: 16 // ~60 FPS
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
// Apply velocity to position
|
||||
let newY = contentY - momentumVelocity * 0.016;
|
||||
let maxY = Math.max(0, contentHeight - height);
|
||||
|
||||
// Stop momentum at boundaries instead of bouncing
|
||||
if (newY < 0) {
|
||||
contentY = 0;
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
return;
|
||||
} else if (newY > maxY) {
|
||||
contentY = maxY;
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
contentY = newY;
|
||||
|
||||
// Apply friction
|
||||
momentumVelocity *= friction;
|
||||
|
||||
// Stop if velocity too low
|
||||
if (Math.abs(momentumVelocity) < 5) {
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Smooth return to bounds animation
|
||||
NumberAnimation {
|
||||
id: returnToBoundsAnimation
|
||||
|
||||
target: gridView
|
||||
property: "contentY"
|
||||
duration: 300
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
212
Widgets/DankListView.qml
Normal file
212
Widgets/DankListView.qml
Normal file
@@ -0,0 +1,212 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
|
||||
property real mouseWheelSpeed: 12
|
||||
|
||||
// Simple position preservation
|
||||
property real savedY: 0
|
||||
property bool justChanged: false
|
||||
property bool isUserScrolling: false
|
||||
|
||||
// Kinetic scrolling momentum properties
|
||||
property real momentumVelocity: 0
|
||||
property bool isMomentumActive: false
|
||||
property real friction: 0.95
|
||||
property real minMomentumVelocity: 50
|
||||
property real maxMomentumVelocity: 2500
|
||||
|
||||
flickDeceleration: 1500
|
||||
maximumFlickVelocity: 2000
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
boundsMovement: Flickable.FollowBoundsBehavior
|
||||
pressDelay: 0
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
|
||||
onMovementStarted: isUserScrolling = true
|
||||
onMovementEnded: isUserScrolling = false
|
||||
|
||||
onContentYChanged: {
|
||||
if (!justChanged && isUserScrolling) {
|
||||
savedY = contentY;
|
||||
}
|
||||
justChanged = false;
|
||||
}
|
||||
|
||||
// Restore position when model changes
|
||||
onModelChanged: {
|
||||
justChanged = true;
|
||||
contentY = savedY;
|
||||
}
|
||||
|
||||
WheelHandler {
|
||||
id: wheelHandler
|
||||
|
||||
// Tunable parameters for responsive scrolling
|
||||
property real touchpadSpeed: 1.8 // Touchpad sensitivity
|
||||
property real momentumRetention: 0.92
|
||||
property real lastWheelTime: 0
|
||||
property real momentum: 0
|
||||
property var velocitySamples: []
|
||||
|
||||
function startMomentum() {
|
||||
isMomentumActive = true;
|
||||
momentumTimer.start();
|
||||
}
|
||||
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
|
||||
onWheel: (event) => {
|
||||
isUserScrolling = true; // Mark as user interaction
|
||||
|
||||
let currentTime = Date.now();
|
||||
let timeDelta = currentTime - lastWheelTime;
|
||||
lastWheelTime = currentTime;
|
||||
|
||||
// Detect mouse wheel vs touchpad, seems like assuming based on the increments is the only way in QT
|
||||
const deltaY = event.angleDelta.y;
|
||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0;
|
||||
|
||||
if (isMouseWheel) {
|
||||
momentumTimer.stop();
|
||||
isMomentumActive = false;
|
||||
velocitySamples = [];
|
||||
momentum = 0;
|
||||
|
||||
const lines = Math.floor(Math.abs(deltaY) / 120);
|
||||
const scrollAmount = (deltaY > 0 ? -lines : lines) * mouseWheelSpeed;
|
||||
let newY = listView.contentY + scrollAmount;
|
||||
newY = Math.max(0, Math.min(listView.contentHeight - listView.height, newY));
|
||||
|
||||
if (listView.flicking)
|
||||
listView.cancelFlick();
|
||||
|
||||
listView.contentY = newY;
|
||||
savedY = newY;
|
||||
} else {
|
||||
momentumTimer.stop();
|
||||
isMomentumActive = false;
|
||||
|
||||
// Calculate scroll delta based on input type
|
||||
let delta = 0;
|
||||
if (event.pixelDelta.y !== 0) {
|
||||
// Touchpad with pixel precision
|
||||
delta = event.pixelDelta.y * touchpadSpeed;
|
||||
} else {
|
||||
// Fallback for touchpad without pixel delta
|
||||
delta = event.angleDelta.y / 8 * touchpadSpeed;
|
||||
}
|
||||
|
||||
// Track velocity for momentum
|
||||
velocitySamples.push({
|
||||
"delta": delta,
|
||||
"time": currentTime
|
||||
});
|
||||
velocitySamples = velocitySamples.filter((s) => {
|
||||
return currentTime - s.time < 100;
|
||||
});
|
||||
|
||||
// Calculate momentum velocity from samples
|
||||
if (velocitySamples.length > 1) {
|
||||
let totalDelta = velocitySamples.reduce((sum, s) => {
|
||||
return sum + s.delta;
|
||||
}, 0);
|
||||
let timeSpan = currentTime - velocitySamples[0].time;
|
||||
if (timeSpan > 0)
|
||||
momentumVelocity = Math.max(-maxMomentumVelocity,
|
||||
Math.min(maxMomentumVelocity,
|
||||
totalDelta / timeSpan * 1000));
|
||||
}
|
||||
|
||||
// Apply momentum for touchpad (smooth continuous scrolling)
|
||||
if (event.pixelDelta.y !== 0 && timeDelta < 50) {
|
||||
momentum = momentum * momentumRetention + delta * 0.15;
|
||||
delta += momentum;
|
||||
} else {
|
||||
momentum = 0;
|
||||
}
|
||||
|
||||
// Apply scrolling with proper bounds checking
|
||||
let newY = listView.contentY - delta;
|
||||
newY = Math.max(0, Math.min(listView.contentHeight - listView.height, newY));
|
||||
|
||||
// Cancel any conflicting flicks and apply new position
|
||||
if (listView.flicking)
|
||||
listView.cancelFlick();
|
||||
|
||||
listView.contentY = newY;
|
||||
savedY = newY; // Update saved position
|
||||
}
|
||||
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
onActiveChanged: {
|
||||
if (!active) {
|
||||
isUserScrolling = false;
|
||||
|
||||
// Start momentum if applicable (touchpad only)
|
||||
if (Math.abs(momentumVelocity) >= minMomentumVelocity) {
|
||||
startMomentum();
|
||||
} else {
|
||||
velocitySamples = [];
|
||||
momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Physics-based momentum timer for kinetic scrolling (touchpad only)
|
||||
Timer {
|
||||
id: momentumTimer
|
||||
interval: 16 // ~60 FPS
|
||||
repeat: true
|
||||
|
||||
onTriggered: {
|
||||
// Apply velocity to position
|
||||
let newY = contentY - momentumVelocity * 0.016;
|
||||
let maxY = Math.max(0, contentHeight - height);
|
||||
|
||||
// Stop momentum at boundaries instead of bouncing
|
||||
if (newY < 0) {
|
||||
contentY = 0;
|
||||
savedY = 0;
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
return;
|
||||
} else if (newY > maxY) {
|
||||
contentY = maxY;
|
||||
savedY = maxY;
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
contentY = newY;
|
||||
savedY = newY; // Keep updating saved position during momentum
|
||||
|
||||
// Apply friction
|
||||
momentumVelocity *= friction;
|
||||
|
||||
// Stop if velocity too low
|
||||
if (Math.abs(momentumVelocity) < 5) {
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Smooth return to bounds animation
|
||||
NumberAnimation {
|
||||
id: returnToBoundsAnimation
|
||||
target: listView
|
||||
property: "contentY"
|
||||
duration: 300
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingS
|
||||
|
||||
ListView {
|
||||
DankListView {
|
||||
id: searchResultsList
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
@@ -20,6 +20,7 @@ Column {
|
||||
signal compactModeChanged(string widgetId, bool enabled)
|
||||
|
||||
width: parent.width
|
||||
height: implicitHeight
|
||||
spacing: Theme.spacingM
|
||||
|
||||
Row {
|
||||
@@ -258,6 +259,7 @@ Column {
|
||||
drag.axis: Drag.YAxis
|
||||
drag.minimumY: -delegateItem.height
|
||||
drag.maximumY: itemsList.height
|
||||
preventStealing: true
|
||||
onPressed: {
|
||||
delegateItem.z = 2;
|
||||
delegateItem.originalY = delegateItem.y;
|
||||
|
||||
@@ -96,7 +96,7 @@ Popup {
|
||||
height: parent.height - 120 // Leave space for header and description
|
||||
clip: true
|
||||
|
||||
ListView {
|
||||
DankListView {
|
||||
id: widgetList
|
||||
|
||||
spacing: Theme.spacingS
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
GridView {
|
||||
id: gridView
|
||||
|
||||
// Kinetic scrolling momentum properties
|
||||
property real momentumVelocity: 0
|
||||
property bool isMomentumActive: false
|
||||
property real friction: 0.95
|
||||
property real minMomentumVelocity: 50
|
||||
property real maxMomentumVelocity: 2500
|
||||
|
||||
// Qt 6.9+ scrolling: flickDeceleration/maximumFlickVelocity only affect touch now
|
||||
flickDeceleration: 1500
|
||||
maximumFlickVelocity: 2000
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
boundsMovement: Flickable.FollowBoundsBehavior
|
||||
pressDelay: 0
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
|
||||
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
|
||||
WheelHandler {
|
||||
id: wheelHandler
|
||||
|
||||
// Tunable parameters for responsive scrolling
|
||||
property real mouseWheelSpeed: 20
|
||||
// Higher = faster mouse wheel
|
||||
property real touchpadSpeed: 1.8
|
||||
// Touchpad sensitivity
|
||||
property real momentumRetention: 0.92
|
||||
property real lastWheelTime: 0
|
||||
property real momentum: 0
|
||||
property var velocitySamples: []
|
||||
|
||||
function startMomentum() {
|
||||
isMomentumActive = true;
|
||||
momentumTimer.start();
|
||||
}
|
||||
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
onWheel: (event) => {
|
||||
// Stop any existing momentum
|
||||
momentumTimer.stop();
|
||||
isMomentumActive = false;
|
||||
let currentTime = Date.now();
|
||||
let timeDelta = currentTime - lastWheelTime;
|
||||
lastWheelTime = currentTime;
|
||||
// Calculate scroll delta based on input type
|
||||
let delta = 0;
|
||||
if (event.pixelDelta.y !== 0)
|
||||
// Touchpad with pixel precision
|
||||
delta = event.pixelDelta.y * touchpadSpeed;
|
||||
else
|
||||
// Mouse wheel - moderate steps for comfortable scrolling
|
||||
delta = event.angleDelta.y / 120 * cellHeight * 1.2;
|
||||
// Track velocity for momentum
|
||||
velocitySamples.push({
|
||||
"delta": delta,
|
||||
"time": currentTime
|
||||
});
|
||||
velocitySamples = velocitySamples.filter((s) => {
|
||||
return currentTime - s.time < 100;
|
||||
});
|
||||
// Calculate momentum velocity from samples
|
||||
if (velocitySamples.length > 1) {
|
||||
let totalDelta = velocitySamples.reduce((sum, s) => {
|
||||
return sum + s.delta;
|
||||
}, 0);
|
||||
let timeSpan = currentTime - velocitySamples[0].time;
|
||||
if (timeSpan > 0)
|
||||
momentumVelocity = Math.max(-maxMomentumVelocity, Math.min(maxMomentumVelocity, totalDelta / timeSpan * 1000));
|
||||
|
||||
}
|
||||
// Apply momentum for touchpad (smooth continuous scrolling)
|
||||
if (event.pixelDelta.y !== 0 && timeDelta < 50) {
|
||||
momentum = momentum * momentumRetention + delta * 0.15;
|
||||
delta += momentum;
|
||||
} else {
|
||||
momentum = 0;
|
||||
}
|
||||
// Apply scrolling with proper bounds checking
|
||||
let newY = contentY - delta;
|
||||
newY = Math.max(0, Math.min(contentHeight - height, newY));
|
||||
// Cancel any conflicting flicks and apply new position
|
||||
if (flicking)
|
||||
cancelFlick();
|
||||
|
||||
contentY = newY;
|
||||
event.accepted = true;
|
||||
}
|
||||
onActiveChanged: {
|
||||
if (!active && Math.abs(momentumVelocity) >= minMomentumVelocity) {
|
||||
startMomentum();
|
||||
} else if (!active) {
|
||||
velocitySamples = [];
|
||||
momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Physics-based momentum timer for kinetic scrolling
|
||||
Timer {
|
||||
id: momentumTimer
|
||||
|
||||
interval: 16 // ~60 FPS
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
// Apply velocity to position
|
||||
let newY = contentY - momentumVelocity * 0.016;
|
||||
let maxY = Math.max(0, contentHeight - height);
|
||||
|
||||
// Stop momentum at boundaries instead of bouncing
|
||||
if (newY < 0) {
|
||||
contentY = 0;
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
return;
|
||||
} else if (newY > maxY) {
|
||||
contentY = maxY;
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
contentY = newY;
|
||||
|
||||
// Apply friction
|
||||
momentumVelocity *= friction;
|
||||
|
||||
// Stop if velocity too low
|
||||
if (Math.abs(momentumVelocity) < 5) {
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Smooth return to bounds animation
|
||||
NumberAnimation {
|
||||
id: returnToBoundsAnimation
|
||||
|
||||
target: gridView
|
||||
property: "contentY"
|
||||
duration: 300
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
|
||||
// Kinetic scrolling momentum properties
|
||||
property real momentumVelocity: 0
|
||||
property bool isMomentumActive: false
|
||||
property real friction: 0.95
|
||||
property real minMomentumVelocity: 50
|
||||
property real maxMomentumVelocity: 2500
|
||||
|
||||
// Qt 6.9+ scrolling: flickDeceleration/maximumFlickVelocity only affect touch now
|
||||
flickDeceleration: 1500
|
||||
maximumFlickVelocity: 2000
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
boundsMovement: Flickable.FollowBoundsBehavior
|
||||
pressDelay: 0
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
|
||||
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling
|
||||
WheelHandler {
|
||||
id: wheelHandler
|
||||
|
||||
// Tunable parameters for responsive scrolling
|
||||
property real mouseWheelSpeed: 20
|
||||
// Higher = faster mouse wheel
|
||||
property real touchpadSpeed: 1.8
|
||||
// Touchpad sensitivity
|
||||
property real momentumRetention: 0.92
|
||||
property real lastWheelTime: 0
|
||||
property real momentum: 0
|
||||
property var velocitySamples: []
|
||||
|
||||
function startMomentum() {
|
||||
isMomentumActive = true;
|
||||
momentumTimer.start();
|
||||
}
|
||||
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
onWheel: (event) => {
|
||||
// Stop any existing momentum
|
||||
momentumTimer.stop();
|
||||
isMomentumActive = false;
|
||||
let currentTime = Date.now();
|
||||
let timeDelta = currentTime - lastWheelTime;
|
||||
lastWheelTime = currentTime;
|
||||
// Calculate scroll delta based on input type
|
||||
let delta = 0;
|
||||
if (event.pixelDelta.y !== 0)
|
||||
// Touchpad with pixel precision
|
||||
delta = event.pixelDelta.y * touchpadSpeed;
|
||||
else
|
||||
// Mouse wheel - moderate steps for comfortable scrolling
|
||||
delta = event.angleDelta.y / 120 * 72 * 1.2; // Using default item height
|
||||
// Track velocity for momentum
|
||||
velocitySamples.push({
|
||||
"delta": delta,
|
||||
"time": currentTime
|
||||
});
|
||||
velocitySamples = velocitySamples.filter((s) => {
|
||||
return currentTime - s.time < 100;
|
||||
});
|
||||
// Calculate momentum velocity from samples
|
||||
if (velocitySamples.length > 1) {
|
||||
let totalDelta = velocitySamples.reduce((sum, s) => {
|
||||
return sum + s.delta;
|
||||
}, 0);
|
||||
let timeSpan = currentTime - velocitySamples[0].time;
|
||||
if (timeSpan > 0)
|
||||
momentumVelocity = Math.max(-maxMomentumVelocity, Math.min(maxMomentumVelocity, totalDelta / timeSpan * 1000));
|
||||
|
||||
}
|
||||
// Apply momentum for touchpad (smooth continuous scrolling)
|
||||
if (event.pixelDelta.y !== 0 && timeDelta < 50) {
|
||||
momentum = momentum * momentumRetention + delta * 0.15;
|
||||
delta += momentum;
|
||||
} else {
|
||||
momentum = 0;
|
||||
}
|
||||
// Apply scrolling with proper bounds checking
|
||||
let newY = listView.contentY - delta;
|
||||
newY = Math.max(0, Math.min(listView.contentHeight - listView.height, newY));
|
||||
// Cancel any conflicting flicks and apply new position
|
||||
if (listView.flicking)
|
||||
listView.cancelFlick();
|
||||
|
||||
listView.contentY = newY;
|
||||
event.accepted = true;
|
||||
}
|
||||
onActiveChanged: {
|
||||
if (!active && Math.abs(momentumVelocity) >= minMomentumVelocity) {
|
||||
startMomentum();
|
||||
} else if (!active) {
|
||||
velocitySamples = [];
|
||||
momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Physics-based momentum timer for kinetic scrolling
|
||||
Timer {
|
||||
id: momentumTimer
|
||||
|
||||
interval: 16 // ~60 FPS
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
// Apply velocity to position
|
||||
let newY = contentY - momentumVelocity * 0.016;
|
||||
let maxY = Math.max(0, contentHeight - height);
|
||||
|
||||
// Stop momentum at boundaries instead of bouncing
|
||||
if (newY < 0) {
|
||||
contentY = 0;
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
return;
|
||||
} else if (newY > maxY) {
|
||||
contentY = maxY;
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
contentY = newY;
|
||||
|
||||
// Apply friction
|
||||
momentumVelocity *= friction;
|
||||
|
||||
// Stop if velocity too low
|
||||
if (Math.abs(momentumVelocity) < 5) {
|
||||
stop();
|
||||
isMomentumActive = false;
|
||||
momentumVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Smooth return to bounds animation
|
||||
NumberAnimation {
|
||||
id: returnToBoundsAnimation
|
||||
|
||||
target: listView
|
||||
property: "contentY"
|
||||
duration: 300
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user