refactor: Refactors AgentRoleDialog's modes handling (#325)

* fix: Fixes `undefined-bool-conversion` compilation warning.

* refactor: Replaces `AgentRoleDialog::m_editMode` with `AgentRoleDialog::m_action`

---------

Co-authored-by: Ivan Lebedev <ilebedev@flightpath3d.com>
This commit is contained in:
lebedeviv1988
2026-03-05 09:48:01 +00:00
committed by GitHub
parent e2e13f0f38
commit b7a9787cc3
3 changed files with 32 additions and 19 deletions

View File

@ -29,21 +29,24 @@
namespace QodeAssist::Settings {
AgentRoleDialog::AgentRoleDialog(QWidget *parent)
: QDialog(parent)
, m_editMode(false)
AgentRoleDialog::AgentRoleDialog(Action action, QWidget *parent)
: QDialog{parent}
, m_action{action}
{
setWindowTitle(tr("Add Agent Role"));
setupUI();
}
auto getTitle = [](Action action) {
switch(action)
{
case Action::Add:
return tr("Add Agent Role");
case Action::Duplicate:
return tr("Duplicate Agent Role");
case Action::Edit:
return tr("Edit Agent Role");
}
};
AgentRoleDialog::AgentRoleDialog(const AgentRole &role, bool editMode, QWidget *parent)
: QDialog(parent)
, m_editMode(editMode)
{
setWindowTitle(editMode ? tr("Edit Agent Role") : tr("Duplicate Agent Role"));
setWindowTitle(getTitle(action));
setupUI();
setRole(role);
}
void AgentRoleDialog::setupUI()
@ -83,7 +86,7 @@ void AgentRoleDialog::setupUI()
connect(m_idEdit, &QLineEdit::textChanged, this, &AgentRoleDialog::validateInput);
connect(m_systemPromptEdit, &QTextEdit::textChanged, this, &AgentRoleDialog::validateInput);
if (m_editMode) {
if (m_action == Action::Edit) {
m_idEdit->setEnabled(false);
m_idEdit->setToolTip(tr("ID cannot be changed for existing roles"));
}