refactor: Change quick refactor ui layout

This commit is contained in:
Petr Mironychev
2026-01-20 18:08:49 +01:00
parent 6f11260cd1
commit b32433c336
2 changed files with 153 additions and 131 deletions

View File

@ -73,15 +73,15 @@ static QIcon createThemedIcon(const QString &svgPath, const QColor &color)
painter.end(); painter.end();
QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
uchar *bits = image.bits(); uchar *bits = image.bits();
const int bytesPerPixel = 4; const int bytesPerPixel = 4;
const int totalBytes = image.width() * image.height() * bytesPerPixel; const int totalBytes = image.width() * image.height() * bytesPerPixel;
const int newR = color.red(); const int newR = color.red();
const int newG = color.green(); const int newG = color.green();
const int newB = color.blue(); const int newB = color.blue();
for (int i = 0; i < totalBytes; i += bytesPerPixel) { for (int i = 0; i < totalBytes; i += bytesPerPixel) {
int alpha = bits[i + 3]; int alpha = bits[i + 3];
if (alpha > 0) { if (alpha > 0) {
@ -101,12 +101,17 @@ QuickRefactorDialog::QuickRefactorDialog(QWidget *parent, const QString &lastIns
setWindowTitle(Tr::tr("Quick Refactor")); setWindowTitle(Tr::tr("Quick Refactor"));
setupUi(); setupUi();
if (!m_lastInstructions.isEmpty()) {
m_instructionEdit->setPlainText(m_lastInstructions);
m_instructionEdit->selectAll();
}
QTimer::singleShot(0, this, &QuickRefactorDialog::updateDialogSize); QTimer::singleShot(0, this, &QuickRefactorDialog::updateDialogSize);
m_quickInstructionEdit->installEventFilter(this); m_instructionEdit->installEventFilter(this);
m_textEdit->installEventFilter(this); m_commandsComboBox->installEventFilter(this);
updateDialogSize(); updateDialogSize();
m_quickInstructionEdit->setFocus(); m_instructionEdit->setFocus();
} }
void QuickRefactorDialog::setupUi() void QuickRefactorDialog::setupUi()
@ -175,58 +180,65 @@ void QuickRefactorDialog::setupUi()
mainLayout->addLayout(actionsLayout); mainLayout->addLayout(actionsLayout);
QLabel *quickInstructionLabel = new QLabel(Tr::tr("Quick Instruction:"), this); QLabel *instructionLabel = new QLabel(Tr::tr("Your Current Instruction:"), this);
mainLayout->addWidget(quickInstructionLabel); mainLayout->addWidget(instructionLabel);
m_quickInstructionEdit = new QLineEdit(this); m_instructionEdit = new QPlainTextEdit(this);
m_quickInstructionEdit->setPlaceholderText(Tr::tr("Type your instruction here...")); m_instructionEdit->setMinimumHeight(80);
mainLayout->addWidget(m_quickInstructionEdit); m_instructionEdit->setPlaceholderText(Tr::tr("Type or edit your instruction..."));
mainLayout->addWidget(m_instructionEdit);
QHBoxLayout *savedInstructionsLayout = new QHBoxLayout(); QHBoxLayout *savedInstructionsLayout = new QHBoxLayout();
savedInstructionsLayout->setSpacing(4); savedInstructionsLayout->setSpacing(4);
QLabel *savedLabel = new QLabel(Tr::tr("Or select saved:"), this); QLabel *savedLabel = new QLabel(Tr::tr("Or Load saved:"), this);
savedInstructionsLayout->addWidget(savedLabel); savedInstructionsLayout->addWidget(savedLabel);
m_commandsComboBox = new QComboBox(this); m_commandsComboBox = new QComboBox(this);
m_commandsComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_commandsComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
m_commandsComboBox->setEditable(true);
m_commandsComboBox->setInsertPolicy(QComboBox::NoInsert);
m_commandsComboBox->lineEdit()->setPlaceholderText(Tr::tr("Search saved instructions..."));
QCompleter *completer = new QCompleter(this);
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setFilterMode(Qt::MatchContains);
m_commandsComboBox->setCompleter(completer);
savedInstructionsLayout->addWidget(m_commandsComboBox); savedInstructionsLayout->addWidget(m_commandsComboBox);
m_addCommandButton = new QToolButton(this); m_addCommandButton = new QToolButton(this);
m_addCommandButton->setText("+"); m_addCommandButton->setText("+");
m_addCommandButton->setToolTip(Tr::tr("Add Custom Instruction")); m_addCommandButton->setToolTip(Tr::tr("Add Custom Instruction"));
m_addCommandButton->setFocusPolicy(Qt::NoFocus);
savedInstructionsLayout->addWidget(m_addCommandButton); savedInstructionsLayout->addWidget(m_addCommandButton);
m_editCommandButton = new QToolButton(this); m_editCommandButton = new QToolButton(this);
m_editCommandButton->setText(""); m_editCommandButton->setText("");
m_editCommandButton->setToolTip(Tr::tr("Edit Custom Instruction")); m_editCommandButton->setToolTip(Tr::tr("Edit Custom Instruction"));
m_editCommandButton->setFocusPolicy(Qt::NoFocus);
savedInstructionsLayout->addWidget(m_editCommandButton); savedInstructionsLayout->addWidget(m_editCommandButton);
m_deleteCommandButton = new QToolButton(this); m_deleteCommandButton = new QToolButton(this);
m_deleteCommandButton->setText(""); m_deleteCommandButton->setText("");
m_deleteCommandButton->setToolTip(Tr::tr("Delete Custom Instruction")); m_deleteCommandButton->setToolTip(Tr::tr("Delete Custom Instruction"));
m_deleteCommandButton->setFocusPolicy(Qt::NoFocus);
savedInstructionsLayout->addWidget(m_deleteCommandButton); savedInstructionsLayout->addWidget(m_deleteCommandButton);
m_openFolderButton = new QToolButton(this); m_openFolderButton = new QToolButton(this);
m_openFolderButton->setText("📁"); m_openFolderButton->setText("📁");
m_openFolderButton->setToolTip(Tr::tr("Open Instructions Folder")); m_openFolderButton->setToolTip(Tr::tr("Open Instructions Folder"));
m_openFolderButton->setFocusPolicy(Qt::NoFocus);
savedInstructionsLayout->addWidget(m_openFolderButton); savedInstructionsLayout->addWidget(m_openFolderButton);
mainLayout->addLayout(savedInstructionsLayout); mainLayout->addLayout(savedInstructionsLayout);
QFrame *separator = new QFrame(this); connect(
separator->setFrameShape(QFrame::HLine); m_instructionEdit,
separator->setFrameShadow(QFrame::Sunken); &QPlainTextEdit::textChanged,
mainLayout->addWidget(separator); this,
&QuickRefactorDialog::updateDialogSize);
m_instructionsLabel = new QLabel(Tr::tr("Additional Context (optional):"), this);
mainLayout->addWidget(m_instructionsLabel);
m_textEdit = new QPlainTextEdit(this);
m_textEdit->setMinimumHeight(60);
m_textEdit->setPlaceholderText(Tr::tr("Add extra details or context..."));
connect(m_textEdit, &QPlainTextEdit::textChanged, this, &QuickRefactorDialog::updateDialogSize);
connect( connect(
m_commandsComboBox, m_commandsComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged), QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -246,8 +258,6 @@ void QuickRefactorDialog::setupUi()
this, this,
&QuickRefactorDialog::onOpenInstructionsFolder); &QuickRefactorDialog::onOpenInstructionsFolder);
mainLayout->addWidget(m_textEdit);
loadCustomCommands(); loadCustomCommands();
loadAvailableConfigurations(); loadAvailableConfigurations();
@ -259,9 +269,23 @@ void QuickRefactorDialog::setupUi()
QDialogButtonBox *buttonBox QDialogButtonBox *buttonBox
= new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::accepted, this, &QuickRefactorDialog::validateAndAccept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
mainLayout->addWidget(buttonBox); mainLayout->addWidget(buttonBox);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
QPushButton *cancelButton = buttonBox->button(QDialogButtonBox::Cancel);
if (okButton) {
okButton->installEventFilter(this);
}
if (cancelButton) {
cancelButton->installEventFilter(this);
}
setTabOrder(m_instructionEdit, m_commandsComboBox);
setTabOrder(m_commandsComboBox, okButton);
setTabOrder(okButton, cancelButton);
} }
void QuickRefactorDialog::createActionButtons() void QuickRefactorDialog::createActionButtons()
@ -296,27 +320,12 @@ void QuickRefactorDialog::createActionButtons()
QString QuickRefactorDialog::instructions() const QString QuickRefactorDialog::instructions() const
{ {
QString result; return m_instructionEdit->toPlainText().trimmed();
QString quickInstruction = m_quickInstructionEdit->text().trimmed();
if (!quickInstruction.isEmpty()) {
result = quickInstruction;
}
QString additionalText = m_textEdit->toPlainText().trimmed();
if (!additionalText.isEmpty()) {
if (!result.isEmpty()) {
result += "\n\n";
}
result += additionalText;
}
return result;
} }
void QuickRefactorDialog::setInstructions(const QString &instructions) void QuickRefactorDialog::setInstructions(const QString &instructions)
{ {
m_quickInstructionEdit->setText(instructions); m_instructionEdit->setPlainText(instructions);
} }
QuickRefactorDialog::Action QuickRefactorDialog::selectedAction() const QuickRefactorDialog::Action QuickRefactorDialog::selectedAction() const
@ -324,19 +333,31 @@ QuickRefactorDialog::Action QuickRefactorDialog::selectedAction() const
return m_selectedAction; return m_selectedAction;
} }
void QuickRefactorDialog::keyPressEvent(QKeyEvent *event)
{
QDialog::keyPressEvent(event);
}
bool QuickRefactorDialog::eventFilter(QObject *watched, QEvent *event) bool QuickRefactorDialog::eventFilter(QObject *watched, QEvent *event)
{ {
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) {
if (watched == m_quickInstructionEdit) { if (watched == m_instructionEdit) {
accept(); if (keyEvent->key() == Qt::Key_Tab) {
m_commandsComboBox->setFocus();
return true; return true;
} else if (watched == m_textEdit) { }
if (keyEvent->modifiers() & Qt::ShiftModifier) { }
return false;
if (watched == m_commandsComboBox || watched == m_commandsComboBox->lineEdit()) {
if (keyEvent->key() == Qt::Key_Tab) {
QPushButton *okButton = findChild<QPushButton *>();
if (okButton && okButton->text() == "OK") {
okButton->setFocus();
} else {
focusNextChild();
} }
accept();
return true; return true;
} }
} }
@ -348,8 +369,7 @@ void QuickRefactorDialog::useLastInstructions()
{ {
if (!m_lastInstructions.isEmpty()) { if (!m_lastInstructions.isEmpty()) {
m_commandsComboBox->setCurrentIndex(0); m_commandsComboBox->setCurrentIndex(0);
m_quickInstructionEdit->setText(m_lastInstructions); m_instructionEdit->setPlainText(m_lastInstructions);
m_textEdit->clear();
m_selectedAction = Action::RepeatLast; m_selectedAction = Action::RepeatLast;
} }
accept(); accept();
@ -358,10 +378,10 @@ void QuickRefactorDialog::useLastInstructions()
void QuickRefactorDialog::useImproveCodeTemplate() void QuickRefactorDialog::useImproveCodeTemplate()
{ {
m_commandsComboBox->setCurrentIndex(0); m_commandsComboBox->setCurrentIndex(0);
m_quickInstructionEdit->setText(Tr::tr( m_instructionEdit->setPlainText(
"Improve the selected code by enhancing readability, efficiency, and maintainability. " Tr::tr(
"Follow best practices for C++/Qt and fix any potential issues.")); "Improve the selected code by enhancing readability, efficiency, and maintainability. "
m_textEdit->clear(); "Follow best practices for C++/Qt and fix any potential issues."));
m_selectedAction = Action::ImproveCode; m_selectedAction = Action::ImproveCode;
accept(); accept();
} }
@ -369,36 +389,29 @@ void QuickRefactorDialog::useImproveCodeTemplate()
void QuickRefactorDialog::useAlternativeSolutionTemplate() void QuickRefactorDialog::useAlternativeSolutionTemplate()
{ {
m_commandsComboBox->setCurrentIndex(0); m_commandsComboBox->setCurrentIndex(0);
m_quickInstructionEdit->setText( m_instructionEdit->setPlainText(
Tr::tr("Suggest an alternative implementation approach for the selected code. " Tr::tr(
"Provide a different solution that might be cleaner, more efficient, " "Suggest an alternative implementation approach for the selected code. "
"or uses different Qt/C++ patterns or idioms.")); "Provide a different solution that might be cleaner, more efficient, "
m_textEdit->clear(); "or uses different Qt/C++ patterns or idioms."));
m_selectedAction = Action::AlternativeSolution; m_selectedAction = Action::AlternativeSolution;
accept(); accept();
} }
void QuickRefactorDialog::updateDialogSize() void QuickRefactorDialog::updateDialogSize()
{ {
QString text = m_textEdit->toPlainText(); QString text = m_instructionEdit->toPlainText();
QFontMetrics fm(m_textEdit->font()); QFontMetrics fm(m_instructionEdit->font());
QStringList lines = text.split('\n'); QStringList lines = text.split('\n');
int lineCount = lines.size(); int lineCount = qMax(lines.size(), 3);
if (lineCount <= 1) { m_instructionEdit->setMaximumHeight(QWIDGETSIZE_MAX);
int singleLineHeight = fm.height() + 10;
m_textEdit->setMinimumHeight(singleLineHeight);
m_textEdit->setMaximumHeight(singleLineHeight);
} else {
m_textEdit->setMaximumHeight(QWIDGETSIZE_MAX);
int lineHeight = fm.height() + 2; int lineHeight = fm.height() + 2;
int textEditHeight = qMin(qMax(lineCount, 3) * lineHeight, 15 * lineHeight);
int textEditHeight = qMin(qMax(lineCount, 2) * lineHeight, 20 * lineHeight); m_instructionEdit->setMinimumHeight(textEditHeight);
m_textEdit->setMinimumHeight(textEditHeight);
}
int maxWidth = 500; int maxWidth = 500;
for (const QString &line : lines) { for (const QString &line : lines) {
@ -410,14 +423,7 @@ void QuickRefactorDialog::updateDialogSize()
QRect screenGeometry = screen->availableGeometry(); QRect screenGeometry = screen->availableGeometry();
int newWidth = qMin(maxWidth + 40, screenGeometry.width() * 3 / 4); int newWidth = qMin(maxWidth + 40, screenGeometry.width() * 3 / 4);
int newHeight = qMin(m_instructionEdit->minimumHeight() + 200, screenGeometry.height() * 3 / 4);
int newHeight;
if (lineCount <= 1) {
newHeight = 150;
} else {
newHeight = m_textEdit->minimumHeight() + 150;
}
newHeight = qMin(newHeight, screenGeometry.height() * 3 / 4);
resize(newWidth, newHeight); resize(newWidth, newHeight);
} }
@ -425,24 +431,21 @@ void QuickRefactorDialog::updateDialogSize()
void QuickRefactorDialog::loadCustomCommands() void QuickRefactorDialog::loadCustomCommands()
{ {
m_commandsComboBox->clear(); m_commandsComboBox->clear();
m_commandsComboBox->addItem(Tr::tr("-- Select saved instruction --"), QString()); m_commandsComboBox->addItem("", QString());
auto &manager = CustomInstructionsManager::instance(); auto &manager = CustomInstructionsManager::instance();
const QVector<CustomInstruction> &instructions = manager.instructions(); const QVector<CustomInstruction> &instructions = manager.instructions();
int defaultInstructionIndex = -1; QStringList instructionNames;
for (int i = 0; i < instructions.size(); ++i) { for (const CustomInstruction &instruction : instructions) {
const CustomInstruction &instruction = instructions[i];
m_commandsComboBox->addItem(instruction.name, instruction.id); m_commandsComboBox->addItem(instruction.name, instruction.id);
instructionNames.append(instruction.name);
if (instruction.isDefault) {
defaultInstructionIndex = i + 1;
}
} }
if (defaultInstructionIndex > 0) { if (m_commandsComboBox->completer()) {
m_commandsComboBox->setCurrentIndex(defaultInstructionIndex); QStringListModel *model = new QStringListModel(instructionNames, this);
m_commandsComboBox->completer()->setModel(model);
} }
bool hasInstructions = !instructions.isEmpty(); bool hasInstructions = !instructions.isEmpty();
@ -452,18 +455,29 @@ void QuickRefactorDialog::loadCustomCommands()
CustomInstruction QuickRefactorDialog::findCurrentInstruction() const CustomInstruction QuickRefactorDialog::findCurrentInstruction() const
{ {
int currentIndex = m_commandsComboBox->currentIndex(); QString currentText = m_commandsComboBox->currentText().trimmed();
if (currentIndex <= 0) { if (currentText.isEmpty()) {
return CustomInstruction();
}
QString instructionId = m_commandsComboBox->itemData(currentIndex).toString();
if (instructionId.isEmpty()) {
return CustomInstruction(); return CustomInstruction();
} }
auto &manager = CustomInstructionsManager::instance(); auto &manager = CustomInstructionsManager::instance();
return manager.getInstructionById(instructionId); const QVector<CustomInstruction> &instructions = manager.instructions();
for (const CustomInstruction &instruction : instructions) {
if (instruction.name == currentText) {
return instruction;
}
}
int currentIndex = m_commandsComboBox->currentIndex();
if (currentIndex > 0) {
QString instructionId = m_commandsComboBox->itemData(currentIndex).toString();
if (!instructionId.isEmpty()) {
return manager.getInstructionById(instructionId);
}
}
return CustomInstruction();
} }
void QuickRefactorDialog::onCommandSelected(int index) void QuickRefactorDialog::onCommandSelected(int index)
@ -474,7 +488,7 @@ void QuickRefactorDialog::onCommandSelected(int index)
CustomInstruction instruction = findCurrentInstruction(); CustomInstruction instruction = findCurrentInstruction();
if (!instruction.id.isEmpty()) { if (!instruction.id.isEmpty()) {
m_quickInstructionEdit->setText(instruction.body); m_instructionEdit->setPlainText(instruction.body);
} }
} }
@ -487,13 +501,7 @@ void QuickRefactorDialog::onAddCustomCommand()
if (manager.saveInstruction(instruction)) { if (manager.saveInstruction(instruction)) {
loadCustomCommands(); loadCustomCommands();
m_commandsComboBox->setCurrentText(instruction.name);
for (int i = 0; i < m_commandsComboBox->count(); ++i) {
if (m_commandsComboBox->itemData(i).toString() == instruction.id) {
m_commandsComboBox->setCurrentIndex(i);
break;
}
}
} else { } else {
QMessageBox::warning( QMessageBox::warning(
this, this,
@ -506,10 +514,12 @@ void QuickRefactorDialog::onAddCustomCommand()
void QuickRefactorDialog::onEditCustomCommand() void QuickRefactorDialog::onEditCustomCommand()
{ {
CustomInstruction instruction = findCurrentInstruction(); CustomInstruction instruction = findCurrentInstruction();
if (instruction.id.isEmpty()) { if (instruction.id.isEmpty()) {
QMessageBox::information( QMessageBox::information(
this, Tr::tr("No Instruction Selected"), Tr::tr("Please select an instruction to edit.")); this,
Tr::tr("No Instruction Selected"),
Tr::tr("Please select an instruction to edit."));
return; return;
} }
@ -520,13 +530,7 @@ void QuickRefactorDialog::onEditCustomCommand()
if (manager.saveInstruction(updatedInstruction)) { if (manager.saveInstruction(updatedInstruction)) {
loadCustomCommands(); loadCustomCommands();
m_commandsComboBox->setCurrentText(updatedInstruction.name);
for (int i = 0; i < m_commandsComboBox->count(); ++i) {
if (m_commandsComboBox->itemData(i).toString() == updatedInstruction.id) {
m_commandsComboBox->setCurrentIndex(i);
break;
}
}
} else { } else {
QMessageBox::warning( QMessageBox::warning(
this, this,
@ -539,10 +543,12 @@ void QuickRefactorDialog::onEditCustomCommand()
void QuickRefactorDialog::onDeleteCustomCommand() void QuickRefactorDialog::onDeleteCustomCommand()
{ {
CustomInstruction instruction = findCurrentInstruction(); CustomInstruction instruction = findCurrentInstruction();
if (instruction.id.isEmpty()) { if (instruction.id.isEmpty()) {
QMessageBox::information( QMessageBox::information(
this, Tr::tr("No Instruction Selected"), Tr::tr("Please select an instruction to delete.")); this,
Tr::tr("No Instruction Selected"),
Tr::tr("Please select an instruction to delete."));
return; return;
} }
@ -557,7 +563,7 @@ void QuickRefactorDialog::onDeleteCustomCommand()
if (manager.deleteInstruction(instruction.id)) { if (manager.deleteInstruction(instruction.id)) {
loadCustomCommands(); loadCustomCommands();
m_commandsComboBox->setCurrentIndex(0); m_commandsComboBox->setCurrentIndex(0);
m_quickInstructionEdit->clear(); m_commandsComboBox->clearEditText();
} else { } else {
QMessageBox::warning( QMessageBox::warning(
this, this,
@ -571,12 +577,12 @@ void QuickRefactorDialog::onOpenInstructionsFolder()
{ {
QString path = QString("%1/qodeassist/quick_refactor/instructions") QString path = QString("%1/qodeassist/quick_refactor/instructions")
.arg(Core::ICore::userResourcePath().toFSPathString()); .arg(Core::ICore::userResourcePath().toFSPathString());
QDir dir(path); QDir dir(path);
if (!dir.exists()) { if (!dir.exists()) {
dir.mkpath("."); dir.mkpath(".");
} }
QUrl url = QUrl::fromLocalFile(dir.absolutePath()); QUrl url = QUrl::fromLocalFile(dir.absolutePath());
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} }
@ -596,8 +602,8 @@ void QuickRefactorDialog::loadAvailableConfigurations()
auto &manager = Settings::ConfigurationManager::instance(); auto &manager = Settings::ConfigurationManager::instance();
manager.loadConfigurations(Settings::ConfigurationType::QuickRefactor); manager.loadConfigurations(Settings::ConfigurationType::QuickRefactor);
QVector<Settings::AIConfiguration> configs QVector<Settings::AIConfiguration> configs = manager.configurations(
= manager.configurations(Settings::ConfigurationType::QuickRefactor); Settings::ConfigurationType::QuickRefactor);
m_configComboBox->clear(); m_configComboBox->clear();
m_configComboBox->addItem(Tr::tr("Current"), QString()); m_configComboBox->addItem(Tr::tr("Current"), QString());
@ -642,4 +648,20 @@ void QuickRefactorDialog::onConfigurationChanged(int index)
} }
} }
void QuickRefactorDialog::validateAndAccept()
{
QString instruction = m_instructionEdit->toPlainText().trimmed();
if (instruction.isEmpty()) {
QMessageBox::warning(
this,
Tr::tr("No Instruction"),
Tr::tr("Please type an instruction or select a saved one."));
m_instructionEdit->setFocus();
return;
}
accept();
}
} // namespace QodeAssist } // namespace QodeAssist

View File

@ -51,6 +51,7 @@ public:
QString selectedConfiguration() const; QString selectedConfiguration() const;
bool eventFilter(QObject *watched, QEvent *event) override; bool eventFilter(QObject *watched, QEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
private slots: private slots:
void useLastInstructions(); void useLastInstructions();
@ -66,14 +67,14 @@ private slots:
void loadCustomCommands(); void loadCustomCommands();
void loadAvailableConfigurations(); void loadAvailableConfigurations();
void onConfigurationChanged(int index); void onConfigurationChanged(int index);
void validateAndAccept();
private: private:
void setupUi(); void setupUi();
void createActionButtons(); void createActionButtons();
CustomInstruction findCurrentInstruction() const; CustomInstruction findCurrentInstruction() const;
QLineEdit *m_quickInstructionEdit; QPlainTextEdit *m_instructionEdit;
QPlainTextEdit *m_textEdit;
QToolButton *m_repeatButton; QToolButton *m_repeatButton;
QToolButton *m_improveButton; QToolButton *m_improveButton;
QToolButton *m_alternativeButton; QToolButton *m_alternativeButton;
@ -86,7 +87,6 @@ private:
QToolButton *m_thinkingButton; QToolButton *m_thinkingButton;
QComboBox *m_commandsComboBox; QComboBox *m_commandsComboBox;
QComboBox *m_configComboBox; QComboBox *m_configComboBox;
QLabel *m_instructionsLabel;
Action m_selectedAction = Action::Custom; Action m_selectedAction = Action::Custom;
QString m_lastInstructions; QString m_lastInstructions;