mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-22 16:20:07 +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 <QStandardPaths>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#include "3rdparty/fix_old_qt.h"
|
|
||||||
#include "3rdparty/qv2ray/wrapper.hpp"
|
#include "3rdparty/qv2ray/wrapper.hpp"
|
||||||
#include "fmt/Preset.hpp"
|
#include "fmt/Preset.hpp"
|
||||||
#include "main/NekoGui.hpp"
|
#include "main/NekoGui.hpp"
|
||||||
@ -254,23 +253,7 @@ namespace Qv2ray::components::proxy {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QString str = NekoGui::dataStore->system_proxy_format;
|
// we don't use this for windows
|
||||||
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();
|
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
QList<ProcessArgument> actions;
|
QList<ProcessArgument> actions;
|
||||||
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "manual"}};
|
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));
|
p.setBrush(QBrush(Qt::blue));
|
||||||
} else if (status == TrayIconStatus::VPN) {
|
} else if (status == TrayIconStatus::VPN) {
|
||||||
p.setBrush(QBrush(Qt::red));
|
p.setBrush(QBrush(Qt::red));
|
||||||
|
} else if (status == TrayIconStatus::DNS) {
|
||||||
|
p.setBrush(QBrush(Qt::yellow));
|
||||||
}
|
}
|
||||||
p.drawRoundedRect(
|
p.drawRoundedRect(
|
||||||
QRect(side - d - margin,
|
QRect(side - d - margin,
|
||||||
|
|||||||
@ -9,6 +9,7 @@ namespace Icon {
|
|||||||
RUNNING,
|
RUNNING,
|
||||||
SYSTEM_PROXY,
|
SYSTEM_PROXY,
|
||||||
VPN,
|
VPN,
|
||||||
|
DNS,
|
||||||
};
|
};
|
||||||
|
|
||||||
QPixmap GetTrayIcon(TrayIconStatus status);
|
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) {
|
connect(ui->system_dns, &QCheckBox::clicked, this, [=](bool checked) {
|
||||||
if (const auto ok = set_system_dns(checked); !ok) {
|
if (const auto ok = set_system_dns(checked); !ok) {
|
||||||
ui->system_dns->setChecked(!checked);
|
ui->system_dns->setChecked(!checked);
|
||||||
|
} else {
|
||||||
|
refresh_status();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// only windows is supported for now
|
// only windows is supported for now
|
||||||
@ -852,6 +854,8 @@ void MainWindow::refresh_status(const QString &traffic_update) {
|
|||||||
if (running != nullptr) {
|
if (running != nullptr) {
|
||||||
if (NekoGui::dataStore->spmode_vpn) {
|
if (NekoGui::dataStore->spmode_vpn) {
|
||||||
icon_status_new = Icon::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) {
|
} else if (NekoGui::dataStore->spmode_system_proxy) {
|
||||||
icon_status_new = Icon::SYSTEM_PROXY;
|
icon_status_new = Icon::SYSTEM_PROXY;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user