Thread fetch more button
Changes threads so there is a button to fetch more events. Also adds a separator between the thread root and the rest of the events.
This commit is contained in:
@@ -2,8 +2,11 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Qt.labs.qmlmodels
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
/**
|
||||
@@ -54,6 +57,11 @@ DelegateChooser {
|
||||
|
||||
signal removeLinkPreview(int index)
|
||||
|
||||
/**
|
||||
* @brief Request more events in the thread be loaded.
|
||||
*/
|
||||
signal fetchMoreEvents()
|
||||
|
||||
role: "componentType"
|
||||
|
||||
DelegateChoice {
|
||||
@@ -218,6 +226,14 @@ DelegateChooser {
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: MessageComponentType.FetchButton
|
||||
delegate: FetchButtonComponent {
|
||||
maxContentWidth: root.maxContentWidth
|
||||
onFetchMoreEvents: root.fetchMoreEvents()
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: MessageComponentType.Verification
|
||||
delegate: MimeComponent {
|
||||
@@ -233,6 +249,14 @@ DelegateChooser {
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: MessageComponentType.Separator
|
||||
delegate: Kirigami.Separator {
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: root.maxContentWidth
|
||||
}
|
||||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: MessageComponentType.Other
|
||||
delegate: Item {}
|
||||
|
||||
@@ -27,6 +27,7 @@ ecm_add_qml_module(timeline GENERATE_PLUGIN_SOURCE
|
||||
ChatBarComponent.qml
|
||||
CodeComponent.qml
|
||||
EncryptedComponent.qml
|
||||
FetchButtonComponent.qml
|
||||
FileComponent.qml
|
||||
ImageComponent.qml
|
||||
ItineraryComponent.qml
|
||||
|
||||
52
src/timeline/FetchButtonComponent.qml
Normal file
52
src/timeline/FetchButtonComponent.qml
Normal file
@@ -0,0 +1,52 @@
|
||||
// SPDX-FileCopyrightText: 2025 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.delegates as Delegates
|
||||
|
||||
import org.kde.neochat
|
||||
import org.kde.neochat.chatbar
|
||||
|
||||
/**
|
||||
* @brief A component to show a reply button for threads in a message bubble.
|
||||
*/
|
||||
Delegates.RoundedItemDelegate {
|
||||
id: root
|
||||
|
||||
/**
|
||||
* @brief The maximum width that the bubble's content can be.
|
||||
*/
|
||||
property real maxContentWidth: -1
|
||||
|
||||
/**
|
||||
* @brief Request more events in the thread be loaded.
|
||||
*/
|
||||
signal fetchMoreEvents()
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: root.maxContentWidth
|
||||
|
||||
leftInset: 0
|
||||
rightInset: 0
|
||||
|
||||
highlighted: true
|
||||
|
||||
icon.name: "arrow-up"
|
||||
icon.width: Kirigami.Units.iconSizes.sizeForLabels
|
||||
icon.height: Kirigami.Units.iconSizes.sizeForLabels
|
||||
text: i18nc("@action:button", "Fetch More Events")
|
||||
|
||||
onClicked: {
|
||||
root.fetchMoreEvents()
|
||||
}
|
||||
|
||||
contentItem: Kirigami.Icon {
|
||||
implicitWidth: root.icon.width
|
||||
implicitHeight: root.icon.height
|
||||
source: root.icon.name
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@ ColumnLayout {
|
||||
}
|
||||
onShowMessageMenu: root.showMessageMenu()
|
||||
onRemoveLinkPreview: index => threadRepeater.model.closeLinkPreview(index)
|
||||
onFetchMoreEvents: threadRepeater.model.fetchMoreEvents(5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user