metal-kompanion/integrations/konsole/KompanionKonsolePlugin/kompanionagentpanel.cpp

59 lines
1.8 KiB
C++

#include "kompanionagentpanel.h"
#include <KLocalizedString>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
KompanionAgentPanel::KompanionAgentPanel(QWidget *parent)
: QWidget(parent)
{
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(12, 12, 12, 12);
layout->setSpacing(8);
m_statusLabel = new QLabel(i18n("No active session."));
m_statusLabel->setWordWrap(true);
layout->addWidget(m_statusLabel);
m_attachButton = new QPushButton(i18n("Attach Active Tab"), this);
m_attachButton->setEnabled(false);
layout->addWidget(m_attachButton);
connect(m_attachButton, &QPushButton::clicked, this, &KompanionAgentPanel::requestAttach);
m_launchButton = new QPushButton(i18n("Launch Demo Agent Shell"), this);
layout->addWidget(m_launchButton);
connect(m_launchButton, &QPushButton::clicked, this, &KompanionAgentPanel::requestLaunch);
auto *hint = new QLabel(i18n("The demo issues Kompanion CLI bootstrap commands inside the terminal."
" Replace these hooks with the minimal TTY bridge once it is ready."));
hint->setWordWrap(true);
hint->setObjectName(QStringLiteral("kompanionHintLabel"));
layout->addWidget(hint);
layout->addStretch();
}
void KompanionAgentPanel::setActiveSessionInfo(const QString &title, const QString &directory)
{
if (title.isEmpty() && directory.isEmpty()) {
m_statusLabel->setText(i18n("No active session."));
return;
}
if (directory.isEmpty()) {
m_statusLabel->setText(i18n("Active session: %1", title));
return;
}
m_statusLabel->setText(i18n("Active session: %1\nDirectory: %2", title, directory));
}
void KompanionAgentPanel::setAttachEnabled(bool enabled)
{
m_attachButton->setEnabled(enabled);
}
#include "moc_kompanionagentpanel.cpp"