feat: support set application's working directory

Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
ComixHe
2023-10-07 18:11:22 +08:00
committed by Comix
parent fb0fc0a8ee
commit 8970298ad0
6 changed files with 36 additions and 4 deletions

View File

@ -19,6 +19,8 @@ QStringList generateCommand(const QVariantMap &props) noexcept
options.emplace_back(std::make_unique<setEnvLaunchOption>(value));
} else if (key == hookLaunchOption::key()) {
options.emplace_back(std::make_unique<hookLaunchOption>(value));
} else if (key == setPathLaunchOption::key()) {
options.emplace_back(std::make_unique<setPathLaunchOption>(value));
} else {
qWarning() << "unsupported options" << key;
}
@ -106,3 +108,13 @@ QStringList setEnvLaunchOption::generateCommandLine() const noexcept
return QStringList{QString{"--Environment=%1"}.arg(str)};
}
QStringList setPathLaunchOption::generateCommandLine() const noexcept
{
auto str = m_val.toString();
if (str.isEmpty()) {
return {};
}
return QStringList{QString{"--WorkingDirectory=%1"}.arg(str)};
}

View File

@ -94,4 +94,20 @@ struct hookLaunchOption : public LaunchOption
[[nodiscard]] QStringList generateCommandLine() const noexcept override { return m_val.toStringList(); };
};
struct setPathLaunchOption : public LaunchOption
{
using LaunchOption::LaunchOption;
[[nodiscard]] const QString &type() const noexcept override
{
static QString tp{systemdOption};
return tp;
}
[[nodiscard]] static const QString &key() noexcept
{
static QString path{"path"};
return path;
}
[[nodiscard]] QStringList generateCommandLine() const noexcept override;
};
QStringList generateCommand(const QVariantMap &props) noexcept;