1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 15: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:
bbedward
2025-08-07 15:22:40 -04:00
parent 02ab8e2db5
commit 98d2ca24a8
25 changed files with 973 additions and 788 deletions

View File

@@ -429,7 +429,7 @@ DankModal {
border.width: 1 border.width: 1
clip: true clip: true
ListView { DankListView {
id: clipboardListView id: clipboardListView
anchors.fill: parent anchors.fill: parent

View File

@@ -283,8 +283,9 @@ DankModal {
border.color: Theme.outlineLight border.color: Theme.outlineLight
border.width: 1 border.width: 1
GoodScrollingListView { DankListView {
id: resultsList id: resultsList
mouseWheelSpeed: 20
property int itemHeight: 60 property int itemHeight: 60
property int iconSize: 40 property int iconSize: 40
@@ -448,7 +449,7 @@ DankModal {
} }
} }
GoodScrollingGridView { DankGridView {
id: resultsGrid id: resultsGrid
property int currentIndex: appLauncher.selectedIndex property int currentIndex: appLauncher.selectedIndex

View File

@@ -368,8 +368,9 @@ PanelWindow {
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05) border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
border.width: 1 border.width: 1
GoodScrollingListView { DankListView {
id: appList id: appList
mouseWheelSpeed: 20
property int itemHeight: 72 property int itemHeight: 72
property int iconSize: 56 property int iconSize: 56
@@ -533,7 +534,7 @@ PanelWindow {
} }
} }
GoodScrollingGridView { DankGridView {
id: appGrid id: appGrid
property int currentIndex: appLauncher.selectedIndex property int currentIndex: appLauncher.selectedIndex

View File

@@ -101,7 +101,7 @@ Rectangle {
} }
ListView { DankListView {
id: eventsList id: eventsList
anchors.top: headerRow.bottom anchors.top: headerRow.bottom

View File

@@ -33,46 +33,90 @@ Item {
} }
} }
ScrollView { // Output Tab - DankFlickable
DankFlickable {
width: parent.width width: parent.width
height: parent.height - 48 height: parent.height - 48
visible: audioTab.audioSubTab === 0 visible: audioTab.audioSubTab === 0
clip: true clip: true
contentHeight: outputColumn.height
contentWidth: width
mouseWheelSpeed: 20
Column { Column {
id: outputColumn
width: parent.width width: parent.width
spacing: Theme.spacingL 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 width: parent.width
height: parent.height - 48 height: parent.height - 48
visible: audioTab.audioSubTab === 1 visible: audioTab.audioSubTab === 1
clip: true clip: true
contentHeight: inputColumn.height
contentWidth: width
mouseWheelSpeed: 20
Column { Column {
id: inputColumn
width: parent.width width: parent.width
spacing: Theme.spacingL spacing: Theme.spacingL
MicrophoneControl { Loader {
width: parent.width
sourceComponent: microphoneComponent
} }
AudioInputDevicesList { 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
}
}
}

View File

@@ -11,7 +11,15 @@ import qs.Widgets
Column { Column {
id: root 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 width: parent.width
spacing: Theme.spacingM spacing: Theme.spacingM
@@ -117,10 +125,11 @@ Column {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
if (bluetoothContextMenuWindow) { var contextMenu = root.findBluetoothContextMenu();
bluetoothContextMenuWindow.deviceData = modelData; if (contextMenu) {
let localPos = btMenuButtonArea.mapToItem(bluetoothContextMenuWindow.parentItem, btMenuButtonArea.width / 2, btMenuButtonArea.height); contextMenu.deviceData = modelData;
bluetoothContextMenuWindow.show(localPos.x, localPos.y); let localPos = btMenuButtonArea.mapToItem(contextMenu.parentItem, btMenuButtonArea.width / 2, btMenuButtonArea.height);
contextMenu.show(localPos.x, localPos.y);
} }
} }
} }

View File

@@ -12,33 +12,39 @@ import qs.Widgets
Item { Item {
id: bluetoothTab id: bluetoothTab
ScrollView { property alias bluetoothContextMenuWindow: bluetoothContextMenuWindow
DankFlickable {
anchors.fill: parent anchors.fill: parent
clip: true clip: true
ScrollBar.vertical.policy: ScrollBar.AsNeeded contentHeight: mainColumn.height
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff contentWidth: width
mouseWheelSpeed: 20
Column { Column {
id: mainColumn
width: parent.width width: parent.width
spacing: Theme.spacingL spacing: Theme.spacingL
BluetoothToggle { Loader {
width: parent.width
sourceComponent: toggleComponent
} }
PairedDevicesList { Loader {
bluetoothContextMenuWindow: bluetoothContextMenuWindow width: parent.width
sourceComponent: pairedComponent
} }
AvailableDevicesList { Loader {
width: parent.width
sourceComponent: availableComponent
} }
} }
} }
BluetoothContextMenu { BluetoothContextMenu {
id: bluetoothContextMenuWindow id: bluetoothContextMenuWindow
parentItem: bluetoothTab parentItem: bluetoothTab
} }
@@ -57,7 +63,26 @@ Item {
onClicked: { onClicked: {
} }
} }
} }
} Component {
id: toggleComponent
BluetoothToggle {
width: parent.width
}
}
Component {
id: pairedComponent
PairedDevicesList {
width: parent.width
}
}
Component {
id: availableComponent
AvailableDevicesList {
width: parent.width
}
}
}

View File

@@ -8,7 +8,7 @@ import qs.Modules
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
ScrollView { Item {
id: displayTab id: displayTab
property var brightnessDebounceTimer property var brightnessDebounceTimer
@@ -16,19 +16,61 @@ ScrollView {
brightnessDebounceTimer: Timer { brightnessDebounceTimer: Timer {
property int pendingValue: 0 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 repeat: false
onTriggered: { onTriggered: {
BrightnessService.setBrightnessInternal(pendingValue); BrightnessService.setBrightnessInternal(pendingValue);
} }
} }
clip: true DankFlickable {
Column { anchors.fill: parent
width: parent.width clip: true
spacing: Theme.spacingL 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 { Column {
width: parent.width width: parent.width
spacing: Theme.spacingM spacing: Theme.spacingM
@@ -48,12 +90,10 @@ ScrollView {
rightIcon: "brightness_high" rightIcon: "brightness_high"
enabled: BrightnessService.brightnessAvailable enabled: BrightnessService.brightnessAvailable
onSliderValueChanged: function(newValue) { onSliderValueChanged: function(newValue) {
brightnessDebounceTimer.pendingValue = newValue; brightnessDebounceTimer.pendingValue = newValue;
brightnessDebounceTimer.restart(); brightnessDebounceTimer.restart();
} }
onSliderDragFinished: function(finalValue) { onSliderDragFinished: function(finalValue) {
brightnessDebounceTimer.stop(); brightnessDebounceTimer.stop();
BrightnessService.setBrightnessInternal(finalValue); BrightnessService.setBrightnessInternal(finalValue);
} }
@@ -66,9 +106,11 @@ ScrollView {
visible: BrightnessService.ddcAvailable && !BrightnessService.laptopBacklightAvailable visible: BrightnessService.ddcAvailable && !BrightnessService.laptopBacklightAvailable
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
} }
}
Component {
id: settingsComponent
Column { Column {
width: parent.width width: parent.width
spacing: Theme.spacingM spacing: Theme.spacingM
@@ -110,12 +152,10 @@ ScrollView {
font.weight: Font.Medium font.weight: Font.Medium
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
} }
MouseArea { MouseArea {
id: nightModeToggle id: nightModeToggle
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
@@ -129,7 +169,6 @@ ScrollView {
} }
} }
} }
} }
Rectangle { Rectangle {
@@ -158,12 +197,10 @@ ScrollView {
font.weight: Font.Medium font.weight: Font.Medium
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
} }
MouseArea { MouseArea {
id: lightModeToggle id: lightModeToggle
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
@@ -177,40 +214,9 @@ ScrollView {
duration: Theme.shortDuration duration: Theme.shortDuration
easing.type: Theme.standardEasing 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)
}
}
}

View File

@@ -2,144 +2,27 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import qs.Common import qs.Common
import qs.Services import qs.Services
import qs.Widgets
ListView { DankListView {
id: root id: root
property alias count: root.count property alias count: root.count
readonly property real listContentHeight: root.contentHeight property alias listContentHeight: root.contentHeight
readonly property bool atYBeginning: root.contentY === 0
property real stableY: 0
property bool isUserScrolling: false
width: parent.width width: parent.width
height: parent.height height: parent.height
clip: true clip: true
model: NotificationService.groupedNotifications model: NotificationService.groupedNotifications
spacing: Theme.spacingL 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 { NotificationEmptyState {
visible: root.count === 0 visible: root.count === 0
anchors.centerIn: parent 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 { delegate: NotificationCard {
notificationGroup: modelData notificationGroup: modelData
} }
} }

View File

@@ -49,9 +49,7 @@ Column {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
processListView.captureAnchor();
SysMonitorService.setSortBy("name"); SysMonitorService.setSortBy("name");
processListView.restoreAnchor();
} }
} }
@@ -90,9 +88,7 @@ Column {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
processListView.captureAnchor();
SysMonitorService.setSortBy("cpu"); SysMonitorService.setSortBy("cpu");
processListView.restoreAnchor();
} }
} }
@@ -131,9 +127,7 @@ Column {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
processListView.captureAnchor();
SysMonitorService.setSortBy("memory"); SysMonitorService.setSortBy("memory");
processListView.restoreAnchor();
} }
} }
@@ -173,9 +167,7 @@ Column {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
processListView.captureAnchor();
SysMonitorService.setSortBy("pid"); SysMonitorService.setSortBy("pid");
processListView.restoreAnchor();
} }
} }
@@ -211,9 +203,7 @@ Column {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
processListView.captureAnchor();
SysMonitorService.toggleSortOrder(); SysMonitorService.toggleSortOrder();
processListView.restoreAnchor();
} }
} }
@@ -228,101 +218,21 @@ Column {
} }
ListView { DankListView {
id: processListView id: processListView
property real stableY: 0
property bool isUserScrolling: false
property bool isScrollBarDragging: false
property string keyRoleName: "pid" 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 width: parent.width
height: parent.height - columnHeaders.height height: parent.height - columnHeaders.height
clip: true clip: true
spacing: 4 spacing: 4
model: SysMonitorService.processes 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 { delegate: ProcessListItem {
process: modelData process: modelData
contextMenu: root.contextMenu 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
}
} }
} }

View File

@@ -5,35 +5,49 @@ import qs.Common
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
ScrollView { Item {
id: appearanceTab id: appearanceTab
// Qt 6.9+ scrolling: Enhanced mouse wheel and touchpad responsiveness DankFlickable {
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling anchors.fill: parent
WheelHandler { anchors.topMargin: Theme.spacingL
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad anchors.bottomMargin: Theme.spacingXL
onWheel: (event) => { clip: true
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * 1.8 : event.angleDelta.y / 120 * 80 contentHeight: mainColumn.height
let flickable = appearanceTab.contentItem contentWidth: width
let newY = flickable.contentY - delta mouseWheelSpeed: 20
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
flickable.contentY = newY Column {
event.accepted = true id: mainColumn
width: parent.width
spacing: 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
}
} }
} }
contentWidth: availableWidth // Display Settings Component
contentHeight: column.implicitHeight + Theme.spacingXL Component {
clip: true id: displayComponent
Column {
id: column
width: parent.width
spacing: Theme.spacingXL
topPadding: Theme.spacingL
bottomPadding: Theme.spacingXL
StyledRect { StyledRect {
width: parent.width width: parent.width
height: displaySection.implicitHeight + Theme.spacingL * 2 height: displaySection.implicitHeight + Theme.spacingL * 2
@@ -273,9 +287,13 @@ ScrollView {
} }
} }
} }
}
// Transparency Settings Component
Component {
id: transparencyComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: transparencySection.implicitHeight + Theme.spacingL * 2 height: transparencySection.implicitHeight + Theme.spacingL * 2
@@ -391,9 +409,13 @@ ScrollView {
} }
} }
} }
}
// Theme Color Component
Component {
id: themeComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: themeSection.implicitHeight + Theme.spacingL * 2 height: themeSection.implicitHeight + Theme.spacingL * 2
@@ -759,9 +781,13 @@ ScrollView {
} }
} }
} }
}
// System App Theming Component
Component {
id: systemThemingComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: systemThemingSection.implicitHeight + Theme.spacingL * 2 height: systemThemingSection.implicitHeight + Theme.spacingL * 2
@@ -828,9 +854,7 @@ ScrollView {
} }
} }
} }
} }
Process { Process {

View File

@@ -4,34 +4,44 @@ import Quickshell.Widgets
import qs.Common import qs.Common
import qs.Widgets import qs.Widgets
ScrollView { Item {
id: launcherTab id: launcherTab
// Qt 6.9+ scrolling: Enhanced mouse wheel and touchpad responsiveness DankFlickable {
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling anchors.fill: parent
WheelHandler { anchors.topMargin: Theme.spacingL
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad anchors.bottomMargin: Theme.spacingXL
onWheel: (event) => { clip: true
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * 1.8 : event.angleDelta.y / 120 * 80 contentHeight: mainColumn.height
let flickable = launcherTab.contentItem contentWidth: width
let newY = flickable.contentY - delta mouseWheelSpeed: 20
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
flickable.contentY = newY Column {
event.accepted = true id: mainColumn
width: parent.width
spacing: Theme.spacingXL
Loader {
width: parent.width
sourceComponent: appLauncherComponent
}
Loader {
width: parent.width
sourceComponent: dockComponent
}
Loader {
width: parent.width
sourceComponent: recentlyUsedComponent
}
} }
} }
contentHeight: column.implicitHeight + Theme.spacingXL // App Launcher Component
clip: true Component {
id: appLauncherComponent
Column {
id: column
width: parent.width
spacing: Theme.spacingXL
topPadding: Theme.spacingL
bottomPadding: Theme.spacingXL
StyledRect { StyledRect {
width: parent.width width: parent.width
height: appLauncherSection.implicitHeight + Theme.spacingL * 2 height: appLauncherSection.implicitHeight + Theme.spacingL * 2
@@ -159,9 +169,13 @@ ScrollView {
} }
} }
} }
}
// Dock Component
Component {
id: dockComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: dockSection.implicitHeight + Theme.spacingL * 2 height: dockSection.implicitHeight + Theme.spacingL * 2
@@ -262,7 +276,12 @@ ScrollView {
} }
} }
}
// Recently Used Apps Component
Component {
id: recentlyUsedComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: recentlyUsedSection.implicitHeight + Theme.spacingL * 2 height: recentlyUsedSection.implicitHeight + Theme.spacingL * 2
@@ -474,9 +493,6 @@ ScrollView {
} }
} }
} }
} }
} }

View File

@@ -7,35 +7,47 @@ import qs.Modals
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
ScrollView { Item {
id: personalizationTab 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 profileBrowser: profileBrowserLoader.item
property alias wallpaperBrowser: wallpaperBrowserLoader.item property alias wallpaperBrowser: wallpaperBrowserLoader.item
contentHeight: column.implicitHeight DankFlickable {
clip: true anchors.fill: parent
anchors.topMargin: Theme.spacingL
Column { anchors.bottomMargin: Theme.spacingXL
id: column clip: true
contentHeight: mainColumn.height
width: parent.width contentWidth: width
spacing: Theme.spacingXL mouseWheelSpeed: 20
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 { StyledRect {
width: parent.width width: parent.width
height: profileSection.implicitHeight + Theme.spacingL * 2 height: profileSection.implicitHeight + Theme.spacingL * 2
@@ -294,9 +306,13 @@ ScrollView {
} }
} }
} }
}
// Wallpaper Component
Component {
id: wallpaperComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: wallpaperSection.implicitHeight + Theme.spacingL * 2 height: wallpaperSection.implicitHeight + Theme.spacingL * 2
@@ -491,9 +507,13 @@ ScrollView {
} }
} }
} }
}
// Dynamic Theme Component
Component {
id: dynamicThemeComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: dynamicThemeSection.implicitHeight + Theme.spacingL * 2 height: dynamicThemeSection.implicitHeight + Theme.spacingL * 2
@@ -568,9 +588,7 @@ ScrollView {
} }
} }
} }
} }
LazyLoader { LazyLoader {

View File

@@ -3,32 +3,39 @@ import QtQuick.Controls
import qs.Common import qs.Common
import qs.Widgets import qs.Widgets
ScrollView { Item {
id: timeWeatherTab id: timeWeatherTab
// Qt 6.9+ scrolling: Enhanced mouse wheel and touchpad responsiveness DankFlickable {
// Custom wheel handler for Qt 6.9+ responsive mouse wheel scrolling anchors.fill: parent
WheelHandler { anchors.topMargin: Theme.spacingL
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad anchors.bottomMargin: Theme.spacingXL
onWheel: (event) => { clip: true
let delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y * 1.8 : event.angleDelta.y / 120 * 80 contentHeight: mainColumn.height
let flickable = timeWeatherTab.contentItem contentWidth: width
let newY = flickable.contentY - delta mouseWheelSpeed: 20
newY = Math.max(0, Math.min(flickable.contentHeight - flickable.height, newY))
flickable.contentY = newY Column {
event.accepted = true id: mainColumn
width: parent.width
spacing: Theme.spacingXL
Loader {
width: parent.width
sourceComponent: timeComponent
}
Loader {
width: parent.width
sourceComponent: weatherComponent
}
} }
} }
contentHeight: column.implicitHeight // Time Format Component
clip: true Component {
id: timeComponent
Column {
id: column
width: parent.width
spacing: Theme.spacingXL
StyledRect { StyledRect {
width: parent.width width: parent.width
height: timeSection.implicitHeight + Theme.spacingL * 2 height: timeSection.implicitHeight + Theme.spacingL * 2
@@ -76,9 +83,13 @@ ScrollView {
} }
} }
} }
}
// Weather Component
Component {
id: weatherComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: weatherSection.implicitHeight + Theme.spacingL * 2 height: weatherSection.implicitHeight + Theme.spacingL * 2
@@ -171,9 +182,6 @@ ScrollView {
} }
} }
} }
} }
} }

View File

@@ -3,23 +3,9 @@ import QtQuick.Controls
import qs.Common import qs.Common
import qs.Widgets import qs.Widgets
ScrollView { Item {
id: widgetsTab 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: [{ property var baseWidgetDefinitions: [{
"id": "launcherButton", "id": "launcherButton",
"text": "App Launcher", "text": "App Launcher",
@@ -305,8 +291,6 @@ ScrollView {
return widgets; return widgets;
} }
contentHeight: column.implicitHeight + Theme.spacingXL
clip: true
Component.onCompleted: { Component.onCompleted: {
if (!SettingsData.topBarLeftWidgets || SettingsData.topBarLeftWidgets.length === 0) if (!SettingsData.topBarLeftWidgets || SettingsData.topBarLeftWidgets.length === 0)
SettingsData.setTopBarLeftWidgets(defaultLeftWidgets); SettingsData.setTopBarLeftWidgets(defaultLeftWidgets);
@@ -347,14 +331,46 @@ ScrollView {
}); });
} }
Column { DankFlickable {
id: column anchors.fill: parent
anchors.topMargin: Theme.spacingL
width: parent.width anchors.bottomMargin: Theme.spacingXL
spacing: Theme.spacingXL clip: true
topPadding: Theme.spacingL contentHeight: mainColumn.height
bottomPadding: Theme.spacingXL contentWidth: width
mouseWheelSpeed: 20
Column {
id: mainColumn
width: parent.width
spacing: 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 { Row {
width: parent.width width: parent.width
spacing: Theme.spacingM spacing: Theme.spacingM
@@ -406,7 +422,6 @@ ScrollView {
color: Theme.surfaceText color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }
MouseArea { MouseArea {
@@ -427,7 +442,6 @@ ScrollView {
duration: Theme.shortDuration duration: Theme.shortDuration
easing.type: Theme.standardEasing easing.type: Theme.standardEasing
} }
} }
Behavior on border.color { Behavior on border.color {
@@ -435,13 +449,15 @@ ScrollView {
duration: Theme.shortDuration duration: Theme.shortDuration
easing.type: Theme.standardEasing easing.type: Theme.standardEasing
} }
} }
} }
} }
}
// Message Component
Component {
id: messageComponent
Rectangle { Rectangle {
width: parent.width width: parent.width
height: messageText.contentHeight + Theme.spacingM * 2 height: messageText.contentHeight + Theme.spacingM * 2
@@ -449,9 +465,6 @@ ScrollView {
color: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3) 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.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
border.width: 1 border.width: 1
visible: true
opacity: 1
z: 1
StyledText { StyledText {
id: messageText id: messageText
@@ -463,9 +476,13 @@ ScrollView {
width: parent.width - Theme.spacingM * 2 width: parent.width - Theme.spacingM * 2
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
} }
}
// Sections Component
Component {
id: sectionsComponent
Column { Column {
width: parent.width width: parent.width
spacing: Theme.spacingL spacing: Theme.spacingL
@@ -568,9 +585,13 @@ ScrollView {
} }
} }
} }
} }
}
// Workspace Settings Component
Component {
id: workspaceComponent
StyledRect { StyledRect {
width: parent.width width: parent.width
height: workspaceSection.implicitHeight + Theme.spacingL * 2 height: workspaceSection.implicitHeight + Theme.spacingL * 2
@@ -604,7 +625,6 @@ ScrollView {
color: Theme.surfaceText color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }
DankToggle { DankToggle {
@@ -626,44 +646,10 @@ ScrollView {
return SettingsData.setShowWorkspacePadding(checked); 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 { DankWidgetSelectionPopup {
id: widgetSelectionPopup id: widgetSelectionPopup

View File

@@ -63,7 +63,7 @@ PanelWindow {
menu: currentTrayItem && currentTrayItem.hasMenu ? currentTrayItem.menu : null menu: currentTrayItem && currentTrayItem.hasMenu ? currentTrayItem.menu : null
} }
ListView { DankListView {
id: menuList id: menuList
property real maxTextWidth: { property real maxTextWidth: {

View File

@@ -269,7 +269,7 @@ Rectangle {
visible: root.enableFuzzySearch visible: root.enableFuzzySearch
} }
ListView { DankListView {
id: listView id: listView
width: parent.width width: parent.width

163
Widgets/DankFlickable.qml Normal file
View 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
View 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
View 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
}
}

View File

@@ -250,7 +250,7 @@ Item {
anchors.fill: parent anchors.fill: parent
anchors.margins: Theme.spacingS anchors.margins: Theme.spacingS
ListView { DankListView {
id: searchResultsList id: searchResultsList
anchors.fill: parent anchors.fill: parent

View File

@@ -20,6 +20,7 @@ Column {
signal compactModeChanged(string widgetId, bool enabled) signal compactModeChanged(string widgetId, bool enabled)
width: parent.width width: parent.width
height: implicitHeight
spacing: Theme.spacingM spacing: Theme.spacingM
Row { Row {
@@ -258,6 +259,7 @@ Column {
drag.axis: Drag.YAxis drag.axis: Drag.YAxis
drag.minimumY: -delegateItem.height drag.minimumY: -delegateItem.height
drag.maximumY: itemsList.height drag.maximumY: itemsList.height
preventStealing: true
onPressed: { onPressed: {
delegateItem.z = 2; delegateItem.z = 2;
delegateItem.originalY = delegateItem.y; delegateItem.originalY = delegateItem.y;

View File

@@ -96,7 +96,7 @@ Popup {
height: parent.height - 120 // Leave space for header and description height: parent.height - 120 // Leave space for header and description
clip: true clip: true
ListView { DankListView {
id: widgetList id: widgetList
spacing: Theme.spacingS spacing: Theme.spacingS

View File

@@ -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
}
}

View File

@@ -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
}
}