Try out scrollview for timeline

This commit is contained in:
Nicolas Werner 2023-10-18 22:33:23 +02:00
parent fab7805610
commit 280f316b27
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
6 changed files with 293 additions and 295 deletions

View file

@ -143,11 +143,11 @@ Page {
enabled: false enabled: false
height: avatarSize height: avatarSize
roomid: model.id roomid: model.id
textColor: model.avatarUrl.startsWith(":/") ? communityItem.unimportantText : communityItem.importantText textColor: model.avatarUrl?.startsWith(":/") == true ? communityItem.unimportantText : communityItem.importantText
url: { url: {
if (model.avatarUrl.startsWith("mxc://")) if (model.avatarUrl?.startsWith("mxc://") == true)
return model.avatarUrl.replace("mxc://", "image://MxcImage/"); return model.avatarUrl.replace("mxc://", "image://MxcImage/");
else if (model.avatarUrl.length > 0) else if ((model.avatarUrl?.length ?? 0) > 0)
return model.avatarUrl; return model.avatarUrl;
else else
return ""; return "";

View file

@ -2,9 +2,6 @@
// //
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// TODO: using any Qt 6 API version will screw up the reply text color. We need to
// figure out a more permanent fix than just importing the old version.
//import QtQuick 2.15
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import im.nheko import im.nheko

View file

@ -31,23 +31,16 @@ Item {
target: MainWindow target: MainWindow
} }
ScrollBar {
id: scrollbar
anchors.bottom: parent.bottom ScrollView {
anchors.right: parent.right id: scrollView
anchors.top: parent.top anchors.fill: parent
parent: chat.parent
}
ListView { ListView {
id: chat id: chat
property int delegateMaxWidth: ((Settings.timelineMaxWidth > 100 && Settings.timelineMaxWidth < chatRoot.availableWidth) ? Settings.timelineMaxWidth : chatRoot.availableWidth) - chatRoot.padding * 2 - (scrollbar.interactive ? scrollbar.width : 0) property int delegateMaxWidth: ((Settings.timelineMaxWidth > 100 && Settings.timelineMaxWidth < chatRoot.availableWidth) ? Settings.timelineMaxWidth : chatRoot.availableWidth) - chatRoot.padding * 2 - scrollView.effectiveScrollBarWidth
readonly property alias filteringInProgress: filteredTimeline.filteringInProgress readonly property alias filteringInProgress: filteredTimeline.filteringInProgress
ScrollBar.vertical: scrollbar
anchors.fill: parent
anchors.rightMargin: scrollbar.interactive ? scrollbar.width : 0
// reuseItems still has a few bugs, see https://bugreports.qt.io/browse/QTBUG-95105 https://bugreports.qt.io/browse/QTBUG-95107 // reuseItems still has a few bugs, see https://bugreports.qt.io/browse/QTBUG-95105 https://bugreports.qt.io/browse/QTBUG-95107
//onModelChanged: if (room) room.sendReset() //onModelChanged: if (room) room.sendReset()
//reuseItems: true //reuseItems: true
@ -359,6 +352,8 @@ Item {
} }
} }
} }
}
Platform.Menu { Platform.Menu {
id: messageContextMenuC id: messageContextMenuC
@ -641,7 +636,7 @@ Item {
anchors { anchors {
bottom: parent.bottom bottom: parent.bottom
bottomMargin: Nheko.paddingMedium + (fullWidth - width) / 2 bottomMargin: Nheko.paddingMedium + (fullWidth - width) / 2
right: scrollbar.left right: parent.left
rightMargin: Nheko.paddingMedium + (fullWidth - width) / 2 rightMargin: Nheko.paddingMedium + (fullWidth - width) / 2
} }
Image { Image {

View file

@ -29,7 +29,7 @@ Rectangle {
anchors.rightMargin: replyPopup.width < 450 ? 2 * (22 + 16) : 3 * (22 + 16) anchors.rightMargin: replyPopup.width < 450 ? 2 * (22 + 16) : 3 * (22 + 16)
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Nheko.paddingSmall anchors.topMargin: Nheko.paddingSmall
eventId: room.reply ?? "" eventId: room?.reply ?? ""
userColor: TimelineManager.userColor(modelData.userId, palette.window) userColor: TimelineManager.userColor(modelData.userId, palette.window)
visible: room && room.reply visible: room && room.reply
maxWidth: parent.width - anchors.leftMargin - anchors.rightMargin maxWidth: parent.width - anchors.leftMargin - anchors.rightMargin

View file

@ -4,10 +4,10 @@
import ".." import ".."
import "../components" import "../components"
import QtQuick 2.12 import QtQuick
import QtQuick.Controls 2.5 import QtQuick.Controls
import QtQuick.Layouts 1.3 import QtQuick.Layouts
import im.nheko 1.0 import im.nheko
ApplicationWindow { ApplicationWindow {

View file

@ -163,14 +163,20 @@ TimelineFilter::setSource(TimelineModel *s)
this->setSourceModel(s); this->setSourceModel(s);
connect(s, &TimelineModel::currentIndexChanged, this, &TimelineFilter::currentIndexChanged); if (s) {
connect( connect(
s, &TimelineModel::fetchedMore, this, &TimelineFilter::fetchAgain, Qt::QueuedConnection); s, &TimelineModel::currentIndexChanged, this, &TimelineFilter::currentIndexChanged);
connect(s,
&TimelineModel::fetchedMore,
this,
&TimelineFilter::fetchAgain,
Qt::QueuedConnection);
connect(s, connect(s,
&TimelineModel::dataChanged, &TimelineModel::dataChanged,
this, this,
&TimelineFilter::sourceDataChanged, &TimelineFilter::sourceDataChanged,
Qt::QueuedConnection); Qt::QueuedConnection);
}
// reset the search index a second time just to be safe. // reset the search index a second time just to be safe.
incrementalSearchIndex = 0; incrementalSearchIndex = 0;