From 10549ba6437a904ba26805ecb2de3036ad2e25b2 Mon Sep 17 00:00:00 2001 From: reionwong Date: Sun, 21 Nov 2021 03:04:10 +0800 Subject: [PATCH] Improve launch interface --- session/application.cpp | 10 ++++++++++ session/application.h | 1 + session/com.cutefish.Session.xml | 5 +++++ session/networkproxymanager.cpp | 14 +++++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/session/application.cpp b/session/application.cpp index 89908d1..93c1fab 100644 --- a/session/application.cpp +++ b/session/application.cpp @@ -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 diff --git a/session/application.h b/session/application.h index fcdccc5..54a0880 100644 --- a/session/application.h +++ b/session/application.h @@ -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(); diff --git a/session/com.cutefish.Session.xml b/session/com.cutefish.Session.xml index 9fd6aba..bff1c1f 100644 --- a/session/com.cutefish.Session.xml +++ b/session/com.cutefish.Session.xml @@ -23,5 +23,10 @@ + + + + + diff --git a/session/networkproxymanager.cpp b/session/networkproxymanager.cpp index e648ac2..f9329ff 100644 --- a/session/networkproxymanager.cpp +++ b/session/networkproxymanager.cpp @@ -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()); } } }