93 lines
1.7 KiB
QML
93 lines
1.7 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import Quickshell
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import ZShell.Llm
|
|
import ZShell.Config
|
|
import qs.Services
|
|
import qs.Components
|
|
|
|
Item {
|
|
id: root
|
|
|
|
property alias model: list.model
|
|
|
|
signal loadChatRequest(content: ChatSession)
|
|
signal newChatRequest
|
|
|
|
CustomListView {
|
|
id: list
|
|
|
|
anchors.fill: parent
|
|
cacheBuffer: height * 2
|
|
clip: true
|
|
spacing: Tokens.spacing.medium
|
|
|
|
delegate: CustomRect {
|
|
id: chatItem
|
|
|
|
required property var modelData
|
|
|
|
color: Colors.tPalette.m3surfaceContainer
|
|
implicitHeight: layout.implicitHeight + layout.anchors.topMargin + layout.anchors.bottomMargin
|
|
implicitWidth: ListView.view.width
|
|
radius: Tokens.rounding.medium
|
|
|
|
ColumnLayout {
|
|
id: layout
|
|
|
|
anchors.bottomMargin: Tokens.padding.small
|
|
anchors.fill: parent
|
|
anchors.leftMargin: Tokens.padding.medium
|
|
anchors.rightMargin: Tokens.padding.medium
|
|
anchors.topMargin: Tokens.padding.small
|
|
spacing: 0
|
|
|
|
CustomText {
|
|
id: title
|
|
|
|
text: chatItem.modelData.title
|
|
}
|
|
|
|
CustomText {
|
|
id: timestamp
|
|
|
|
color: Colors.palette.m3outline
|
|
font.pointSize: Tokens.font.size.small
|
|
text: chatItem.modelData.updatedAt.toLocaleString(Qt.locale("en_US"), "MMM d, yyyy - h:mm AP")
|
|
}
|
|
}
|
|
|
|
StateLayer {
|
|
onClicked: {
|
|
root.loadChatRequest(chatItem.modelData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
IconButton {
|
|
id: newChatBtn
|
|
|
|
anchors.bottom: parent.bottom
|
|
anchors.margins: Tokens.padding.small
|
|
anchors.right: parent.right
|
|
font.pointSize: Math.round(18 * 1.2)
|
|
icon: "add"
|
|
padding: 8
|
|
radius: Tokens.rounding.full
|
|
|
|
onClicked: {
|
|
root.newChatRequest();
|
|
}
|
|
|
|
Elevation {
|
|
anchors.fill: parent
|
|
level: newChatBtn.stateLayer.containsMouse ? 4 : 3
|
|
radius: parent.radius
|
|
z: -1
|
|
}
|
|
}
|
|
}
|