mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
full stack for windows
This commit is contained in:
parent
12cc69e41c
commit
28fddc2fb3
13 changed files with 118 additions and 94 deletions
|
@ -39,10 +39,10 @@ namespace platform { namespace keys{
|
||||||
namespace display {
|
namespace display {
|
||||||
extern const char* description;
|
extern const char* description;
|
||||||
extern const char* name;
|
extern const char* name;
|
||||||
extern const char* coordsLeft;
|
extern const char* boundsLeft;
|
||||||
extern const char* coordsRight;
|
extern const char* boundsRight;
|
||||||
extern const char* coordsTop;
|
extern const char* boundsTop;
|
||||||
extern const char* coordsBottom;
|
extern const char* boundsBottom;
|
||||||
extern const char* gpu;
|
extern const char* gpu;
|
||||||
}
|
}
|
||||||
namespace memory {
|
namespace memory {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "../PlatformKeys.h"
|
#include "../PlatformKeys.h"
|
||||||
#include <GPUIdent.h>
|
#include <GPUIdent.h>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
using namespace platform;
|
using namespace platform;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ void AndroidInstance::enumerateCpus() {
|
||||||
_cpus.push_back(cpu);
|
_cpus.push_back(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidInstance::enumerateGpus() {
|
void AndroidInstance::enumerateGpusAndDisplays() {
|
||||||
GPUIdent* ident = GPUIdent::getInstance();
|
GPUIdent* ident = GPUIdent::getInstance();
|
||||||
json gpu = {};
|
json gpu = {};
|
||||||
gpu[keys::gpu::model] = ident->getName().toUtf8().constData();
|
gpu[keys::gpu::model] = ident->getName().toUtf8().constData();
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace platform {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void enumerateCpus() override;
|
void enumerateCpus() override;
|
||||||
void enumerateGpus() override;
|
void enumerateGpusAndDisplays() override;
|
||||||
void enumerateMemory() override;
|
void enumerateMemory() override;
|
||||||
void enumerateComputer() override;
|
void enumerateComputer() override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <CPUIdent.h>
|
#include <CPUIdent.h>
|
||||||
|
|
||||||
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
#include <GPUIdent.h>
|
#include <GPUIdent.h>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
|
||||||
|
@ -27,7 +30,7 @@ void LinuxInstance::enumerateCpus() {
|
||||||
_cpus.push_back(cpu);
|
_cpus.push_back(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxInstance::enumerateGpus() {
|
void LinuxInstance::enumerateGpusAndDisplays() {
|
||||||
GPUIdent* ident = GPUIdent::getInstance();
|
GPUIdent* ident = GPUIdent::getInstance();
|
||||||
json gpu = {};
|
json gpu = {};
|
||||||
gpu[keys::gpu::model] = ident->getName().toUtf8().constData();
|
gpu[keys::gpu::model] = ident->getName().toUtf8().constData();
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace platform {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void enumerateCpus() override;
|
void enumerateCpus() override;
|
||||||
void enumerateGpus() override;
|
void enumerateGpusAndDisplays() override;
|
||||||
void enumerateMemory() override;
|
void enumerateMemory() override;
|
||||||
void enumerateComputer() override;
|
void enumerateComputer() override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <CPUIdent.h>
|
#include <CPUIdent.h>
|
||||||
#include <GPUIdent.h>
|
|
||||||
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -42,7 +43,7 @@ void MACOSInstance::enumerateCpus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MACOSInstance::enumerateGpus() {
|
void MACOSInstance::enumerateGpusAndDisplays() {
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// Collect Renderer info as exposed by the CGL layers
|
// Collect Renderer info as exposed by the CGL layers
|
||||||
GLuint cglDisplayMask = -1; // Iterate over all of them.
|
GLuint cglDisplayMask = -1; // Iterate over all of them.
|
||||||
|
@ -191,9 +192,6 @@ void MACOSInstance::enumerateGpus() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MACOSInstance::enumerateDisplays() {
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
uint32_t numDisplays = 0;
|
uint32_t numDisplays = 0;
|
||||||
CGError error = CGGetOnlineDisplayList(0, nullptr, &numDisplays);
|
CGError error = CGGetOnlineDisplayList(0, nullptr, &numDisplays);
|
||||||
|
@ -240,10 +238,10 @@ void MACOSInstance::enumerateDisplays() {
|
||||||
|
|
||||||
display["ppi"] = sqrt(displayModeHeight * displayModeHeight + displayModeWidth * displayModeWidth) / displaySizeDiagonalInches;
|
display["ppi"] = sqrt(displayModeHeight * displayModeHeight + displayModeWidth * displayModeWidth) / displaySizeDiagonalInches;
|
||||||
|
|
||||||
display["coordLeft"] = displayBounds.origin.x;
|
display[keys::display::boundsLeft] = displayBounds.origin.x;
|
||||||
display["coordRight"] = displayBounds.origin.x + displayBounds.size.width;
|
display[keys::display::boundsRight] = displayBounds.origin.x + displayBounds.size.width;
|
||||||
display["coordTop"] = displayBounds.origin.y;
|
display[keys::display::boundsTop] = displayBounds.origin.y;
|
||||||
display["coordBottom"] = displayBounds.origin.y + displayBounds.size.height;
|
display[keys::display::boundsBottom] = displayBounds.origin.y + displayBounds.size.height;
|
||||||
|
|
||||||
display["isMaster"] = displayMaster;
|
display["isMaster"] = displayMaster;
|
||||||
|
|
||||||
|
@ -289,11 +287,11 @@ void MACOSInstance::enumerateComputer(){
|
||||||
_computer[keys::computer::model]=std::string(model);
|
_computer[keys::computer::model]=std::string(model);
|
||||||
|
|
||||||
free(model);
|
free(model);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto sysInfo = QSysInfo();
|
auto sysInfo = QSysInfo();
|
||||||
|
|
||||||
_computer[keys::computer::OSVersion] = sysInfo.kernelVersion().toStdString();
|
_computer[keys::computer::OSVersion] = sysInfo.kernelVersion().toStdString();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@ namespace platform {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void enumerateCpus() override;
|
void enumerateCpus() override;
|
||||||
void enumerateGpus() override;
|
void enumerateGpusAndDisplays() override;
|
||||||
void enumerateDisplays() override;
|
|
||||||
void enumerateMemory() override;
|
void enumerateMemory() override;
|
||||||
void enumerateComputer() override;
|
void enumerateComputer() override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,10 +40,10 @@ namespace platform { namespace keys {
|
||||||
namespace display {
|
namespace display {
|
||||||
const char* description = "description";
|
const char* description = "description";
|
||||||
const char* name = "deviceName";
|
const char* name = "deviceName";
|
||||||
const char* coordsLeft = "coordinatesleft";
|
const char* boundsLeft = "boundsLeft";
|
||||||
const char* coordsRight = "coordinatesright";
|
const char* boundsRight = "boundsRight";
|
||||||
const char* coordsTop = "coordinatestop";
|
const char* boundsTop = "boundsTop";
|
||||||
const char* coordsBottom = "coordinatesbottom";
|
const char* boundsBottom = "boundsBottom";
|
||||||
const char* gpu = "gpu";
|
const char* gpu = "gpu";
|
||||||
}
|
}
|
||||||
namespace memory {
|
namespace memory {
|
||||||
|
|
|
@ -19,8 +19,7 @@ bool Instance::enumeratePlatform() {
|
||||||
enumerateComputer();
|
enumerateComputer();
|
||||||
enumerateMemory();
|
enumerateMemory();
|
||||||
enumerateCpus();
|
enumerateCpus();
|
||||||
enumerateGpus();
|
enumerateGpusAndDisplays();
|
||||||
enumerateDisplays();
|
|
||||||
enumerateNics();
|
enumerateNics();
|
||||||
|
|
||||||
// And profile the platform and put the tier in "computer"
|
// And profile the platform and put the tier in "computer"
|
||||||
|
@ -102,10 +101,10 @@ json Instance::listAllKeys() {
|
||||||
|
|
||||||
keys::display::description,
|
keys::display::description,
|
||||||
keys::display::name,
|
keys::display::name,
|
||||||
keys::display::coordsLeft,
|
keys::display::boundsLeft,
|
||||||
keys::display::coordsRight,
|
keys::display::boundsRight,
|
||||||
keys::display::coordsTop,
|
keys::display::boundsTop,
|
||||||
keys::display::coordsBottom,
|
keys::display::boundsBottom,
|
||||||
keys::display::gpu,
|
keys::display::gpu,
|
||||||
|
|
||||||
keys::memory::memTotal,
|
keys::memory::memTotal,
|
||||||
|
|
|
@ -35,8 +35,7 @@ public:
|
||||||
json getAll();
|
json getAll();
|
||||||
|
|
||||||
void virtual enumerateCpus()=0;
|
void virtual enumerateCpus()=0;
|
||||||
void virtual enumerateGpus()=0;
|
void virtual enumerateGpusAndDisplays()=0;
|
||||||
void virtual enumerateDisplays() {}
|
|
||||||
void virtual enumerateNics();
|
void virtual enumerateNics();
|
||||||
void virtual enumerateMemory() = 0;
|
void virtual enumerateMemory() = 0;
|
||||||
void virtual enumerateComputer()=0;
|
void virtual enumerateComputer()=0;
|
||||||
|
|
|
@ -11,23 +11,31 @@
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <CPUIdent.h>
|
#include <CPUIdent.h>
|
||||||
#include <GPUIdent.h>
|
|
||||||
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
#include <sstream>
|
||||||
|
#include <qstring>
|
||||||
|
#include <qsysinfo>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include <dxgi1_3.h>
|
#include <dxgi1_3.h>
|
||||||
#pragma comment(lib, "dxgi.lib")
|
#pragma comment(lib, "dxgi.lib")
|
||||||
|
#include <shellscalingapi.h>
|
||||||
|
#pragma comment(lib, "Shcore.lib")
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace platform;
|
using namespace platform;
|
||||||
|
|
||||||
void WINInstance::enumerateCpus() {
|
void WINInstance::enumerateCpus() {
|
||||||
json cpu = {};
|
json cpu = {};
|
||||||
|
|
||||||
cpu[keys::cpu::vendor] = CPUIdent::Vendor();
|
cpu[keys::cpu::vendor] = CPUIdent::Vendor();
|
||||||
cpu[keys::cpu::model] = CPUIdent::Brand();
|
cpu[keys::cpu::model] = CPUIdent::Brand();
|
||||||
cpu[keys::cpu::numCores] = std::thread::hardware_concurrency();
|
cpu[keys::cpu::numCores] = std::thread::hardware_concurrency();
|
||||||
|
@ -35,19 +43,20 @@ void WINInstance::enumerateCpus() {
|
||||||
_cpus.push_back(cpu);
|
_cpus.push_back(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINInstance::enumerateGpus() {
|
void WINInstance::enumerateGpusAndDisplays() {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
struct ConvertLargeIntegerToQString {
|
struct ConvertLargeIntegerToString {
|
||||||
QString convert(const LARGE_INTEGER& version) {
|
std::string convert(const LARGE_INTEGER& version) {
|
||||||
QString value;
|
std::ostringstream value;
|
||||||
value.append(QString::number(uint32_t(((version.HighPart & 0xFFFF0000) >> 16) & 0x0000FFFF)));
|
value << uint32_t(((version.HighPart & 0xFFFF0000) >> 16) & 0x0000FFFF);
|
||||||
value.append(".");
|
value << ".";
|
||||||
value.append(QString::number(uint32_t((version.HighPart) & 0x0000FFFF)));
|
value << uint32_t((version.HighPart) & 0x0000FFFF);
|
||||||
value.append(".");
|
value << ".";
|
||||||
value.append(QString::number(uint32_t(((version.LowPart & 0xFFFF0000) >> 16) & 0x0000FFFF)));
|
value << uint32_t(((version.LowPart & 0xFFFF0000) >> 16) & 0x0000FFFF);
|
||||||
value.append(".");
|
value << ".";
|
||||||
value.append(QString::number(uint32_t((version.LowPart) & 0x0000FFFF)));
|
value << uint32_t((version.LowPart) & 0x0000FFFF);
|
||||||
return value;
|
|
||||||
|
return value.str();
|
||||||
}
|
}
|
||||||
} convertDriverVersionToString;
|
} convertDriverVersionToString;
|
||||||
|
|
||||||
|
@ -58,7 +67,6 @@ void WINInstance::enumerateGpus() {
|
||||||
IDXGIFactory1* pFactory = nullptr;
|
IDXGIFactory1* pFactory = nullptr;
|
||||||
hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)(&pFactory));
|
hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)(&pFactory));
|
||||||
if (hr != S_OK || pFactory == nullptr) {
|
if (hr != S_OK || pFactory == nullptr) {
|
||||||
// qCDebug(shared) << "Unable to create DXGI";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +93,7 @@ void WINInstance::enumerateGpus() {
|
||||||
gpu[keys::gpu::vendor] = findGPUVendorInDescription(gpu[keys::gpu::model].get<std::string>());
|
gpu[keys::gpu::vendor] = findGPUVendorInDescription(gpu[keys::gpu::model].get<std::string>());
|
||||||
const SIZE_T BYTES_PER_MEGABYTE = 1024 * 1024;
|
const SIZE_T BYTES_PER_MEGABYTE = 1024 * 1024;
|
||||||
gpu[keys::gpu::videoMemory] = (uint32_t)(adapterDesc.DedicatedVideoMemory / BYTES_PER_MEGABYTE);
|
gpu[keys::gpu::videoMemory] = (uint32_t)(adapterDesc.DedicatedVideoMemory / BYTES_PER_MEGABYTE);
|
||||||
gpu[keys::gpu::driver] = convertDriverVersionToString.convert(version).toStdString();
|
gpu[keys::gpu::driver] = convertDriverVersionToString.convert(version);
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> displayIndices;
|
std::vector<int> displayIndices;
|
||||||
|
|
||||||
|
@ -98,12 +105,22 @@ void WINInstance::enumerateGpus() {
|
||||||
DXGI_OUTPUT_DESC outputDesc;
|
DXGI_OUTPUT_DESC outputDesc;
|
||||||
pOutput->GetDesc(&outputDesc);
|
pOutput->GetDesc(&outputDesc);
|
||||||
|
|
||||||
// Grab the Monitor desc
|
// Grab the dpi info for the monitor
|
||||||
// MONITOR_DESC
|
UINT dpiX{ 0 };
|
||||||
|
UINT dpiY{ 0 };
|
||||||
|
GetDpiForMonitor(outputDesc.Monitor, MDT_RAW_DPI, &dpiX, &dpiY);
|
||||||
|
UINT dpiXScaled{ 0 };
|
||||||
|
UINT dpiYScaled{ 0 };
|
||||||
|
GetDpiForMonitor(outputDesc.Monitor, MDT_EFFECTIVE_DPI, &dpiXScaled, &dpiYScaled);
|
||||||
|
|
||||||
|
// CUrrent display mode
|
||||||
|
DEVMODEW devMode;
|
||||||
|
devMode.dmSize = sizeof(DEVMODEW);
|
||||||
|
EnumDisplaySettingsW(outputDesc.DeviceName, ENUM_CURRENT_SETTINGS, &devMode);
|
||||||
|
|
||||||
json display = {};
|
json display = {};
|
||||||
|
|
||||||
// Desiplay name
|
// Display name
|
||||||
std::wstring wDeviceName(outputDesc.DeviceName);
|
std::wstring wDeviceName(outputDesc.DeviceName);
|
||||||
std::string deviceName(wDeviceName.begin(), wDeviceName.end());
|
std::string deviceName(wDeviceName.begin(), wDeviceName.end());
|
||||||
display[keys::display::name] = deviceName;
|
display[keys::display::name] = deviceName;
|
||||||
|
@ -111,14 +128,29 @@ void WINInstance::enumerateGpus() {
|
||||||
|
|
||||||
// Rect region of the desktop in desktop units
|
// Rect region of the desktop in desktop units
|
||||||
display["desktopRect"] = (outputDesc.AttachedToDesktop ? true : false);
|
display["desktopRect"] = (outputDesc.AttachedToDesktop ? true : false);
|
||||||
display[keys::display::coordsLeft] = outputDesc.DesktopCoordinates.left;
|
display[keys::display::boundsLeft] = outputDesc.DesktopCoordinates.left;
|
||||||
display[keys::display::coordsRight] = outputDesc.DesktopCoordinates.right;
|
display[keys::display::boundsRight] = outputDesc.DesktopCoordinates.right;
|
||||||
display[keys::display::coordsBottom] = outputDesc.DesktopCoordinates.bottom;
|
display[keys::display::boundsBottom] = outputDesc.DesktopCoordinates.bottom;
|
||||||
display[keys::display::coordsTop] = outputDesc.DesktopCoordinates.top;
|
display[keys::display::boundsTop] = outputDesc.DesktopCoordinates.top;
|
||||||
|
|
||||||
|
// DPI
|
||||||
|
display["ppiX"] = dpiX;
|
||||||
|
display["ppiY"] = dpiY;
|
||||||
|
display["physicalWidth"] = devMode.dmPelsWidth / (float) dpiX;
|
||||||
|
display["physicalHeight"] = devMode.dmPelsHeight / (float) dpiY;
|
||||||
|
display["modeWidth"] = devMode.dmPelsWidth;
|
||||||
|
display["modeHeight"] = devMode.dmPelsHeight;
|
||||||
|
|
||||||
|
//Average the ppiX and Y scaled vs the the true ppi
|
||||||
|
display["ppi"] = 0.5f * (dpiX + dpiY);
|
||||||
|
display["desktopPPIScale"] = 0.5f * (dpiX / (float) dpiXScaled + dpiY / (float)dpiYScaled);
|
||||||
|
|
||||||
|
// refreshrate
|
||||||
|
display["frequency"] = devMode.dmDisplayFrequency;
|
||||||
|
|
||||||
// Add the display index to the list of displays of the gpu
|
// Add the display index to the list of displays of the gpu
|
||||||
displayIndices.push_back(_displays.size());
|
displayIndices.push_back(_displays.size());
|
||||||
|
|
||||||
// And set the gpu index to the display description
|
// And set the gpu index to the display description
|
||||||
display[keys::display::gpu] = _gpus.size();
|
display[keys::display::gpu] = _gpus.size();
|
||||||
|
|
||||||
|
@ -136,22 +168,11 @@ void WINInstance::enumerateGpus() {
|
||||||
}
|
}
|
||||||
pFactory->Release();
|
pFactory->Release();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GPUIdent* ident = GPUIdent::getInstance();
|
|
||||||
|
|
||||||
json gpu = {};
|
|
||||||
gpu[keys::gpu::model] = ident->getName().toUtf8().constData();
|
|
||||||
gpu[keys::gpu::vendor] = findGPUVendorInDescription(gpu[keys::gpu::model].get<std::string>());
|
|
||||||
gpu[keys::gpu::videoMemory] = ident->getMemory();
|
|
||||||
gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData();
|
|
||||||
|
|
||||||
_gpus.push_back(gpu);
|
|
||||||
// _displays = ident->getOutput();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINInstance::enumerateMemory() {
|
void WINInstance::enumerateMemory() {
|
||||||
json ram = {};
|
json ram = {};
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
MEMORYSTATUSEX statex;
|
MEMORYSTATUSEX statex;
|
||||||
statex.dwLength = sizeof(statex);
|
statex.dwLength = sizeof(statex);
|
||||||
|
@ -162,11 +183,11 @@ void WINInstance::enumerateMemory() {
|
||||||
_memory = ram;
|
_memory = ram;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINInstance::enumerateComputer(){
|
void WINInstance::enumerateComputer() {
|
||||||
_computer[keys::computer::OS] = keys::computer::OS_WINDOWS;
|
_computer[keys::computer::OS] = keys::computer::OS_WINDOWS;
|
||||||
_computer[keys::computer::vendor] = "";
|
_computer[keys::computer::vendor] = "";
|
||||||
_computer[keys::computer::model] = "";
|
_computer[keys::computer::model] = "";
|
||||||
|
|
||||||
auto sysInfo = QSysInfo();
|
auto sysInfo = QSysInfo();
|
||||||
|
|
||||||
_computer[keys::computer::OSVersion] = sysInfo.kernelVersion().toStdString();
|
_computer[keys::computer::OSVersion] = sysInfo.kernelVersion().toStdString();
|
||||||
|
@ -180,23 +201,23 @@ void WINInstance::enumerateNics() {
|
||||||
// We can usually do better than the QNetworkInterface::humanReadableName() by
|
// We can usually do better than the QNetworkInterface::humanReadableName() by
|
||||||
// matching up Iphlpapi.lib IP_ADAPTER_INFO by mac id.
|
// matching up Iphlpapi.lib IP_ADAPTER_INFO by mac id.
|
||||||
ULONG buflen = sizeof(IP_ADAPTER_INFO);
|
ULONG buflen = sizeof(IP_ADAPTER_INFO);
|
||||||
IP_ADAPTER_INFO* pAdapterInfo = (IP_ADAPTER_INFO*) malloc(buflen);
|
IP_ADAPTER_INFO* pAdapterInfo = (IP_ADAPTER_INFO*)malloc(buflen);
|
||||||
|
|
||||||
// Size the buffer:
|
// Size the buffer:
|
||||||
if (GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) {
|
if (GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) {
|
||||||
free(pAdapterInfo);
|
free(pAdapterInfo);
|
||||||
pAdapterInfo = (IP_ADAPTER_INFO *) malloc(buflen);
|
pAdapterInfo = (IP_ADAPTER_INFO*)malloc(buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now get the data...
|
// Now get the data...
|
||||||
if (GetAdaptersInfo(pAdapterInfo, &buflen) == NO_ERROR) {
|
if (GetAdaptersInfo(pAdapterInfo, &buflen) == NO_ERROR) {
|
||||||
for (json& nic : _nics) { // ... loop through the nics from above...
|
for (json& nic : _nics) { // ... loop through the nics from above...
|
||||||
// ...convert the json to a string without the colons...
|
// ...convert the json to a string without the colons...
|
||||||
QString qtmac = nic[keys::nic::mac].get<std::string>().c_str();
|
QString qtmac = nic[keys::nic::mac].get<std::string>().c_str();
|
||||||
QString qtraw = qtmac.remove(QChar(':'), Qt::CaseInsensitive).toLower();
|
QString qtraw = qtmac.remove(QChar(':'), Qt::CaseInsensitive).toLower();
|
||||||
// ... and find the matching one in pAdapter:
|
// ... and find the matching one in pAdapter:
|
||||||
for (IP_ADAPTER_INFO* pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next) {
|
for (IP_ADAPTER_INFO* pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next) {
|
||||||
QByteArray wmac = QByteArray((const char*) (pAdapter->Address), pAdapter->AddressLength);
|
QByteArray wmac = QByteArray((const char*)(pAdapter->Address), pAdapter->AddressLength);
|
||||||
QString wraw = wmac.toHex();
|
QString wraw = wmac.toHex();
|
||||||
if (qtraw == wraw) {
|
if (qtraw == wraw) {
|
||||||
nic[keys::nic::name] = pAdapter->Description;
|
nic[keys::nic::name] = pAdapter->Description;
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace platform {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void enumerateCpus() override;
|
void enumerateCpus() override;
|
||||||
void enumerateGpus() override;
|
void enumerateGpusAndDisplays() override;
|
||||||
void enumerateMemory() override;
|
void enumerateMemory() override;
|
||||||
void enumerateComputer () override;
|
void enumerateComputer () override;
|
||||||
void enumerateNics() override;
|
void enumerateNics() override;
|
||||||
|
|
|
@ -86,20 +86,30 @@ PropFolderPanel {
|
||||||
var itemLabel = proItem.property;
|
var itemLabel = proItem.property;
|
||||||
var itemDepth = root.indentDepth + 1;
|
var itemDepth = root.indentDepth + 1;
|
||||||
if (Array.isArray(itemRootObject)) {
|
if (Array.isArray(itemRootObject)) {
|
||||||
if (objectItem.length > 1) {
|
itemLabel = proItem.property + "[] / " + itemRootObject.length
|
||||||
itemLabel = itemLabel + " " + objectItem.length
|
if (itemRootObject.length == 0) {
|
||||||
|
var component = Qt.createComponent("PropItem.qml");
|
||||||
|
component.createObject(propItemsContainer, {
|
||||||
|
"label": itemLabel
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
itemLabel = itemLabel + " " + objectItem.length
|
var component = Qt.createComponent("PropGroup.qml");
|
||||||
itemRootObject = itemRootObject[0];
|
component.createObject(propItemsContainer, {
|
||||||
|
"label": itemLabel,
|
||||||
|
"rootObject":itemRootObject,
|
||||||
|
"indentDepth": itemDepth,
|
||||||
|
"isUnfold": true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
var component = Qt.createComponent("PropGroup.qml");
|
||||||
|
component.createObject(propItemsContainer, {
|
||||||
|
"label": itemLabel,
|
||||||
|
"rootObject":itemRootObject,
|
||||||
|
"indentDepth": itemDepth,
|
||||||
|
"isUnfold": true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
var component = Qt.createComponent("PropGroup.qml");
|
|
||||||
component.createObject(propItemsContainer, {
|
|
||||||
"label": itemLabel,
|
|
||||||
"rootObject":itemRootObject,
|
|
||||||
"indentDepth": itemDepth,
|
|
||||||
"isUnfold": true,
|
|
||||||
})
|
|
||||||
} break;
|
} break;
|
||||||
case 'printLabel': {
|
case 'printLabel': {
|
||||||
var component = Qt.createComponent("PropItem.qml");
|
var component = Qt.createComponent("PropItem.qml");
|
||||||
|
@ -126,12 +136,6 @@ PropFolderPanel {
|
||||||
function populateFromObjectProps(object) {
|
function populateFromObjectProps(object) {
|
||||||
var propsModel = []
|
var propsModel = []
|
||||||
|
|
||||||
if (Array.isArray(object)) {
|
|
||||||
if (object.length <= 1) {
|
|
||||||
object = object[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var props = Object.keys(object);
|
var props = Object.keys(object);
|
||||||
for (var p in props) {
|
for (var p in props) {
|
||||||
var o = {};
|
var o = {};
|
||||||
|
|
Loading…
Reference in a new issue