From 6256b4fd337321f7647b4705de66f56092794a58 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Thu, 27 Apr 2023 16:27:53 -0400 Subject: [PATCH] Have to be able to change the download path from the download dialog and other fixes. --- download.cpp | 5 ++- qml/ModelDownloaderDialog.qml | 85 ++++++++++++++++++++++++++++++----- qml/SettingsDialog.qml | 7 +-- qml/ThumbsDownDialog.qml | 1 + 4 files changed, 82 insertions(+), 16 deletions(-) diff --git a/download.cpp b/download.cpp index 0caf118d..6b4bf907 100644 --- a/download.cpp +++ b/download.cpp @@ -30,7 +30,10 @@ Download::Download() &Download::handleSslErrors); connect(this, &Download::downloadLocalModelsPathChanged, this, &Download::updateModelList); updateModelList(); - m_downloadLocalModelsPath = defaultLocalModelsPath(); + QSettings settings; + settings.sync(); + m_downloadLocalModelsPath = settings.value("modelPath", + defaultLocalModelsPath()).toString(); } bool operator==(const ModelInfo& lhs, const ModelInfo& rhs) { diff --git a/qml/ModelDownloaderDialog.qml b/qml/ModelDownloaderDialog.qml index 414724f3..1222b9c4 100644 --- a/qml/ModelDownloaderDialog.qml +++ b/qml/ModelDownloaderDialog.qml @@ -1,6 +1,8 @@ +import QtCore import QtQuick import QtQuick.Controls import QtQuick.Controls.Basic +import QtQuick.Dialogs import QtQuick.Layouts import download import llm @@ -82,6 +84,7 @@ Dialog { id: description text: " - " + modelData.description leftPadding: 20 + rightPadding: 20 anchors.top: modelName.bottom anchors.left: modelName.left anchors.right: parent.right @@ -135,7 +138,8 @@ Dialog { objectName: "itemProgressBar" anchors.top: modelName.top anchors.right: downloadButton.left - padding: 20 + anchors.topMargin: 20 + anchors.rightMargin: 20 width: 100 visible: downloading background: Rectangle { @@ -153,7 +157,7 @@ Dialog { width: itemProgressBar.visualPosition * parent.width height: parent.height radius: 2 - color: theme.backgroundLightest + color: theme.assistantColor } } Accessible.role: Accessible.ProgressBar @@ -211,7 +215,8 @@ Dialog { } anchors.top: modelName.top anchors.right: parent.right - padding: 20 + anchors.topMargin: 15 + anchors.rightMargin: 20 visible: !modelData.installed && !modelData.calcHash onClicked: { if (!downloading) { @@ -303,16 +308,72 @@ Dialog { } } - Label { - Layout.alignment: Qt.AlignLeft + property string defaultModelPath: Download.defaultLocalModelsPath() + property alias modelPath: settings.modelPath + Settings { + id: settings + property string modelPath: settingsDialog.defaultModelPath + } + + Component.onCompleted: { + Download.downloadLocalModelsPath = settings.modelPath + } + + Component.onDestruction: { + settings.sync() + } + + RowLayout { + Layout.alignment: Qt.AlignCenter Layout.fillWidth: true - text: qsTr("NOTE: models will be downloaded to\n") + Download.downloadLocalModelsPath - wrapMode: Text.WrapAnywhere - horizontalAlignment: Text.AlignHCenter - color: theme.textColor - Accessible.role: Accessible.Paragraph - Accessible.name: qsTr("Model download path") - Accessible.description: qsTr("The path where downloaded models will be saved.") + spacing: 20 + FolderDialog { + id: modelPathDialog + title: "Please choose a directory" + onAccepted: { + Download.downloadLocalModelsPath = selectedFolder + settings.modelPath = Download.downloadLocalModelsPath + settings.sync() + } + } + Label { + id: modelPathLabel + text: qsTr("Download path:") + color: theme.textColor + Layout.row: 1 + Layout.column: 0 + } + TextField { + id: modelPathDisplayLabel + text: Download.downloadLocalModelsPath + readOnly: true + color: theme.textColor + Layout.fillWidth: true + ToolTip.text: qsTr("Path where model files will be downloaded to") + ToolTip.visible: hovered + Accessible.role: Accessible.ToolTip + Accessible.name: modelPathDisplayLabel.text + Accessible.description: ToolTip.text + } + Button { + text: qsTr("Browse") + contentItem: Text { + text: qsTr("Browse") + horizontalAlignment: Text.AlignHCenter + color: theme.textColor + Accessible.role: Accessible.Button + Accessible.name: text + Accessible.description: qsTr("Opens a folder picker dialog to choose where to save model files") + } + background: Rectangle { + opacity: .5 + border.color: theme.backgroundLightest + border.width: 1 + radius: 10 + color: theme.backgroundLight + } + onClicked: modelPathDialog.open() + } } } } diff --git a/qml/SettingsDialog.qml b/qml/SettingsDialog.qml index 71f87120..ea079761 100644 --- a/qml/SettingsDialog.qml +++ b/qml/SettingsDialog.qml @@ -11,8 +11,8 @@ import llm Dialog { id: settingsDialog modal: true + width: 1024 height: 600 - width: 600 opacity: 0.9 background: Rectangle { anchors.fill: parent @@ -537,7 +537,7 @@ The prompt below is a question to answer, a task to complete, or a conversation } Label { id: modelPathLabel - text: qsTr("Model file path:") + text: qsTr("Download path:") color: theme.textColor Layout.row: 1 Layout.column: 0 @@ -550,10 +550,11 @@ The prompt below is a question to answer, a task to complete, or a conversation implicitWidth: 300 Layout.row: 1 Layout.column: 1 + Layout.fillWidth: true ToolTip.text: qsTr("Path where model files will be downloaded to") ToolTip.visible: hovered Accessible.role: Accessible.ToolTip - Accessible.name: topKLabel.text + Accessible.name: modelPathDisplayLabel.text Accessible.description: ToolTip.text } Button { diff --git a/qml/ThumbsDownDialog.qml b/qml/ThumbsDownDialog.qml index e36ca8e4..abc98073 100644 --- a/qml/ThumbsDownDialog.qml +++ b/qml/ThumbsDownDialog.qml @@ -19,6 +19,7 @@ Dialog { } property alias response: thumbsDownNewResponse.text + Column { anchors.fill: parent spacing: 20