Simplify chat pane scrolling
This commit is contained in:
parent
8103d80df2
commit
b28330b5d5
|
|
@ -13,9 +13,6 @@ Column {
|
|||
required property var blockSegments
|
||||
required property string blockRenderedHtml
|
||||
|
||||
// Reference to parent ListView for scroll control
|
||||
property ListView parentListView: null
|
||||
|
||||
// Expand state based on block type
|
||||
property bool blockExpanded: {
|
||||
switch (blockType) {
|
||||
|
|
@ -137,26 +134,6 @@ Column {
|
|||
selectionColor: theme.highlightColor
|
||||
selectedTextColor: theme.highlightedTextColor
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (!activeFocus && root.parentListView)
|
||||
root.parentListView.interactive = true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
propagateComposedEvents: true
|
||||
cursorShape: Qt.IBeamCursor
|
||||
onPressed: function(mouse) {
|
||||
if (root.parentListView) root.parentListView.interactive = false
|
||||
mouse.accepted = false
|
||||
}
|
||||
onReleased: function(mouse) {
|
||||
if (root.parentListView) root.parentListView.interactive = true
|
||||
mouse.accepted = false
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
|
|
@ -211,27 +188,7 @@ Column {
|
|||
selectionColor: theme.highlightColor
|
||||
selectedTextColor: theme.highlightedTextColor
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (!activeFocus && root.parentListView)
|
||||
root.parentListView.interactive = true
|
||||
}
|
||||
|
||||
// Left-click: disable ListView flick while selecting text
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
propagateComposedEvents: true
|
||||
cursorShape: Qt.IBeamCursor
|
||||
onPressed: function(mouse) {
|
||||
if (root.parentListView) root.parentListView.interactive = false
|
||||
mouse.accepted = false
|
||||
}
|
||||
onReleased: function(mouse) {
|
||||
if (root.parentListView) root.parentListView.interactive = true
|
||||
mouse.accepted = false
|
||||
}
|
||||
}
|
||||
|
||||
// Right-click: lazy context menu
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
|
@ -355,18 +312,16 @@ Column {
|
|||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
propagateComposedEvents: true
|
||||
acceptedButtons: Qt.RightButton
|
||||
cursorShape: Qt.IBeamCursor
|
||||
onPressed: function(mouse) {
|
||||
if (root.parentListView) root.parentListView.interactive = false
|
||||
mouse.accepted = false
|
||||
onClicked: {
|
||||
if (!sourceEdit._menu) {
|
||||
sourceEdit._menu = contextMenuComponent.createObject(sourceEdit)
|
||||
}
|
||||
onReleased: function(mouse) {
|
||||
if (root.parentListView) root.parentListView.interactive = true
|
||||
mouse.accepted = false
|
||||
sourceEdit._menu.popup()
|
||||
}
|
||||
}
|
||||
property Menu _menu: null
|
||||
}
|
||||
|
||||
Column {
|
||||
|
|
|
|||
|
|
@ -115,57 +115,12 @@ Item {
|
|||
spacing: 4
|
||||
anchors.fill: parent
|
||||
anchors.margins: 4
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
visible: ollie.daemonConnected && ollie.activeAgentId !== ""
|
||||
|
||||
property bool followTail: true
|
||||
|
||||
reuseItems: true
|
||||
|
||||
onCountChanged: {
|
||||
if (followTail)
|
||||
scrollTimer.restart()
|
||||
}
|
||||
|
||||
onContentHeightChanged: {
|
||||
if (followTail)
|
||||
scrollTimer.restart()
|
||||
}
|
||||
|
||||
onMovementEnded: followTail = atYEnd
|
||||
|
||||
Timer {
|
||||
id: scrollTimer
|
||||
interval: 16
|
||||
onTriggered: {
|
||||
if (chatView.followTail && chatView.contentHeight > chatView.height)
|
||||
chatView.positionViewAtEnd()
|
||||
}
|
||||
}
|
||||
|
||||
delegate: ChatBlockDelegate {
|
||||
width: chatView.width - 8
|
||||
parentListView: chatView
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll to bottom button
|
||||
Button {
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 12
|
||||
text: "↓"
|
||||
font.pixelSize: 16
|
||||
implicitWidth: 36
|
||||
implicitHeight: 36
|
||||
visible: chatView.visible && !chatView.followTail
|
||||
onClicked: {
|
||||
chatView.followTail = true
|
||||
chatView.positionViewAtEnd()
|
||||
}
|
||||
ToolTip.text: "Scroll to bottom"
|
||||
ToolTip.visible: hovered
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle { Layout.fillWidth: true; height: 1; color: theme.midColor }
|
||||
|
|
|
|||
Reference in New Issue