Terminal: Lazily open remote terminals

Move the burden of finding the shell of a device from the shell menu
to the TerminalWidget, so that opening the shell menu does not block
the ui.

Change-Id: I7f2e5a891f20faa53a1e3eec879866219f9bee0b
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-08-10 06:44:27 +02:00
parent d611fe6821
commit 92355bf40d
7 changed files with 60 additions and 38 deletions

View File

@@ -3,6 +3,9 @@
#include "shellmodel.h"
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/algorithm.h>
#include <utils/environment.h>
#include <utils/filepath.h>
@@ -138,11 +141,10 @@ ShellModelPrivate::ShellModelPrivate()
});
// ... and filter out non-existing shells.
localShells = Utils::transform(
Utils::filtered(shells, [](const FilePath &shell) {return shell.exists(); }),
[&iconProvider](const FilePath &shell) {
return ShellItemBuilder(iconProvider, shell).item();
});
localShells = Utils::transform(Utils::filtered(shells, &FilePath::exists),
[&iconProvider](const FilePath &shell) {
return ShellItemBuilder(iconProvider, shell).item();
});
}
}
@@ -161,14 +163,15 @@ QList<ShellModelItem> ShellModel::local() const
QList<ShellModelItem> ShellModel::remote() const
{
const auto deviceCmds = Utils::Terminal::Hooks::instance().getTerminalCommandsForDevicesHook()();
QList<ShellModelItem> result;
const QList<ShellModelItem> deviceItems = Utils::transform(
deviceCmds, [](const Utils::Terminal::NameAndCommandLine &item) -> ShellModelItem {
return ShellModelItem{item.name, {item.commandLine}};
ProjectExplorer::DeviceManager::instance()->forEachDevice(
[&result](const QSharedPointer<const ProjectExplorer::IDevice> &device) {
if (device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
result << ShellModelItem{device->displayName(), {{device->rootPath(), {}}}};
});
return deviceItems;
return result;
}
} // namespace Terminal::Internal