2023-05-23 18:51:14 +00:00
|
|
|
import QtCore
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Controls.Basic
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Dialogs
|
2023-06-22 19:44:49 +00:00
|
|
|
import chatlistmodel
|
2023-05-23 18:51:14 +00:00
|
|
|
import localdocs
|
|
|
|
import llm
|
|
|
|
|
2023-07-06 14:53:43 +00:00
|
|
|
MyDialog {
|
2023-05-23 18:51:14 +00:00
|
|
|
id: collectionsDialog
|
|
|
|
modal: true
|
|
|
|
padding: 20
|
|
|
|
width: 480
|
|
|
|
height: 640
|
|
|
|
|
2023-11-22 14:10:44 +00:00
|
|
|
signal addRemoveClicked
|
2023-06-22 19:44:49 +00:00
|
|
|
property var currentChat: ChatListModel.currentChat
|
2023-05-23 18:51:14 +00:00
|
|
|
|
|
|
|
Label {
|
|
|
|
id: listLabel
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
2024-01-22 19:41:47 +00:00
|
|
|
text: qsTr("Local Documents")
|
|
|
|
color: theme.titleTextColor
|
2023-08-07 17:54:13 +00:00
|
|
|
font.pixelSize: theme.fontSizeLarge
|
2024-01-22 19:41:47 +00:00
|
|
|
font.bold: true
|
2023-05-23 18:51:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
id: scrollView
|
|
|
|
anchors.top: listLabel.bottom
|
|
|
|
anchors.topMargin: 20
|
2023-11-22 14:10:44 +00:00
|
|
|
anchors.bottom: collectionSettings.top
|
|
|
|
anchors.bottomMargin: 20
|
2023-05-23 18:51:14 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
clip: true
|
|
|
|
contentHeight: 300
|
2024-01-22 19:41:47 +00:00
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
2023-05-23 18:51:14 +00:00
|
|
|
|
|
|
|
background: Rectangle {
|
2024-01-22 19:41:47 +00:00
|
|
|
color: theme.controlBackground
|
2023-05-23 18:51:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: listView
|
|
|
|
model: LocalDocs.localDocsModel
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2024-01-22 19:41:47 +00:00
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
parent: listView.parent
|
|
|
|
anchors.top: listView.top
|
|
|
|
anchors.left: listView.right
|
|
|
|
anchors.bottom: listView.bottom
|
|
|
|
}
|
|
|
|
|
2023-05-23 18:51:14 +00:00
|
|
|
delegate: Rectangle {
|
|
|
|
id: item
|
|
|
|
width: listView.width
|
|
|
|
height: collectionId.height + 40
|
2024-01-22 19:41:47 +00:00
|
|
|
color: index % 2 === 0 ? theme.darkContrast : theme.lightContrast
|
2023-05-23 18:51:14 +00:00
|
|
|
MyCheckBox {
|
|
|
|
id: checkBox
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.margins: 20
|
|
|
|
checked: currentChat.hasCollection(collection)
|
|
|
|
onClicked: {
|
|
|
|
if (checkBox.checked) {
|
|
|
|
currentChat.addCollection(collection)
|
|
|
|
} else {
|
|
|
|
currentChat.removeCollection(collection)
|
|
|
|
}
|
|
|
|
}
|
2023-10-24 16:13:32 +00:00
|
|
|
ToolTip.text: qsTr("Warning: searching collections while indexing can return incomplete results")
|
|
|
|
ToolTip.visible: hovered && model.indexing
|
2023-05-23 18:51:14 +00:00
|
|
|
}
|
|
|
|
Text {
|
|
|
|
id: collectionId
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: checkBox.right
|
|
|
|
anchors.margins: 20
|
2023-10-24 16:13:32 +00:00
|
|
|
anchors.leftMargin: 10
|
2023-05-23 18:51:14 +00:00
|
|
|
text: collection
|
2023-08-07 17:54:13 +00:00
|
|
|
font.pixelSize: theme.fontSizeLarge
|
2023-05-23 18:51:14 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
color: theme.textColor
|
|
|
|
}
|
2023-10-24 16:13:32 +00:00
|
|
|
ProgressBar {
|
|
|
|
id: itemProgressBar
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: collectionId.right
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.margins: 20
|
|
|
|
anchors.leftMargin: 40
|
2024-01-22 17:36:01 +00:00
|
|
|
visible: model.indexing || model.currentEmbeddingsToIndex !== model.totalEmbeddingsToIndex || model.error !== ""
|
|
|
|
value: model.error !== "" ? 0 : model.indexing ?
|
|
|
|
(model.totalBytesToIndex - model.currentBytesToIndex) / model.totalBytesToIndex :
|
|
|
|
(model.currentEmbeddingsToIndex / model.totalEmbeddingsToIndex)
|
2023-10-24 16:13:32 +00:00
|
|
|
background: Rectangle {
|
|
|
|
implicitHeight: 45
|
2024-01-22 17:36:01 +00:00
|
|
|
color: model.error ? theme.textErrorColor : theme.progressBackground
|
2023-10-24 16:13:32 +00:00
|
|
|
radius: 3
|
|
|
|
}
|
|
|
|
contentItem: Item {
|
|
|
|
implicitHeight: 40
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: itemProgressBar.visualPosition * parent.width
|
|
|
|
height: parent.height
|
|
|
|
radius: 2
|
2024-01-22 19:41:47 +00:00
|
|
|
color: theme.progressForeground
|
2023-10-24 16:13:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Accessible.role: Accessible.ProgressBar
|
|
|
|
Accessible.name: qsTr("Indexing progressBar")
|
|
|
|
Accessible.description: qsTr("Shows the progress made in the indexing")
|
2024-01-22 17:36:01 +00:00
|
|
|
ToolTip.text: model.error
|
|
|
|
ToolTip.visible: hovered && model.error !== ""
|
2023-10-24 16:13:32 +00:00
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: speedLabel
|
2024-02-06 14:34:38 +00:00
|
|
|
color: theme.progressText
|
2024-01-22 17:36:01 +00:00
|
|
|
visible: model.indexing || model.currentEmbeddingsToIndex !== model.totalEmbeddingsToIndex
|
2023-10-24 16:13:32 +00:00
|
|
|
anchors.verticalCenter: itemProgressBar.verticalCenter
|
|
|
|
anchors.left: itemProgressBar.left
|
|
|
|
anchors.right: itemProgressBar.right
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2024-01-22 17:36:01 +00:00
|
|
|
text: model.error !== "" ? qsTr("error...") : (model.indexing ? qsTr("indexing...") : qsTr("embeddings..."))
|
2023-10-24 16:13:32 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
font.pixelSize: theme.fontSizeLarge
|
|
|
|
}
|
2023-05-23 18:51:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-11-22 14:10:44 +00:00
|
|
|
|
2024-01-22 19:41:47 +00:00
|
|
|
MySettingsButton {
|
2023-11-22 14:10:44 +00:00
|
|
|
id: collectionSettings
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: qsTr("Add & Remove")
|
|
|
|
font.pixelSize: theme.fontSizeLarger
|
|
|
|
onClicked: {
|
|
|
|
addRemoveClicked()
|
|
|
|
}
|
|
|
|
}
|
2023-05-23 18:51:14 +00:00
|
|
|
}
|