forked from qt-creator/qt-creator
Terminal: Simplify OpenTerminalParameters construction
Change-Id: I4dcc2146f227e4a408c88de62f7594953c8ccb66 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
d222cc2dbd
commit
ce082bb09f
@@ -41,6 +41,20 @@ enum class ExitBehavior { Close, Restart, Keep };
|
||||
|
||||
struct OpenTerminalParameters
|
||||
{
|
||||
OpenTerminalParameters() = default;
|
||||
OpenTerminalParameters(const CommandLine &commandLine) : shellCommand(commandLine) {}
|
||||
OpenTerminalParameters(const FilePath &directory, std::optional<Environment> env) :
|
||||
workingDirectory(directory),
|
||||
environment(env)
|
||||
{}
|
||||
OpenTerminalParameters(const CommandLine &commandLine,
|
||||
const FilePath &directory,
|
||||
std::optional<Environment> env) :
|
||||
shellCommand(commandLine),
|
||||
workingDirectory(directory),
|
||||
environment(env)
|
||||
{}
|
||||
|
||||
std::optional<CommandLine> shellCommand;
|
||||
std::optional<FilePath> workingDirectory;
|
||||
std::optional<Environment> environment;
|
||||
|
@@ -106,7 +106,7 @@ void FileUtils::showInFileSystemView(const FilePath &path)
|
||||
|
||||
void FileUtils::openTerminal(const FilePath &path, const Environment &env)
|
||||
{
|
||||
Terminal::Hooks::instance().openTerminal({std::nullopt, path, env});
|
||||
Terminal::Hooks::instance().openTerminal({path, env});
|
||||
}
|
||||
|
||||
QString FileUtils::msgFindInDirectory()
|
||||
|
@@ -3630,7 +3630,7 @@ void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env
|
||||
|
||||
BuildConfiguration *bc = activeBuildConfiguration(ProjectTree::projectForNode(currentNode));
|
||||
if (!bc) {
|
||||
Terminal::Hooks::instance().openTerminal({{}, currentNode->directory(), environment});
|
||||
Terminal::Hooks::instance().openTerminal({currentNode->directory(), environment});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3649,7 +3649,7 @@ void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env
|
||||
if (!shell.isEmpty() && buildDevice->rootPath().needsDevice()) {
|
||||
Terminal::Hooks::instance().openTerminal({CommandLine{shell, {}}, workingDir, environment});
|
||||
} else {
|
||||
Terminal::Hooks::instance().openTerminal({std::nullopt, workingDir, environment});
|
||||
Terminal::Hooks::instance().openTerminal({workingDir, environment});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3684,7 +3684,7 @@ void ProjectExplorerPluginPrivate::openTerminalHereWithRunEnv()
|
||||
Terminal::Hooks::instance().openTerminal(
|
||||
{CommandLine{shell, {}}, workingDir, runnable.environment});
|
||||
} else {
|
||||
Terminal::Hooks::instance().openTerminal({std::nullopt, workingDir, runnable.environment});
|
||||
Terminal::Hooks::instance().openTerminal({workingDir, runnable.environment});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -162,7 +162,7 @@ QList<ShellModelItem> ShellModel::remote() const
|
||||
|
||||
const QList<ShellModelItem> deviceItems = Utils::transform(
|
||||
deviceCmds, [](const Utils::Terminal::NameAndCommandLine &item) -> ShellModelItem {
|
||||
return ShellModelItem{item.name, {}, {item.commandLine, std::nullopt, std::nullopt}};
|
||||
return ShellModelItem{item.name, {}, {item.commandLine}};
|
||||
});
|
||||
|
||||
return deviceItems;
|
||||
|
@@ -40,11 +40,9 @@ public:
|
||||
|
||||
TerminalWidget *terminal = m_terminalPane->stoppedTerminalWithId(id);
|
||||
|
||||
const OpenTerminalParameters openParameters{setup.m_commandLine,
|
||||
std::nullopt,
|
||||
std::nullopt,
|
||||
ExitBehavior::Keep,
|
||||
id};
|
||||
OpenTerminalParameters openParameters{setup.m_commandLine};
|
||||
openParameters.m_exitBehavior = ExitBehavior::Keep;
|
||||
openParameters.identifier = id;
|
||||
|
||||
if (!terminal) {
|
||||
terminal = new TerminalWidget(nullptr, openParameters);
|
||||
|
Reference in New Issue
Block a user