Improve launch interface

pull/21/head
reionwong 4 years ago
parent 811ae676dc
commit 10549ba643

@ -146,6 +146,16 @@ void Application::launch(const QString &exec, const QStringList &args)
process.startDetached();
}
void Application::launch(const QString &exec, const QString &workingDir, const QStringList &args)
{
QProcess process;
process.setProgram(exec);
process.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
process.setWorkingDirectory(workingDir);
process.setArguments(args);
process.startDetached();
}
void Application::initEnvironments()
{
// Set defaults

@ -63,6 +63,7 @@ public slots:
}
void launch(const QString &exec, const QStringList &args);
void launch(const QString &exec, const QString &workingDir, const QStringList &args);
private:
void initEnvironments();

@ -23,5 +23,10 @@
<arg name="exec" type="s" direction="in"/>
<arg name="args" type="as" direction="in"/>
</method>
<method name="launch">
<arg name="exec" type="s" direction="in"/>
<arg name="workingDirectory" type="s" direction="in"/>
<arg name="args" type="as" direction="in"/>
</method>
</interface>
</node>

@ -38,6 +38,12 @@ void NetworkProxyManager::update()
qunsetenv("ALL_PROXY");
qunsetenv("NO_PROXY");
qunsetenv("http_proxy");
qunsetenv("https_proxy");
qunsetenv("ftp_proxy");
qunsetenv("all_proxy");
qunsetenv("no_proxy");
m_settings.sync();
m_flag = m_settings.value("ProxyFlag", 0).toInt();
@ -70,16 +76,22 @@ void NetworkProxyManager::update()
if (!m_httpProxy.isEmpty() && !m_httpProxyPort.isEmpty()) {
qputenv("HTTP_PROXY", httpProxy.toLatin1());
qputenv("HTTPS_PROXY", httpProxy.toLatin1());
qputenv("http_proxy", httpProxy.toLatin1());
qputenv("https_proxy", httpProxy.toLatin1());
}
if (!m_ftpProxy.isEmpty() && !m_ftpProxyPort.isEmpty()) {
qputenv("FTP_PROXY", ftpProxy.toLatin1());
qputenv("ftp_proxy", ftpProxy.toLatin1());
}
qputenv("NO_PROXY", "localhost,127.0.0.0/8,::1");
qputenv("no_proxy", "localhost,127.0.0.0/8,::1");
if (!m_socksProxy.isEmpty() && !m_socksProxyPort.isEmpty()) {
qputenv("ALL_PROXY", QString("socks://%1:%2/").arg(m_socksProxy).arg(m_socksProxyPort).toLatin1());
// qputenv("ALL_PROXY", QString("socks://%1:%2/").arg(m_socksProxy).arg(m_socksProxyPort).toLatin1());
// qputenv("all_proxy", QString("socks://%1:%2/").arg(m_socksProxy).arg(m_socksProxyPort).toLatin1());
}
}
}

Loading…
Cancel
Save