From 057d97ee4d459a3e9aad4ced6f878b25f2d67cd0 Mon Sep 17 00:00:00 2001 From: Nova Date: Sat, 21 Sep 2024 14:54:03 +0330 Subject: [PATCH] feat: Improve tray icon and fix QvProxy windows issues --- .../qv2ray/v2/proxy/QvProxyConfigurator.cpp | 19 +------------------ ui/Icon.cpp | 2 ++ ui/Icon.hpp | 1 + ui/mainwindow.cpp | 4 ++++ 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp b/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp index 693c5ca..a5e32d5 100644 --- a/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp +++ b/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp @@ -16,7 +16,6 @@ #include #include -#include "3rdparty/fix_old_qt.h" #include "3rdparty/qv2ray/wrapper.hpp" #include "fmt/Preset.hpp" #include "main/NekoGui.hpp" @@ -254,23 +253,7 @@ namespace Qv2ray::components::proxy { #endif #ifdef Q_OS_WIN - QString str = NekoGui::dataStore->system_proxy_format; - if (str.isEmpty()) str = Preset::Windows::system_proxy_format[0]; - str = str.replace("{ip}", address) - .replace("{http_port}", Int2String(httpPort)) - .replace("{socks_port}", Int2String(socksPort)); - // - LOG("Windows proxy string: " + str); - auto proxyStrW = new WCHAR[str.length() + 1]; - wcscpy(proxyStrW, str.toStdWString().c_str()); - // - __QueryProxyOptions(); - - if (!__SetProxyOptions(proxyStrW, false)) { - LOG("Failed to set proxy."); - } - - __QueryProxyOptions(); + // we don't use this for windows #elif defined(Q_OS_LINUX) QList actions; actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "manual"}}; diff --git a/ui/Icon.cpp b/ui/Icon.cpp index b248f3c..a34beb3 100644 --- a/ui/Icon.cpp +++ b/ui/Icon.cpp @@ -34,6 +34,8 @@ QPixmap Icon::GetTrayIcon(Icon::TrayIconStatus status) { p.setBrush(QBrush(Qt::blue)); } else if (status == TrayIconStatus::VPN) { p.setBrush(QBrush(Qt::red)); + } else if (status == TrayIconStatus::DNS) { + p.setBrush(QBrush(Qt::yellow)); } p.drawRoundedRect( QRect(side - d - margin, diff --git a/ui/Icon.hpp b/ui/Icon.hpp index 4395344..7c529c7 100644 --- a/ui/Icon.hpp +++ b/ui/Icon.hpp @@ -9,6 +9,7 @@ namespace Icon { RUNNING, SYSTEM_PROXY, VPN, + DNS, }; QPixmap GetTrayIcon(TrayIconStatus status); diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index aba2df7..d21e1ea 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -327,6 +327,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi connect(ui->system_dns, &QCheckBox::clicked, this, [=](bool checked) { if (const auto ok = set_system_dns(checked); !ok) { ui->system_dns->setChecked(!checked); + } else { + refresh_status(); } }); // only windows is supported for now @@ -852,6 +854,8 @@ void MainWindow::refresh_status(const QString &traffic_update) { if (running != nullptr) { if (NekoGui::dataStore->spmode_vpn) { icon_status_new = Icon::VPN; + } else if (NekoGui::dataStore->system_dns_set) { + icon_status_new = Icon::DNS; } else if (NekoGui::dataStore->spmode_system_proxy) { icon_status_new = Icon::SYSTEM_PROXY; } else {