mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-06-30 01:59:11 -04:00
refactor: Move to agent architecture
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <solutions/terminal/terminalview.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include "ProviderInstanceWriter.hpp"
|
||||
#include "ProviderSettings.hpp"
|
||||
#include "SectionBox.hpp"
|
||||
#include "SettingsTheme.hpp"
|
||||
#include "SettingsUiBuilders.hpp"
|
||||
@@ -37,7 +39,7 @@ ProviderDetailPane::ProviderDetailPane(QWidget *parent)
|
||||
m_sourcePathLabel = new QLabel(this);
|
||||
m_sourcePathLabel->setFont(monospaceFont(11));
|
||||
QPalette spp = m_sourcePathLabel->palette();
|
||||
spp.setColor(QPalette::WindowText, spp.color(QPalette::Mid));
|
||||
spp.setColor(QPalette::WindowText, Utils::creatorColor(Utils::Theme::PanelTextColorMid));
|
||||
m_sourcePathLabel->setPalette(spp);
|
||||
|
||||
m_editBtn = new QPushButton(tr("Edit…"), this);
|
||||
@@ -157,6 +159,14 @@ ProviderDetailPane::ProviderDetailPane(QWidget *parent)
|
||||
m_apiKeySaveBtn->setEnabled(false);
|
||||
m_apiKeyClearBtn = new QPushButton(tr("Clear"), this);
|
||||
m_apiKeyClearBtn->setToolTip(tr("Erase the stored API key for this provider"));
|
||||
m_legacyKeyBtn = new QPushButton(tr("Insert legacy key"), this);
|
||||
m_legacyKeyBtn->setVisible(false);
|
||||
connect(m_legacyKeyBtn, &QPushButton::clicked, this, [this] {
|
||||
if (m_legacyKeyValue.isEmpty())
|
||||
return;
|
||||
m_apiKeyEdit->setText(m_legacyKeyValue);
|
||||
m_revealKeyBtn->setChecked(true);
|
||||
});
|
||||
connect(m_apiKeyEdit, &QLineEdit::textChanged, this, [this](const QString &t) {
|
||||
m_apiKeySaveBtn->setEnabled(!t.isEmpty());
|
||||
});
|
||||
@@ -189,14 +199,15 @@ ProviderDetailPane::ProviderDetailPane(QWidget *parent)
|
||||
credGrid->setVerticalSpacing(4);
|
||||
FormBuilder credForm(credGrid);
|
||||
credForm.row(tr("API key:"), keyRow);
|
||||
credGrid->addWidget(m_keyHint, credForm.currentRow(), 1);
|
||||
credGrid->addWidget(m_legacyKeyBtn, credForm.currentRow(), 1, Qt::AlignLeft);
|
||||
credGrid->addWidget(m_keyHint, credForm.currentRow() + 1, 1);
|
||||
credSection->bodyLayout()->addLayout(credGrid);
|
||||
|
||||
m_launchSection = new SectionBox(tr("Launch"), this);
|
||||
m_launchEmptyHint = new QLabel(this);
|
||||
m_launchEmptyHint->setWordWrap(true);
|
||||
QPalette lehp = m_launchEmptyHint->palette();
|
||||
lehp.setColor(QPalette::WindowText, lehp.color(QPalette::Mid));
|
||||
lehp.setColor(QPalette::WindowText, Utils::creatorColor(Utils::Theme::PanelTextColorMid));
|
||||
m_launchEmptyHint->setPalette(lehp);
|
||||
m_launchCmdLabel = new QLabel(this);
|
||||
m_launchCmdLabel->setFont(monospaceFont(11));
|
||||
@@ -318,6 +329,18 @@ void ProviderDetailPane::populate(const Providers::ProviderInstance &inst, bool
|
||||
m_keyHint->setText(tr("No key stored yet. Type a key and press Save key."));
|
||||
}
|
||||
|
||||
const LegacyApiKeyEntry legacy
|
||||
= needsKey ? legacyApiKeyForClientApi(inst.clientApi) : LegacyApiKeyEntry{};
|
||||
m_legacyKeyValue = legacy.value;
|
||||
if (!legacy.value.isEmpty()) {
|
||||
m_legacyKeyBtn->setToolTip(
|
||||
tr("Insert the API key saved in the old %1 settings into the field.")
|
||||
.arg(legacy.label));
|
||||
m_legacyKeyBtn->setVisible(true);
|
||||
} else {
|
||||
m_legacyKeyBtn->setVisible(false);
|
||||
}
|
||||
|
||||
m_samplePreview->setText(
|
||||
QStringLiteral("# sample request line\nPOST %1/<agent endpoint>").arg(inst.url));
|
||||
applyPreviewPalette();
|
||||
@@ -348,6 +371,8 @@ void ProviderDetailPane::clear()
|
||||
m_apiKeySaveBtn->setEnabled(false);
|
||||
m_apiKeyClearBtn->setEnabled(false);
|
||||
m_revealKeyBtn->setEnabled(false);
|
||||
m_legacyKeyValue.clear();
|
||||
m_legacyKeyBtn->setVisible(false);
|
||||
m_samplePreview->clear();
|
||||
m_rawToml->clear();
|
||||
m_editBtn->setVisible(false);
|
||||
@@ -398,7 +423,9 @@ void ProviderDetailPane::setLaunchState(
|
||||
}
|
||||
|
||||
const QString detachedNote = m_current.launch.detach
|
||||
? tr(" <span style='color:gray'>(detached — survives Qt Creator restart)</span>")
|
||||
? QStringLiteral(" <span style='color:%1'>%2</span>")
|
||||
.arg(Utils::creatorColor(Utils::Theme::PanelTextColorMid).name(),
|
||||
tr("(detached — survives Qt Creator restart)"))
|
||||
: QString();
|
||||
m_launchCmdLabel->setText(
|
||||
QStringLiteral("<b>%1</b> %2%3")
|
||||
@@ -473,10 +500,10 @@ Providers::ProviderInstance ProviderDetailPane::collectEdits() const
|
||||
|
||||
void ProviderDetailPane::applyPreviewPalette()
|
||||
{
|
||||
const Theme theme = themeFor(palette());
|
||||
m_samplePreview->setStyleSheet(QStringLiteral(
|
||||
"QLabel { background:%1; border:1px solid %2; }")
|
||||
.arg(theme.codeBg, theme.rowSeparator));
|
||||
m_samplePreview->setStyleSheet(
|
||||
QStringLiteral("QLabel { background:%1; border:1px solid %2; }")
|
||||
.arg(cssColor(Utils::creatorColor(Utils::Theme::BackgroundColorNormal)),
|
||||
cssColor(Utils::creatorColor(Utils::Theme::SplitterColor))));
|
||||
}
|
||||
|
||||
void ProviderDetailPane::applyTerminalPalette()
|
||||
|
||||
Reference in New Issue
Block a user