This commit is contained in:
parhelia512 2025-12-08 19:12:16 +08:00
parent dde50e5eb8
commit 38f5e1cf29

View File

@ -278,10 +278,19 @@ namespace Qv2ray::components::proxy {
const auto configPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
QString kwriteconfigCmd = qEnvironmentVariable("KDE_SESSION_VERSION") == "5" ? "kwriteconfig5" : qEnvironmentVariable("KDE_SESSION_VERSION") == "6" ? "kwriteconfig6" : "kwriteconfig";
//
// Configure HTTP Proxies for HTTP, FTP and HTTPS
if (hasHTTP) {
// iterate over protocols...
for (const auto &protocol: QStringList{"http", "ftp", "https"}) {
// for GNOME:
{
actions << ProcessArgument{"gsettings",
{"set", "org.gnome.system.proxy." + protocol, "host", address}};
actions << ProcessArgument{"gsettings",
{"set", "org.gnome.system.proxy." + protocol, "port", QSTRN(httpPort)}};
}
// for KDE:
if (isKDE) {
actions << ProcessArgument{kwriteconfigCmd,
@ -290,18 +299,17 @@ namespace Qv2ray::components::proxy {
"--key", protocol + "Proxy", //
"http://" + address + " " + QSTRN(httpPort)}};
}
// for GNOME:
else {
actions << ProcessArgument{"gsettings",
{"set", "org.gnome.system.proxy." + protocol, "host", address}};
actions << ProcessArgument{"gsettings",
{"set", "org.gnome.system.proxy." + protocol, "port", QSTRN(httpPort)}};
}
}
}
// Configure SOCKS5 Proxies
if (hasSOCKS) {
// for GNOME:
{
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy.socks", "host", address}};
actions << ProcessArgument{"gsettings",
{"set", "org.gnome.system.proxy.socks", "port", QSTRN(socksPort)}};
// for KDE:
if (isKDE) {
actions << ProcessArgument{kwriteconfigCmd,
@ -310,15 +318,15 @@ namespace Qv2ray::components::proxy {
"--key", "socksProxy", //
"socks://" + address + " " + QSTRN(socksPort)}};
}
// for GNOME:
else {
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy.socks", "host", address}};
actions << ProcessArgument{"gsettings",
{"set", "org.gnome.system.proxy.socks", "port", QSTRN(socksPort)}};
}
}
// Setting Proxy Mode to Manual
{
// for GNOME:
{
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "manual"}};
}
// Setting Proxy Mode to Manual
// for KDE:
if (isKDE) {
actions << ProcessArgument{kwriteconfigCmd,
@ -326,9 +334,6 @@ namespace Qv2ray::components::proxy {
"--group", "Proxy Settings", //
"--key", "ProxyType", "1"}};
}
// for GNOME:
else {
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "manual"}};
}
// Notify kioslaves to reload system proxy configuration.
@ -390,6 +395,12 @@ namespace Qv2ray::components::proxy {
const auto configRoot = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
// Setting System Proxy Mode to: None
{
// for GNOME:
{
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "none"}};
}
// for KDE:
if (isKDE) {
actions << ProcessArgument{qEnvironmentVariable("KDE_SESSION_VERSION") == "5" ? "kwriteconfig5" : qEnvironmentVariable("KDE_SESSION_VERSION") == "6" ? "kwriteconfig6" : "kwriteconfig",
@ -397,9 +408,6 @@ namespace Qv2ray::components::proxy {
"--group", "Proxy Settings", //
"--key", "ProxyType", "0"}};
}
// for GNOME:
{
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "none"}};
}
// Notify kioslaves to reload system proxy configuration.