mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-29 16:58:18 +00:00
Add the ability to change the directory via text field not just 'browse' button.
This commit is contained in:
parent
ed9da866fd
commit
66457b88c4
@ -94,6 +94,7 @@ qt_add_qml_module(chat
|
|||||||
qml/Theme.qml
|
qml/Theme.qml
|
||||||
qml/MyButton.qml
|
qml/MyButton.qml
|
||||||
qml/MyComboBox.qml
|
qml/MyComboBox.qml
|
||||||
|
qml/MyDirectoryField.qml
|
||||||
qml/MyTextField.qml
|
qml/MyTextField.qml
|
||||||
qml/MyCheckBox.qml
|
qml/MyCheckBox.qml
|
||||||
qml/MyBusyIndicator.qml
|
qml/MyBusyIndicator.qml
|
||||||
|
@ -63,6 +63,22 @@ bool LLM::checkForUpdates() const
|
|||||||
return QProcess::startDetached(fileName);
|
return QProcess::startDetached(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LLM::directoryExists(const QString &path) const
|
||||||
|
{
|
||||||
|
const QUrl url(path);
|
||||||
|
const QString localFilePath = url.isLocalFile() ? url.toLocalFile() : path;
|
||||||
|
const QFileInfo info(localFilePath);
|
||||||
|
return info.exists() && info.isDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LLM::fileExists(const QString &path) const
|
||||||
|
{
|
||||||
|
const QUrl url(path);
|
||||||
|
const QString localFilePath = url.isLocalFile() ? url.toLocalFile() : path;
|
||||||
|
const QFileInfo info(localFilePath);
|
||||||
|
return info.exists() && info.isFile();
|
||||||
|
}
|
||||||
|
|
||||||
int32_t LLM::threadCount() const
|
int32_t LLM::threadCount() const
|
||||||
{
|
{
|
||||||
return m_threadCount;
|
return m_threadCount;
|
||||||
|
@ -25,6 +25,8 @@ public:
|
|||||||
bool compatHardware() const { return m_compatHardware; }
|
bool compatHardware() const { return m_compatHardware; }
|
||||||
|
|
||||||
Q_INVOKABLE bool checkForUpdates() const;
|
Q_INVOKABLE bool checkForUpdates() const;
|
||||||
|
Q_INVOKABLE bool directoryExists(const QString &path) const;
|
||||||
|
Q_INVOKABLE bool fileExists(const QString &path) const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void chatListModelChanged();
|
void chatListModelChanged();
|
||||||
|
@ -9,8 +9,8 @@ import localdocs
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string collection: ""
|
property alias collection: collection.text
|
||||||
property string folder_path: ""
|
property alias folder_path: folderEdit.text
|
||||||
|
|
||||||
property int defaultChunkSize: 256
|
property int defaultChunkSize: 256
|
||||||
property int defaultRetrievalSize: 3
|
property int defaultRetrievalSize: 3
|
||||||
@ -60,24 +60,19 @@ Item {
|
|||||||
placeholderTextColor: theme.mutedTextColor
|
placeholderTextColor: theme.mutedTextColor
|
||||||
ToolTip.text: qsTr("Name of the collection to add (Required)")
|
ToolTip.text: qsTr("Name of the collection to add (Required)")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
onEditingFinished: {
|
|
||||||
root.collection = text
|
|
||||||
}
|
|
||||||
Accessible.role: Accessible.EditableText
|
Accessible.role: Accessible.EditableText
|
||||||
Accessible.name: collection.text
|
Accessible.name: collection.text
|
||||||
Accessible.description: ToolTip.text
|
Accessible.description: ToolTip.text
|
||||||
}
|
}
|
||||||
|
|
||||||
MyTextField {
|
MyDirectoryField {
|
||||||
id: folderLabel
|
id: folderEdit
|
||||||
anchors.left: collection.right
|
anchors.left: collection.right
|
||||||
anchors.leftMargin: 10
|
anchors.leftMargin: 10
|
||||||
anchors.right: browseButton.left
|
anchors.right: browseButton.left
|
||||||
anchors.rightMargin: 10
|
anchors.rightMargin: 10
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: root.folder_path
|
text: root.folder_path
|
||||||
readOnly: true
|
|
||||||
color: theme.textColor
|
|
||||||
placeholderText: qsTr("Folder path...")
|
placeholderText: qsTr("Folder path...")
|
||||||
placeholderTextColor: theme.mutedTextColor
|
placeholderTextColor: theme.mutedTextColor
|
||||||
ToolTip.text: qsTr("Folder path to documents (Required)")
|
ToolTip.text: qsTr("Folder path to documents (Required)")
|
||||||
@ -100,7 +95,7 @@ Item {
|
|||||||
text: qsTr("Add")
|
text: qsTr("Add")
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
enabled: root.collection !== "" && root.folder_path != ""
|
enabled: root.collection !== "" && root.folder_path !== "" && folderEdit.isValid
|
||||||
Accessible.role: Accessible.Button
|
Accessible.role: Accessible.Button
|
||||||
Accessible.name: text
|
Accessible.name: text
|
||||||
Accessible.description: qsTr("Add button")
|
Accessible.description: qsTr("Add button")
|
||||||
|
@ -386,7 +386,8 @@ Dialog {
|
|||||||
title: "Please choose a directory"
|
title: "Please choose a directory"
|
||||||
currentFolder: "file://" + Download.downloadLocalModelsPath
|
currentFolder: "file://" + Download.downloadLocalModelsPath
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
Download.downloadLocalModelsPath = selectedFolder
|
modelPathDisplayField.text = selectedFolder
|
||||||
|
Download.downloadLocalModelsPath = modelPathDisplayField.text
|
||||||
settings.modelPath = Download.downloadLocalModelsPath
|
settings.modelPath = Download.downloadLocalModelsPath
|
||||||
settings.sync()
|
settings.sync()
|
||||||
}
|
}
|
||||||
@ -398,20 +399,23 @@ Dialog {
|
|||||||
Layout.row: 1
|
Layout.row: 1
|
||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
MyDirectoryField {
|
||||||
id: modelPathDisplayLabel
|
id: modelPathDisplayField
|
||||||
text: Download.downloadLocalModelsPath
|
text: Download.downloadLocalModelsPath
|
||||||
readOnly: true
|
|
||||||
color: theme.textColor
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
ToolTip.text: qsTr("Path where model files will be downloaded to")
|
ToolTip.text: qsTr("Path where model files will be downloaded to")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
Accessible.role: Accessible.ToolTip
|
Accessible.role: Accessible.ToolTip
|
||||||
Accessible.name: modelPathDisplayLabel.text
|
Accessible.name: modelPathDisplayField.text
|
||||||
Accessible.description: ToolTip.text
|
Accessible.description: ToolTip.text
|
||||||
background: Rectangle {
|
onEditingFinished: {
|
||||||
color: theme.backgroundLighter
|
if (isValid) {
|
||||||
radius: 10
|
Download.downloadLocalModelsPath = modelPathDisplayField.text
|
||||||
|
settings.modelPath = Download.downloadLocalModelsPath
|
||||||
|
settings.sync()
|
||||||
|
} else {
|
||||||
|
text = Download.downloadLocalModelsPath
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MyButton {
|
MyButton {
|
||||||
|
17
gpt4all-chat/qml/MyDirectoryField.qml
Normal file
17
gpt4all-chat/qml/MyDirectoryField.qml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import QtCore
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Controls.Basic
|
||||||
|
import llm
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: myDirectoryField
|
||||||
|
padding: 10
|
||||||
|
property bool isValid: LLM.directoryExists(text)
|
||||||
|
color: text === "" || isValid ? theme.textColor : theme.textErrorColor
|
||||||
|
background: Rectangle {
|
||||||
|
implicitWidth: 150
|
||||||
|
color: theme.backgroundLighter
|
||||||
|
radius: 10
|
||||||
|
}
|
||||||
|
}
|
@ -651,7 +651,8 @@ Dialog {
|
|||||||
title: "Please choose a directory"
|
title: "Please choose a directory"
|
||||||
currentFolder: "file://" + Download.downloadLocalModelsPath
|
currentFolder: "file://" + Download.downloadLocalModelsPath
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
Download.downloadLocalModelsPath = selectedFolder
|
modelPathDisplayField.text = selectedFolder
|
||||||
|
Download.downloadLocalModelsPath = modelPathDisplayField.text
|
||||||
settings.modelPath = Download.downloadLocalModelsPath
|
settings.modelPath = Download.downloadLocalModelsPath
|
||||||
settings.sync()
|
settings.sync()
|
||||||
}
|
}
|
||||||
@ -663,24 +664,26 @@ Dialog {
|
|||||||
Layout.row: 2
|
Layout.row: 2
|
||||||
Layout.column: 0
|
Layout.column: 0
|
||||||
}
|
}
|
||||||
TextField {
|
MyDirectoryField {
|
||||||
id: modelPathDisplayLabel
|
id: modelPathDisplayField
|
||||||
text: Download.downloadLocalModelsPath
|
text: Download.downloadLocalModelsPath
|
||||||
readOnly: true
|
|
||||||
color: theme.textColor
|
|
||||||
implicitWidth: 300
|
implicitWidth: 300
|
||||||
padding: 10
|
|
||||||
Layout.row: 2
|
Layout.row: 2
|
||||||
Layout.column: 1
|
Layout.column: 1
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
ToolTip.text: qsTr("Path where model files will be downloaded to")
|
ToolTip.text: qsTr("Path where model files will be downloaded to")
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
Accessible.role: Accessible.ToolTip
|
Accessible.role: Accessible.ToolTip
|
||||||
Accessible.name: modelPathDisplayLabel.text
|
Accessible.name: modelPathDisplayField.text
|
||||||
Accessible.description: ToolTip.text
|
Accessible.description: ToolTip.text
|
||||||
background: Rectangle {
|
onEditingFinished: {
|
||||||
color: theme.backgroundLighter
|
if (isValid) {
|
||||||
radius: 10
|
Download.downloadLocalModelsPath = modelPathDisplayField.text
|
||||||
|
settings.modelPath = Download.downloadLocalModelsPath
|
||||||
|
settings.sync()
|
||||||
|
} else {
|
||||||
|
text = Download.downloadLocalModelsPath
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MyButton {
|
MyButton {
|
||||||
|
Loading…
Reference in New Issue
Block a user