From ee2c3950e8ce1bb88b91c6aa7d9dd1047d4e1cf1 Mon Sep 17 00:00:00 2001 From: Petr Mironychev <9195189+Palm1r@users.noreply.github.com> Date: Mon, 23 Dec 2024 23:17:43 +0100 Subject: [PATCH] fix: path to chat file without project --- ChatView/ChatModel.cpp | 1 + ChatView/ChatModel.hpp | 1 + ChatView/ChatRootView.cpp | 7 ++----- settings/ProjectSettings.cpp | 8 ++++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChatView/ChatModel.cpp b/ChatView/ChatModel.cpp index 4740aa6..102095e 100644 --- a/ChatView/ChatModel.cpp +++ b/ChatView/ChatModel.cpp @@ -121,6 +121,7 @@ void ChatModel::clear() m_totalTokens = 0; endResetModel(); emit totalTokensChanged(); + emit modelReseted(); } QList ChatModel::processMessageContent(const QString &content) const diff --git a/ChatView/ChatModel.hpp b/ChatView/ChatModel.hpp index 2be2563..2bc0369 100644 --- a/ChatView/ChatModel.hpp +++ b/ChatView/ChatModel.hpp @@ -71,6 +71,7 @@ class ChatModel : public QAbstractListModel signals: void totalTokensChanged(); void tokensThresholdChanged(); + void modelReseted(); private: void trim(); diff --git a/ChatView/ChatRootView.cpp b/ChatView/ChatRootView.cpp index 3aac9fe..93fd2eb 100644 --- a/ChatView/ChatRootView.cpp +++ b/ChatView/ChatRootView.cpp @@ -60,6 +60,8 @@ ChatRootView::ChatRootView(QQuickItem *parent) this, &ChatRootView::autosave); + connect(m_chatModel, &ChatModel::modelReseted, [this]() { m_recentFilePath = QString(); }); + generateColors(); } @@ -251,11 +253,6 @@ QString ChatRootView::getSuggestedFileName() const { QStringList parts; - if (auto project = ProjectExplorer::ProjectManager::startupProject()) { - QString projectName = project->projectDirectory().fileName(); - parts << projectName; - } - if (m_chatModel->rowCount() > 0) { QString firstMessage = m_chatModel->data(m_chatModel->index(0), ChatModel::Content).toString(); diff --git a/settings/ProjectSettings.cpp b/settings/ProjectSettings.cpp index b5edfe0..4be7392 100644 --- a/settings/ProjectSettings.cpp +++ b/settings/ProjectSettings.cpp @@ -22,6 +22,7 @@ #include "GeneralSettings.hpp" #include "SettingsConstants.hpp" #include "SettingsTr.hpp" +#include #include namespace QodeAssist::Settings { @@ -41,8 +42,11 @@ ProjectSettings::ProjectSettings(ProjectExplorer::Project *project) chatHistoryPath.setSettingsKey(Constants::QODE_ASSIST_CHAT_HISTORY_PATH); chatHistoryPath.setExpectedKind(Utils::PathChooser::ExistingDirectory); chatHistoryPath.setLabelText(Tr::tr("Chat History Path:")); - chatHistoryPath.setDefaultValue( - project->projectDirectory().toString() + "/.qodeassist/chat_history"); + + QString projectChatHistoryPath + = QString("%1/qodeassist/chat_history").arg(Core::ICore::userResourcePath().toString()); + + chatHistoryPath.setDefaultValue(projectChatHistoryPath); Utils::Store map = Utils::storeFromVariant( project->namedSettings(Constants::QODE_ASSIST_PROJECT_SETTINGS_ID));