Clean up the settings dialog for localdocs a bit.

This commit is contained in:
Adam Treat 2023-05-23 11:05:04 -04:00 committed by AT
parent d555ed3b07
commit 2827c5876c
4 changed files with 128 additions and 181 deletions

View File

@ -78,7 +78,6 @@ qt_add_qml_module(chat
main.qml main.qml
qml/ChatDrawer.qml qml/ChatDrawer.qml
qml/LocalDocs.qml qml/LocalDocs.qml
qml/AddCollectionDialog.qml
qml/ModelDownloaderDialog.qml qml/ModelDownloaderDialog.qml
qml/NetworkDialog.qml qml/NetworkDialog.qml
qml/NewVersionDialog.qml qml/NewVersionDialog.qml

View File

@ -1,98 +0,0 @@
import QtCore
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Dialogs
import QtQuick.Layouts
Dialog {
id: addCollectionDialog
anchors.centerIn: parent
opacity: 0.9
padding: 20
modal: true
Theme {
id: theme
}
property string collection: ""
property string folder_path: ""
FolderDialog {
id: folderDialog
title: "Please choose a directory"
currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
onAccepted: {
addCollectionDialog.folder_path = selectedFolder
}
}
Row {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: childrenRect.height
spacing: 20
TextField {
id: collection
implicitWidth: 200
horizontalAlignment: Text.AlignJustify
color: theme.textColor
background: Rectangle {
implicitWidth: 150
color: theme.backgroundLighter
radius: 10
}
padding: 10
placeholderText: qsTr("Collection name...")
placeholderTextColor: theme.mutedTextColor
ToolTip.text: qsTr("Name of the collection to add (Required)")
ToolTip.visible: hovered
onEditingFinished: {
addCollectionDialog.collection = text
}
Accessible.role: Accessible.EditableText
Accessible.name: collection.text
Accessible.description: ToolTip.text
}
MyTextField {
id: folderLabel
text: folder_path
readOnly: true
color: theme.textColor
implicitWidth: 300
padding: 10
placeholderText: qsTr("Folder path...")
placeholderTextColor: theme.mutedTextColor
ToolTip.text: qsTr("Folder path to documents (Required)")
ToolTip.visible: hovered
}
MyButton {
text: qsTr("Browse")
onClicked: {
folderDialog.open();
}
}
MyButton {
text: qsTr("Add")
enabled: addCollectionDialog.collection !== "" && addCollectionDialog.folder_path != ""
Accessible.role: Accessible.Button
Accessible.name: text
Accessible.description: qsTr("Add button")
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
}
}
background: Rectangle {
anchors.fill: parent
color: theme.backgroundDarkest
border.width: 1
border.color: theme.dialogBorder
radius: 10
}
}

View File

@ -1,61 +1,101 @@
import QtCore
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Controls.Basic import QtQuick.Controls.Basic
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Dialogs
import localdocs import localdocs
Item { Item {
AddCollectionDialog { id: root
id: addCollectionDialog property string collection: ""
} property string folder_path: ""
Connections { FolderDialog {
target: addCollectionDialog id: folderDialog
function onAccepted() { title: "Please choose a directory"
LocalDocs.addFolder(addCollectionDialog.collection, addCollectionDialog.folder_path) currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
onAccepted: {
root.folder_path = selectedFolder
} }
} }
GridLayout { Rectangle {
id: gridLayout id: addCollection
columns: 2 anchors.left: parent.left
rowSpacing: 10 anchors.right: parent.right
columnSpacing: 10 height: collection.height + 20
color: theme.backgroundDark
Label { MyTextField {
id: contextItemsPerPrompt id: collection
text: qsTr("Context items per prompt:") anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
width: 225
horizontalAlignment: Text.AlignJustify
color: theme.textColor color: theme.textColor
Layout.row: 0 placeholderText: qsTr("Collection name...")
Layout.column: 0 placeholderTextColor: theme.mutedTextColor
ToolTip.text: qsTr("Name of the collection to add (Required)")
ToolTip.visible: hovered
onEditingFinished: {
root.collection = text
}
Accessible.role: Accessible.EditableText
Accessible.name: collection.text
Accessible.description: ToolTip.text
} }
MyTextField { MyTextField {
Layout.row: 0 id: folderLabel
Layout.column: 1 anchors.left: collection.right
} anchors.leftMargin: 10
anchors.right: browseButton.left
Label { anchors.rightMargin: 10
id: chunkLabel anchors.verticalCenter: parent.verticalCenter
text: qsTr("Chunksize:") text: root.folder_path
readOnly: true
color: theme.textColor color: theme.textColor
Layout.row: 1 placeholderText: qsTr("Folder path...")
Layout.column: 0 placeholderTextColor: theme.mutedTextColor
ToolTip.text: qsTr("Folder path to documents (Required)")
ToolTip.visible: hovered
} }
MyTextField { MyButton {
id: chunkSizeTextField id: browseButton
Layout.row: 1 text: qsTr("Browse")
Layout.column: 1 anchors.right: addButton.left
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
onClicked: {
folderDialog.open();
}
}
MyButton {
id: addButton
text: qsTr("Add")
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
enabled: root.collection !== "" && root.folder_path != ""
Accessible.role: Accessible.Button
Accessible.name: text
Accessible.description: qsTr("Add button")
onClicked: {
LocalDocs.addFolder(root.collection, root.folder_path)
root.collection = ""
root.folder_path = ""
collection.clear()
}
} }
} }
ScrollView { ScrollView {
id: scrollView id: scrollView
anchors.top: gridLayout.bottom anchors.top: addCollection.bottom
anchors.topMargin: 20 anchors.bottom: gridLayout.top
anchors.bottom: newCollectionButton.top anchors.bottomMargin: 20
anchors.bottomMargin: 10
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
clip: true clip: true
@ -70,32 +110,6 @@ Item {
id: listView id: listView
model: LocalDocs.localDocsModel model: LocalDocs.localDocsModel
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
headerPositioning: ListView.InlineHeader
header: Rectangle {
width: listView.width
height: collectionLabel.height + 40
color: theme.backgroundDark
Label {
id: collectionLabel
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.margins: 20
text: "Collection"
color: theme.textColor
font.bold: true
width: 200
}
Label {
anchors.left: collectionLabel.right
anchors.margins: 20
anchors.verticalCenter: parent.verticalCenter
text: "Folder"
color: theme.textColor
font.bold: true
}
}
delegate: Rectangle { delegate: Rectangle {
id: item id: item
width: listView.width width: listView.width
@ -129,11 +143,11 @@ Item {
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.margins: 20 anchors.margins: 20
width: childrenRect.width width: Math.max(removeButton.width, busyIndicator.width)
height: Math.max(removeButton.height, busyIndicator.height) height: Math.max(removeButton.height, busyIndicator.height)
MyButton { MyButton {
id: removeButton id: removeButton
anchors.verticalCenter: parent.verticalCenter anchors.centerIn: parent
text: qsTr("Remove") text: qsTr("Remove")
visible: !item.removing visible: !item.removing
onClicked: { onClicked: {
@ -143,7 +157,7 @@ Item {
} }
BusyIndicator { BusyIndicator {
id: busyIndicator id: busyIndicator
anchors.verticalCenter: parent.verticalCenter anchors.centerIn: parent
visible: item.removing visible: item.removing
} }
} }
@ -151,26 +165,58 @@ Item {
} }
} }
MyButton { GridLayout {
id: newCollectionButton id: gridLayout
anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
text: qsTr("New collection")
onClicked: {
addCollectionDialog.open();
}
}
MyButton {
id: restoreDefaultsButton
anchors.left: parent.left anchors.left: parent.left
anchors.bottom: parent.bottom anchors.right: parent.right
text: qsTr("Restore Defaults") columns: 3
Accessible.role: Accessible.Button rowSpacing: 10
Accessible.name: text columnSpacing: 10
Accessible.description: qsTr("Restores the settings dialog to a default state")
onClicked: { Label {
// settingsDialog.restoreGenerationDefaults() id: chunkLabel
Layout.row: 0
Layout.column: 0
color: theme.textColor
text: qsTr("Document snippet size (characters):")
}
MyTextField {
id: chunkSizeTextField
Layout.row: 0
Layout.column: 1
ToolTip.text: qsTr("Number of characters per document snippet. NOTE: larger numbers increase likelihood of factual responses, but also result in slower generation.")
ToolTip.visible: hovered
}
Label {
id: contextItemsPerPrompt
Layout.row: 1
Layout.column: 0
color: theme.textColor
text: qsTr("Document snippets to process per prompt:")
}
MyTextField {
Layout.row: 1
Layout.column: 1
ToolTip.text: qsTr("Best N matches of retrieved document snippets to add to the context for prompt. NOTE: larger numbers increase likelihood of factual responses, but also result in slower generation.")
ToolTip.visible: hovered
}
MyButton {
id: restoreDefaultsButton
Layout.row: 2
Layout.column: 1
Layout.fillWidth: true
text: qsTr("Restore Defaults")
Accessible.role: Accessible.Button
Accessible.name: text
Accessible.description: qsTr("Restores the settings dialog to a default state")
onClicked: {
// settingsDialog.restoreGenerationDefaults()
}
} }
} }
} }

View File

@ -226,7 +226,7 @@ Dialog {
color: theme.textColor color: theme.textColor
font.bold: localDocsButton.checked font.bold: localDocsButton.checked
font.pixelSize: localDocsButton.checked ? theme.fontSizeLarger : theme.fontSizeLarge font.pixelSize: localDocsButton.checked ? theme.fontSizeLarger : theme.fontSizeLarge
text: qsTr("LocalDocs") text: qsTr("Local Docs Plugin")
} }
background: Rectangle { background: Rectangle {
color: localDocsButton.checked ? theme.backgroundDarkest : theme.backgroundLight color: localDocsButton.checked ? theme.backgroundDarkest : theme.backgroundLight