mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 13:42:51 +08:00
feat: Improve tray icon and fix QvProxy windows issues
This commit is contained in:
parent
7ab7939687
commit
057d97ee4d
19
3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp
vendored
19
3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp
vendored
@ -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"}};
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -9,6 +9,7 @@ namespace Icon {
|
||||
RUNNING,
|
||||
SYSTEM_PROXY,
|
||||
VPN,
|
||||
DNS,
|
||||
};
|
||||
|
||||
QPixmap GetTrayIcon(TrayIconStatus status);
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user