mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-09-07 03:20:26 +00:00
Begin implementing the localdocs ui in earnest.
This commit is contained in:
98
gpt4all-chat/qml/AddCollectionDialog.qml
Normal file
98
gpt4all-chat/qml/AddCollectionDialog.qml
Normal file
@@ -0,0 +1,98 @@
|
||||
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
|
||||
}
|
||||
}
|
@@ -2,35 +2,175 @@ import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Basic
|
||||
import QtQuick.Layouts
|
||||
import localdocs
|
||||
|
||||
GridLayout {
|
||||
columns: 2
|
||||
rowSpacing: 10
|
||||
columnSpacing: 10
|
||||
|
||||
Label {
|
||||
text: qsTr("Collections:")
|
||||
color: theme.textColor
|
||||
Layout.row: 1
|
||||
Layout.column: 0
|
||||
Item {
|
||||
AddCollectionDialog {
|
||||
id: addCollectionDialog
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 10
|
||||
Layout.row: 1
|
||||
Layout.column: 1
|
||||
MyComboBox {
|
||||
id: comboBox
|
||||
Layout.minimumWidth: 350
|
||||
Connections {
|
||||
target: addCollectionDialog
|
||||
function onAccepted() {
|
||||
LocalDocs.addFolder(addCollectionDialog.collection, addCollectionDialog.folder_path)
|
||||
}
|
||||
MyButton {
|
||||
text: "Add"
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
id: gridLayout
|
||||
columns: 2
|
||||
rowSpacing: 10
|
||||
columnSpacing: 10
|
||||
|
||||
Label {
|
||||
id: contextItemsPerPrompt
|
||||
text: qsTr("Context items per prompt:")
|
||||
color: theme.textColor
|
||||
Layout.row: 0
|
||||
Layout.column: 0
|
||||
}
|
||||
MyButton {
|
||||
text: "Remove"
|
||||
|
||||
MyTextField {
|
||||
Layout.row: 0
|
||||
Layout.column: 1
|
||||
}
|
||||
MyButton {
|
||||
text: "Rename"
|
||||
|
||||
Label {
|
||||
id: chunkLabel
|
||||
text: qsTr("Chunksize:")
|
||||
color: theme.textColor
|
||||
Layout.row: 1
|
||||
Layout.column: 0
|
||||
}
|
||||
|
||||
MyTextField {
|
||||
id: chunkSizeTextField
|
||||
Layout.row: 1
|
||||
Layout.column: 1
|
||||
}
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
id: scrollView
|
||||
anchors.top: gridLayout.bottom
|
||||
anchors.topMargin: 20
|
||||
anchors.bottom: newCollectionButton.top
|
||||
anchors.bottomMargin: 10
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
clip: true
|
||||
contentHeight: 300
|
||||
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
||||
|
||||
background: Rectangle {
|
||||
color: theme.backgroundLighter
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
model: LocalDocs.localDocsModel
|
||||
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 {
|
||||
id: item
|
||||
width: listView.width
|
||||
height: buttons.height + 20
|
||||
color: index % 2 === 0 ? theme.backgroundLight : theme.backgroundLighter
|
||||
property bool removing: false
|
||||
|
||||
Text {
|
||||
id: collectionId
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.margins: 20
|
||||
text: collection
|
||||
elide: Text.ElideRight
|
||||
color: theme.textColor
|
||||
width: 200
|
||||
}
|
||||
|
||||
Text {
|
||||
id: folderId
|
||||
anchors.left: collectionId.right
|
||||
anchors.margins: 20
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: folder_path
|
||||
elide: Text.ElideRight
|
||||
color: theme.textColor
|
||||
}
|
||||
|
||||
Item {
|
||||
id: buttons
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.margins: 20
|
||||
width: childrenRect.width
|
||||
height: Math.max(removeButton.height, busyIndicator.height)
|
||||
MyButton {
|
||||
id: removeButton
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: qsTr("Remove")
|
||||
visible: !item.removing
|
||||
onClicked: {
|
||||
item.removing = true
|
||||
LocalDocs.removeFolder(collection, folder_path)
|
||||
}
|
||||
}
|
||||
BusyIndicator {
|
||||
id: busyIndicator
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: item.removing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MyButton {
|
||||
id: newCollectionButton
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
text: qsTr("New collection")
|
||||
onClicked: {
|
||||
addCollectionDialog.open();
|
||||
}
|
||||
}
|
||||
|
||||
MyButton {
|
||||
id: restoreDefaultsButton
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -234,21 +234,28 @@ Dialog {
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 1 ? localDocsButton.checked : 0
|
||||
height: localDocsButton.checked
|
||||
color: theme.tabBorder
|
||||
}
|
||||
Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: !localDocsButton.checked
|
||||
color: theme.tabBorder
|
||||
}
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
width: 1 ? localDocsButton.checked : 0
|
||||
width: localDocsButton.checked
|
||||
color: theme.tabBorder
|
||||
}
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
width: 1 ? localDocsButton.checked : 0
|
||||
width: localDocsButton.checked
|
||||
color: theme.tabBorder
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user