mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-02-07 15:08:24 +00:00
fix(ui/modules/Linphone/Chat/Chat): workaround to scroll correctly at chat end
This commit is contained in:
parent
6a91163a0d
commit
66c8bb6dca
3 changed files with 56 additions and 31 deletions
|
|
@ -17,9 +17,7 @@ class ChatModel::MessageHandlers : public linphone::ChatMessageListener {
|
|||
public:
|
||||
MessageHandlers (ChatModel *chat_model) : m_chat_model(chat_model) {}
|
||||
|
||||
~MessageHandlers () {
|
||||
qDebug() << "handlers";
|
||||
}
|
||||
~MessageHandlers () = default;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,12 @@ import Common 1.0
|
|||
// =============================================================================
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
|
||||
ScrollBar.vertical: ForceScrollBar {
|
||||
id: scrollBar
|
||||
|
||||
onPressedChanged: pressed ? listView.movementStarted() : listView.movementEnded()
|
||||
}
|
||||
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
|
|
|||
|
|
@ -25,16 +25,23 @@ ColumnLayout {
|
|||
ScrollableListView {
|
||||
id: chat
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
property bool _bindToEnd: false
|
||||
property bool _tryToLoadMoreEntries: true
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
function _loadMoreEntries () {
|
||||
if (atYBeginning && !_tryToLoadMoreEntries) {
|
||||
_tryToLoadMoreEntries = true
|
||||
positionViewAtIndex(0, ListView.Beginning)
|
||||
positionViewAtBeginning()
|
||||
proxyModel.loadMoreEntries()
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
|
|
@ -44,6 +51,49 @@ ColumnLayout {
|
|||
property: '$sectionDate'
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Component.onCompleted: {
|
||||
function goToEnd () {
|
||||
return Utils.setTimeout(chat, 100, function () {
|
||||
if (_bindToEnd) {
|
||||
positionViewAtEnd()
|
||||
}
|
||||
|
||||
return goToEnd()
|
||||
})
|
||||
}
|
||||
goToEnd()
|
||||
|
||||
var initView = function () {
|
||||
_tryToLoadMoreEntries = false
|
||||
_bindToEnd = true
|
||||
}
|
||||
|
||||
// Received only if more entries were loaded.
|
||||
proxyModel.moreEntriesLoaded.connect(function (n) {
|
||||
positionViewAtIndex(n - 1, ListView.Beginning)
|
||||
_tryToLoadMoreEntries = false
|
||||
})
|
||||
|
||||
// When the view is changed (for example `Calls` -> `Messages`),
|
||||
// the position is set at end and it can be possible to load
|
||||
// more entries.
|
||||
proxyModel.entryTypeFilterChanged.connect(initView)
|
||||
|
||||
// First render.
|
||||
initView()
|
||||
}
|
||||
|
||||
onMovementStarted: _bindToEnd = false
|
||||
onMovementEnded: {
|
||||
if (atYEnd) {
|
||||
_bindToEnd = true
|
||||
}
|
||||
}
|
||||
|
||||
onContentYChanged: _loadMoreEntries()
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Heading.
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
@ -178,33 +228,6 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var initView = function () {
|
||||
positionViewAtEnd()
|
||||
_tryToLoadMoreEntries = false
|
||||
|
||||
// TODO: Remove these lines when this issue will not be longer valid :
|
||||
// https://bugreports.qt.io/browse/QTBUG-49989
|
||||
Utils.setTimeout(chat, 10, positionViewAtEnd)
|
||||
}
|
||||
|
||||
// Received only if more entries were loaded.
|
||||
proxyModel.moreEntriesLoaded.connect(function (n) {
|
||||
positionViewAtIndex(n - 1, ListView.Beginning)
|
||||
_tryToLoadMoreEntries = false
|
||||
})
|
||||
|
||||
// When the view is changed (for example `Calls` -> `Messages`),
|
||||
// the position is set at end and it can be possible to load
|
||||
// more entries.
|
||||
proxyModel.entryTypeFilterChanged.connect(initView)
|
||||
|
||||
// First render.
|
||||
initView()
|
||||
}
|
||||
|
||||
onContentYChanged: _loadMoreEntries()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue