feat: Add quick refactor command via context menu (#161)

* feat: Add quick refactor command via context menu
* feat: Add settings for Quick Refactor
This commit is contained in:
Petr Mironychev
2025-04-14 01:01:44 +02:00
committed by GitHub
parent 418578743a
commit bacde51d71
9 changed files with 497 additions and 3 deletions

View File

@ -218,6 +218,18 @@ CodeCompletionSettings::CodeCompletionSettings()
maxChangesCacheSize.setRange(2, 1000);
maxChangesCacheSize.setDefaultValue(10);
// Quick refactor command settings
useOpenFilesInQuickRefactor.setSettingsKey(Constants::CC_USE_OPEN_FILES_IN_QUICK_REFACTOR);
useOpenFilesInQuickRefactor.setLabelText(
Tr::tr("Include context from open files in quick refactor"));
useOpenFilesInQuickRefactor.setDefaultValue(false);
quickRefactorSystemPrompt.setSettingsKey(Constants::CC_QUICK_REFACTOR_SYSTEM_PROMPT);
quickRefactorSystemPrompt.setDisplayStyle(Utils::StringAspect::TextEditDisplay);
quickRefactorSystemPrompt.setDefaultValue(
"You are an expert C++, Qt, and QML code completion assistant. Your task is to provide"
"precise and contextually appropriate code completions to insert depending on user "
"instructions.\n\n");
// Ollama Settings
ollamaLivetime.setSettingsKey(Constants::CC_OLLAMA_LIVETIME);
ollamaLivetime.setToolTip(
@ -303,6 +315,10 @@ CodeCompletionSettings::CodeCompletionSettings()
Space{8},
Group{title(Tr::tr("Context Settings")), contextItem},
Space{8},
Group{
title(Tr::tr("Quick Refactor Settings")),
Column{useOpenFilesInQuickRefactor, quickRefactorSystemPrompt}},
Space{8},
Group{title(Tr::tr("Ollama Settings")), Column{Row{ollamaGrid, Stretch{1}}}},
Stretch{1}};
});
@ -371,6 +387,8 @@ void CodeCompletionSettings::resetSettingsToDefaults()
resetAspect(customLanguages);
resetAspect(showProgressWidget);
resetAspect(useOpenFilesContext);
resetAspect(useOpenFilesInQuickRefactor);
resetAspect(quickRefactorSystemPrompt);
}
}

View File

@ -77,6 +77,10 @@ public:
Utils::BoolAspect useProjectChangesCache{this};
Utils::IntegerAspect maxChangesCacheSize{this};
// Quick refactor command settings
Utils::BoolAspect useOpenFilesInQuickRefactor{this};
Utils::StringAspect quickRefactorSystemPrompt{this};
// Ollama Settings
Utils::StringAspect ollamaLivetime{this};
Utils::IntegerAspect contextWindow{this};

View File

@ -120,6 +120,10 @@ const char CC_MAX_CHANGES_CACHE_SIZE[] = "QodeAssist.ccMaxChangesCacheSize";
const char CA_USE_SYSTEM_PROMPT[] = "QodeAssist.useChatSystemPrompt";
const char CA_SYSTEM_PROMPT[] = "QodeAssist.chatSystemPrompt";
// quick refactor command settings
const char CC_QUICK_REFACTOR_SYSTEM_PROMPT[] = "QodeAssist.ccQuickRefactorSystemPrompt";
const char CC_USE_OPEN_FILES_IN_QUICK_REFACTOR[] = "QodeAssist.ccUseOpenFilesInQuickRefactor";
// preset prompt settings
const char CC_TEMPERATURE[] = "QodeAssist.ccTemperature";
const char CC_MAX_TOKENS[] = "QodeAssist.ccMaxTokens";