mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-18 12:40:06 +08:00
refactoring, add tooltip for HWID checkbox
This commit is contained in:
parent
8111b7fe72
commit
6f8f817a74
@ -553,6 +553,9 @@
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="sub_send_hwid">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>HWID=%1</p><p>OS=%2</p><p>OS Version=%3</p><p>Model=%4</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable sending HWID, device model, and OS version when updating subscription</string>
|
||||
</property>
|
||||
|
||||
@ -94,6 +94,10 @@
|
||||
<message>
|
||||
<source>Enable sending HWID, device model, and OS version when updating subscription</source>
|
||||
<translation>Включить отправку HWID, модели устройства и версии ОС при обновлении подписки</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source><html><head/><body><p>HWID=%1</p><p>OS=%2</p><p>OS Version=%3</p><p>Model=%4</p></body></html></source>
|
||||
<translation><html><head/><body><p>HWID=%1</p><p>ОС=%2</p><p>Версия ОС=%3</p><p>Модель=%4</p></body></html></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Core</source>
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#pragma comment(lib, "wbemuuid.lib")
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static QString queryWmiProperty(const QString& wmiClass, const QString& property) {
|
||||
HRESULT hres;
|
||||
@ -116,7 +115,6 @@ static QString queryWmiProperty(const QString& wmiClass, const QString& property
|
||||
pSvc->Release();
|
||||
pLoc->Release();
|
||||
CoUninitialize();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -130,50 +128,56 @@ static QString winModel() {
|
||||
#endif
|
||||
|
||||
DeviceDetails GetDeviceDetails() {
|
||||
DeviceDetails details;
|
||||
static const DeviceDetails details = []() {
|
||||
DeviceDetails d;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
details.hwid = QSysInfo::machineUniqueId();
|
||||
if (details.hwid.isEmpty()) {
|
||||
auto productType = QSysInfo::productType().toUtf8();
|
||||
details.hwid = QString("%1-%2").arg(QSysInfo::machineHostName(), QString::fromUtf8(productType));
|
||||
}
|
||||
|
||||
details.os = QStringLiteral("Windows");
|
||||
VersionInfo info;
|
||||
WinVersion::GetVersion(info);
|
||||
details.osVersion = QString("%1.%2.%3").arg(info.Major).arg(info.Minor).arg(info.BuildNum);
|
||||
auto wm = winModel();
|
||||
auto wbb = winBaseBoard();
|
||||
details.model = (wm == wbb) ? wm : wm + "/" + wbb;
|
||||
#elif defined(Q_OS_LINUX)
|
||||
QString mid;
|
||||
QFile f1("/etc/machine-id");
|
||||
if (f1.exists() && f1.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
mid = QString::fromUtf8(f1.readAll()).trimmed();
|
||||
f1.close();
|
||||
}
|
||||
else {
|
||||
QFile f2("/var/lib/dbus/machine-id");
|
||||
if (f2.exists() && f2.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
mid = QString::fromUtf8(f2.readAll()).trimmed();
|
||||
f2.close();
|
||||
#ifdef Q_OS_WIN
|
||||
d.hwid = QSysInfo::machineUniqueId();
|
||||
if (d.hwid.isEmpty()) {
|
||||
auto productType = QSysInfo::productType().toUtf8();
|
||||
d.hwid = QString("%1-%2").arg(QSysInfo::machineHostName(), QString::fromUtf8(productType));
|
||||
}
|
||||
}
|
||||
details.hwid = mid;
|
||||
details.os = QStringLiteral("Linux");
|
||||
details.osVersion = QSysInfo::kernelVersion();
|
||||
details.model = QSysInfo::prettyProductName();
|
||||
#elif defined(Q_OS_MACOS)
|
||||
details.hwid = QSysInfo::machineUniqueId();
|
||||
details.os = QStringLiteral("macOS");
|
||||
details.osVersion = QSysInfo::productVersion();
|
||||
details.model = QSysInfo::prettyProductName();
|
||||
#else
|
||||
details.hwid = QSysInfo::machineUniqueId();
|
||||
details.os = QSysInfo::productType();
|
||||
details.osVersion = QSysInfo::productVersion();
|
||||
details.model = QSysInfo::prettyProductName();
|
||||
#endif
|
||||
|
||||
d.os = QStringLiteral("Windows ") + QSysInfo::productVersion();
|
||||
|
||||
VersionInfo info;
|
||||
WinVersion::GetVersion(info);
|
||||
d.osVersion = QString("%1.%2.%3").arg(info.Major).arg(info.Minor).arg(info.BuildNum);
|
||||
|
||||
auto wm = winModel();
|
||||
auto wbb = winBaseBoard();
|
||||
d.model = (wm == wbb) ? wm : wm + "/" + wbb;
|
||||
if (d.hwid.isEmpty()) d.model = QSysInfo::prettyProductName();
|
||||
#elif defined(Q_OS_LINUX)
|
||||
QString mid;
|
||||
QFile f1("/etc/machine-id");
|
||||
if (f1.exists() && f1.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
mid = QString::fromUtf8(f1.readAll()).trimmed();
|
||||
f1.close();
|
||||
}
|
||||
else {
|
||||
QFile f2("/var/lib/dbus/machine-id");
|
||||
if (f2.exists() && f2.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
mid = QString::fromUtf8(f2.readAll()).trimmed();
|
||||
f2.close();
|
||||
}
|
||||
}
|
||||
d.hwid = mid;
|
||||
d.os = QStringLiteral("Linux");
|
||||
d.osVersion = QSysInfo::kernelVersion();
|
||||
d.model = QSysInfo::prettyProductName();
|
||||
#elif defined(Q_OS_MACOS)
|
||||
d.hwid = QSysInfo::machineUniqueId();
|
||||
d.os = QStringLiteral("macOS");
|
||||
d.osVersion = QSysInfo::productVersion();
|
||||
d.model = QSysInfo::prettyProductName();
|
||||
#else
|
||||
d.hwid = QSysInfo::machineUniqueId();
|
||||
d.os = QSysInfo::productType();
|
||||
d.osVersion = QSysInfo::productVersion();
|
||||
d.model = QSysInfo::prettyProductName();
|
||||
#endif
|
||||
return d;
|
||||
}();
|
||||
return details;
|
||||
}
|
||||
@ -54,6 +54,7 @@
|
||||
#include <3rdparty/QHotkey/qhotkey.h>
|
||||
#include <3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.hpp>
|
||||
#include <include/global/HTTPRequestHelper.hpp>
|
||||
#include "include/global/DeviceDetailsHelper.hpp"
|
||||
|
||||
#include "include/sys/macos/MacOS.h"
|
||||
|
||||
@ -133,6 +134,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
Configs::dataStore->inbound_socks_port = MkPort();
|
||||
}
|
||||
|
||||
//init HWID data
|
||||
runOnNewThread([=, this] {GetDeviceDetails(); });
|
||||
|
||||
// Prepare core
|
||||
Configs::dataStore->core_port = MkPort();
|
||||
if (Configs::dataStore->core_port <= 0) Configs::dataStore->core_port = 19810;
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "include/global/GuiUtils.hpp"
|
||||
#include "include/global/Configs.hpp"
|
||||
#include "include/global/HTTPRequestHelper.hpp"
|
||||
#include "include/global/DeviceDetailsHelper.hpp"
|
||||
|
||||
#include <QStyleFactory>
|
||||
#include <QFileDialog>
|
||||
@ -118,6 +119,13 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
||||
D_LOAD_BOOL(sub_insecure)
|
||||
D_LOAD_BOOL(sub_send_hwid)
|
||||
D_LOAD_INT_ENABLE(sub_auto_update, sub_auto_update_enable)
|
||||
auto details = GetDeviceDetails();
|
||||
ui->sub_send_hwid->setToolTip(
|
||||
ui->sub_send_hwid->toolTip()
|
||||
.arg(details.hwid.isEmpty() ? "N/A" : details.hwid,
|
||||
details.os.isEmpty() ? "N/A" : details.os,
|
||||
details.osVersion.isEmpty() ? "N/A" : details.osVersion,
|
||||
details.model.isEmpty() ? "N/A" : details.model));
|
||||
|
||||
// Core
|
||||
ui->groupBox_core->setTitle(software_core_name);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user