Remove ScrollHelper. Scrolling is fixed in Qt upstream.
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
import QtQuick 2.12
|
||||
|
||||
ListView {
|
||||
pixelAligned: true
|
||||
|
||||
ScrollHelper {
|
||||
anchors.fill: parent
|
||||
|
||||
flickable: parent
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
|
||||
* Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
|
||||
/*
|
||||
* The MouseArea + interactive: false + maximumFlickVelocity are required
|
||||
* to fix scrolling for desktop systems where we don't want flicking behaviour.
|
||||
*
|
||||
* See also:
|
||||
* ScrollView.qml in qtquickcontrols
|
||||
* qquickwheelarea.cpp in qtquickcontrols
|
||||
*/
|
||||
MouseArea {
|
||||
id: root
|
||||
propagateComposedEvents: true
|
||||
|
||||
property Flickable flickable
|
||||
property alias enabled: root.enabled
|
||||
|
||||
//Place the mouse area under the flickable
|
||||
z: -1
|
||||
onFlickableChanged: {
|
||||
if (enabled) {
|
||||
flickable.interactive = false
|
||||
flickable.maximumFlickVelocity = 100000
|
||||
flickable.boundsBehavior = Flickable.StopAtBounds
|
||||
root.parent = flickable
|
||||
}
|
||||
}
|
||||
|
||||
function calculateNewPosition(flickableItem, wheel) {
|
||||
//Nothing to scroll
|
||||
if (flickableItem.contentHeight < flickableItem.height) {
|
||||
return flickableItem.contentY;
|
||||
}
|
||||
//Ignore 0 events (happens at least with Christians trackpad)
|
||||
if (wheel.pixelDelta.y == 0 && wheel.angleDelta.y == 0) {
|
||||
return flickableItem.contentY;
|
||||
}
|
||||
//pixelDelta seems to be the same as angleDelta/8
|
||||
var pixelDelta = 0
|
||||
//The pixelDelta is a smaller number if both are provided, so pixelDelta can be 0 while angleDelta is still something. So we check the angleDelta
|
||||
if (wheel.angleDelta.y) {
|
||||
var wheelScrollLines = 3 //Default value of QApplication wheelScrollLines property
|
||||
var pixelPerLine = 20 //Default value in Qt, originally comes from QTextEdit
|
||||
var ticks = (wheel.angleDelta.y / 8) / 15.0 //Divide by 8 gives us pixels typically come in 15pixel steps.
|
||||
pixelDelta = ticks * pixelPerLine * wheelScrollLines
|
||||
} else {
|
||||
pixelDelta = wheel.pixelDelta.y
|
||||
}
|
||||
|
||||
if (!pixelDelta) {
|
||||
return flickableItem.contentY;
|
||||
}
|
||||
|
||||
var minYExtent = flickableItem.originY + flickableItem.topMargin;
|
||||
var maxYExtent = (flickableItem.contentHeight + flickableItem.bottomMargin + flickableItem.originY) - flickableItem.height;
|
||||
|
||||
if (typeof(flickableItem.headerItem) !== "undefined" && flickableItem.headerItem) {
|
||||
minYExtent += flickableItem.headerItem.height
|
||||
}
|
||||
|
||||
//Avoid overscrolling
|
||||
return Math.max(minYExtent, Math.min(maxYExtent, flickableItem.contentY - pixelDelta));
|
||||
}
|
||||
|
||||
onWheel: {
|
||||
var newPos = calculateNewPosition(flickable, wheel);
|
||||
// console.warn("Delta: ", wheel.pixelDelta.y);
|
||||
// console.warn("Old position: ", flickable.contentY);
|
||||
// console.warn("New position: ", newPos);
|
||||
|
||||
// Show the scrollbars
|
||||
flickable.flick(0, 0);
|
||||
flickable.contentY = newPos;
|
||||
cancelFlickStateTimer.start()
|
||||
}
|
||||
|
||||
|
||||
Timer {
|
||||
id: cancelFlickStateTimer
|
||||
//How long the scrollbar will remain visible
|
||||
interval: 500
|
||||
// Hide the scrollbars
|
||||
onTriggered: flickable.cancelFlick();
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@ module Spectral.Component
|
||||
AutoMouseArea 2.0 AutoMouseArea.qml
|
||||
MaterialIcon 2.0 MaterialIcon.qml
|
||||
SideNavButton 2.0 SideNavButton.qml
|
||||
ScrollHelper 2.0 ScrollHelper.qml
|
||||
AutoListView 2.0 AutoListView.qml
|
||||
AutoTextField 2.0 AutoTextField.qml
|
||||
Avatar 2.0 Avatar.qml
|
||||
FullScreenImage 2.0 FullScreenImage.qml
|
||||
|
||||
@@ -172,7 +172,7 @@ Drawer {
|
||||
}
|
||||
}
|
||||
|
||||
AutoListView {
|
||||
ListView {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
@@ -180,6 +180,8 @@ Drawer {
|
||||
|
||||
clip: true
|
||||
|
||||
pixelAligned: true
|
||||
|
||||
boundsBehavior: Flickable.DragOverBounds
|
||||
|
||||
model: UserListModel {
|
||||
|
||||
@@ -185,7 +185,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
AutoListView {
|
||||
ListView {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
@@ -197,6 +197,8 @@ Item {
|
||||
|
||||
model: sortedRoomListModel
|
||||
|
||||
pixelAligned: true
|
||||
|
||||
boundsBehavior: Flickable.DragOverBounds
|
||||
|
||||
ScrollBar.vertical: ScrollBar {}
|
||||
|
||||
@@ -223,7 +223,7 @@ Item {
|
||||
|
||||
spacing: 16
|
||||
|
||||
AutoListView {
|
||||
ListView {
|
||||
readonly property int largestVisibleIndex: count > 0 ? indexAt(contentX + (width / 2), contentY + height - 1) : -1
|
||||
readonly property bool noNeedMoreContent: !currentRoom || currentRoom.eventsHistoryJob || currentRoom.allHistoryLoaded
|
||||
|
||||
@@ -241,6 +241,8 @@ Item {
|
||||
|
||||
boundsBehavior: Flickable.DragOverBounds
|
||||
|
||||
pixelAligned: true
|
||||
|
||||
model: SortFilterProxyModel {
|
||||
id: sortedMessageEventModel
|
||||
|
||||
@@ -254,16 +256,10 @@ Item {
|
||||
|
||||
onModelReset: {
|
||||
movingTimer.stop()
|
||||
messageListView.positionViewAtBeginning()
|
||||
if (currentRoom) {
|
||||
movingTimer.restart()
|
||||
|
||||
var lastScrollPosition = sortedMessageEventModel.mapFromSource(currentRoom.savedTopVisibleIndex())
|
||||
if (lastScrollPosition === 0) {
|
||||
messageListView.positionViewAtBeginning()
|
||||
} else {
|
||||
messageListView.currentIndex = lastScrollPosition
|
||||
}
|
||||
|
||||
if (messageListView.contentY < messageListView.originY + 10 || currentRoom.timelineSize < 20)
|
||||
currentRoom.getPreviousContent(50)
|
||||
}
|
||||
|
||||
2
res.qrc
2
res.qrc
@@ -26,8 +26,6 @@
|
||||
<file>imports/Spectral/Panel/RoomListPanel.qml</file>
|
||||
<file>imports/Spectral/Panel/RoomPanel.qml</file>
|
||||
<file>imports/Spectral/Panel/RoomHeader.qml</file>
|
||||
<file>imports/Spectral/Component/ScrollHelper.qml</file>
|
||||
<file>imports/Spectral/Component/AutoListView.qml</file>
|
||||
<file>imports/Spectral/Component/AutoTextField.qml</file>
|
||||
<file>imports/Spectral/Panel/RoomPanelInput.qml</file>
|
||||
<file>imports/Spectral/Component/Timeline/SectionDelegate.qml</file>
|
||||
|
||||
Reference in New Issue
Block a user