diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-01-10 12:58:04 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-01-11 12:45:28 +0000 |
commit | b89865b96796dda96ffe3fb683e348f71160df8f (patch) | |
tree | 7db7a3687577411185d7668db23ccd13c21d6467 /src/plugins/remotelinux/linuxdevice.cpp | |
parent | 28f7c7935f4d142d5498d58465ff004462e996a6 (diff) |
RemoteLinux: Offer to open a remote shell
... in the settings dialog.
This allows users to poke around in the device they'be just configured,
e.g. for doing quick custom checks.
[ChangeLog] A remote shell can now be started for Linux devices.
Change-Id: I4570ca89d64606029759767a9f771168d7273510
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/remotelinux/linuxdevice.cpp')
-rw-r--r-- | src/plugins/remotelinux/linuxdevice.cpp | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 426a12e04c..83dd01c6d8 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -34,10 +34,12 @@ #include "remotelinuxenvironmentreader.h" #include <coreplugin/id.h> +#include <coreplugin/messagemanager.h> #include <projectexplorer/devicesupport/sshdeviceprocesslist.h> #include <projectexplorer/runconfiguration.h> #include <ssh/sshremoteprocessrunner.h> #include <utils/algorithm.h> +#include <utils/hostosinfo.h> #include <utils/port.h> #include <utils/qtcassert.h> @@ -50,6 +52,9 @@ namespace RemoteLinux { const char Delimiter0[] = "x--"; const char Delimiter1[] = "---"; + +static Core::Id openShellActionId() { return "RemoteLinux.OpenShellAction"; } + static QString visualizeNull(QString s) { return s.replace(QLatin1Char('\0'), QLatin1String("<null>")); @@ -182,7 +187,10 @@ IDeviceWidget *LinuxDevice::createWidget() QList<Core::Id> LinuxDevice::actionIds() const { - return QList<Core::Id>() << Core::Id(Constants::GenericDeployKeyToDeviceActionId); + QList<Core::Id> ids({Core::Id(Constants::GenericDeployKeyToDeviceActionId)}); + if (Utils::HostOsInfo::isAnyUnixHost()) + ids << openShellActionId(); + return ids; } QString LinuxDevice::displayNameForActionId(Core::Id actionId) const @@ -191,6 +199,8 @@ QString LinuxDevice::displayNameForActionId(Core::Id actionId) const if (actionId == Constants::GenericDeployKeyToDeviceActionId) return tr("Deploy Public Key..."); + if (actionId == openShellActionId()) + return tr("Open Remote Shell"); return QString(); // Can't happen. } @@ -198,13 +208,35 @@ void LinuxDevice::executeAction(Core::Id actionId, QWidget *parent) { QTC_ASSERT(actionIds().contains(actionId), return); - QDialog *d = nullptr; - const LinuxDevice::ConstPtr device = sharedFromThis().staticCast<const LinuxDevice>(); - if (actionId == Constants::GenericDeployKeyToDeviceActionId) - d = PublicKeyDeploymentDialog::createDialog(device, parent); - if (d) - d->exec(); - delete d; + if (actionId == Constants::GenericDeployKeyToDeviceActionId) { + const LinuxDevice::ConstPtr device = sharedFromThis().staticCast<const LinuxDevice>(); + QDialog * const d = PublicKeyDeploymentDialog::createDialog(device, parent); + if (d) + d->exec(); + delete d; + return; + } + if (actionId == openShellActionId()) { + DeviceProcess * const proc = createProcess(nullptr); + QObject::connect(proc, &DeviceProcess::finished, [proc] { + if (!proc->errorString().isEmpty()) { + Core::MessageManager::write(tr("Error running remote shell: %1") + .arg(proc->errorString()), + Core::MessageManager::ModeSwitch); + } + proc->deleteLater(); + }); + QObject::connect(proc, &DeviceProcess::error, [proc] { + Core::MessageManager::write(tr("Error starting remote shell."), + Core::MessageManager::ModeSwitch); + proc->deleteLater(); + }); + Runnable runnable; + runnable.device = sharedFromThis().staticCast<const LinuxDevice>(); + proc->setRunInTerminal(true); + proc->start(runnable); + return; + } } Utils::OsType LinuxDevice::osType() const |