feat: Improve tray icon and fix QvProxy windows issues

This commit is contained in:
Nova 2024-09-21 14:54:03 +03:30
parent 7ab7939687
commit 057d97ee4d
No known key found for this signature in database
GPG Key ID: 389787EC83F5D73A
4 changed files with 8 additions and 18 deletions

View File

@ -16,7 +16,6 @@
#include <QStandardPaths>
#include <QProcess>
#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<ProcessArgument> actions;
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "manual"}};

View File

@ -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,

View File

@ -9,6 +9,7 @@ namespace Icon {
RUNNING,
SYSTEM_PROXY,
VPN,
DNS,
};
QPixmap GetTrayIcon(TrayIconStatus status);

View File

@ -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 {