feat: Add default option for custom instructions

This commit is contained in:
Petr Mironychev
2025-11-17 15:54:35 +01:00
parent 944e7fb00a
commit f3aa706227
5 changed files with 52 additions and 1 deletions

View File

@ -320,9 +320,16 @@ void QuickRefactorDialog::loadCustomCommands()
const QVector<CustomInstruction> &instructions = manager.instructions();
QStringList instructionNames;
for (const CustomInstruction &instruction : instructions) {
int defaultInstructionIndex = -1;
for (int i = 0; i < instructions.size(); ++i) {
const CustomInstruction &instruction = instructions[i];
m_commandsComboBox->addItem(instruction.name, instruction.id);
instructionNames.append(instruction.name);
if (instruction.isDefault) {
defaultInstructionIndex = i + 1;
}
}
if (m_commandsComboBox->completer()) {
@ -330,6 +337,10 @@ void QuickRefactorDialog::loadCustomCommands()
m_commandsComboBox->completer()->setModel(model);
}
if (defaultInstructionIndex > 0) {
m_commandsComboBox->setCurrentIndex(defaultInstructionIndex);
}
bool hasInstructions = !instructions.isEmpty();
m_editCommandButton->setEnabled(hasInstructions);
m_deleteCommandButton->setEnabled(hasInstructions);