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