mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
Connect on the SSH server
This commit is contained in:
@@ -11,8 +11,6 @@
|
||||
|
||||
#include "sshconfigurationdata.h"
|
||||
|
||||
constexpr const int SSHRole = Qt::UserRole + 1;
|
||||
|
||||
SSHManagerModel::SSHManagerModel(QObject *parent)
|
||||
: QStandardItemModel(parent)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,10 @@ class SSHConfigurationData;
|
||||
class SSHManagerModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Roles {
|
||||
SSHRole = Qt::UserRole + 1
|
||||
};
|
||||
|
||||
SSHManagerModel(QObject *parent = nullptr);
|
||||
~SSHManagerModel();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "sshmanagermodel.h"
|
||||
#include "sshconfigurationdata.h"
|
||||
#include "session/SessionController.h"
|
||||
#include "terminalDisplay/TerminalDisplay.h"
|
||||
|
||||
#include "profile/ProfileModel.h"
|
||||
|
||||
@@ -65,6 +66,8 @@ d(std::make_unique<SSHManagerTreeWidget::Private>())
|
||||
menu->popup(ui->treeView->viewport()->mapToGlobal(pos));
|
||||
});
|
||||
|
||||
connect(ui->treeView, &QTreeView::doubleClicked, this, &SSHManagerTreeWidget::connectRequested);
|
||||
|
||||
hideInfoPane();
|
||||
}
|
||||
|
||||
@@ -177,3 +180,36 @@ void SSHManagerTreeWidget::setCurrentController(Konsole::SessionController *cont
|
||||
qDebug() << "Controller changed to" << controller;
|
||||
d->controller = controller;
|
||||
}
|
||||
|
||||
void SSHManagerTreeWidget::connectRequested(const QModelIndex& idx)
|
||||
{
|
||||
if (idx.parent() == d->model->invisibleRootItem()->index()) {
|
||||
qDebug() << "Clicking on a folder";
|
||||
return;
|
||||
}
|
||||
qDebug() << "Connecting";
|
||||
auto item = d->model->itemFromIndex(idx);
|
||||
auto data = item->data(SSHManagerModel::SSHRole).value<SSHConfigurationData>();
|
||||
|
||||
if (!d->controller) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString sshCommand = QStringLiteral("ssh ");
|
||||
if (data.port > -1) {
|
||||
sshCommand += QStringLiteral("-p %1 ").arg(data.port);
|
||||
}
|
||||
/*
|
||||
if (!url.userName().isEmpty()) {
|
||||
sshCommand += (url.userName() + QLatin1Char('@'));
|
||||
}
|
||||
*/
|
||||
if (!data.host.isEmpty()) {
|
||||
sshCommand += data.host;
|
||||
}
|
||||
|
||||
d->controller->session()->sendTextToTerminal(sshCommand, QLatin1Char('\r'));
|
||||
if (d->controller->session()->views().count()) {
|
||||
d->controller->session()->views().at(0)->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
void setModel(SSHManagerModel *model);
|
||||
void triggerRemove();
|
||||
void setCurrentController(Konsole::SessionController *controller);
|
||||
void connectRequested(const QModelIndex& idx);
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
|
||||
Reference in New Issue
Block a user