diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index ec9e890cb..c63232605 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -262,6 +262,7 @@ ui/modules/Common/Styles/Tooltip/TooltipStyle.qml ui/modules/Common/Tooltip/TooltipArea.qml ui/modules/Common/Tooltip/Tooltip.qml + ui/modules/Common/View/ScrollableListView.js ui/modules/Common/View/ScrollableListView.qml ui/modules/Linphone/Account/AccountStatus.qml ui/modules/Linphone/Calls/CallControls.qml diff --git a/linphone-desktop/ui/modules/Common/Misc/ForceScrollBar.qml b/linphone-desktop/ui/modules/Common/Misc/ForceScrollBar.qml index 46aaeb777..f9cf1d7ea 100644 --- a/linphone-desktop/ui/modules/Common/Misc/ForceScrollBar.qml +++ b/linphone-desktop/ui/modules/Common/Misc/ForceScrollBar.qml @@ -26,6 +26,4 @@ ScrollBar { radius: ForceScrollBarStyle.contentItem.radius } hoverEnabled: true - - visible: size < 1.0 } diff --git a/linphone-desktop/ui/modules/Common/View/ScrollableListView.js b/linphone-desktop/ui/modules/Common/View/ScrollableListView.js new file mode 100644 index 000000000..a43a4cad6 --- /dev/null +++ b/linphone-desktop/ui/modules/Common/View/ScrollableListView.js @@ -0,0 +1,13 @@ +// ============================================================================= +// `ScrollableListView.qml` Logic. +// ============================================================================= + +function positionViewAtEnd () { + view.interactive = false + scrollAnimation.start() + view.interactive = true +} + +function getYEnd () { + return view.originY + view.contentHeight - view.height +} diff --git a/linphone-desktop/ui/modules/Common/View/ScrollableListView.qml b/linphone-desktop/ui/modules/Common/View/ScrollableListView.qml index 49048dd9b..addd59e55 100644 --- a/linphone-desktop/ui/modules/Common/View/ScrollableListView.qml +++ b/linphone-desktop/ui/modules/Common/View/ScrollableListView.qml @@ -3,25 +3,55 @@ import QtQuick.Controls 2.0 import Common 1.0 +import 'ScrollableListView.js' as Logic + // ============================================================================= ListView { - id: listView + id: view - ScrollBar.horizontal: ForceScrollBar { - id: hScrollBar + // --------------------------------------------------------------------------- - onPressedChanged: pressed ? listView.movementStarted() : listView.movementEnded() + function positionViewAtEnd () { + Logic.positionViewAtEnd() } + // --------------------------------------------------------------------------- + ScrollBar.vertical: ForceScrollBar { id: vScrollBar - onPressedChanged: pressed ? listView.movementStarted() : listView.movementEnded() + onPressedChanged: pressed ? view.movementStarted() : view.movementEnded() } + // --------------------------------------------------------------------------- + boundsBehavior: Flickable.StopAtBounds clip: true - contentWidth: vScrollBar.visible ? width - vScrollBar.width : width + contentWidth: width - vScrollBar.width spacing: 0 + + // --------------------------------------------------------------------------- + + SequentialAnimation { + id: scrollAnimation + + ScriptAction { + script: { + view.contentY = view.contentY + view.contentY = Logic.getYEnd() + view.contentY = view.contentY + } + } + + PauseAnimation { + duration: 200 + } + + ScriptAction { + script: { + view.contentY = Logic.getYEnd() + } + } + } } diff --git a/linphone-desktop/ui/modules/Linphone/Chat/Chat.js b/linphone-desktop/ui/modules/Linphone/Chat/Chat.js index 95a76ece2..bc81f119f 100644 --- a/linphone-desktop/ui/modules/Linphone/Chat/Chat.js +++ b/linphone-desktop/ui/modules/Linphone/Chat/Chat.js @@ -28,22 +28,6 @@ function getComponentFromEntry (chatEntry) { return chatEntry.isOutgoing ? 'OutgoingMessage.qml' : 'IncomingMessage.qml' } -function handleCurrentItemChanged (currentItem) { - // Go to last item only! - if (!chat.bindToEnd || !currentItem || chat.currentIndex + 1 !== chat.count) { - return - } - - var chatHeight = chat.height - var messageY = currentItem.mapToItem(chat.contentItem, 0, 0).y - var messageHeight = currentItem.height - console.log(chat.contentY, chatHeight, messageY) - if (chat.contentY <= messageY) { - chat.contentY = messageY - } - chat.currentIndex = -1 -} - function handleFilesDropped (files) { chat.bindToEnd = true files.forEach(proxyModel.sendFileMessage) @@ -69,7 +53,7 @@ function handleDataChanged (_, bottomRight) { var index = bottomRight.row if (chat.bindToEnd && index + 1 === n) { - chat.currentIndex = index + chat.positionViewAtEnd() } } diff --git a/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml b/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml index 728021ffd..5e32f559f 100644 --- a/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml @@ -52,7 +52,6 @@ Rectangle { Component.onCompleted: Logic.initView() onContentYChanged: Logic.loadMoreEntries() - onCurrentItemChanged: Logic.handleCurrentItemChanged(currentItem) onMovementEnded: Logic.handleMovementEnded() onMovementStarted: Logic.handleMovementStarted() diff --git a/linphone-desktop/ui/views/App/Main/Home.qml b/linphone-desktop/ui/views/App/Main/Home.qml index 3c713bca3..a49bb66b5 100644 --- a/linphone-desktop/ui/views/App/Main/Home.qml +++ b/linphone-desktop/ui/views/App/Main/Home.qml @@ -12,8 +12,10 @@ import App.Styles 1.0 Rectangle { color: HomeStyle.color - ScrollableListView { + ListView { anchors.horizontalCenter: parent.horizontalCenter + boundsBehavior: Flickable.StopAtBounds + clip: true orientation: ListView.Horizontal spacing: HomeStyle.spacing