mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-03-09 15:20:06 -04:00
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:
@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user