refactor: fix deprecation up to Qt 5.15
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
@ -282,6 +282,23 @@ void LaunchTask::emitFailed(QString reason)
|
||||
Task::emitFailed(reason);
|
||||
}
|
||||
|
||||
void LaunchTask::substituteVariables(const QStringList &args) const
|
||||
{
|
||||
auto variables = m_instance->getVariables();
|
||||
auto envVariables = QProcessEnvironment::systemEnvironment();
|
||||
|
||||
for (auto arg : args) {
|
||||
for (auto key : variables)
|
||||
{
|
||||
arg.replace("$" + key, variables.value(key));
|
||||
}
|
||||
for (auto env : envVariables.keys())
|
||||
{
|
||||
arg.replace("$" + env, envVariables.value(env));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString LaunchTask::substituteVariables(const QString &cmd) const
|
||||
{
|
||||
QString out = cmd;
|
||||
|
@ -85,6 +85,7 @@ public: /* methods */
|
||||
shared_qobject_ptr<LogModel> getLogModel();
|
||||
|
||||
public:
|
||||
void substituteVariables(const QStringList &args) const;
|
||||
QString substituteVariables(const QString &cmd) const;
|
||||
QString censorPrivateInfo(QString in);
|
||||
|
||||
|
@ -27,9 +27,19 @@ PostLaunchCommand::PostLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
||||
|
||||
void PostLaunchCommand::executeTask()
|
||||
{
|
||||
//FIXME: where to put this?
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
auto args = QProcess::splitCommand(m_command);
|
||||
m_parent->substituteVariables(args);
|
||||
|
||||
emit logLine(tr("Running Post-Launch command: %1").arg(args.join(' ')), MessageLevel::Launcher);
|
||||
const QString program = args.takeFirst();
|
||||
m_process.start(program, args);
|
||||
#else
|
||||
QString postlaunch_cmd = m_parent->substituteVariables(m_command);
|
||||
emit logLine(tr("Running Post-Launch command: %1").arg(postlaunch_cmd), MessageLevel::Launcher);
|
||||
m_process.start(postlaunch_cmd);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PostLaunchCommand::on_state(LoggedProcess::State state)
|
||||
|
@ -28,9 +28,18 @@ PreLaunchCommand::PreLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
||||
void PreLaunchCommand::executeTask()
|
||||
{
|
||||
//FIXME: where to put this?
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
auto args = QProcess::splitCommand(m_command);
|
||||
m_parent->substituteVariables(args);
|
||||
|
||||
emit logLine(tr("Running Pre-Launch command: %1").arg(args.join(' ')), MessageLevel::Launcher);
|
||||
const QString program = args.takeFirst();
|
||||
m_process.start(program, args);
|
||||
#else
|
||||
QString prelaunch_cmd = m_parent->substituteVariables(m_command);
|
||||
emit logLine(tr("Running Pre-Launch command: %1").arg(prelaunch_cmd), MessageLevel::Launcher);
|
||||
m_process.start(prelaunch_cmd);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PreLaunchCommand::on_state(LoggedProcess::State state)
|
||||
|
Reference in New Issue
Block a user