diff --git a/deepin-devicemanager-server/CMakeLists.txt b/deepin-devicemanager-server/CMakeLists.txt index 242825003..c8b62421c 100644 --- a/deepin-devicemanager-server/CMakeLists.txt +++ b/deepin-devicemanager-server/CMakeLists.txt @@ -2,6 +2,7 @@ project(deepin-devicemanager-server C CXX) add_subdirectory(deepin-deviceinfo) add_subdirectory(deepin-devicecontrol) +add_subdirectory(customgpuinfo) #TEST-------------------------------------------------- if (CMAKE_COVERAGE_ARG STREQUAL "CMAKE_COVERAGE_ARG_ON") diff --git a/deepin-devicemanager-server/customgpuinfo/CMakeLists.txt b/deepin-devicemanager-server/customgpuinfo/CMakeLists.txt new file mode 100644 index 000000000..e9071dde6 --- /dev/null +++ b/deepin-devicemanager-server/customgpuinfo/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.7) + +set(BIN_NAME "customgpuinfo") + +find_package(Qt5 COMPONENTS Core REQUIRED) + +file(GLOB_RECURSE SRC + "${CMAKE_CURRENT_SOURCE_DIR}/*.h" + "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" +) + +add_executable(${BIN_NAME} + ${SRC} +) + +target_include_directories(${BIN_NAME} PUBLIC + Qt5::Core +) + +target_link_libraries(${BIN_NAME} PRIVATE + Qt5::Core +) + +install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/deepin-devicemanager) diff --git a/deepin-devicemanager-server/customgpuinfo/main.cpp b/deepin-devicemanager-server/customgpuinfo/main.cpp new file mode 100644 index 000000000..c26460bd4 --- /dev/null +++ b/deepin-devicemanager-server/customgpuinfo/main.cpp @@ -0,0 +1,121 @@ +// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include +#include +#include +#include +#include + +#include + +// 名称("Name") 厂商("Vendor") 型号("Model") 版本(Version) 显存("Graphics Memory") + +constexpr char kName[] { "Name" }; +constexpr char kVendor[] { "Vendor" }; +constexpr char kModel[] { "Model" }; +constexpr char kVersion[] { "Version" }; +constexpr char kGraphicsMemory[] { "Graphics Memory" }; + +bool getGpuBaseInfo(QMap &mapInfo) +{ + QProcess process; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + process.setProcessEnvironment(env); + process.start("/usr/bin/glxinfo", QStringList() << "-B"); + if (!process.waitForFinished(3000)) { + qCritical() << "Error executing glxinfo:" << process.errorString(); + return false; + } + + QString output = QString::fromLocal8Bit(process.readAllStandardOutput()); + QStringList lines = output.split('\n'); + QRegularExpression regex("^([^:]+):\\s*(.+)$"); + for (const QString &line : lines) { + QRegularExpressionMatch match = regex.match(line); + if (match.hasMatch()) { + QString key = match.captured(1).trimmed(); + QString value = match.captured(2).trimmed(); + if (key == "OpenGL renderer string") { + mapInfo.insert(kName, value); + mapInfo.insert(kModel, value); + } else if (key == "OpenGL vendor string") { + mapInfo.insert(kVendor, value); + } + } + } + + return true; +} + +bool getGpuMemInfoForFTDTM(QMap &mapInfo) +{ + const QString filePath = "/sys/kernel/debug/gc/meminfo"; + QString totalValue; + bool foundTotal = false; + + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qCritical() << "Error opening /sys/kernel/debug/gc/meminfo:" << file.errorString(); + return false; + } + + QString content = QString::fromUtf8(file.readAll()); + file.close(); + + if (content.isEmpty()) { + qCritical() << "Error: /sys/kernel/debug/gc/meminfo File is empty!"; + return false; + } + + QRegularExpression system0Regex(R"(POOL SYSTEM0:*(.*?)POOL VIRTUAL:)", + QRegularExpression::DotMatchesEverythingOption); + QRegularExpressionMatch system0Match = system0Regex.match(content); + + if (!system0Match.hasMatch()) { + qCritical() << "Error: Failed to find SYSTEM0 section"; + return false; + } + + QString system0Content = system0Match.captured(1); + QRegularExpression totalRegex(R"(Total\s*:\s*(\d+)\s+B)"); + QRegularExpressionMatch totalMatch = totalRegex.match(system0Content); + if (totalMatch.hasMatch()) { + totalValue = totalMatch.captured(1); + foundTotal = true; + } + + if (!foundTotal || totalValue.isEmpty()) { + qCritical() << "Error: Failed to find Total value in SYSTEM0 content"; + return false; + } + + bool ok; + quint64 memSize = totalValue.trimmed().toULong(&ok, 10); + if (ok && memSize >= 1048576) { + memSize /= 1048576; + auto curSize = memSize / 1024.0; + if (curSize >= 1) { + totalValue = QString::number(curSize) + "GB"; + } else { + totalValue = QString::number(memSize) + "MB"; + } + } + + mapInfo.insert(kGraphicsMemory, totalValue); + + return true; +} + +int main(int argc, char *argv[]) +{ + QMap mapInfo; + if (getGpuBaseInfo(mapInfo) && getGpuMemInfoForFTDTM(mapInfo)) { + for (auto it = mapInfo.begin(); it != mapInfo.end(); ++it) + std::cout << it.key().toStdString() << ": " << it.value().toStdString() << std::endl; + return 0; + } else { + return 1; + } +} diff --git a/deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp b/deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp index 561cdecc1..23f19260d 100644 --- a/deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp +++ b/deepin-devicemanager-server/deepin-devicecontrol/src/controlinterface.cpp @@ -140,9 +140,7 @@ bool ControlInterface::enable(const QString &hclass, const QString &name, const // 先从数据库中查找路径,防止设备更换usb接口 QString sPath = EnableSqlManager::getInstance()->authorizedPath(value); - if (sPath.isEmpty()) { - sPath = path; - } + sPath = path; // 判断是内置设备,还是外设,内置设备通过remove文件禁用,外设通过authorized文件禁用 bool res = false; diff --git a/deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/drivermanager.cpp b/deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/drivermanager.cpp index 10034d7c6..d4106e589 100644 --- a/deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/drivermanager.cpp +++ b/deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/drivermanager.cpp @@ -237,7 +237,7 @@ bool DriverManager::installDriver(const QString &filepath) //模块已被加载 /* * 下面代码由 liujun 于 2021年11月9号 注释 - * 为修复bug https://pms.uniontech.com/zentao/bug-view-101808.html + * 为修复bug 101808 */ // if (mp_modcore->modIsLoaded(filepath)) { // sigProgressDetail(10, QString("could not insert module %1 :file exist").arg(filepath)); diff --git a/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp b/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp index dbb27f3e4..f39d6a88a 100644 --- a/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp +++ b/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp @@ -52,14 +52,17 @@ void EnableSqlManager::removeDateFromRemoveTable(const QString &path) void EnableSqlManager::insertDataToAuthorizedTable(const QString &hclass, const QString &name, const QString &path, const QString &unique_id, bool exist, const QString &strDriver) { // 数据库已经存在该设备记录 - if (uniqueIDExistedEX(unique_id)) { + if (uniqueIDExistedEX(unique_id, path)) { return; } // 数据库没有该设备记录,则直接插入 // QString sql = QString("INSERT INTO %1 (class, name, path, unique_id, exist, driver) VALUES (%2, %3, %4, %5, %6, %7);") // .arg(DB_TABLE_AUTHORIZED).arg(":hclass").arg(":name").arg(":path").arg(":unique_id").arg(":exist").arg(":strDriver"); - if(!m_sqlQuery.prepare("INSERT INTO authorized (class, name, path, unique_id, exist, driver) VALUES (:hclass, :name, :path, :unique_id, :exist, :strDriver);")) return; + if(!m_sqlQuery.prepare("INSERT INTO authorized (class, name, path, unique_id, exist, driver) VALUES (:hclass, :name, :path, :unique_id, :exist, :strDriver);")){ + qDebug() << "insert data to authorized table failed"; + return; + } m_sqlQuery.bindValue(":hclass", QVariant(hclass)); m_sqlQuery.bindValue(":name", QVariant(name)); m_sqlQuery.bindValue(":path", QVariant(path)); @@ -124,20 +127,26 @@ void EnableSqlManager::removeDataFromPrinterTable(const QString &name) } } -bool EnableSqlManager::uniqueIDExisted(const QString &key) +bool EnableSqlManager::uniqueIDExisted(const QString &key, const QString path) { QString sql = QString("SELECT COUNT(*) FROM %1 WHERE unique_id=%2;").arg(DB_TABLE_AUTHORIZED).arg(":param"); + if (!path.isEmpty()){ + sql = QString("SELECT COUNT(*) FROM %1 WHERE unique_id=%2 and path=%3;").arg(DB_TABLE_AUTHORIZED).arg(":param").arg(":path"); + } if(!m_sqlQuery.prepare(sql)) return false; m_sqlQuery.bindValue(":param", QVariant(key)); + if (!path.isEmpty()){ + m_sqlQuery.bindValue(":path", QVariant(path)); + } if (m_sqlQuery.exec() && m_sqlQuery.next()) { return m_sqlQuery.value(0).toInt() > 0; } return false; } -bool EnableSqlManager::uniqueIDExistedEX(const QString &key) +bool EnableSqlManager::uniqueIDExistedEX(const QString &key, const QString path) { - return uniqueIDExisted(key); + return uniqueIDExisted(key, path); } bool EnableSqlManager::isUniqueIdEnabled(const QString &key) diff --git a/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.h b/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.h index 273fe9325..6c8d7a870 100644 --- a/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.h +++ b/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.h @@ -90,14 +90,14 @@ class EnableSqlManager : public QObject * @param key * @return */ - bool uniqueIDExisted(const QString &key); + bool uniqueIDExisted(const QString &key, const QString path = ""); /** * @brief uniqueIDExistedForEnable * @param key * @return */ - bool uniqueIDExistedEX(const QString &key); + bool uniqueIDExistedEX(const QString &key, const QString path = ""); /** * @brief isUniqueIdEnabled 判断设备是否被禁用了 diff --git a/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp b/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp index 33910d3c3..b2f051a01 100644 --- a/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp +++ b/deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -138,34 +139,51 @@ void EnableUtils::disableInDevice() bool EnableUtils::ioctlOperateNetworkLogicalName(const QString &logicalName, bool enable) { - // 1. 通过ioctl禁用 - int fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) - return false; - struct ifreq ifr; - strncpy(ifr.ifr_name, logicalName.toStdString().c_str(),IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ - 1] = '\0'; - short flag; - if (enable) { - flag = IFF_UP | IFF_PROMISC; - } else { - flag = ~(IFF_UP | IFF_PROMISC); - } - // 先获取标识 - if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { - close(fd); - return false; - } - // 获取后重新设置标识 - if (enable) { - ifr.ifr_ifru.ifru_flags |= flag; + if (logicalName.startsWith("wlan") || logicalName.startsWith("wlp")) { // Wireless LAN + QString cmd = QString("rfkill %1 $(rfkill list | grep -A 2 \"phy$(iw dev %2 info 2>/dev/null | awk '/wiphy/{print $2}')\" | awk 'NR==1{print $1}' | tr -d ':')") + .arg(enable ? "unblock" : "block") + .arg(logicalName); + int ret = system(cmd.toStdString().c_str()); + if (ret != 0) { + qCritical() << "Failed to block/unblock wifi: " << " error code: " << ret ; + } + cmd = QString("/sbin/ifconfig %1 %2").arg(logicalName).arg(enable ? "up" : "down"); + ret = system(cmd.toStdString().c_str()); + if (ret != 0) { + qCritical() << "Failed to up/down network: " << logicalName << enable << " error code: " << ret ; + return false; + } } else { - ifr.ifr_ifru.ifru_flags &= flag; - } + // 1. 通过ioctl禁用 + int fd = socket(AF_INET, SOCK_STREAM, 0); + if (fd < 0) + return false; + + struct ifreq ifr; + strncpy(ifr.ifr_name, logicalName.toStdString().c_str(),IFNAMSIZ); + ifr.ifr_name[IFNAMSIZ - 1] = '\0'; + short flag; + if (enable) { + flag = IFF_UP | IFF_PROMISC; + } else { + flag = ~(IFF_UP | IFF_PROMISC); + } + // 先获取标识 + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { + close(fd); + return false; + } + // 获取后重新设置标识 + if (enable) { + ifr.ifr_ifru.ifru_flags |= flag; + } else { + ifr.ifr_ifru.ifru_flags &= flag; + } - if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { - close(fd); - return false; + if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { + close(fd); + return false; + } } return true; } diff --git a/deepin-devicemanager-server/deepin-devicecontrol/src/wakecontrol/wakeuputils.cpp b/deepin-devicemanager-server/deepin-devicecontrol/src/wakecontrol/wakeuputils.cpp index 186c7ba39..d3a9ad613 100644 --- a/deepin-devicemanager-server/deepin-devicecontrol/src/wakecontrol/wakeuputils.cpp +++ b/deepin-devicemanager-server/deepin-devicecontrol/src/wakecontrol/wakeuputils.cpp @@ -117,7 +117,12 @@ WakeupUtils::EthStatus WakeupUtils::wakeOnLanIsOpen(const QString &logicalName) struct ifreq ifr; struct ethtool_wolinfo wolinfo; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, logicalName.toStdString().c_str(), sizeof(logicalName.toStdString().c_str())); + memset(&wolinfo, 0, sizeof(wolinfo)); + + QByteArray nameBytes = logicalName.toLocal8Bit(); + strncpy(ifr.ifr_name, nameBytes.constData(), IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = '\0'; + wolinfo.cmd = ETHTOOL_GWOL; ifr.ifr_data = reinterpret_cast(&wolinfo); if (0 != ioctl(fd, SIOCETHTOOL, &ifr)) { @@ -147,7 +152,12 @@ bool WakeupUtils::setWakeOnLan(const QString &logicalName, bool open) struct ifreq ifr; struct ethtool_wolinfo wolinfo; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, logicalName.toStdString().c_str(), sizeof(logicalName.toStdString().c_str())); + memset(&wolinfo, 0, sizeof(wolinfo)); + + QByteArray nameBytes = logicalName.toLocal8Bit(); + strncpy(ifr.ifr_name, nameBytes.constData(), IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = '\0'; + wolinfo.cmd = ETHTOOL_SWOL; if (open) wolinfo.wolopts = 0 | WAKE_MAGIC; diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/monitorusb.cpp b/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/monitorusb.cpp index fa088b4ce..9b3542f9f 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/monitorusb.cpp +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/hotplug/monitorusb.cpp @@ -47,8 +47,8 @@ void MonitorUsb::monitor() break; FD_ZERO(&fds); FD_SET(fd, &fds); - tv.tv_sec = 0; - tv.tv_usec = 10000; + tv.tv_sec = 1; + tv.tv_usec = 0; int ret = select(fd + 1, &fds, nullptr, nullptr, &tv); // 判断是否有事件产生 diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp index cb23d33b6..89d975ecf 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include #include using namespace PolkitQt1; @@ -56,3 +58,30 @@ void DeviceInterface::setMonitorDeviceFlag(bool flag) parentMainJob->setWorkingFlag(flag); } } + +QString DeviceInterface::getGpuInfoByCustom(const QString &cmd, const QStringList &arguments) +{ + static bool firstFlag = true; + static QString gpuinfo; + if (firstFlag) { + firstFlag = false; + + QProcess process; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + if (arguments.size() > 1) { + env.insert("DISPLAY", arguments[0]); + env.insert("XAUTHORITY", arguments[1]); + } + process.setProcessEnvironment(env); + process.start(cmd, arguments); + if (!process.waitForFinished(4000)) { + qCritical() << QString("Error executing %1 :").arg(cmd) << process.errorString(); + return gpuinfo; + } + + if (process.exitCode() == 0) + gpuinfo = QString::fromLocal8Bit(process.readAllStandardOutput()); + } + + return gpuinfo; +} diff --git a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.h b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.h index f1ad9f158..01c656107 100644 --- a/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.h +++ b/deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.h @@ -39,6 +39,8 @@ public slots: */ Q_SCRIPTABLE void setMonitorDeviceFlag(bool flag); + Q_SCRIPTABLE QString getGpuInfoByCustom(const QString &cmd, const QStringList &arguments); + private: bool getUserAuthorPasswd(); }; diff --git a/deepin-devicemanager/assets/oeminfo_sampleAnduseGuideLine_zh_CN.toml b/deepin-devicemanager/assets/oeminfo_sampleAnduseGuideLine_zh_CN.toml index 427ae3fa0..0afc0cc52 100755 --- a/deepin-devicemanager/assets/oeminfo_sampleAnduseGuideLine_zh_CN.toml +++ b/deepin-devicemanager/assets/oeminfo_sampleAnduseGuideLine_zh_CN.toml @@ -245,7 +245,7 @@ GPU vendor ="toml_GPU vendor" #29 : GPU GPU type ="toml_GPU type" #30 : GPU类型 SubVendor ="toml_SubVendor" #31 : 子制造商 SubDevice ="toml_SubDevice" #32 : 子设备 -latency ="toml_latency" #33 : 延迟 +Latency ="toml_latency" #33 : 延迟 Device ="toml_Device" #34 : 设备 Config Status ="toml_Config Status" #35 : 配置状态 Driver Modules ="toml_Driver Modules" #36 : 驱动模块 @@ -263,6 +263,7 @@ Display Ratio ="toml_Display Ratio" #9 : 显 Current Resolution ="toml_Current Resolution" #10 : 当前分辨率 Support Resolution ="toml_Support Resolution" #11 : 支持分辨率 Date ="toml_Date" #12 : 日期 +Refresh Rate ="toml_Refresh Rate" #13 : 支持的屏幕刷新率 [NetWork.flagLabel] #(网络适配器) Name ="toml_Name" #1 : 名称 @@ -311,7 +312,7 @@ Sysfs ="toml_Sysfs" #16 : Sysfs Handlers ="toml_Handlers" #17 : 处理程序 SubVendor ="toml_SubVendor" #18 : 子制造商 SubDevice ="toml_SubDevice" #19 : 子设备 -latency ="toml_latency" #20 : 延迟 +Latency ="toml_latency" #20 : 延迟 Bus ="toml_Bus" #21 : 总线 Version ="toml_Version" #22 : 版本 Config Status ="toml_Config Status" #23 : 配置状态 @@ -500,4 +501,6 @@ Device File ="toml_Device File" #10 : 设备文件 #4-3-2.双匹配key需要两个值同时匹配:key2:"Vendor_ID 和 Product_ID"("物理ID"中VID和PID值); key3:"Vendor 和 Name"(制造商和名称); 。 #4-4.匹配生效后表头下面每行key名与对应设备管理器中显示每条信息名一致,其值则会被显示到对应界面。 #4-3.若匹配key匹配上某一设备且值尾包括有"_NOUSE"则该个设备所有信息将被删除显示。 -#4-4.增加一个设备信息则不需要匹配;没有写入该文件的表头所代表设备将不会被修改;没有写入该文件的key值所代表设备信息将不会被修改。 \ No newline at end of file +#4-4.增加一个设备信息则不需要匹配;没有写入该文件的表头所代表设备将不会被修改;没有写入该文件的key值所代表设备信息将不会被修改。 +#4-5.1 增加 tomlmatchkey = { Size = "512", Name = "xname" } # 内联表 "{Size:512G}{Name:xx1}{Vendor:xx2}" # 匹配键名 +#4-5.2 增加 tomlconfigdemanding ="adjust" # 配置需求 “adjust delete add” diff --git a/deepin-devicemanager/assets/org.deepin.devicemanager.json b/deepin-devicemanager/assets/org.deepin.devicemanager.json index cbc0690f8..8f53b60a1 100644 --- a/deepin-devicemanager/assets/org.deepin.devicemanager.json +++ b/deepin-devicemanager/assets/org.deepin.devicemanager.json @@ -15,15 +15,35 @@ "permissions": "readwrite", "visibility": "public" }, - "specialComType": { + "specialComType": { "value": -1, "serial": 0, "flags": ["global"], "name": "Special Computer Type", "name[zh_CN]": "特殊机器类型", - "description": "special computer type:PGUW(value:1),KLVV/L540(value:2),KLVU(value:3),PGUV/W585(value:4),PGUX(value:5)", + "description": "special computer type:PGUW(value:1),KLVV/L540(value:2),KLVU(value:3),PGUV/W585(value:4),PGUX(value:5),FLMX(value:6)", "permissions": "readwrite", "visibility": "private" - } - } + }, + "TomlFilesName": { + "value": "tomlFilesName", + "serial": 0, + "flags": ["global"], + "name": "config the toml name", + "name[zh_CN]": "设置toml文件名", + "description": "此配置项默认为无效的。如需让toml文件内容显示生效,请配置对应文件名。需保证操作者具备读取权限。", + "permissions": "readwrite", + "visibility": "private" + }, + "CommandToGetGPUInfo": { + "value": "", + "serial": 0, + "flags": ["global"], + "name": "Command to get GPU infomation", + "name[zh_CN]": "获取GPU信息的命令", + "description": "此配置项默认为空。如果specialComType==8,程序则启用此项配置。", + "permissions": "readwrite", + "visibility": "private" + } + } } diff --git a/deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp b/deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp index 067fa586c..54c110e81 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp @@ -119,14 +119,14 @@ bool DeviceAudio::setInfoFromLshw(const QMap &mapInfo) TomlFixMethod DeviceAudio::setInfoFromTomlOneByOne(const QMap &mapInfo) { TomlFixMethod ret = TOML_None; -// must cover the loadOtherDeviceInfo + // must cover the loadOtherDeviceInfo // 添加基本信息 - ret = setTomlAttribute(mapInfo, "SysFS_Path", m_SysPath); - ret = setTomlAttribute(mapInfo, "KernelModeDriver", m_Driver); + setTomlAttribute(mapInfo, "SysFS_Path", m_SysPath); + setTomlAttribute(mapInfo, "KernelModeDriver", m_Driver); // 添加其他信息,成员变量 - ret = setTomlAttribute(mapInfo, "Chip", m_Chip); - ret = setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); - ret = setTomlAttribute(mapInfo, "Memory Address", m_Memory); + setTomlAttribute(mapInfo, "Chip", m_Chip); + setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); + setTomlAttribute(mapInfo, "Memory Address", m_Memory); ret = setTomlAttribute(mapInfo, "IRQ", m_Irq); //3. 获取设备的其它信息 getOtherMapInfo(mapInfo); @@ -263,7 +263,7 @@ const QString &DeviceAudio::driver() const } const QString &DeviceAudio::uniqueID() const { - return m_SysPath; + return m_UniqueID; } EnableDeviceStatus DeviceAudio::setEnable(bool e) { @@ -304,44 +304,44 @@ const QString DeviceAudio::getOverviewInfo() void DeviceAudio::initFilterKey() { // 添加可显示的属性 - addFilterKey(tr("Device Name")); - addFilterKey(QObject::tr("SubVendor")); - addFilterKey(QObject::tr("SubDevice")); - addFilterKey(QObject::tr("Driver Status")); - addFilterKey(QObject::tr("Driver Activation Cmd")); - addFilterKey(QObject::tr("Config Status")); - addFilterKey(QObject::tr("latency")); - addFilterKey(QObject::tr("Phys")); - addFilterKey(QObject::tr("Sysfs")); - addFilterKey(QObject::tr("Handlers")); - addFilterKey(QObject::tr("PROP")); - addFilterKey(QObject::tr("EV")); - addFilterKey(QObject::tr("KEY")); - addFilterKey(QObject::tr("Bus")); - addFilterKey(QObject::tr("Version")); - addFilterKey(QObject::tr("Driver")); + addFilterKey("Device Name"); + addFilterKey("SubVendor"); + addFilterKey("SubDevice"); + addFilterKey("Driver Status"); + addFilterKey("Driver Activation Cmd"); + addFilterKey("Config Status"); + addFilterKey("latency"); + addFilterKey("Phys"); + addFilterKey("Sysfs"); + addFilterKey("Handlers"); + addFilterKey("PROP"); + addFilterKey("EV"); + addFilterKey("KEY"); + addFilterKey("Bus"); + addFilterKey("Version"); + addFilterKey("Driver"); } void DeviceAudio::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("SysFS_Path"), m_SysPath); - addBaseDeviceInfo(tr("Description"), m_Description); - addBaseDeviceInfo(tr("Revision"), m_Version); - addBaseDeviceInfo(tr("KernelModeDriver"), m_Driver); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("SysFS_Path"), m_SysPath); + addBaseDeviceInfo(("Description"), m_Description); + addBaseDeviceInfo(("Revision"), m_Version); + addBaseDeviceInfo(("KernelModeDriver"), m_Driver); } void DeviceAudio::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Module Alias"), m_Modalias); - addOtherDeviceInfo(tr("Physical ID"), m_PhysID); - addOtherDeviceInfo(tr("Chip"), m_Chip); - addOtherDeviceInfo(tr("Capabilities"), m_Capabilities); - addOtherDeviceInfo(tr("Memory Address"), m_Memory); // 1050需求 内存改为内存地址 - addOtherDeviceInfo(tr("IRQ"), m_Irq); + addOtherDeviceInfo(("Module Alias"), m_Modalias); + addOtherDeviceInfo(("Physical ID"), m_PhysID); + addOtherDeviceInfo(("Chip"), m_Chip); + addOtherDeviceInfo(("Capabilities"), m_Capabilities); + addOtherDeviceInfo(("Memory Address"), m_Memory); // 1050需求 内存改为内存地址 + addOtherDeviceInfo(("IRQ"), m_Irq); // 将QMap内容转存为QList> mapInfoToList(); } @@ -349,8 +349,8 @@ void DeviceAudio::loadOtherDeviceInfo() void DeviceAudio::loadTableHeader() { // 表头信息 - m_TableHeader.append(tr("Name")); - m_TableHeader.append(tr("Vendor")); + m_TableHeader.append("Name"); + m_TableHeader.append("Vendor"); } void DeviceAudio::loadTableData() @@ -359,11 +359,11 @@ void DeviceAudio::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceBios.cpp b/deepin-devicemanager/src/DeviceManager/DeviceBios.cpp index d734314ad..92fbd0ab7 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceBios.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceBios.cpp @@ -23,8 +23,8 @@ TomlFixMethod DeviceBios::setInfoFromTomlOneByOne(const QMap & TomlFixMethod ret = TOML_None; ret = setTomlAttribute(mapInfo, "Version", m_Version, true); - ret = setTomlAttribute(mapInfo, "Product Name", m_ProductName, true); - ret = setTomlAttribute(mapInfo, "Chipset", m_ChipsetFamily, true); + setTomlAttribute(mapInfo, "Product Name", m_ProductName, true); + setTomlAttribute(mapInfo, "Chipset", m_ChipsetFamily, true); // ret = setTomlAttribute(mapInfo, "Vendor", m_Vendor,true); // m_IsBoard = true; @@ -39,7 +39,7 @@ bool DeviceBios::setBiosInfo(const QMap &mapInfo) return false; // 获取BIOS信息 - m_Name = QObject::tr("BIOS Information"); + m_Name = ("BIOS Information"); m_tomlName = ("BIOS Information"); setAttribute(mapInfo, "Vendor", m_Vendor); setAttribute(mapInfo, "Version", m_Version); @@ -61,7 +61,7 @@ bool DeviceBios::setBaseBoardInfo(const QMap &mapInfo) return false; // 获取主板信息 - m_Name = QObject::tr("Base Board Information"); + m_Name = ("Base Board Information"); m_tomlName = ("Base Board Information"); setAttribute(mapInfo, "Manufacturer", m_Vendor); setAttribute(mapInfo, "Version", m_Version); @@ -83,7 +83,7 @@ bool DeviceBios::setSystemInfo(const QMap &mapInfo) return false; // 获取系统信息 - m_Name = QObject::tr("System Information"); + m_Name = ("System Information"); m_tomlName = ("System Information"); setAttribute(mapInfo, "Manufacturer", m_Vendor); setAttribute(mapInfo, "Version", m_Version); @@ -99,7 +99,7 @@ bool DeviceBios::setChassisInfo(const QMap &mapInfo) return false; // 获取机箱信息 - m_Name = QObject::tr("Chassis Information"); + m_Name = ("Chassis Information"); m_tomlName = ("Chassis Information"); setAttribute(mapInfo, "Manufacturer", m_Vendor); setAttribute(mapInfo, "Version", m_Version); @@ -115,7 +115,7 @@ bool DeviceBios::setMemoryInfo(const QMap &mapInfo) return false; // 获取内存插槽信息 - m_Name = QObject::tr("Physical Memory Array"); + m_Name = ("Physical Memory Array"); m_tomlName = ("Physical Memory Array"); setAttribute(mapInfo, "Manufacturer", m_Vendor); setAttribute(mapInfo, "Version", m_Version); @@ -157,7 +157,7 @@ bool DeviceBios::isBoard()const QString DeviceBios::subTitle() { - return m_Name; + return translateStr(m_Name); } const QString DeviceBios::getOverviewInfo() @@ -173,76 +173,76 @@ void DeviceBios::initFilterKey() { // 添加可显示属性 - addFilterKey(QObject::tr("Release Date")); - addFilterKey(QObject::tr("Address")); - addFilterKey(QObject::tr("Runtime Size")); - addFilterKey(QObject::tr("ROM Size")); - addFilterKey(QObject::tr("Characteristics")); - addFilterKey(QObject::tr("BIOS Revision")); - addFilterKey(QObject::tr("Firmware Revision")); - - addFilterKey(QObject::tr("Product Name")); - addFilterKey(QObject::tr("Serial Number")); - addFilterKey(QObject::tr("Asset Tag")); - addFilterKey(QObject::tr("Features")); - addFilterKey(QObject::tr("Location In Chassis")); - addFilterKey(QObject::tr("Chassis Handle")); - addFilterKey(QObject::tr("Type")); - addFilterKey(QObject::tr("Contained Object Handles")); - - addFilterKey(QObject::tr("Product Name")); - addFilterKey(QObject::tr("Serial Number")); - addFilterKey(QObject::tr("UUID")); - addFilterKey(QObject::tr("Wake-up Type")); - addFilterKey(QObject::tr("SKU Number")); - addFilterKey(QObject::tr("Family")); - - - addFilterKey(QObject::tr("Type")); - addFilterKey(QObject::tr("Lock")); - addFilterKey(QObject::tr("Serial Number")); - addFilterKey(QObject::tr("Asset Tag")); - addFilterKey(QObject::tr("Boot-up State")); - addFilterKey(QObject::tr("Power Supply State")); - addFilterKey(QObject::tr("Thermal State")); - addFilterKey(QObject::tr("Security Status")); - addFilterKey(QObject::tr("OEM Information")); - addFilterKey(QObject::tr("Height")); - addFilterKey(QObject::tr("Number Of Power Cords")); - addFilterKey(QObject::tr("Contained Elements")); - addFilterKey(QObject::tr("SKU Number")); - - addFilterKey(QObject::tr("Location")); - addFilterKey(QObject::tr("Error Correction Type")); - addFilterKey(QObject::tr("Maximum Capacity")); - addFilterKey(QObject::tr("Error Information Handle")); - addFilterKey(QObject::tr("Number Of Devices")); - - addFilterKey(QObject::tr("BIOS ROMSIZE")); - addFilterKey(QObject::tr("Release date")); - addFilterKey(QObject::tr("Board name")); - addFilterKey(QObject::tr("Family")); - - addFilterKey(QObject::tr("BIOS Information")); - addFilterKey(QObject::tr("Base Board Information")); - addFilterKey(QObject::tr("System Information")); - addFilterKey(QObject::tr("Chassis Information")); - addFilterKey(QObject::tr("Physical Memory Array")); - - addFilterKey(QObject::tr("SMBIOS Version")); - - addFilterKey(QObject::tr("Language Description Format")); - addFilterKey(QObject::tr("Installable Languages")); - addFilterKey(QObject::tr("Currently Installed Language")); + addFilterKey("Release Date"); + addFilterKey("Address"); + addFilterKey("Runtime Size"); + addFilterKey("ROM Size"); + addFilterKey("Characteristics"); + addFilterKey("BIOS Revision"); + addFilterKey("Firmware Revision"); + + addFilterKey("Product Name"); + addFilterKey("Serial Number"); + addFilterKey("Asset Tag"); + addFilterKey("Features"); + addFilterKey("Location In Chassis"); +// addFilterKey("Chassis Handle"); + addFilterKey("Type"); +// addFilterKey("Contained Object Handles"); + + addFilterKey("Product Name"); + addFilterKey("Serial Number"); + addFilterKey("UUID"); + addFilterKey("Wake-up Type"); + addFilterKey("SKU Number"); + addFilterKey("Family"); + + + addFilterKey("Type"); + addFilterKey("Lock"); + addFilterKey("Serial Number"); + addFilterKey("Asset Tag"); + addFilterKey("Boot-up State"); + addFilterKey("Power Supply State"); + addFilterKey("Thermal State"); + addFilterKey("Security Status"); + addFilterKey("OEM Information"); + addFilterKey("Height"); + addFilterKey("Number Of Power Cords"); + addFilterKey("Contained Elements"); + addFilterKey("SKU Number"); + + addFilterKey("Location"); + addFilterKey("Error Correction Type"); + addFilterKey("Maximum Capacity"); + addFilterKey("Error Information Handle"); + addFilterKey("Number Of Devices"); + + addFilterKey("BIOS ROMSIZE"); + addFilterKey("Release date"); + addFilterKey("Board name"); + addFilterKey("Family"); + + addFilterKey("BIOS Information"); + addFilterKey("Base Board Information"); + addFilterKey("System Information"); + addFilterKey("Chassis Information"); + addFilterKey("Physical Memory Array"); + + addFilterKey("SMBIOS Version"); + + addFilterKey("Language Description Format"); + addFilterKey("Installable Languages"); + addFilterKey("Currently Installed Language"); } void DeviceBios::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Version"), m_Version); - addBaseDeviceInfo(tr("Chipset"), m_ChipsetFamily); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Version"), m_Version); + addBaseDeviceInfo(("Chipset"), m_ChipsetFamily); } void DeviceBios::loadOtherDeviceInfo() diff --git a/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp b/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp index 0d518380c..7ab898171 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp @@ -116,42 +116,24 @@ TomlFixMethod DeviceBluetooth::setInfoFromTomlOneByOne(const QMap &mapInfo) -{ - // 机器自身蓝牙 - const QList > &otherAttribs = getOtherAttribs(); - QMap tmpMaps; - for (QPair attrib : otherAttribs) { - tmpMaps[attrib.first] = attrib.second; - } - - if ("UART" == tmpMaps[QObject::tr("Bus")]) {//内置:UART 外接USB:USB - setAttribute(mapInfo, "Chip Type", m_Name); - setAttribute(mapInfo, "Vendor", m_Vendor); - return true; - } else { - return false; - } -} - const QString &DeviceBluetooth::name()const { return m_Model; @@ -204,59 +186,59 @@ bool DeviceBluetooth::enable() void DeviceBluetooth::initFilterKey() { // 添加可显示的属性 - addFilterKey(QObject::tr("Bus")); - addFilterKey(QObject::tr("BD Address")); - addFilterKey(QObject::tr("ACL MTU")); - addFilterKey(QObject::tr("SCO MTU")); - addFilterKey(QObject::tr("Features")); - addFilterKey(QObject::tr("Packet type")); - addFilterKey(QObject::tr("Link policy")); - addFilterKey(QObject::tr("Link mode")); - addFilterKey(QObject::tr("Class")); - addFilterKey(QObject::tr("Service Classes")); - addFilterKey(QObject::tr("Device Class")); - addFilterKey(QObject::tr("HCI Version")); - addFilterKey(QObject::tr("LMP Version")); - addFilterKey(QObject::tr("Subversion")); - - addFilterKey(QObject::tr("Device")); - addFilterKey(QObject::tr("Serial ID")); - - addFilterKey(QObject::tr("product")); - addFilterKey(QObject::tr("description")); - // addFilterKey(QObject::tr("physical id")); - addFilterKey(QObject::tr("Class")); - addFilterKey(QObject::tr("Powered")); - addFilterKey(QObject::tr("Discoverable")); - addFilterKey(QObject::tr("Pairable")); - addFilterKey(QObject::tr("UUID")); - addFilterKey(QObject::tr("Modalias")); - addFilterKey(QObject::tr("Discovering")); + addFilterKey("Bus"); + addFilterKey("BD Address"); + addFilterKey("ACL MTU"); + addFilterKey("SCO MTU"); + addFilterKey("Features"); + addFilterKey("Packet type"); + addFilterKey("Link policy"); + addFilterKey("Link mode"); + addFilterKey("Class"); + addFilterKey("Service Classes"); + addFilterKey("Device Class"); + addFilterKey("HCI Version"); + addFilterKey("LMP Version"); + addFilterKey("Subversion"); + + addFilterKey("Device"); + addFilterKey("Serial ID"); + + addFilterKey("product"); + addFilterKey("description"); + // addFilterKey("physical id"); + addFilterKey("Class"); + addFilterKey("Powered"); + addFilterKey("Discoverable"); + addFilterKey("Pairable"); + addFilterKey("UUID"); + addFilterKey("Modalias"); + addFilterKey("Discovering"); } void DeviceBluetooth::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Alias"), m_Alias); - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Version"), m_Version); - addBaseDeviceInfo(tr("Model"), m_Model); + addBaseDeviceInfo(("Alias"), m_Alias); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Version"), m_Version); + addBaseDeviceInfo(("Model"), m_Model); } void DeviceBluetooth::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Module Alias"), m_Modalias); - addOtherDeviceInfo(tr("Physical ID"), m_PhysID); - addOtherDeviceInfo(tr("Speed"), m_Speed); - addOtherDeviceInfo(tr("Maximum Power"), m_MaximumPower); - addOtherDeviceInfo(tr("Driver Version"), m_DriverVersion); - addOtherDeviceInfo(tr("Driver"), m_Driver); - addOtherDeviceInfo(tr("Capabilities"), m_Capabilities); - addOtherDeviceInfo(tr("Bus Info"), m_BusInfo); - addOtherDeviceInfo(tr("Logical Name"), m_LogicalName); - addOtherDeviceInfo(tr("MAC Address"), m_MAC); + addOtherDeviceInfo(("Module Alias"), m_Modalias); + addOtherDeviceInfo(("Physical ID"), m_PhysID); + addOtherDeviceInfo(("Speed"), m_Speed); + addOtherDeviceInfo(("Maximum Power"), m_MaximumPower); + addOtherDeviceInfo(("Driver Version"), m_DriverVersion); + addOtherDeviceInfo(("Driver"), m_Driver); + addOtherDeviceInfo(("Capabilities"), m_Capabilities); + addOtherDeviceInfo(("Bus Info"), m_BusInfo); + addOtherDeviceInfo(("Logical Name"), m_LogicalName); + addOtherDeviceInfo(("MAC Address"), m_MAC); // 将QMap内容转存为QList> mapInfoToList(); @@ -268,11 +250,11 @@ void DeviceBluetooth::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.h b/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.h index 68e0a9665..5480bac6f 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.h @@ -45,13 +45,6 @@ class DeviceBluetooth : public DeviceBaseInfo */ TomlFixMethod setInfoFromTomlOneByOne(const QMap &mapInfo); - /** - * @brief setInfoFromWifiInfo:设置从cat /sys/hisys/wal/wifi_devices_info里面获取的信息 - * @param mapInfo: 由cat /sys/hisys/wal/wifi_devices_info获取的信息map - * @return 布尔值,true:信息设置成功;false:信息设置失败 - */ - bool setInfoFromWifiInfo(const QMap &mapInfo); - /** * @brief name:获取名称属性值 * @return QString:名称属性值 diff --git a/deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp b/deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp index 9f8eae772..73252100e 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp @@ -42,10 +42,10 @@ bool DeviceCdrom::setInfoFromLshw(const QMap &mapInfo) TomlFixMethod DeviceCdrom::setInfoFromTomlOneByOne(const QMap &mapInfo) { TomlFixMethod ret = TOML_None; - ret = setTomlAttribute(mapInfo, "Model", m_Type); - ret = setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); - ret = setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); - ret = setTomlAttribute(mapInfo, "Maximum Power", m_MaxPower); + setTomlAttribute(mapInfo, "Model", m_Type); + setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); + setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); + setTomlAttribute(mapInfo, "Maximum Power", m_MaxPower); ret = setTomlAttribute(mapInfo, "Speed", m_Speed); //3. 获取设备的其它信息 getOtherMapInfo(mapInfo); @@ -105,41 +105,41 @@ const QString DeviceCdrom::getOverviewInfo() void DeviceCdrom::initFilterKey() { // 添加可显示的属性 - addFilterKey(QObject::tr("Serial ID")); - addFilterKey(QObject::tr("Driver Modules")); - addFilterKey(QObject::tr("Device File")); - addFilterKey(QObject::tr("Device Files")); - addFilterKey(QObject::tr("Device Number")); - // addFilterKey(QObject::tr("Module Alias")); - addFilterKey(QObject::tr("Config Status")); - addFilterKey(QObject::tr("Application")); - // addFilterKey(QObject::tr("physical id")); - - addFilterKey(QObject::tr("status")); - addFilterKey(QObject::tr("logical name")); -// addFilterKey(QObject::tr("bus info")); - addFilterKey(QObject::tr("ansiversion")); + addFilterKey("Serial ID"); + addFilterKey("Driver Modules"); + addFilterKey("Device File"); + addFilterKey("Device Files"); + addFilterKey("Device Number"); + // addFilterKey("Module Alias"); + addFilterKey("Config Status"); + addFilterKey("Application"); + // addFilterKey("physical id"); + + addFilterKey("status"); + addFilterKey("logical name"); +// addFilterKey("bus info"); + addFilterKey("ansiversion"); } void DeviceCdrom::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Model"), m_Type); - addBaseDeviceInfo(tr("Version"), m_Version); - addBaseDeviceInfo(tr("Bus Info"), m_BusInfo); - addBaseDeviceInfo(tr("Capabilities"), m_Capabilities); - addBaseDeviceInfo(tr("Driver"), m_Driver); - addBaseDeviceInfo(tr("Maximum Power"), m_MaxPower); - addBaseDeviceInfo(tr("Speed"), m_Speed); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Model"), m_Type); + addBaseDeviceInfo(("Version"), m_Version); + addBaseDeviceInfo(("Bus Info"), m_BusInfo); + addBaseDeviceInfo(("Capabilities"), m_Capabilities); + addBaseDeviceInfo(("Driver"), m_Driver); + addBaseDeviceInfo(("Maximum Power"), m_MaxPower); + addBaseDeviceInfo(("Speed"), m_Speed); } void DeviceCdrom::loadOtherDeviceInfo() { - addOtherDeviceInfo(tr("Module Alias"), m_Modalias); - addOtherDeviceInfo(tr("Physical ID"), m_PhysID); + addOtherDeviceInfo(("Module Alias"), m_Modalias); + addOtherDeviceInfo(("Physical ID"), m_PhysID); // 将QMap内容转存为QList> mapInfoToList(); } @@ -150,11 +150,11 @@ void DeviceCdrom::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceComputer.cpp b/deepin-devicemanager/src/DeviceManager/DeviceComputer.cpp index 337bdb1a3..a263e9262 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceComputer.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceComputer.cpp @@ -24,10 +24,10 @@ TomlFixMethod DeviceComputer::setInfoFromTomlOneByOne(const QMap &mapLscpu, const QMap &m { TomlFixMethod ret = TOML_None; // 添加基本信息 - ret = setTomlAttribute(mapInfo, "CPU ID", m_PhysicalID); - ret = setTomlAttribute(mapInfo, "Core ID", m_CoreID); - ret = setTomlAttribute(mapInfo, "Threads", m_ThreadNum); - ret = setTomlAttribute(mapInfo, "Frequency", m_Frequency); - ret = setTomlAttribute(mapInfo, "Current Speed", m_CurFrequency); - ret = setTomlAttribute(mapInfo, "Max Speed", m_MaxFrequency); - ret = setTomlAttribute(mapInfo, "BogoMIPS", m_BogoMIPS); - ret = setTomlAttribute(mapInfo, "Architecture", m_Architecture); - ret = setTomlAttribute(mapInfo, "CPU Family", m_Familly); - ret = setTomlAttribute(mapInfo, "Model", m_Model); + setTomlAttribute(mapInfo, "CPU ID", m_PhysicalID); + setTomlAttribute(mapInfo, "Core ID", m_CoreID); + setTomlAttribute(mapInfo, "Threads", m_ThreadNum); + setTomlAttribute(mapInfo, "Frequency", m_Frequency); + setTomlAttribute(mapInfo, "Current Frequency", m_CurFrequency); + setTomlAttribute(mapInfo, "Max Frequency", m_MaxFrequency); + setTomlAttribute(mapInfo, "BogoMIPS", m_BogoMIPS); + setTomlAttribute(mapInfo, "Architecture", m_Architecture); + setTomlAttribute(mapInfo, "CPU Family", m_Familly); + setTomlAttribute(mapInfo, "Model", m_Model); // 添加其他信息,成员变量 - ret = setTomlAttribute(mapInfo, "Virtualization", m_HardwareVirtual); - ret = setTomlAttribute(mapInfo, "Flags", m_Flags); - ret = setTomlAttribute(mapInfo, "Extensions", m_Extensions); - ret = setTomlAttribute(mapInfo, "L4 Cache", m_CacheL4); - ret = setTomlAttribute(mapInfo, "L3 Cache", m_CacheL3); - ret = setTomlAttribute(mapInfo, "L2 Cache", m_CacheL2); - ret = setTomlAttribute(mapInfo, "L1i Cache", m_CacheL1Order); - ret = setTomlAttribute(mapInfo, "L1d Cache", m_CacheL1Data); + setTomlAttribute(mapInfo, "Virtualization", m_HardwareVirtual); + setTomlAttribute(mapInfo, "Flags", m_Flags); + setTomlAttribute(mapInfo, "Extensions", m_Extensions); + setTomlAttribute(mapInfo, "L4 Cache", m_CacheL4); + setTomlAttribute(mapInfo, "L3 Cache", m_CacheL3); + setTomlAttribute(mapInfo, "L2 Cache", m_CacheL2); + setTomlAttribute(mapInfo, "L1i Cache", m_CacheL1Order); + setTomlAttribute(mapInfo, "L1d Cache", m_CacheL1Data); ret = setTomlAttribute(mapInfo, "Stepping", m_Step); //3. 获取设备的其它信息 getOtherMapInfo(mapInfo); @@ -251,6 +251,12 @@ void DeviceCpu::setInfoFromDmidecode(const QMap &mapInfo) setAttribute(mapInfo, "product", m_Name); } + if (Common::specialComType > 0) { + if (mapInfo.contains("Version")) { + setAttribute(mapInfo, "Version", m_Name); + } + } + // 获取设备基本信息 setAttribute(mapInfo, "Manufacturer", m_Vendor); setAttribute(mapInfo, "Max Speed", m_Frequency, false); @@ -267,15 +273,15 @@ void DeviceCpu::loadOtherDeviceInfo() { // 倒序,头插,保证原来的顺序 // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Virtualization"), m_HardwareVirtual); - addOtherDeviceInfo(tr("Flags"), m_Flags); - addOtherDeviceInfo(tr("Extensions"), m_Extensions); - addOtherDeviceInfo(tr("L4 Cache"), m_CacheL4); - addOtherDeviceInfo(tr("L3 Cache"), m_CacheL3); - addOtherDeviceInfo(tr("L2 Cache"), m_CacheL2); - addOtherDeviceInfo(tr("L1i Cache"), m_CacheL1Order); - addOtherDeviceInfo(tr("L1d Cache"), m_CacheL1Data); - addOtherDeviceInfo(tr("Stepping"), m_Step); + addOtherDeviceInfo(("Virtualization"), m_HardwareVirtual); + addOtherDeviceInfo(("Flags"), m_Flags); + addOtherDeviceInfo(("Extensions"), m_Extensions); + addOtherDeviceInfo(("L4 Cache"), m_CacheL4); + addOtherDeviceInfo(("L3 Cache"), m_CacheL3); + addOtherDeviceInfo(("L2 Cache"), m_CacheL2); + addOtherDeviceInfo(("L1i Cache"), m_CacheL1Order); + addOtherDeviceInfo(("L1d Cache"), m_CacheL1Data); + addOtherDeviceInfo(("Stepping"), m_Step); // 将QMap内容转存为QList> mapInfoToList(); @@ -284,10 +290,10 @@ void DeviceCpu::loadOtherDeviceInfo() void DeviceCpu::loadTableHeader() { // 加载表头 - m_TableHeader.append(tr("Name")); - m_TableHeader.append(tr("Vendor")); - m_TableHeader.append(frequencyIsRange() ? tr("Speed") : tr("Max Speed")); - m_TableHeader.append(tr("Architecture")); + m_TableHeader.append("Name"); + m_TableHeader.append("Vendor"); + m_TableHeader.append(frequencyIsRange() ? ("Frequency") : ("Max Frequency")); + m_TableHeader.append("Architecture"); } void DeviceCpu::loadTableData() @@ -302,85 +308,85 @@ void DeviceCpu::loadTableData() void DeviceCpu::getTrNumber() { // 将数字转换为英文翻译 - m_trNumber.insert(1, QObject::tr("One")); - m_trNumber.insert(2, QObject::tr("Two")); - m_trNumber.insert(4, QObject::tr("Four")); - m_trNumber.insert(6, QObject::tr("Six")); - m_trNumber.insert(8, QObject::tr("Eight")); - m_trNumber.insert(9, QObject::tr("Nine")); - m_trNumber.insert(10, QObject::tr("Ten")); - m_trNumber.insert(12, QObject::tr("Twelve")); - m_trNumber.insert(14, QObject::tr("Fourteen")); - m_trNumber.insert(16, QObject::tr("Sixteen")); - m_trNumber.insert(18, QObject::tr("Eighteen")); - - m_trNumber.insert(20, QObject::tr("Twenty")); - m_trNumber.insert(22, QObject::tr("Twenty-two")); - m_trNumber.insert(24, QObject::tr("Twenty-four")); - m_trNumber.insert(26, QObject::tr("Twenty-six")); - m_trNumber.insert(28, QObject::tr("Twenty-eight")); - - m_trNumber.insert(30, QObject::tr("Thirty")); - m_trNumber.insert(32, QObject::tr("Thirty-two")); - m_trNumber.insert(34, QObject::tr("Thirty-four")); - m_trNumber.insert(36, QObject::tr("Thirty-six")); - m_trNumber.insert(38, QObject::tr("Thirty-eight")); - - m_trNumber.insert(40, QObject::tr("Forty")); - m_trNumber.insert(42, QObject::tr("Forty-two")); - m_trNumber.insert(44, QObject::tr("Forty-four")); - m_trNumber.insert(46, QObject::tr("Forty-six")); - m_trNumber.insert(48, QObject::tr("Forty-eight")); - - m_trNumber.insert(50, QObject::tr("Fifty")); - m_trNumber.insert(52, QObject::tr("Fifty-two")); - m_trNumber.insert(54, QObject::tr("Fifty-four")); - m_trNumber.insert(56, QObject::tr("Fifty-six")); - m_trNumber.insert(58, QObject::tr("Fifty-eight")); - - m_trNumber.insert(60, QObject::tr("Sixty")); - m_trNumber.insert(62, QObject::tr("Sixty-two")); - m_trNumber.insert(64, QObject::tr("Sixty-four")); - m_trNumber.insert(66, QObject::tr("Sixty-six")); - m_trNumber.insert(68, QObject::tr("Sixty-eight")); - - m_trNumber.insert(70, QObject::tr("Seventy")); - m_trNumber.insert(72, QObject::tr("Seventy-two")); - m_trNumber.insert(74, QObject::tr("Seventy-four")); - m_trNumber.insert(76, QObject::tr("Seventy-six")); - m_trNumber.insert(78, QObject::tr("Seventy-eight")); - - m_trNumber.insert(80, QObject::tr("Eighty")); - m_trNumber.insert(82, QObject::tr("Eighty-two")); - m_trNumber.insert(84, QObject::tr("Eighty-four")); - m_trNumber.insert(86, QObject::tr("Eighty-six")); - m_trNumber.insert(88, QObject::tr("Eighty-eight")); - - m_trNumber.insert(90, QObject::tr("Ninety")); - m_trNumber.insert(92, QObject::tr("Ninety-two")); - m_trNumber.insert(94, QObject::tr("Ninety-four")); - m_trNumber.insert(96, QObject::tr("Ninety-six")); - m_trNumber.insert(98, QObject::tr("Ninety-eight")); - - m_trNumber.insert(100, QObject::tr("One hundred")); - m_trNumber.insert(102, QObject::tr("One hundred and Two")); - m_trNumber.insert(104, QObject::tr("One hundred and four")); - m_trNumber.insert(106, QObject::tr("One hundred and Six")); - m_trNumber.insert(108, QObject::tr("One hundred and Eight")); - - m_trNumber.insert(110, QObject::tr("One hundred and Ten")); - m_trNumber.insert(112, QObject::tr("One hundred and Twelve")); - m_trNumber.insert(114, QObject::tr("One hundred and Fourteen")); - m_trNumber.insert(116, QObject::tr("One hundred and Sixteen")); - m_trNumber.insert(118, QObject::tr("One hundred and Eighteen")); - - m_trNumber.insert(120, QObject::tr("One hundred and Twenty")); - m_trNumber.insert(122, QObject::tr("One hundred and Twenty-two")); - m_trNumber.insert(124, QObject::tr("One hundred and Twenty-four")); - m_trNumber.insert(126, QObject::tr("One hundred and Twenty-six")); - m_trNumber.insert(128, QObject::tr("One hundred and Twenty-eight")); - m_trNumber.insert(192, QObject::tr("One hundred and Ninety-two")); - m_trNumber.insert(256, QObject::tr("Two hundred and fifty-six")); + m_trNumber.insert(1, translateStr("One")); + m_trNumber.insert(2, translateStr("Two")); + m_trNumber.insert(4, translateStr("Four")); + m_trNumber.insert(6, translateStr("Six")); + m_trNumber.insert(8, translateStr("Eight")); + m_trNumber.insert(9, translateStr("Nine")); + m_trNumber.insert(10, translateStr("Ten")); + m_trNumber.insert(12, translateStr("Twelve")); + m_trNumber.insert(14, translateStr("Fourteen")); + m_trNumber.insert(16, translateStr("Sixteen")); + m_trNumber.insert(18, translateStr("Eighteen")); + + m_trNumber.insert(20, translateStr("Twenty")); + m_trNumber.insert(22, translateStr("Twenty-two")); + m_trNumber.insert(24, translateStr("Twenty-four")); + m_trNumber.insert(26, translateStr("Twenty-six")); + m_trNumber.insert(28, translateStr("Twenty-eight")); + + m_trNumber.insert(30, translateStr("Thirty")); + m_trNumber.insert(32, translateStr("Thirty-two")); + m_trNumber.insert(34, translateStr("Thirty-four")); + m_trNumber.insert(36, translateStr("Thirty-six")); + m_trNumber.insert(38, translateStr("Thirty-eight")); + + m_trNumber.insert(40, translateStr("Forty")); + m_trNumber.insert(42, translateStr("Forty-two")); + m_trNumber.insert(44, translateStr("Forty-four")); + m_trNumber.insert(46, translateStr("Forty-six")); + m_trNumber.insert(48, translateStr("Forty-eight")); + + m_trNumber.insert(50, translateStr("Fifty")); + m_trNumber.insert(52, translateStr("Fifty-two")); + m_trNumber.insert(54, translateStr("Fifty-four")); + m_trNumber.insert(56, translateStr("Fifty-six")); + m_trNumber.insert(58, translateStr("Fifty-eight")); + + m_trNumber.insert(60, translateStr("Sixty")); + m_trNumber.insert(62, translateStr("Sixty-two")); + m_trNumber.insert(64, translateStr("Sixty-four")); + m_trNumber.insert(66, translateStr("Sixty-six")); + m_trNumber.insert(68, translateStr("Sixty-eight")); + + m_trNumber.insert(70, translateStr("Seventy")); + m_trNumber.insert(72, translateStr("Seventy-two")); + m_trNumber.insert(74, translateStr("Seventy-four")); + m_trNumber.insert(76, translateStr("Seventy-six")); + m_trNumber.insert(78, translateStr("Seventy-eight")); + + m_trNumber.insert(80, translateStr("Eighty")); + m_trNumber.insert(82, translateStr("Eighty-two")); + m_trNumber.insert(84, translateStr("Eighty-four")); + m_trNumber.insert(86, translateStr("Eighty-six")); + m_trNumber.insert(88, translateStr("Eighty-eight")); + + m_trNumber.insert(90, translateStr("Ninety")); + m_trNumber.insert(92, translateStr("Ninety-two")); + m_trNumber.insert(94, translateStr("Ninety-four")); + m_trNumber.insert(96, translateStr("Ninety-six")); + m_trNumber.insert(98, translateStr("Ninety-eight")); + + m_trNumber.insert(100, translateStr("One hundred")); + m_trNumber.insert(102, translateStr("One hundred and Two")); + m_trNumber.insert(104, translateStr("One hundred and four")); + m_trNumber.insert(106, translateStr("One hundred and Six")); + m_trNumber.insert(108, translateStr("One hundred and Eight")); + + m_trNumber.insert(110, translateStr("One hundred and Ten")); + m_trNumber.insert(112, translateStr("One hundred and Twelve")); + m_trNumber.insert(114, translateStr("One hundred and Fourteen")); + m_trNumber.insert(116, translateStr("One hundred and Sixteen")); + m_trNumber.insert(118, translateStr("One hundred and Eighteen")); + + m_trNumber.insert(120, translateStr("One hundred and Twenty")); + m_trNumber.insert(122, translateStr("One hundred and Twenty-two")); + m_trNumber.insert(124, translateStr("One hundred and Twenty-four")); + m_trNumber.insert(126, translateStr("One hundred and Twenty-six")); + m_trNumber.insert(128, translateStr("One hundred and Twenty-eight")); + m_trNumber.insert(192, translateStr("One hundred and Ninety-two")); + m_trNumber.insert(256, translateStr("Two hundred and fifty-six")); } diff --git a/deepin-devicemanager/src/DeviceManager/DeviceCpu.h b/deepin-devicemanager/src/DeviceManager/DeviceCpu.h index 0670fb6bd..ea132ba88 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceCpu.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceCpu.h @@ -6,7 +6,7 @@ #ifndef DEVICECPU_H #define DEVICECPU_H #include "DeviceInfo.h" - +#include "commonfunction.h" /** * @brief The DeviceCpu class * 用来描述CPU的类 diff --git a/deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp b/deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp index 00d9aaed4..1d45c2c64 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp @@ -36,21 +36,21 @@ DeviceGpu::DeviceGpu() void DeviceGpu::initFilterKey() { // 添加可显示属性 - addFilterKey(QObject::tr("Device")); - addFilterKey(QObject::tr("SubVendor")); - addFilterKey(QObject::tr("SubDevice")); - addFilterKey(QObject::tr("Driver Modules")); - addFilterKey(QObject::tr("Config Status")); - addFilterKey(QObject::tr("latency")); - - // gpuinfo 华为KLU和PanGuV - addFilterKey(QObject::tr("GDDR capacity")); - addFilterKey(QObject::tr("GPU vendor")); - addFilterKey(QObject::tr("GPU type")); - addFilterKey(QObject::tr("EGL version")); - addFilterKey(QObject::tr("EGL client APIs")); - addFilterKey(QObject::tr("GL version")); - addFilterKey(QObject::tr("GLSL version")); + addFilterKey("Device"); + addFilterKey("SubVendor"); + addFilterKey("SubDevice"); + addFilterKey("Driver Modules"); + addFilterKey("Config Status"); + addFilterKey("Latency"); + + // gpuinfo + addFilterKey("GDDR capacity"); + addFilterKey("GPU vendor"); + addFilterKey("GPU type"); + addFilterKey("EGL version"); + addFilterKey("EGL client APIs"); + addFilterKey("GL version"); + addFilterKey("GLSL version"); } @@ -58,11 +58,11 @@ void DeviceGpu::initFilterKey() void DeviceGpu::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Model"), m_Model); - addBaseDeviceInfo(tr("Version"), m_Version); - addBaseDeviceInfo(tr("Graphics Memory"), m_GraphicsMemory); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Model"), m_Model); + addBaseDeviceInfo(("Version"), m_Version); + addBaseDeviceInfo(("Graphics Memory"), m_GraphicsMemory); } void DeviceGpu::setLshwInfo(const QMap &mapInfo) @@ -168,12 +168,12 @@ bool DeviceGpu::setHwinfoInfo(const QMap &mapInfo) foreach (const QString &item, items) { if (item.isEmpty()) continue; - QStringList items = allStr.split(":", QString::SkipEmptyParts); - if (items.size() != 2) + QStringList tmpItems = allStr.split(":", QString::SkipEmptyParts); + if (tmpItems.size() != 2) continue; - if (items.first().trimmed() == "VRAM total size") { + if (tmpItems.first().trimmed() == "VRAM total size") { bool ok; - quint64 vramSize = items.last().trimmed().toULong(&ok, 16); + quint64 vramSize = tmpItems.last().trimmed().toULong(&ok, 16); if (ok && vramSize >= 1048576) { vramSize /= 1048576; auto curSize = vramSize / 1024.0; @@ -284,6 +284,28 @@ void DeviceGpu::setGpuInfo(const QMap &mapInfo) getOtherMapInfo(mapInfo); } +// 名称(Name) 厂商(Vendor) 型号(Model) 版本(Version) 显存(Graphics Memory) +void DeviceGpu::setGpuInfoByCustom(const QMap &mapInfo) +{ + m_extraInfo.clear(); + QMap::const_iterator it = mapInfo.constBegin(); + for (; it != mapInfo.constEnd(); ++it) { + if (it.key() == "Name") { + m_Name = it.value(); + } else if (it.key() == "Vendor") { + m_Vendor = it.value(); + } else if (it.key() == "Model") { + m_Model = it.value(); + } else if (it.key() == "Version") { + m_Version = it.value(); + } else if (it.key() == "Graphics Memory") { + m_GraphicsMemory = it.value(); + } else { + m_extraInfo.insert(it.key(), it.value()); + } + } +} + const QString &DeviceGpu::name() const { return m_Name; @@ -315,32 +337,35 @@ void DeviceGpu::loadOtherDeviceInfo() QString type = Common::boardVendorType(); // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Module Alias"), m_Modalias); - addOtherDeviceInfo(tr("Physical ID"), m_PhysID); - addOtherDeviceInfo(tr("Memory Address"), m_MemAddress); - addOtherDeviceInfo(tr("IO Port"), m_IOPort); - addOtherDeviceInfo(tr("Bus Info"), m_BusInfo); - if (type != "KLVV" && type != "KLVU" && type != "PGUV" && type != "PGUW") { - addOtherDeviceInfo(tr("Maximum Resolution"), m_MaximumResolution); - addOtherDeviceInfo(tr("Minimum Resolution"), m_MinimumResolution); + addOtherDeviceInfo(("Module Alias"), m_Modalias); + addOtherDeviceInfo(("Physical ID"), m_PhysID); + addOtherDeviceInfo(("Memory Address"), m_MemAddress); + addOtherDeviceInfo(("IO Port"), m_IOPort); + addOtherDeviceInfo(("Bus Info"), m_BusInfo); + if (type != Common::specialHString()) { + addOtherDeviceInfo(("Maximum Resolution"), m_MaximumResolution); + addOtherDeviceInfo(("Minimum Resolution"), m_MinimumResolution); } - addOtherDeviceInfo(tr("Current Resolution"), m_CurrentResolution); - addOtherDeviceInfo(tr("Driver"), m_Driver); - addOtherDeviceInfo(tr("Description"), m_Description); -// addOtherDeviceInfo(tr("Clock"), m_Clock); - addOtherDeviceInfo(tr("DP"), m_DisplayPort); - addOtherDeviceInfo(tr("eDP"), m_eDP); - addOtherDeviceInfo(tr("HDMI"), m_HDMI); - addOtherDeviceInfo(tr("VGA"), m_VGA); - addOtherDeviceInfo(tr("DVI"), m_DVI); - addOtherDeviceInfo(tr("DigitalOutput"), m_Digital); // bug-105482添加新接口类型 - addOtherDeviceInfo(tr("Display Output"), m_DisplayOutput); - addOtherDeviceInfo(tr("Capabilities"), m_Capabilities); - addOtherDeviceInfo(tr("IRQ"), m_IRQ); -// addOtherDeviceInfo(tr("Width"), m_Width); + addOtherDeviceInfo(("Current Resolution"), m_CurrentResolution); + addOtherDeviceInfo(("Driver"), m_Driver); + addOtherDeviceInfo(("Description"), m_Description); +// addOtherDeviceInfo(("Clock"), m_Clock); + addOtherDeviceInfo(("DP"), m_DisplayPort); + addOtherDeviceInfo(("eDP"), m_eDP); + addOtherDeviceInfo(("HDMI"), m_HDMI); + addOtherDeviceInfo(("VGA"), m_VGA); + addOtherDeviceInfo(("DVI"), m_DVI); + addOtherDeviceInfo(("DigitalOutput"), m_Digital); // bug-105482添加新接口类型 + addOtherDeviceInfo(("Display Output"), m_DisplayOutput); + addOtherDeviceInfo(("Capabilities"), m_Capabilities); + addOtherDeviceInfo(("IRQ"), m_IRQ); +// addOtherDeviceInfo(("Width"), m_Width); // 将QMap内容转存为QList> mapInfoToList(); + + // 将m_extraInfo追加到m_LstOtherInfo中 + appendExtraInfoToOtherInfo(); } void DeviceGpu::loadTableData() @@ -348,9 +373,18 @@ void DeviceGpu::loadTableData() // 加载表格内容 QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } m_TableData.append(tName); m_TableData.append(m_Vendor); m_TableData.append(m_Model); } + +void DeviceGpu::appendExtraInfoToOtherInfo() +{ + QMap::const_iterator iter = m_extraInfo.constBegin(); + for (; iter != m_extraInfo.constEnd(); ++iter) { + if (isValueValid(iter.value())) + m_LstOtherInfo.append(QPair(iter.key(), iter.value())); + } +} diff --git a/deepin-devicemanager/src/DeviceManager/DeviceGpu.h b/deepin-devicemanager/src/DeviceManager/DeviceGpu.h index d5d4e1f40..85d038d06 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceGpu.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceGpu.h @@ -56,6 +56,8 @@ class DeviceGpu: public DeviceBaseInfo */ void setGpuInfo(const QMap &mapInfo); + void setGpuInfoByCustom(const QMap &mapInfo); + /** * @brief name:获取名称属性值 * @return QString 名称属性值 @@ -108,6 +110,9 @@ class DeviceGpu: public DeviceBaseInfo */ void loadTableData() override; +private: + void appendExtraInfoToOtherInfo(); + private: QString m_Model; // m_extraInfo; }; #endif // DEVICEGPU_H diff --git a/deepin-devicemanager/src/DeviceManager/DeviceImage.cpp b/deepin-devicemanager/src/DeviceManager/DeviceImage.cpp index 6ce7aa578..6a39ec33d 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceImage.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceImage.cpp @@ -18,6 +18,7 @@ DeviceImage::DeviceImage() { m_CanEnable = true; m_CanUninstall = true; + m_forcedDisplay = true; } void DeviceImage::setInfoFromLshw(const QMap &mapInfo) @@ -43,13 +44,13 @@ TomlFixMethod DeviceImage::setInfoFromTomlOneByOne(const QMap TomlFixMethod ret = TOML_None; // 添加基本信息 - ret = setTomlAttribute(mapInfo, "Model", m_Model); - ret = setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); - ret = setTomlAttribute(mapInfo, "Version", m_Version); + setTomlAttribute(mapInfo, "Model", m_Model); + setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); + setTomlAttribute(mapInfo, "Version", m_Version); // 添加其他信息,成员变量 - ret = setTomlAttribute(mapInfo, "Speed", m_Speed); - ret = setTomlAttribute(mapInfo, "Maximum Power", m_MaximumPower); - ret = setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); + setTomlAttribute(mapInfo, "Speed", m_Speed); + setTomlAttribute(mapInfo, "Maximum Power", m_MaximumPower); + setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); ret = setTomlAttribute(mapInfo, "Serial Number", m_SerialID); //3. 获取设备的其它信息 getOtherMapInfo(mapInfo); @@ -160,24 +161,24 @@ void DeviceImage::initFilterKey() void DeviceImage::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Version"), m_Version); - addBaseDeviceInfo(tr("Model"), m_Model); - addBaseDeviceInfo(tr("Bus Info"), m_BusInfo); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Version"), m_Version); + addBaseDeviceInfo(("Model"), m_Model); + addBaseDeviceInfo(("Bus Info"), m_BusInfo); } void DeviceImage::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Module Alias"), m_Modalias); - addOtherDeviceInfo(tr("Physical ID"), m_PhysID); - addOtherDeviceInfo(tr("Speed"), m_Speed); - addOtherDeviceInfo(tr("Maximum Power"), m_MaximumPower); - addOtherDeviceInfo(tr("Driver"), m_Driver); - addOtherDeviceInfo(tr("Capabilities"), m_Capabilities); + addOtherDeviceInfo(("Module Alias"), m_Modalias); + addOtherDeviceInfo(("Physical ID"), m_PhysID); + addOtherDeviceInfo(("Speed"), m_Speed); + addOtherDeviceInfo(("Maximum Power"), m_MaximumPower); + addOtherDeviceInfo(("Driver"), m_Driver); + addOtherDeviceInfo(("Capabilities"), m_Capabilities); if (m_SerialID != m_UniqueID) - addOtherDeviceInfo(tr("Serial Number"), m_SerialID); + addOtherDeviceInfo(("Serial Number"), m_SerialID); // 将QMap内容转存为QList> mapInfoToList(); @@ -189,11 +190,11 @@ void DeviceImage::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp b/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp index 75f00f819..448fedaf0 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp @@ -45,6 +45,17 @@ DeviceBaseInfo::~DeviceBaseInfo() } +const QString DeviceBaseInfo::translateStr(const QString &inStr) +{ + return tr(inStr.toLatin1()); +} + +const QString DeviceBaseInfo::nameTr() +{ + return translateStr(m_Name); +} + + const QList> &DeviceBaseInfo::getOtherAttribs() { // 获取其他设备信息列表 @@ -61,15 +72,52 @@ const QList > &DeviceBaseInfo::getBaseAttribs() return m_LstBaseInfo; } +const QList > &DeviceBaseInfo::getOtherTranslationAttribs() +{ + m_LstOtherInfoTr.clear(); + getOtherAttribs(); + for (const auto &pair : m_LstOtherInfo) { + QString trKey =translateStr(pair.first); + if (trKey.isEmpty()) + m_LstOtherInfoTr.append(qMakePair(pair.first, pair.second)); // 添加到目标列表 + else + m_LstOtherInfoTr.append(qMakePair(trKey, pair.second)); + } + return m_LstOtherInfoTr; +} + +const QList > &DeviceBaseInfo::getBaseTranslationAttribs() +{ + m_LstBaseInfoTr.clear(); + getBaseAttribs(); + for (const auto &pair : m_LstBaseInfo) { + QString trKey = translateStr(pair.first); + if (trKey.isEmpty()) + m_LstBaseInfoTr.append(qMakePair(pair.first, pair.second)); // 添加到目标列表 + else + m_LstBaseInfoTr.append(qMakePair(trKey, pair.second)); + } + return m_LstBaseInfoTr; +} + const QStringList &DeviceBaseInfo::getTableHeader() { + m_TableHeaderTr.clear(); // 获取表头 if (m_TableHeader.size() == 0) { loadTableHeader(); m_TableHeader.append(m_CanEnable ? "yes" : "no"); } - return m_TableHeader; + for (const auto &item : m_TableHeader) { + QString trKey = tr(item.toLatin1()); + if (trKey.isEmpty()) + m_TableHeaderTr.append(item); + else + m_TableHeaderTr.append(trKey); + } + + return m_TableHeaderTr; } const QStringList &DeviceBaseInfo::getTableData() @@ -77,7 +125,15 @@ const QStringList &DeviceBaseInfo::getTableData() // 获取表格数据 m_TableData.clear(); loadTableData(); - return m_TableData; + m_TableDataTr.clear(); + for (const auto &item : m_TableData) { + QString trKey = (item); + if (trKey.isEmpty()) + m_TableDataTr.append(item); + else + m_TableDataTr.append(trKey); + } + return m_TableDataTr; } QString DeviceBaseInfo::subTitle() @@ -85,13 +141,13 @@ QString DeviceBaseInfo::subTitle() return QString(""); } -bool DeviceBaseInfo::isValueValid(QString &value) +bool DeviceBaseInfo::isValueValid(const QString &value) { // 判断属性值是否有效 if (value.isEmpty()) return false; - if (value == QObject::tr("Unknown")) + if (value == translateStr("Unknown")) return false; if (value == QString("Unknown")) @@ -144,8 +200,8 @@ void DeviceBaseInfo::setForcedDisplay(const bool &flag) void DeviceBaseInfo::toHtmlString(QDomDocument &doc) { // 设备信息转为Html - baseInfoToHTML(doc, m_LstBaseInfo); - baseInfoToHTML(doc, m_LstOtherInfo); + baseInfoToHTML(doc, m_LstBaseInfoTr); + baseInfoToHTML(doc, m_LstOtherInfoTr); } void DeviceBaseInfo::baseInfoToHTML(QDomDocument &doc, QList > &infoLst) @@ -201,8 +257,8 @@ void DeviceBaseInfo::subTitleToHTML(QDomDocument &doc) void DeviceBaseInfo::toDocString(Docx::Document &doc) { // 设备信息转为doc - baseInfoToDoc(doc, m_LstBaseInfo); - baseInfoToDoc(doc, m_LstOtherInfo); + baseInfoToDoc(doc, m_LstBaseInfoTr); + baseInfoToDoc(doc, m_LstOtherInfoTr); } void DeviceBaseInfo::baseInfoToDoc(Docx::Document &doc, QList > &infoLst) @@ -224,8 +280,8 @@ void DeviceBaseInfo::baseInfoToDoc(Docx::Document &doc, QList > &infoLst) @@ -251,8 +307,8 @@ void DeviceBaseInfo::baseInfoToXlsx(QXlsx::Document &xlsx, QXlsx::Format &boldFo void DeviceBaseInfo::toTxtString(QTextStream &out) { // 设备信息转为txt - baseInfoToTxt(out, m_LstBaseInfo); - baseInfoToTxt(out, m_LstOtherInfo); + baseInfoToTxt(out, m_LstBaseInfoTr); + baseInfoToTxt(out, m_LstOtherInfoTr); } void DeviceBaseInfo::baseInfoToTxt(QTextStream &out, QList > &infoLst) @@ -280,15 +336,15 @@ void DeviceBaseInfo::tableInfoToTxt(QTextStream &out) getTableData(); // 判断是否有表格内容 - if (m_TableData.size() < 1) + if (m_TableDataTr.size() < 1) return; // 设置占位宽度 - QString text = m_TableData[0]; + QString text = m_TableDataTr[0]; out.setFieldWidth(int(text.size() * 1.5)); out.setFieldAlignment(QTextStream::FieldAlignment::AlignRight); - foreach (auto item, m_TableData) { + foreach (auto item, m_TableDataTr) { out.setFieldWidth(28); out << item; } @@ -303,18 +359,18 @@ void DeviceBaseInfo::tableHeaderToTxt(QTextStream &out) getTableHeader(); // 判断是否有表头 - if (m_TableHeader.size() < 1) + if (m_TableHeaderTr.size() < 1) return; // 设置占位宽度 - QString text = m_TableHeader[0]; + QString text = m_TableHeaderTr[0]; out.setFieldWidth(int(text.size() * 1.5)); out.setFieldAlignment(QTextStream::FieldAlignment::AlignLeft); out << "\n"; - for (int col = 0; col < m_TableHeader.size() - 1; ++col) { + for (int col = 0; col < m_TableHeaderTr.size() - 1; ++col) { out.setFieldWidth(30); - out << m_TableHeader[col]; + out << m_TableHeaderTr[col]; } out.setFieldWidth(0); out << "\n"; @@ -326,11 +382,11 @@ void DeviceBaseInfo::tableInfoToHtml(QFile &html) getTableData(); // 判断是否有表格内容 - if (m_TableData.size() < 1) + if (m_TableDataTr.size() < 1) return; // 写表格内容 - foreach (auto item, m_TableData) { + foreach (auto item, m_TableDataTr) { html.write(QString("" + item + "").toUtf8().data()); } @@ -343,14 +399,14 @@ void DeviceBaseInfo::tableHeaderToHtml(QFile &html) getTableHeader(); // 判断是否有表头 - if (m_TableHeader.size() < 1) + if (m_TableHeaderTr.size() < 1) return; html.write("\n"); // 写表头内容 - for (int col = 0; col < m_TableHeader.size() - 1; ++col) - html.write(QString("" + m_TableHeader[col] + "").toUtf8().data()); + for (int col = 0; col < m_TableHeaderTr.size() - 1; ++col) + html.write(QString("" + m_TableHeaderTr[col] + "").toUtf8().data()); html.write("\n"); } @@ -364,13 +420,13 @@ void DeviceBaseInfo::tableInfoToDoc(Docx::Table *tab, int &row) // 获取表格数据 getTableData(); - if (m_TableData.size() < 1) + if (m_TableDataTr.size() < 1) return; // 添加doc表格 - for (int col = 0; col < m_TableData.size(); ++col) { + for (int col = 0; col < m_TableDataTr.size(); ++col) { auto cel = tab->cell(row, col); - cel->addText(m_TableData[col]); + cel->addText(m_TableDataTr[col]); } } @@ -379,14 +435,14 @@ void DeviceBaseInfo::tableHeaderToDoc(Docx::Table *tab) // 表头保存为doc getTableHeader(); - if (m_TableHeader.size() < 1) + if (m_TableHeaderTr.size() < 1) return; // 添加表头信息 - for (int col = 0; col < m_TableHeader.size() - 1; ++col) { + for (int col = 0; col < m_TableHeaderTr.size() - 1; ++col) { tab->addColumn(); auto cel = tab->cell(0, col); - cel->addText(m_TableHeader[col]); + cel->addText(m_TableHeaderTr[col]); } } @@ -395,13 +451,13 @@ void DeviceBaseInfo::tableInfoToXlsx(QXlsx::Document &xlsx) // 获取表格信息 getTableData(); - if (m_TableData.size() < 1) + if (m_TableDataTr.size() < 1) return; // 添加表格信息 int curRow = DeviceManager::instance()->currentXlsRow(); - for (int col = 0; col < m_TableData.size(); ++col) - xlsx.write(curRow, col + 1, m_TableData[col]); + for (int col = 0; col < m_TableDataTr.size(); ++col) + xlsx.write(curRow, col + 1, m_TableDataTr[col]); } void DeviceBaseInfo::tableHeaderToXlsx(QXlsx::Document &xlsx) @@ -409,16 +465,16 @@ void DeviceBaseInfo::tableHeaderToXlsx(QXlsx::Document &xlsx) // 获取表头 getTableHeader(); - if (m_TableHeader.size() < 1) + if (m_TableHeaderTr.size() < 1) return; // 添加表头信息 int curRow = DeviceManager::instance()->currentXlsRow(); - for (int col = 0; col < m_TableHeader.size() - 1; ++col) { + for (int col = 0; col < m_TableHeaderTr.size() - 1; ++col) { QXlsx::Format boldFont; boldFont.setFontSize(10); boldFont.setFontBold(true); - xlsx.write(curRow, col + 1, m_TableHeader[col], boldFont); + xlsx.write(curRow, col + 1, m_TableHeaderTr[col], boldFont); } } @@ -450,8 +506,8 @@ TomlFixMethod DeviceBaseInfo::setInfoFromTomlBase(const QMap & return TOML_Del; } - ret2 = setTomlAttribute(mapInfo, "Revision", m_Version); - ret2 = setTomlAttribute(mapInfo, "Description", m_Description); + setTomlAttribute(mapInfo, "Revision", m_Version); + setTomlAttribute(mapInfo, "Description", m_Description); m_VID = m_VID.toLower(); m_PID = m_PID.toLower(); m_VID_PID = m_VID + m_PID.remove("0x"); @@ -574,10 +630,32 @@ const QString DeviceBaseInfo::getVendorOrModelId(const QString &sysPath, bool fl return vendor; } +void DeviceBaseInfo::setVendorNameBylsusbLspci(const QString &vidpid, const QString &modalias) +{ + if (!vidpid.isEmpty() && modalias.contains("usb")) { + QProcess process; + QString vendorId = vidpid.toLower().remove("0x").trimmed().left(4); + QString deviceId = vidpid.toLower().remove("0x").trimmed().right(4); + process.start("lsusb -v -d " + vendorId + ":" + deviceId); + process.waitForFinished(-1); + + QString output = process.readAllStandardOutput(); + + foreach (QString out, output.split("\n")) { + // 从USB设备获取制造商和设备名称 + if (out.contains("idVendor", Qt::CaseSensitive)) { + m_Vendor = out.remove(0, out.indexOf(vendorId) + 4).trimmed(); + } else if (out.contains("idProduct", Qt::CaseSensitive)) { + m_Name = out.remove(0, out.indexOf(deviceId) + 4).trimmed(); + } + } + } +} + const QString DeviceBaseInfo::getDriverVersion() { QString outInfo = Common::executeClientCmd("modinfo", QStringList() << driver(), QString(), -1); - if(outInfo.isEmpty()) + if (outInfo.isEmpty()) return QString(""); foreach (QString out, outInfo.split("\n")) { @@ -618,9 +696,9 @@ const QString &DeviceBaseInfo::getModalias() const void DeviceBaseInfo::loadTableHeader() { // 添加表头信息 - m_TableHeader.append(tr("Name")); - m_TableHeader.append(tr("Vendor")); - m_TableHeader.append(tr("Model")); + m_TableHeader.append("Name"); + m_TableHeader.append("Vendor"); + m_TableHeader.append("Model"); } void DeviceBaseInfo::addFilterKey(const QString &key) @@ -634,7 +712,7 @@ void DeviceBaseInfo::getOtherMapInfo(const QMap &mapInfo) // 获取其他设备信息 QMap::const_iterator it = mapInfo.begin(); for (; it != mapInfo.end(); ++it) { - QString k = DApplication::translate("QObject", it.key().trimmed().toStdString().data()); + QString k = it.key(); // 可显示设备属性中存在该属性 if (m_FilterKey.find(k) != m_FilterKey.end()) { @@ -660,6 +738,44 @@ void DeviceBaseInfo::addOtherDeviceInfo(const QString &key, const QString &value m_LstOtherInfo.insert(0, QPair(key, value)); } +const QString DeviceBaseInfo::readDeviceInfoKeyValue(const QString &key) +{ + if (key.isEmpty()) + return QString(""); + QList > allBaseAttribs = getBaseAttribs(); + for (const QPair& pair : allBaseAttribs) { + if (key == pair.first) + return pair.second; + } + QList > allOtherAttribs = getOtherAttribs(); + for (const QPair& pair : allOtherAttribs) { + if (key == pair.first) + return pair.second; + } + return QString(""); +} + +bool DeviceBaseInfo::setDeviceInfoKeyValue(const QString &key, const QString &value) +{ + if (key.isEmpty() ||value.isEmpty()) + return false; + + for (QPair pair : getBaseAttribs()) { + if (key == pair.first) { + pair.second = value; + return true; + } + } + + for (QPair pair : getOtherAttribs()) { + if (key == pair.first) { + pair.second = value; + return true; + } + } + return false; +} + void DeviceBaseInfo::setAttribute(const QMap &mapInfo, const QString &key, QString &variable, bool overwrite) { // map中存在该属性 @@ -713,9 +829,9 @@ void DeviceBaseInfo::mapInfoToList() { // m_MapOtherInfo --> m_LstOtherInfo // QMap内容转为QList存储 - auto iter = m_MapOtherInfo.begin(); + QMap::const_iterator iter = m_MapOtherInfo.constBegin(); - for (; iter != m_MapOtherInfo.end(); ++iter) { + for (; iter != m_MapOtherInfo.constEnd(); ++iter) { if (isValueValid(iter.value())) m_LstOtherInfo.append(QPair(iter.key(), iter.value())); } @@ -840,4 +956,304 @@ const QString DeviceBaseInfo::get_string(const QString &sysPathfile) file.close(); return info; } +//只是为了lupdate自动增加翻译而占位 +void DeviceBaseInfo::generatorTranslate() +{ + QStringList translationStrings; + translationStrings \ + << tr("Core(s)") \ + << tr("Processor") \ + << tr("ACL MTU") \ + << tr("Address") \ + << tr("Alias") \ + << tr("ansiversion") \ + << tr("Application") \ + << tr("Architecture") \ + << tr("Array Handle") \ + << tr("Asset Tag") \ + << tr("Auto Negotiation") \ + << tr("Bank Locator") \ + << tr("Base Board Information") \ + << tr("BD Address") \ + << tr("BIOS Information") \ + << tr("BIOS Revision") \ + << tr("BIOS ROMSIZE") \ + << tr("Board name") \ + << tr("BogoMIPS") \ + << tr("Boot-up State") \ + << tr("Broadcast") \ + << tr("Bus") \ + << tr("bus info") \ + << tr("Bus Info") \ + << tr("Cache Size") \ + << tr("Capabilities") \ + << tr("Capacity") \ + << tr("Characteristics") \ + << tr("Chassis Handle") \ + << tr("Chassis Information") \ + << tr("Chip") \ + << tr("Chipset") \ + << tr("Class") \ + << tr("Clock") \ + << tr("Config Status") \ + << tr("Configured Speed") \ + << tr("Configured Voltage") \ + << tr("Contained Elements") \ + << tr("Contained Object Handles") \ + << tr("copies") \ + << tr("Core ID") \ + << tr("CPU architecture") \ + << tr("CPU Family") \ + << tr("CPU ID") \ + << tr("CPU implementer") \ + << tr("CPU part") \ + << tr("CPU revision") \ + << tr("CPU variant") \ + << tr("critical-action") \ + << tr("Currently Installed Language") \ + << tr("Current Resolution") \ + << tr("daemon-version") \ + << tr("Data Width") \ + << tr("Date") \ + << tr("description") \ + << tr("Description") \ + << tr("Design Capacity") \ + << tr("Design Voltage") \ + << tr("Device") \ + << tr("Device Class") \ + << tr("Device File") \ + << tr("Device Files") \ + << tr("Device Name") \ + << tr("Device Number") \ + << tr("DigitalOutput") \ + << tr("Disable") \ + << tr("Discoverable") \ + << tr("Discovering") \ + << tr("Display Input") \ + << tr("Display Output") \ + << tr("Display Ratio") \ + << tr("DP") \ + << tr("Driver") \ + << tr("Driver Activation Cmd") \ + << tr("Driver Modules") \ + << tr("Driver Status") \ + << tr("Driver Version") \ + << tr("Duplex") \ + << tr("DVI") \ + << tr("eDP") \ + << tr("EGL client APIs") \ + << tr("EGL version") \ + << tr("energy") \ + << tr("energy-empty") \ + << tr("energy-full") \ + << tr("energy-full-design") \ + << tr("energy-rate") \ + << tr("Error Correction Type") \ + << tr("Error Information Handle") \ + << tr("EV") \ + << tr("Extensions") \ + << tr("Family") \ + << tr("Features") \ + << tr("Firmware") \ + << tr("Firmware Revision") \ + << tr("Firmware Version") \ + << tr("Flags") \ + << tr("Form Factor") \ + << tr("GDDR capacity") \ + << tr("Geometry (Logical)") \ + << tr("GLSL version") \ + << tr("GL version") \ + << tr("GPU type") \ + << tr("GPU vendor") \ + << tr("Graphics Memory") \ + << tr("guid") \ + << tr("Handlers") \ + << tr("Hardware Class") \ + << tr("has history") \ + << tr("has statistics") \ + << tr("HCI Version") \ + << tr("HDMI") \ + << tr("Height") \ + << tr("icon-name") \ + << tr("Input/Output") \ + << tr("Installable Languages") \ + << tr("Interface") \ + << tr("Interface Type") \ + << tr("ioport") \ + << tr("IO Port") \ + << tr("IP") \ + << tr("IRQ") \ + << tr("job-cancel-after") \ + << tr("job-hold-until") \ + << tr("job-priority") \ + << tr("KernelModeDriver") \ + << tr("KEY") \ + << tr("L1d Cache") \ + << tr("L1i Cache") \ + << tr("L2 Cache") \ + << tr("L3 Cache") \ + << tr("L4 Cache") \ + << tr("Language Description Format") \ + << tr("latency") \ + << tr("Latency") \ + << tr("lid-is-closed") \ + << tr("lid-is-present") \ + << tr("Link") \ + << tr("Link mode") \ + << tr("Link policy") \ + << tr("LMP Version") \ + << tr("Location") \ + << tr("Location In Chassis") \ + << tr("Locator") \ + << tr("Lock") \ + << tr("logical name") \ + << tr("Logical Name") \ + << tr("logicalsectorsize") \ + << tr("Logical Size") \ + << tr("MAC Address") \ + << tr("marker-change-time") \ + << tr("Max Frequency") \ + << tr("Maximum Capacity") \ + << tr("Maximum Current") \ + << tr("Maximum Power") \ + << tr("Maximum Rate") \ + << tr("Maximum Resolution") \ + << tr("Maximum Voltage") \ + << tr("Media Type") \ + << tr("Memory") \ + << tr("Memory Address") \ + << tr("Memory Operating Mode Capability") \ + << tr("Memory Subsystem Controller Manufacturer ID") \ + << tr("Memory Subsystem Controller Product ID") \ + << tr("Memory Technology") \ + << tr("Minimum Resolution") \ + << tr("Minimum Voltage") \ + << tr("Modalias") \ + << tr("Model") \ + << tr("Module Alias") \ + << tr("Module Alias") \ + << tr("Module Manufacturer ID") \ + << tr("Module Product ID") \ + << tr("MSC") \ + << tr("Multicast") \ + << tr("Name") \ + << tr("native-path") \ + << tr("Negotiation Rate") \ + << tr("network") \ + << tr("Non-Volatile Size") \ + << tr("Number Of Devices") \ + << tr("Number Of Power Cords") \ + << tr("number-up") \ + << tr("OEM Information") \ + << tr("on-battery") \ + << tr("online") \ + << tr("orientation-requested") \ + << tr("Packet type") \ + << tr("Pairable") \ + << tr("Part Number") \ + << tr("percentage") \ + << tr("Phys") \ + << tr("physical id") \ + << tr("Physical ID") \ + << tr("Physical Memory Array") \ + << tr("Port") \ + << tr("Powered") \ + << tr("power supply") \ + << tr("Power Supply State") \ + << tr("Primary Monitor") \ + << tr("print-color-mode") \ + << tr("printer-is-accepting-jobs") \ + << tr("printer-is-shared") \ + << tr("printer-is-temporary") \ + << tr("printer-make-and-model") \ + << tr("printer-state-change-time") \ + << tr("printer-state-reasons") \ + << tr("printer-type") \ + << tr("printer-uri-supported") \ + << tr("product") \ + << tr("Product Date") \ + << tr("Product Name") \ + << tr("PROP") \ + << tr("Rank") \ + << tr("rechargeable") \ + << tr("Refresh Rate") \ + << tr("Release date") \ + << tr("Release Date") \ + << tr("Revision") \ + << tr("ROM Size") \ + << tr("Rotation Rate") \ + << tr("Runtime Size") \ + << tr("SBDS Chemistry") \ + << tr("SBDS Manufacture Date") \ + << tr("SBDS Serial Number") \ + << tr("SBDS Version") \ + << tr("SCO MTU") \ + << tr("sectorsize") \ + << tr("Security Status") \ + << tr("Serial ID") \ + << tr("Serial Number") \ + << tr("Service Classes") \ + << tr("Set") \ + << tr("Shared") \ + << tr("sides") \ + << tr("Size") \ + << tr("SKU Number") \ + << tr("Slot") \ + << tr("SMBIOS Version") \ + << tr("state") \ + << tr("status") \ + << tr("Status") \ + << tr("Stepping") \ + << tr("SubDevice") \ + << tr("SubVendor") \ + << tr("Subversion") \ + << tr("Support Resolution") \ + << tr("Sysfs") \ + << tr("SysFS_Path") \ + << tr("System Information") \ + << tr("technology") \ + << tr("temperature") \ + << tr("Temperature") \ + << tr("Thermal State") \ + << tr("Threads") \ + << tr("Total Width") \ + << tr("Type") \ + << tr("Type Detail") \ + << tr("Unavailable") \ + << tr("Uniq") \ + << tr("updated") \ + << tr("URI") \ + << tr("UUID") \ + << tr("Vendor") \ + << tr("Version") \ + << tr("VGA") \ + << tr("Virtualization") \ + << tr("Volatile Size") \ + << tr("voltage") \ + << tr("Voltage") \ + << tr("Wake-up Type") \ + << tr("warning-level") \ + << tr("Width") \ + << tr("battery") \ + << tr("inch") \ + << tr("Architecture") \ + << tr("Frequency") \ + << tr("Max Frequency") \ + << tr("Media Type") \ + << tr("Name") \ + << tr("Size") \ + << tr("Speed") \ + << tr("Type") \ + << tr("Vendor") \ + << tr("Processor"); +} + +void DeviceBaseInfo::setSysPath(const QString &newSysPath) +{ + m_SysPath = newSysPath; +} +void DeviceBaseInfo::setUniqueID(const QString &UniqueID) +{ + m_UniqueID = UniqueID; +} diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInfo.h b/deepin-devicemanager/src/DeviceManager/DeviceInfo.h index 1bf565b2b..e3d6c875e 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInfo.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceInfo.h @@ -43,6 +43,14 @@ class DeviceBaseInfo : public QObject explicit DeviceBaseInfo(QObject *parent = nullptr); virtual ~DeviceBaseInfo(); + const QString translateStr(const QString &inStr); + const QString nameTr(); + /** + * @brief name:获取设备名称 + * @return 设备名称 + */ + virtual const QString &name() const = 0; + /** * @brief getOtherAttribs:获取设备的其它信息 * @return 其他信息组成的map @@ -56,6 +64,19 @@ class DeviceBaseInfo : public QObject */ const QList> &getBaseAttribs(); + /** + * @brief getOtherAttribs:获取设备的其它信息 + * @return 其他信息组成的map + */ + //const QMap &getOtherAttribs()const; + const QList> &getOtherTranslationAttribs(); + + /** + * @brief getBaseAttribs::获取基本设备信息 + * @return 基本信息组成的list + */ + const QList> &getBaseTranslationAttribs(); + /** * @brief getTableHeader : 用于存放表格的头部 * @return : 用于存放表格的头部 @@ -80,12 +101,6 @@ class DeviceBaseInfo : public QObject */ virtual const QString getOverviewInfo(); - /** - * @brief name:获取设备名称 - * @return 设备名称 - */ - virtual const QString &name() const = 0; - /** * @brief vendor:获取设备制造商 * @return 设备制造商 @@ -209,6 +224,14 @@ class DeviceBaseInfo : public QObject */ const QString getVendorOrModelId(const QString &sysPath, bool flag = true); + /** + * @brief setVendorNameBylsusbLspci:获取Vendor 和 Name + * @param vidpid 属性vidpid + * @param modalias + * @return + */ + void setVendorNameBylsusbLspci(const QString &vidpid, const QString &modalias); + /** * @brief get_string:读取文件内信息 * @param path:文件绝对路径+名称 @@ -221,12 +244,26 @@ class DeviceBaseInfo : public QObject */ const QString getDriverVersion(); + /** + * @brief readDeviceInfoKeyValue:读取key信息 + * @param key:属性名称 + * @return :value属性值 + */ + const QString readDeviceInfoKeyValue(const QString &key); + + /** + * @brief readDeviceInfoKeyValue:设置key信息 + * @param key:属性名称 + * @return :value属性值 + */ + bool setDeviceInfoKeyValue(const QString &key, const QString &value); + /** * @brief isValid:判断属性值是否有效 * @param value:属性值 * @return true:属性值有效 */ - bool isValueValid(QString &value); + bool isValueValid(const QString &value); /** * @brief setForcedDisplay:设置强制显示 @@ -357,6 +394,9 @@ class DeviceBaseInfo : public QObject */ TomlFixMethod setInfoFromTomlBase(const QMap &mapInfo); + void setUniqueID(const QString &UniqueID); + void setSysPath(const QString &newSysPath); + protected: /** * @brief:初始化过滤信息 @@ -462,6 +502,9 @@ class DeviceBaseInfo : public QObject */ bool PhysIDMapInfo(const QMap &mapInfo); +private: + void generatorTranslate(); + protected: QString m_Name; //> m_LstBaseInfo; //> m_LstOtherInfo; //> m_LstBaseInfoTr; //> m_LstOtherInfoTr; // m_FilterKey; // &mapInfo) if (m_Driver.isEmpty() && "PS/2" == m_Interface) { m_CanUninstall = false; } + getMouseInfoFromBusDevice(); // 获取其他设备信息 getOtherMapInfo(mapInfo); @@ -67,12 +68,12 @@ TomlFixMethod DeviceInput::setInfoFromTomlOneByOne(const QMap { TomlFixMethod ret = TOML_None; // 添加基本信息 - ret = setTomlAttribute(mapInfo, "Model", m_Model); - ret = setTomlAttribute(mapInfo, "Interface", m_Interface); - ret = setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); + setTomlAttribute(mapInfo, "Model", m_Model); + setTomlAttribute(mapInfo, "Interface", m_Interface); + setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); // 添加其他信息,成员变量 - ret = setTomlAttribute(mapInfo, "Speed", m_Speed); - ret = setTomlAttribute(mapInfo, "Maximum Current", m_MaximumPower); // 将最大功率改为最大电流 + setTomlAttribute(mapInfo, "Speed", m_Speed); + setTomlAttribute(mapInfo, "Maximum Current", m_MaximumPower); // 将最大功率改为最大电流 ret = setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); //3. 获取设备的其它信息 @@ -146,43 +147,7 @@ void DeviceInput::setInfoFromHwinfo(const QMap &mapInfo) // 由bluetoothctl paired-devices设置设备接口 setInfoFromBluetoothctl(); - // 获取其他设备信息 - getOtherMapInfo(mapInfo); -} - -void DeviceInput::setKLUInfoFromHwinfo(const QMap &mapInfo) -{ - // 设置设备基本属性 - setAttribute(mapInfo, "Device", m_Name); - setAttribute(mapInfo, "Vendor", m_Vendor); - setAttribute(mapInfo, "Model", m_Model); - setAttribute(mapInfo, "Revision", m_Version); - if (mapInfo.find("Hotplug") != mapInfo.end()) - setAttribute(mapInfo, "Hotplug", m_Interface); - else - m_Interface = "PS/2"; - - // 上面的方法不适合蓝牙键盘的获取方法 - if (mapInfo.find("Model")->contains("Bluetooth", Qt::CaseInsensitive) || mapInfo.find("Device")->contains("Bluetooth", Qt::CaseInsensitive)) - m_Interface = "Bluetooth"; - - setAttribute(mapInfo, "SysFS BusID", m_BusInfo); - setAttribute(mapInfo, "Hardware Class", m_Description); - setAttribute(mapInfo, "Driver", m_Driver); - setAttribute(mapInfo, "Speed", m_Speed); - - // 获取映射到 lshw设备信息的 关键字 - //1-2:1.0 - QStringList words = mapInfo["SysFS BusID"].split(":"); - if (words.size() == 2) { - QStringList chs = words[0].split("-"); - if (chs.size() == 2) - m_KeyToLshw = QString("usb@%1:%2").arg(chs[0]).arg(chs[1]); - } - - // 由bluetoothctl paired-devices设置设备接口 - setInfoFromBluetoothctl(); - + getMouseInfoFromBusDevice(); // 获取其他设备信息 getOtherMapInfo(mapInfo); } @@ -298,6 +263,110 @@ QString DeviceInput::eventStrFromDeviceFiles(const QString &dfs) return ""; } +InputDeviceBusInfo DeviceInput::getDetailBusInfo(const QString &busId) +{ + InputDeviceBusInfo info; + info.busId = busId; + + // 根据 Bus ID 查找对应的接口类型信息-只会使用 interfaceType,其他内容预留维护参考 + static QMap busInfoMap = { + {"0000", {"0000", "UINPUT", "虚拟设备", "用于软件模拟输入"}}, + {"0001", {"0001", "PCI", "特殊输入卡", "通过 PCI/PCIe 总线连接的设备"}}, + {"0002", {"0002", "ISA", "古老 ISA 设备", "已淘汰的 ISA 接口设备"}}, + {"0003", {"0003", "USB", "USB鼠标/键盘/手柄", "最常见的外设接口,设备路径含 usb"}}, + {"0004", {"0004", "HIL", "HP-HIL终端设备", "历史遗留系统 (HP-HIL)"}}, + {"0005", {"0005", "BLUETOOTH", "蓝牙鼠标/键盘", "设备名称含 bluetooth,需 rfkill 管理"}}, + {"0006", {"0006", "VIRTUAL", "VMware/QEMU虚拟输入", "虚拟机中的输入设备"}}, + {"0007", {"0007", "SERIAL)", "串口鼠标", "设备节点为 /dev/ttyS*"}}, + {"0008", {"0008", "HOST", "内置键盘/触摸板", "通过主板直接连接的设备"}}, + {"0009", {"0009", "Game Port", "游戏手柄", "15针 D-Sub 接口"}}, + {"0010", {"0010", "PARALLEL", "老式输入设备", "/dev/parport*"}}, + {"0011", {"0011", "PS/2", "PS/2鼠标/键盘", "圆形 6-pin 接口,设备节点为 /dev/psaux"}}, + {"0012", {"0012", "RADIO", "无线接收器", "专用 2.4G 设备 (如罗技 Unifying)"}}, + {"0013", {"0013", "J1939", "车载工业设备", "CAN 总线扩展"}}, + {"0018", {"0018", "I2C", "高端触摸板/触控笔", "设备名称含 i2c,需 i2c-tools 调试"}}, + {"0019", {"0019", "SPI", "嵌入式触控屏", "通过 SPI 总线通信"}}, + {"001a", {"001A", "ILLUMINANCE", "环境光传感器", "部分笔记本的自动亮度调节"}}, + {"001b", {"001B", "GDIX", "Surface Dial", "微软 Surface Dial 特殊旋转输入设备"}}, + {"001c", {"001C", "WACOM", "数位板/绘图屏", "设备名含 wacom"}}, + {"001d", {"001D", "UCSI", "USB Type-C输入", "新式笔记本的 USB-C 扩展设备"}} + }; + + // 查找匹配的 Bus ID (不区分大小写) + QString lowerBusId = busId.toLower(); + if (busInfoMap.contains(lowerBusId)) { + return busInfoMap.value(lowerBusId); + } + + // 如果没有找到匹配的,返回未知类型 + info.interfaceType = "Unknown"; + info.typicalDevices = "UnKnown Device"; + info.description = QString("Unrecognized Bus ID: %1").arg(busId); + + return info; +} + +void DeviceInput::getMouseInfoFromBusDevice() +{ + QProcess process; + process.start("cat", QStringList() << "/proc/bus/input/devices"); + process.waitForFinished(10000); + QString rawContent = process.readAllStandardOutput(); + + QMap nameToBusMap; + + if (rawContent.isEmpty()) { + return ; + } + + QStringList deviceBlocks = rawContent.split("\n\n", QString::SkipEmptyParts); + + for (const QString &block : deviceBlocks) { + QString bus, name; + QStringList lines = block.split("\n", QString::SkipEmptyParts); + + for (const QString &line : lines) { + QString trimmedLine = line.trimmed(); + + // 提取 Bus 信息 (I: Bus=0019 ...) + if (trimmedLine.startsWith("I:") && trimmedLine.contains("Bus=")) { + QRegExp busRegex("Bus=([0-9a-fA-F]+)"); + if (busRegex.indexIn(trimmedLine) != -1) { + bus = busRegex.cap(1); + } + } + + // 提取 Name 信息 (N: Name="Sleep Button") + if (trimmedLine.startsWith("N:") && trimmedLine.contains("Name=")) { + QRegExp nameRegex("Name=\"([^\"]+)\""); + if (nameRegex.indexIn(trimmedLine) != -1) { + name = nameRegex.cap(1); + } + } + } + + // 如果同时找到了 name 和 bus,则添加到映射中 + if (!name.isEmpty() && !bus.isEmpty()) { + nameToBusMap.insert(name, bus); + } + } + + if (nameToBusMap.contains(m_Name)) { + QString busID = nameToBusMap.value(m_Name); + m_Interface = getDetailBusInfo(busID).interfaceType; + } +} + +QString DeviceInput::getBusInfo() const +{ + return m_SysPath; +} + +QString DeviceInput::getInterface() const +{ + return m_Interface; +} + const QString &DeviceInput::name() const { return m_Name; @@ -318,7 +387,7 @@ bool DeviceInput::available() if (driver().isEmpty()) { m_Available = false; } - if ("PS/2" == m_Interface || "Bluetooth" == m_Interface) { + if ("PS/2" == m_Interface || "Bluetooth" == m_Interface || "I2C" == m_Interface) { m_Available = true; } return m_forcedDisplay ? m_forcedDisplay : m_Available; @@ -410,7 +479,7 @@ bool DeviceInput::isWakeupMachine() } QString info = file.readAll(); - if (m_Name.contains("PS/2")) { + if (m_Name.contains("PS/2") || m_Interface.contains("PS/2")) { // QStringList lines = info.split("\n"); // for (QString line : lines) { // if (line.startsWith("PS2M" && line.contains("disabled"))) { @@ -454,38 +523,38 @@ bool DeviceInput::bluetoothIsConnected() void DeviceInput::initFilterKey() { // 添加可显示的设备信息 - addFilterKey(QObject::tr("Uniq")); - addFilterKey(QObject::tr("PROP")); - addFilterKey(QObject::tr("EV")); - addFilterKey(QObject::tr("KEY")); - addFilterKey(QObject::tr("MSC")); - addFilterKey(QObject::tr("Device File")); - addFilterKey(QObject::tr("Hardware Class")); + addFilterKey("Uniq"); + addFilterKey("PROP"); + addFilterKey("EV"); + addFilterKey("KEY"); + addFilterKey("MSC"); + addFilterKey("Device File"); + addFilterKey("Hardware Class"); - // addFilterKey(QObject::tr("physical id")); + // addFilterKey("physical id"); } void DeviceInput::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Model"), m_Model); - addBaseDeviceInfo(tr("Interface"), m_Interface); - addBaseDeviceInfo(tr("Bus Info"), m_BusInfo); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Model"), m_Model); + addBaseDeviceInfo(("Interface"), m_Interface); + addBaseDeviceInfo(("Bus Info"), m_BusInfo); } void DeviceInput::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Module Alias"), m_Modalias); - addOtherDeviceInfo(tr("Physical ID"), m_PhysID); - addOtherDeviceInfo(tr("Speed"), m_Speed); - addOtherDeviceInfo(tr("Maximum Current"), m_MaximumPower); // 1050需求将最大功率改为最大电流 - addOtherDeviceInfo(tr("Driver"), m_Driver); - addOtherDeviceInfo(tr("Capabilities"), m_Capabilities); - addOtherDeviceInfo(tr("Version"), m_Version); + addOtherDeviceInfo(("Module Alias"), m_Modalias); + addOtherDeviceInfo(("Physical ID"), m_PhysID); + addOtherDeviceInfo(("Speed"), m_Speed); + addOtherDeviceInfo(("Maximum Current"), m_MaximumPower); // 1050需求将最大功率改为最大电流 + addOtherDeviceInfo(("Driver"), m_Driver); + addOtherDeviceInfo(("Capabilities"), m_Capabilities); + addOtherDeviceInfo(("Version"), m_Version); // 将QMap内容转存为QList> mapInfoToList(); @@ -497,11 +566,11 @@ void DeviceInput::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInput.h b/deepin-devicemanager/src/DeviceManager/DeviceInput.h index 1120f5cd1..35e776f9c 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInput.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceInput.h @@ -8,6 +8,17 @@ #include "DeviceInfo.h" +/** + * @brief The InputDeviceBusInfo class + * 描述InputDevice设备的Bus信息 + */ +struct InputDeviceBusInfo { + QString busId; + QString interfaceType; + QString typicalDevices; + QString description; +}; + /** * @brief The DeviceInput class * 用来描述输入设备的类 @@ -40,12 +51,6 @@ class DeviceInput : public DeviceBaseInfo */ void setInfoFromHwinfo(const QMap &mapInfo); - /** - * @brief setKLUInfoFromHwinfo:特殊处理KLU设备,设置由hwinfo --keyboard 命令获取的设备信息 - * @param mapInfo由hwinfo获取的信息map - */ - void setKLUInfoFromHwinfo(const QMap &mapInfo); - /** * @brief name:获取名称属性值 * @return QString 名称属性值 @@ -125,6 +130,10 @@ class DeviceInput : public DeviceBaseInfo */ bool bluetoothIsConnected(); + QString getBusInfo() const; + + QString getInterface() const; + protected: /** * @brief initFilterKey:初始化可现实的可显示的属性,m_FilterKey @@ -173,6 +182,18 @@ class DeviceInput : public DeviceBaseInfo */ QString eventStrFromDeviceFiles(const QString &dfs); + /** + * @brief getDetailBusInfo + * @param busId Bus ID类别号 + * @return + */ + InputDeviceBusInfo getDetailBusInfo(const QString &busId); + + /** + * @brief getMouseInfoFromBusDevice + * 实时从/proc/bus/input/devices获取设备接口信息 + */ + void getMouseInfoFromBusDevice(); private: QString m_Model; // DeviceManager::convertDeviceList(DeviceType deviceType) if (deviceType == DT_Print) {return m_ListDevicePrint;} if (deviceType == DT_Image) {return m_ListDeviceImage;} if (deviceType == DT_Others) {return m_ListDeviceOthers;} + + return QList(); } DeviceBaseInfo *DeviceManager::createDevice(DeviceType deviceType) { - DeviceBaseInfo *vTemp; + DeviceBaseInfo *vTemp { nullptr }; if (deviceType == DT_Computer) {vTemp = new DeviceComputer(); return vTemp;} if (deviceType == DT_Cpu) {vTemp = new DeviceCpu(); return vTemp;} if (deviceType == DT_Bios) {vTemp = new DeviceBios(); return vTemp;} @@ -385,7 +387,7 @@ DeviceBaseInfo *DeviceManager::createDevice(DeviceType deviceType) return vTemp; } -TomlFixMethod DeviceManager::tomlDeviceSet(DeviceType deviceType, DeviceBaseInfo *device, const QMap &mapInfo) +TomlFixMethod DeviceManager::tomlDeviceMapSet(DeviceType deviceType, DeviceBaseInfo *device, const QMap &mapInfo) { if (!device) { return TOML_None; @@ -467,11 +469,133 @@ TomlFixMethod DeviceManager::tomlDeviceSet(DeviceType deviceType, DeviceBaseInf DevicePower *tomldevice = dynamic_cast(device); (TOML_Del == tomldevice->setInfoFromTomlBase(mapInfo)) ? ret = TOML_Del : ret = tomldevice->setInfoFromTomlOneByOne(mapInfo); } break; - default: { } break; } return ret; } +QString DeviceManager::tomlDeviceReadKeyValue(DeviceType deviceType, DeviceBaseInfo *device, const QString &key) +{ + if (!device) + return QString(""); + + switch (deviceType) { + case DT_Null: + break; + case DT_Computer: { + DeviceComputer *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Cpu: { + DeviceCpu *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Bios: { + DeviceBios *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Memory: { + DeviceMemory *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Storage: { + DeviceStorage *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Gpu: { + DeviceGpu *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Monitor: { + DeviceMonitor *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Network: { + DeviceNetwork *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Audio: { + DeviceAudio *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Bluetoorh: { + DeviceBluetooth *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Keyboard: { + DeviceInput *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Mouse: { + DeviceInput *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Print: { + DevicePrint *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Image: { + DeviceImage *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Cdrom: { + DeviceCdrom *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Others: { + DeviceOthers *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_OtherPCI: { + DeviceOtherPCI *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + case DT_Power: { + DevicePower *tomldevice = dynamic_cast(device); + return tomldevice->readDeviceInfoKeyValue(key); + }; + } + return QString(""); +} + +bool DeviceManager::tomlSetBytomlmatchkey(DeviceType deviceType, DeviceBaseInfo *device, const QString &tomltomlmatchkey, const QString &tomltomlconfigdemanding) +{ + Q_UNUSED(deviceType) + Q_UNUSED(tomltomlconfigdemanding) + + QMap itemMap; + QStringList keyValues = tomltomlmatchkey.split(","); + foreach (const QString &keyValue, keyValues) { + QStringList wordlst = keyValue.split("="); + if (2 == wordlst.size()) { + + QString key = wordlst[0].remove('"').trimmed(); + QString valuetmp = wordlst[1]; + QStringList valuelst; + QString value; + if (valuetmp.contains("#")) { + valuelst = valuetmp.split("#"); + value = valuelst[0].remove('\"').trimmed(); + } else + value = valuetmp.remove('\"').trimmed(); + + itemMap.insert(key, value); + } + } + if(itemMap.size() == 0 ) + return false; + + for (auto key : itemMap.keys()) { + QString tomlKey = key; + QString tomlVal = itemMap.value(key); + QString deviceVal = device->readDeviceInfoKeyValue(tomlKey); + if((0 != deviceVal.compare(tomlVal, Qt::CaseInsensitive))) { + return false; + } + } + + return true; +} + void DeviceManager::tomlDeviceSet(DeviceType deviceType) { @@ -479,7 +603,9 @@ void DeviceManager::tomlDeviceSet(DeviceType deviceType) const QList> &tomlMapLst = cmdInfo(deviceTypeName); for (int j = 0; j < tomlMapLst.size(); j++) { // 加载从toml中获取的信息 bool fixSameOne = false; //初始值设为该项信息没有用过 - bool isSameOne = false; + + QString tomltomlmatchkey = tomlMapLst[j]["tomlmatchkey"]; + QString tomltomlconfigdemanding = PhysID(tomlMapLst[j], "tomlconfigdemanding"); QList lst = convertDeviceList(deviceType); for (int i = 0; i < lst.size(); i++) { // toml中获取的信息 与 原设备信息遍历,相比较作处理 DeviceBaseInfo *device = lst[i]; @@ -488,27 +614,48 @@ void DeviceManager::tomlDeviceSet(DeviceType deviceType) QString pid = PhysID(tomlMapLst[j], "Product_ID"); QString vendor = PhysID(tomlMapLst[j], "Vendor"); QString name = PhysID(tomlMapLst[j], "Name"); - //取出toml中获取的关键字信息设备唯一标识硬件IDS "Modalias", "Vendor_ID", "Vendor","Name";作比较处理 - isSameOne = findByModalias(deviceType, device, modalias); - if (!isSameOne) { - isSameOne = findByVIDPID(deviceType, device, vid, pid); - } - if (!isSameOne) { - isSameOne = findByVendorName(deviceType, device, vendor, name); - } - if (isSameOne) { //存在 就合并信息 setInfoFromTomlOneByOne(const QMap &mapInfo); + bool isSameOne = false; //初始值设为该项信息不属于该设备 + + + isSameOne = tomlSetBytomlmatchkey(deviceType, device, tomltomlmatchkey,tomltomlconfigdemanding); + + if (tomltomlconfigdemanding == "adjust") { fixSameOne = true; //标记为该项信息有用过 , - if (TOML_Del == tomlDeviceSet(deviceType, device, tomlMapLst[j])) { + if (isSameOne) + tomlDeviceMapSet(deviceType, device, tomlMapLst[j]); + } else if (tomltomlconfigdemanding == "delete") { + fixSameOne = true; //标记为该项信息有用过 , + if (isSameOne) { tomlDeviceDel(deviceType, device); //toml 去掉该设备 delete (device); } + } else if (tomltomlconfigdemanding == "add" && !fixSameOne) { + + } else { + //取出toml中获取的关键字信息设备唯一标识硬件IDS "Modalias", "Vendor_ID", "Vendor","Name";作比较处理 + if (!isSameOne) + isSameOne = findByModalias(deviceType, device, modalias); + if (!isSameOne) { + isSameOne = findByVIDPID(deviceType, device, vid, pid); + } + if (!isSameOne) { + isSameOne = findByVendorName(deviceType, device, vendor, name); + } + if (isSameOne&& !fixSameOne) { //存在 就合并信息 + fixSameOne = true; //标记为该项信息有用过 , + if (TOML_Del == tomlDeviceMapSet(deviceType, device, tomlMapLst[j])) { + tomlDeviceDel(deviceType, device); //toml 去掉该设备 + delete (device); + } + } } } //与原设备信息遍历相比完再作添加设备 - if ((deviceType != DT_Bios) && (deviceType != DT_Computer) && !fixSameOne) { - fixSameOne = true; //标记为该项信息有用过 ,则不再增加了 - DeviceBaseInfo *device = createDevice(deviceType); - tomlDeviceSet(deviceType, device, tomlMapLst[j]); - tomlDeviceAdd(deviceType, device); //不存在 就加 + + if (tomltomlconfigdemanding == "add" && !fixSameOne) { + fixSameOne = true; //标记为该项信息有用过 + DeviceBaseInfo *newDevice = createDevice(deviceType); + tomlDeviceMapSet(deviceType, newDevice, tomlMapLst[j]); + tomlDeviceAdd(deviceType, newDevice); //加 } } //end of for (int j = 0;... } @@ -544,6 +691,8 @@ void DeviceManager::tomlDeviceAdd(DeviceType deviceType, DeviceBaseInfo *const d bool DeviceManager::findByModalias(DeviceType deviceType, DeviceBaseInfo *device, const QString &modalias) { + Q_UNUSED(deviceType) + if (modalias.isEmpty()) return false; { @@ -572,6 +721,8 @@ bool DeviceManager::findByModalias(DeviceType deviceType, DeviceBaseInfo *device bool DeviceManager::findByVIDPID(DeviceType deviceType, DeviceBaseInfo *device, const QString &vid, const QString &pid) { + Q_UNUSED(deviceType) + if (vid.isEmpty() || pid.isEmpty()) return false; { @@ -767,37 +918,69 @@ void DeviceManager::checkDiskSize() } } -bool DeviceManager::setStorageDeviceMediaType(const QString &name, const QString &value) +void DeviceManager::orderDiskByType() { - // 设置存储设备介质类型 - QList::iterator it = m_ListDeviceStorage.begin(); - for (; it != m_ListDeviceStorage.end(); ++it) { - DeviceStorage *device = dynamic_cast(*it); - if (!device) - continue; + // 自定义排序 + auto compareDevices = [](DeviceBaseInfo* baseInfo1, DeviceBaseInfo* baseInfo2) { + DeviceStorage *storageA = dynamic_cast(baseInfo1); + DeviceStorage *storageB = dynamic_cast(baseInfo2); - // 设置介质类型 - if (device->setMediaType(name, value)) + if (storageA == nullptr || storageB == nullptr) { + return false; + } + + // 判断是否为 USB 设备(包括 USB 接口的 SSD) + auto isUSBDevice = [](DeviceStorage *device) { + return device->interface().contains("USB") || + (device->interface().contains("USB") && device->mediaType().contains("SSD")); + }; + + // 1. 首先按照 UFS 优先 + if (storageA->interface().contains("UFS") && !storageB->interface().contains("UFS")) return true; - } + if (!storageA->interface().contains("UFS") && storageB->interface().contains("UFS")) + return false; - return false; + // 2. 然后按照 SSD、HDD 排序(排除 USB 接口的 SSD) + if (!isUSBDevice(storageA) && !isUSBDevice(storageB)) { + if (storageA->mediaType().contains("SSD") && !storageB->mediaType().contains("SSD")) + return true; + if (!storageA->mediaType().contains("SSD") && storageB->mediaType().contains("SSD")) + return false; + if (storageA->mediaType().contains("HDD") && !storageB->mediaType().contains("HDD")) + return true; + if (!storageA->mediaType().contains("HDD") && storageB->mediaType().contains("HDD")) + return false; + } + + // 3. 最后按照 USB 设备排序(包括 USB 接口的 SSD) + if (isUSBDevice(storageA) && !isUSBDevice(storageB)) + return false; // USB 设备排在后面 + if (!isUSBDevice(storageA) && isUSBDevice(storageB)) + return true; + + // 如果所有条件都相同,保持原有顺序 + return false; + }; + + // 使用自定义比较函数对列表进行排序 + std::sort(m_ListDeviceStorage.begin(), m_ListDeviceStorage.end(), compareDevices); } -bool DeviceManager::setKLUStorageDeviceMediaType(const QString &name, const QString &value) +bool DeviceManager::setStorageDeviceMediaType(const QString &name, const QString &value) { - // 设置KLU机器存储设备介质类型 + // 设置存储设备介质类型 QList::iterator it = m_ListDeviceStorage.begin(); for (; it != m_ListDeviceStorage.end(); ++it) { DeviceStorage *device = dynamic_cast(*it); - if (!device) continue; - // 设置KLU介质类型 - if (device->setKLUMediaType(name, value)) + // 设置介质类型 + if (device->setMediaType(name, value)) return true; } + return false; } @@ -872,7 +1055,7 @@ void DeviceManager::addMonitor(DeviceMonitor *const device) m_ListDeviceMonitor.append(device); } -void DeviceManager::setMonitorInfoFromXrandr(const QString &main, const QString &edid, const QString &rate) +void DeviceManager::setMonitorInfoFromXrandr(const QString &main, const QString &edid, const QString &rate, const QString &xrandr) { // 从xrandr中添加显示设备信息 QList::iterator it = m_ListDeviceMonitor.begin(); @@ -881,7 +1064,7 @@ void DeviceManager::setMonitorInfoFromXrandr(const QString &main, const QString if (!device) continue; - if (device->setInfoFromXradr(main, edid, rate)) + if (device->setInfoFromXradr(main, edid, rate, xrandr)) return; } } @@ -954,18 +1137,6 @@ bool DeviceManager::setBluetoothInfoFromHwinfo(const QMap &map return false; } -bool DeviceManager::setBluetoothInfoFromWifiInfo(const QMap &mapInfo) -{ - QList::iterator it = m_ListDeviceBluetooth.begin(); - for (; it != m_ListDeviceBluetooth.end(); ++it) { - DeviceBluetooth *device = dynamic_cast(*it); - if (device->setInfoFromWifiInfo(mapInfo)) { - return true; - } - } - return false; -} - DeviceBaseInfo *DeviceManager::getBluetoothDevice(const QString &unique_id) { for (QList::iterator it = m_ListDeviceBluetooth.begin(); it != m_ListDeviceBluetooth.end(); ++it) { @@ -989,22 +1160,77 @@ void DeviceManager::delAudioDevice(DeviceAudio *const device) void DeviceManager::deleteDisableDuplicate_AudioDevice(void) { - if (m_ListDeviceAudio.size() > 0) { - for (QList::iterator it = m_ListDeviceAudio.begin(); it != m_ListDeviceAudio.end(); ++it) { - DeviceAudio *audio_1 = dynamic_cast(*it); - //QString tpath = audio_1->uniqueID(); - // 判断该设备是否已经存在, - if (!audio_1->enable()) { - for (QList::iterator it2 = m_ListDeviceAudio.begin(); it2 != m_ListDeviceAudio.end(); ++it2) { - DeviceAudio *audio_2 = dynamic_cast(*it2); - if (audio_2->name() == audio_1->name()) - if (audio_2->enable()) - m_ListDeviceAudio.removeOne(audio_2); + QHash enabledDevices; + QHash enableDevicePriority; + for (auto it = m_ListDeviceAudio.begin(); it != m_ListDeviceAudio.end(); ++it) { + DeviceAudio* audio = dynamic_cast(*it); + if (!audio) { + continue; + } + if (audio->enable() || !enabledDevices.contains(audio->uniqueID())) { + enabledDevices[audio->uniqueID()] = audio; + if (!enableDevicePriority.contains(audio->uniqueID())) { + if (audio->enable() || ! audio->driver().contains("usb")) { + enableDevicePriority.insert(audio->uniqueID(), 2); + } else { + enableDevicePriority.insert(audio->uniqueID(), 1); } + } else { + enableDevicePriority[audio->uniqueID()] = enableDevicePriority[audio->uniqueID()] + 1; + } + } else { + if (enabledDevices.contains(audio->uniqueID()) && enabledDevices[audio->uniqueID()]->enable()) { + if (!enableDevicePriority.contains(audio->uniqueID())) { + if (audio->enable()) { + enableDevicePriority.insert(audio->uniqueID(), 2); + } else { + enableDevicePriority.insert(audio->uniqueID(), 1); + } + } else { + enableDevicePriority[audio->uniqueID()] = enableDevicePriority[audio->uniqueID()] + 1; + } + audio->setSysPath(enabledDevices[audio->uniqueID()]->sysPath()); + delete enabledDevices[audio->uniqueID()]; + enabledDevices[audio->uniqueID()] = audio; } } + } + qWarning()<<"delete before: "<< m_ListDeviceAudio.size(); + qWarning() << enableDevicePriority; + m_ListDeviceAudio.clear(); + for(auto it : enabledDevices.keys()){ + if (enableDevicePriority.value(it) <= 1) { + continue; + } + m_ListDeviceAudio.push_back(enabledDevices.value(it)); + setAudioDeviceEnable(enabledDevices.value(it), enabledDevices.value(it)->enable()); } + qWarning()<<"delete after: "<< m_ListDeviceAudio.size(); +} + +void DeviceManager::setAudioDeviceEnable(DeviceAudio * const devivce, bool enable) +{ + EnableDeviceStatus status ; + + int i = 0; + do{ + status = devivce->setEnable(enable); + if (status == EDS_Success) { + break; + } + qWarning() << "retry: " << ++i; + }while (i < 3); + + qWarning() << [](EnableDeviceStatus status) { + switch(status) { + case EDS_Cancle: return "Device enable operation was cancelled"; + case EDS_NoSerial: return "Device enable failed: No serial number available"; + case EDS_Faild: return "-----Device enable failed due to unknown error"; + case EDS_Success: return "Device enabled successfully"; + default: return "Unknown device enable status"; + } + }(status); } DeviceBaseInfo *DeviceManager::getAudioDevice(const QString &path) @@ -1067,22 +1293,6 @@ void DeviceManager::addNetworkDevice(DeviceNetwork *const device) m_ListDeviceNetwork.append(device); } -bool DeviceManager::setNetworkInfoFromWifiInfo(const QMap &mapInfo) -{ - QList::iterator it = m_ListDeviceNetwork.begin(); - for (; it != m_ListDeviceNetwork.end(); ++it) { - - DeviceNetwork *device = dynamic_cast(*it); - if (!device) - continue; - - if (device->setInfoFromWifiInfo(mapInfo)) { - return true; - } - } - return false; -} - DeviceBaseInfo *DeviceManager::getNetworkDevice(const QString &unique_id) { for (QList::iterator it = m_ListDeviceNetwork.begin(); it != m_ListDeviceNetwork.end(); ++it) { @@ -1094,7 +1304,7 @@ DeviceBaseInfo *DeviceManager::getNetworkDevice(const QString &unique_id) return nullptr; } -void DeviceManager::correctNetworkLinkStatus(QString linkStatus, QString networkDriver) +void DeviceManager::correctNetworkLinkStatus(const QString &linkStatus, const QString &networkDriver) { if (m_ListDeviceNetwork.size() == 0) return; diff --git a/deepin-devicemanager/src/DeviceManager/DeviceManager.h b/deepin-devicemanager/src/DeviceManager/DeviceManager.h index 8bfc16d7e..53458b821 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceManager.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceManager.h @@ -103,10 +103,12 @@ class DeviceManager : public QObject */ QList convertDeviceList(DeviceType deviceType); QString convertDeviceTomlClassName(DeviceType deviceType); - TomlFixMethod tomlDeviceSet(DeviceType deviceType, DeviceBaseInfo *device, const QMap &mapInfo); + TomlFixMethod tomlDeviceMapSet(DeviceType deviceType, DeviceBaseInfo *device, const QMap &mapInfo); void tomlDeviceSet(DeviceType deviceType); void tomlDeviceDel(DeviceType deviceType, DeviceBaseInfo *const device); void tomlDeviceAdd(DeviceType deviceType, DeviceBaseInfo *const device); + QString tomlDeviceReadKeyValue(DeviceType deviceType, DeviceBaseInfo *device, const QString &key); + bool tomlSetBytomlmatchkey(DeviceType deviceType, DeviceBaseInfo *device, const QString &tomltomlmatchkey, const QString &tomltomlconfigdemanding); /** * @brief * toml 方案内容定义: @@ -129,14 +131,12 @@ class DeviceManager : public QObject * @param KeyID "Module Alias" "VID_PID" * @return */ - DeviceBaseInfo *findByModalias(DeviceType deviceType, const QString &modalias); - DeviceBaseInfo *findByVIDPID(DeviceType deviceType, const QString &vid, const QString &pid); - DeviceBaseInfo *findByVendorName(DeviceType deviceType, const QString &vendor, const QString &name); bool findByModalias(DeviceType deviceType, DeviceBaseInfo *device, const QString &modalias); bool findByVIDPID(DeviceType deviceType, DeviceBaseInfo *device, const QString &vid, const QString &pid); bool findByVendorName(DeviceType deviceType, DeviceBaseInfo *device, const QString &vendor, const QString &name); + /** * @brief getBluetoothAtIndex 根据索引获取device * @param index @@ -196,14 +196,6 @@ class DeviceManager : public QObject */ bool setStorageDeviceMediaType(const QString &name, const QString &value); - /** - * @brief setKLUStorageDeviceMediaType:KLU机器设置存储设备介质类型 - * @param name:逻辑名称 - * @param value:存储设备介质类型信息 - * @return 布尔值:true-设置成功;false-设置失败 - */ - bool setKLUStorageDeviceMediaType(const QString &name, const QString &value); - /** * @brief setStorageInfoFromSmartctl:设置由smartctl获取的存储设备信息 * @param name:逻辑名称 @@ -221,6 +213,11 @@ class DeviceManager : public QObject */ virtual void checkDiskSize(); + /** + * @brief orderDiskByType:按照磁盘类型UFS、SSD、HDD、移动存储设备的顺序显示 + */ + virtual void orderDiskByType(); + // GPU设备相关 ************************************************************************************** /** * @brief addGpuDevice:添加显卡 @@ -271,7 +268,7 @@ class DeviceManager : public QObject * @param main:主显示器信息 * @param edid:edid信息 */ - void setMonitorInfoFromXrandr(const QString &main, const QString &edid, const QString &rate = ""); + void setMonitorInfoFromXrandr(const QString &main, const QString &edid, const QString &rate = "", const QString &xrandr = ""); /** * @brief setMonitorInfoFromDbus:设置由 dbus 获取的显示设备信息 @@ -312,13 +309,6 @@ class DeviceManager : public QObject */ bool setBluetoothInfoFromHwinfo(const QMap &mapInfo); - /** - * @brief setBluetoothInfoFromWifiInfo:设置由WifiInfo获取的蓝牙信息 - * @param mapInfo:由WifiInfo获取的蓝牙信息map - * @return 布尔值:true设置成功;false设置失败 - */ - bool setBluetoothInfoFromWifiInfo(const QMap &mapInfo); - /** * @brief getBluetoothDevice * @param unique_id @@ -346,6 +336,8 @@ class DeviceManager : public QObject */ void deleteDisableDuplicate_AudioDevice(void); + void setAudioDeviceEnable(DeviceAudio *const devivce, bool enable); + /** * @brief getAudioDevice 获取音频设备 * @param path @@ -384,12 +376,6 @@ class DeviceManager : public QObject */ void addNetworkDevice(DeviceNetwork *const device); - /** - * @brief setNetworkInfoFromWifiInfo:设置网络适配器 - * @param mapInfo:由WifiInfo获取的网卡信息map - */ - bool setNetworkInfoFromWifiInfo(const QMap &mapInfo); - /** * @brief getNetworkDevice 获取网卡设备 * @param busInfo @@ -401,7 +387,7 @@ class DeviceManager : public QObject * @brief correctNetworkLinkStatus:校正网络连接状态 * @param linkStatus:连接状态 */ - void correctNetworkLinkStatus(QString linkStatus, QString networkDriver); + void correctNetworkLinkStatus(const QString &linkStatus, const QString &networkDriver); /** * @brief networkDriver:获取所有网络驱动 diff --git a/deepin-devicemanager/src/DeviceManager/DeviceMemory.cpp b/deepin-devicemanager/src/DeviceManager/DeviceMemory.cpp old mode 100644 new mode 100755 index 64c320096..bd52da9ae --- a/deepin-devicemanager/src/DeviceManager/DeviceMemory.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceMemory.cpp @@ -54,17 +54,17 @@ TomlFixMethod DeviceMemory::setInfoFromTomlOneByOne(const QMap { TomlFixMethod ret = TOML_None; // 添加基本信息 - ret = setTomlAttribute(mapInfo, "Size", m_Size); - ret = setTomlAttribute(mapInfo, "Type", m_Type); - ret = setTomlAttribute(mapInfo, "Speed", m_Speed); - ret = setTomlAttribute(mapInfo, "Total Width", m_TotalBandwidth); - ret = setTomlAttribute(mapInfo, "Locator", m_Locator); - ret = setTomlAttribute(mapInfo, "Serial Number", m_SerialNumber); + setTomlAttribute(mapInfo, "Size", m_Size); + setTomlAttribute(mapInfo, "Type", m_Type); + setTomlAttribute(mapInfo, "Speed", m_Speed); + setTomlAttribute(mapInfo, "Total Width", m_TotalBandwidth); + setTomlAttribute(mapInfo, "Locator", m_Locator); + setTomlAttribute(mapInfo, "Serial Number", m_SerialNumber); // 添加其他信息,成员变量 - ret = setTomlAttribute(mapInfo, "Configured Voltage", m_ConfiguredVoltage); - ret = setTomlAttribute(mapInfo, "Maximum Voltage", m_MaximumVoltage); - ret = setTomlAttribute(mapInfo, "Minimum Voltage", m_MinimumVoltage); - ret = setTomlAttribute(mapInfo, "Configured Speed", m_ConfiguredSpeed); + setTomlAttribute(mapInfo, "Configured Voltage", m_ConfiguredVoltage); + setTomlAttribute(mapInfo, "Maximum Voltage", m_MaximumVoltage); + setTomlAttribute(mapInfo, "Minimum Voltage", m_MinimumVoltage); + setTomlAttribute(mapInfo, "Configured Speed", m_ConfiguredSpeed); ret = setTomlAttribute(mapInfo, "Data Width", m_DataBandwidth); //3. 获取设备的其它信息 getOtherMapInfo(mapInfo); @@ -106,39 +106,41 @@ bool DeviceMemory::setInfoFromDmidecode(const QMap &mapInfo) void DeviceMemory::initFilterKey() { // 初始化可显示属性 - addFilterKey(QObject::tr("Array Handle")); // 数组程序 - addFilterKey(QObject::tr("Error Information Handle")); //错误信息程序 - addFilterKey(QObject::tr("Form Factor")); // 尺寸型号 - addFilterKey(QObject::tr("Set")); // 设置 - addFilterKey(QObject::tr("Bank Locator")); // 内存通道 - addFilterKey(QObject::tr("Type Detail")); // 类型详细信息 - addFilterKey(QObject::tr("Asset Tag")); // 资产标签 - addFilterKey(QObject::tr("Part Number")); - addFilterKey(QObject::tr("Rank")); - addFilterKey(QObject::tr("Memory Technology")); // 内存技术 - addFilterKey(QObject::tr("Memory Operating Mode Capability")); // 内存操作模式 - addFilterKey(QObject::tr("Firmware Version")); //固件版本 - addFilterKey(QObject::tr("Module Manufacturer ID")); - addFilterKey(QObject::tr("Module Product ID")); - addFilterKey(QObject::tr("Memory Subsystem Controller Manufacturer ID")); - addFilterKey(QObject::tr("Memory Subsystem Controller Product ID")); - addFilterKey(QObject::tr("Non-Volatile Size")); // 不易丢失大小 - addFilterKey(QObject::tr("Volatile Size")); // 易丢失大小 - addFilterKey(QObject::tr("Cache Size")); // 缓存大小 - addFilterKey(QObject::tr("Logical Size")); // 逻辑大小 +// addFilterKey("Array Handle"); // 数组程序-2 + addFilterKey("Error Information Handle"); //错误信息程序-2 + addFilterKey("Form Factor"); // 尺寸型号-2 + addFilterKey("Set"); // 设置-2 + addFilterKey("Bank Locator"); // 内存通道-2 + addFilterKey("Type Detail"); // 类型详细信息-2 + addFilterKey("Asset Tag"); // 资产标签-2 + addFilterKey("Part Number"); + addFilterKey("Rank"); + addFilterKey("Memory Technology"); // 内存技术-2 + addFilterKey("Memory Operating Mode Capability"); // 内存操作模式-2 + addFilterKey("Firmware Version"); //固件版本-2 + addFilterKey("Module Manufacturer ID"); + addFilterKey("Module Product ID"); + addFilterKey("Memory Subsystem Controller Manufacturer ID"); + addFilterKey("Memory Subsystem Controller Product ID"); + addFilterKey("Non-Volatile Size"); // 不易丢失大小-2 + addFilterKey("Volatile Size"); // 易丢失大小-2 + addFilterKey("Cache Size"); // 缓存大小-2 + addFilterKey("Logical Size"); // 逻辑大小-2 } void DeviceMemory::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Size"), m_Size); - addBaseDeviceInfo(tr("Type"), m_Type); - addBaseDeviceInfo(tr("Speed"), m_Speed); - addBaseDeviceInfo(tr("Total Width"), m_TotalBandwidth); - addBaseDeviceInfo(tr("Locator"), m_Locator); - addBaseDeviceInfo(tr("Serial Number"), m_SerialNumber); + addBaseDeviceInfo(("Name"), m_Name); + if (Common::specialComType <= 0) { + addBaseDeviceInfo(("Vendor"), m_Vendor); + } + addBaseDeviceInfo(("Size"), m_Size); + addBaseDeviceInfo(("Type"), m_Type); + addBaseDeviceInfo(("Speed"), m_Speed); + addBaseDeviceInfo(("Total Width"), m_TotalBandwidth); + addBaseDeviceInfo(("Locator"), m_Locator); + addBaseDeviceInfo(("Serial Number"), m_SerialNumber); } void DeviceMemory::loadOtherDeviceInfo() @@ -146,14 +148,14 @@ void DeviceMemory::loadOtherDeviceInfo() // 倒序,头插,保证原来的顺序 // 添加其他信息,成员变量 if (Common::boardVendorType().isEmpty()) { - addOtherDeviceInfo(tr("Configured Voltage"), m_ConfiguredVoltage); - addOtherDeviceInfo(tr("Maximum Voltage"), m_MaximumVoltage); - addOtherDeviceInfo(tr("Minimum Voltage"), m_MinimumVoltage); - addOtherDeviceInfo(tr("Configured Speed"), m_ConfiguredSpeed); + addOtherDeviceInfo(("Configured Voltage"), m_ConfiguredVoltage); + addOtherDeviceInfo(("Maximum Voltage"), m_MaximumVoltage); + addOtherDeviceInfo(("Minimum Voltage"), m_MinimumVoltage); + addOtherDeviceInfo(("Configured Speed"), m_ConfiguredSpeed); } else { - addOtherDeviceInfo(tr("Configured Speed"), m_ConfiguredSpeed); + addOtherDeviceInfo(("Configured Speed"), m_ConfiguredSpeed); } - addOtherDeviceInfo(tr("Data Width"), m_DataBandwidth); + addOtherDeviceInfo(("Data Width"), m_DataBandwidth); // 将QMap内容转存为QList> mapInfoToList(); @@ -162,11 +164,11 @@ void DeviceMemory::loadOtherDeviceInfo() void DeviceMemory::loadTableHeader() { // 加载表头 - m_TableHeader.append(tr("Name")); - m_TableHeader.append(tr("Vendor")); - m_TableHeader.append(tr("Type")); - m_TableHeader.append(tr("Speed")); - m_TableHeader.append(tr("Size")); + m_TableHeader.append("Name"); + m_TableHeader.append("Vendor"); + m_TableHeader.append("Type"); + m_TableHeader.append("Speed"); + m_TableHeader.append("Size"); } void DeviceMemory::loadTableData() @@ -212,11 +214,13 @@ const QString DeviceMemory::getOverviewInfo() QString nameStr = m_Name != "" ? m_Name : m_Vendor; if (nameStr == "--") nameStr.clear(); - ov += QString("%1(%2 %3 %4)") \ + ov += QString("%1(%2%3 %4)") \ .arg(m_Size) \ - .arg(nameStr) \ + .arg(nameStr + (nameStr.isEmpty() ? "" : " ")) \ .arg(m_Type) \ .arg(m_Speed); + ov = ov.trimmed(); + return ov; } diff --git a/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp b/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp index 370b964a6..4bc976a25 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp @@ -16,6 +16,7 @@ // 其它头文件 #include +#include DWIDGET_USE_NAMESPACE @@ -33,6 +34,7 @@ DeviceMonitor::DeviceMonitor() , m_CurrentResolution("") , m_SerialNumber("") , m_ProductionWeek("") + , m_RefreshRate("") , m_Width(0) , m_Height(0) , m_IsTomlSet(false) @@ -60,7 +62,7 @@ QString DeviceMonitor::parseMonitorSize(const QString &sizeDescription, double & double width = m_Width / 2.54; double height = m_Height / 2.54; inch = std::sqrt(width * width + height * height) / 10.0; - res = QString::number(inch, 10, 1) + " " + QObject::tr("inch") + " ("; + res = QString::number(inch, 10, 1) + " " + translateStr("inch") + " ("; res += sizeDescription; res += ")"; } @@ -77,7 +79,7 @@ QString DeviceMonitor::parseMonitorSize(const QString &sizeDescription, double & double width = m_Width / 2.54; double height = m_Height / 2.54; inch = std::sqrt(width * width + height * height) / 10.0; - res = QString::number(inch, 10, 1) + " " + QObject::tr("inch") + " ("; + res = QString::number(inch, 10, 1) + " " + translateStr("inch") + " ("; res += sizeDescription; res += ")"; } @@ -94,7 +96,9 @@ void DeviceMonitor::setInfoFromHwinfo(const QMap &mapInfo) setAttribute(mapInfo, "", m_DisplayInput); setAttribute(mapInfo, "Size", m_ScreenSize); setAttribute(mapInfo, "", m_MainScreen); - setAttribute(mapInfo, "Resolution", m_SupportResolution); + if (Common::specialComType > 0){ + setAttribute(mapInfo, "Resolution", m_SupportResolution); + } double inch = 0.0; QSize size(0, 0); @@ -102,19 +106,22 @@ void DeviceMonitor::setInfoFromHwinfo(const QMap &mapInfo) m_ScreenSize = inchValue; // 获取当前分辨率 和 当前支持分辨率 - QStringList listResolution = m_SupportResolution.split(" "); - m_SupportResolution = ""; - foreach (const QString &word, listResolution) { - if (word.contains("@")) { - m_SupportResolution.append(word); - m_SupportResolution.append(", "); + if (Common::specialComType > 0){ + QStringList listResolution = m_SupportResolution.split(" "); + m_SupportResolution = ""; + foreach (const QString &word, listResolution) { + if (word.contains("@")) { + m_SupportResolution.append(word); + m_SupportResolution.append(", "); + } } } // 计算显示比例 caculateScreenRatio(); - - m_SupportResolution.replace(QRegExp(", $"), ""); + if (Common::specialComType > 0){ + m_SupportResolution.replace(QRegExp(", $"), ""); + } m_ProductionWeek = transWeekToDate(mapInfo["Year of Manufacture"], mapInfo["Week of Manufacture"]); setAttribute(mapInfo, "Serial ID", m_SerialNumber); @@ -125,45 +132,46 @@ void DeviceMonitor::setInfoFromHwinfo(const QMap &mapInfo) TomlFixMethod DeviceMonitor::setInfoFromTomlOneByOne(const QMap &mapInfo) { - m_IsTomlSet = true; + if (Common::specialComType == 2) + m_IsTomlSet = true; TomlFixMethod ret = TOML_None; // 添加基本信息 - ret = setTomlAttribute(mapInfo, "Type", m_Model); - ret = setTomlAttribute(mapInfo, "Display Input", m_DisplayInput); - ret = setTomlAttribute(mapInfo, "Interface Type", m_Interface); + setTomlAttribute(mapInfo, "Type", m_Model); + setTomlAttribute(mapInfo, "Display Input", m_DisplayInput); + setTomlAttribute(mapInfo, "Interface Type", m_Interface); // 添加其他信息,成员变量 - ret = setTomlAttribute(mapInfo, "Support Resolution", m_SupportResolution); - ret = setTomlAttribute(mapInfo, "Current Resolution", m_CurrentResolution); - ret = setTomlAttribute(mapInfo, "Display Ratio", m_AspectRatio); - ret = setTomlAttribute(mapInfo, "Primary Monitor", m_MainScreen); - ret = setTomlAttribute(mapInfo, "Size", m_ScreenSize); - ret = setTomlAttribute(mapInfo, "Serial Number", m_SerialNumber); - ret = setTomlAttribute(mapInfo, "Product Date", m_ProductionWeek); + setTomlAttribute(mapInfo, "Support Resolution", m_SupportResolution); + setTomlAttribute(mapInfo, "Current Resolution", m_CurrentResolution); + setTomlAttribute(mapInfo, "Display Ratio", m_AspectRatio); + setTomlAttribute(mapInfo, "Primary Monitor", m_MainScreen); + setTomlAttribute(mapInfo, "Size", m_ScreenSize); + setTomlAttribute(mapInfo, "Serial Number", m_SerialNumber); + setTomlAttribute(mapInfo, "Product Date", m_ProductionWeek); + ret = setTomlAttribute(mapInfo, "Refresh Rate", m_RefreshRate); //3. 获取设备的其它信息 getOtherMapInfo(mapInfo); return ret; } -void DeviceMonitor::setInfoFromSelfDefine(const QMap &mapInfo) +void DeviceMonitor::setInfoFromEdid(const QMap &mapInfo) { - setAttribute(mapInfo, "Name", m_Name); - setAttribute(mapInfo, "Vendor", m_Vendor); - setAttribute(mapInfo, "CurResolution", m_CurrentResolution); - setAttribute(mapInfo, "SupportResolution", m_SupportResolution); + m_Name = "Monitor " + mapInfo["Vendor"]; setAttribute(mapInfo, "Size", m_ScreenSize); + setAttribute(mapInfo, "Vendor", m_Vendor); setAttribute(mapInfo, "Date", m_ProductionWeek); - // 加载其他属性 - //loadOtherDeviceInfo(mapInfo); + setAttribute(mapInfo, "Display Input", m_DisplayInput); + setAttribute(mapInfo, "Model", m_Model); + getOtherMapInfo(mapInfo); } -void DeviceMonitor::setInfoFromEdid(const QMap &mapInfo) +void DeviceMonitor::setInfoFromEdidForCustom(const QMap &mapInfo) { - m_Name = "Monitor " + mapInfo["Vendor"]; setAttribute(mapInfo, "Size", m_ScreenSize); setAttribute(mapInfo, "Vendor", m_Vendor); setAttribute(mapInfo, "Date", m_ProductionWeek); setAttribute(mapInfo, "Display Input", m_DisplayInput); setAttribute(mapInfo, "Model", m_Model); + m_Name = m_Model; getOtherMapInfo(mapInfo); } @@ -183,10 +191,19 @@ QString DeviceMonitor::transWeekToDate(const QString &year, const QString &week) return date.toString("yyyy-MM"); } -bool DeviceMonitor::setInfoFromXradr(const QString &main, const QString &edid, const QString &rate) +bool DeviceMonitor::setInfoFromXradr(const QString &main, const QString &edid, const QString &rate, const QString &xrandr) { if(m_IsTomlSet) return false; + + for(auto it: m_LstBaseInfo){ + if (it.first.contains("Display Input")){ + if (!main.contains(it.second, Qt::CaseInsensitive)) { + return false; + } + } + } + // 判断该显示器设备是否已经设置过从xrandr获取的消息 if (!m_Interface.isEmpty()) { // 设置当前分辨率 @@ -200,9 +217,24 @@ bool DeviceMonitor::setInfoFromXradr(const QString &main, const QString &edid, c if (pos > 0 && curRate.size() > pos && !Common::boardVendorType().isEmpty()) { curRate = QString::number(ceil(curRate.left(pos).toDouble())) + curRate.right(curRate.size() - pos); } - m_CurrentResolution = QString("%1@%2").arg(reScreenSize.cap(1)).arg(curRate); + m_CurrentResolution = QString("%1@%2").arg(reScreenSize.cap(1)).arg(curRate).replace("x", "×", Qt::CaseInsensitive); } else - m_CurrentResolution = QString("%1").arg(reScreenSize.cap(1)); + m_CurrentResolution = QString("%1").arg(reScreenSize.cap(1)).replace("x", "×", Qt::CaseInsensitive); + } + } + + if (Common::specialComType <= 0) { + QMap monitorResolutionMap = getMonitorResolutionMap(xrandr, m_RawInterface); + + if (monitorResolutionMap.size() == 1) { + m_SupportResolution.clear(); + foreach (const QString &word, monitorResolutionMap.value(m_RawInterface)) { + if (word.contains("@")) { + m_SupportResolution.append(word); + m_SupportResolution.append(", "); + } + } + m_SupportResolution.replace(QRegExp(", $"), ""); } } return false; @@ -256,40 +288,54 @@ QString DeviceMonitor::subTitle() const QString DeviceMonitor::getOverviewInfo() { QString ov; - - ov = QString("%1(%2)").arg(m_Name).arg(m_ScreenSize); + if (Common::specialComType == 6 || Common::specialComType == 7) { + ov = QString("(%1)").arg(m_ScreenSize); + } else { + ov = QString("%1(%2)").arg(m_Name).arg(m_ScreenSize); + } return ov; } void DeviceMonitor::initFilterKey() { - addFilterKey(QObject::tr("Date")); + addFilterKey("Date"); } void DeviceMonitor::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Type"), m_Model); - addBaseDeviceInfo(tr("Display Input"), m_DisplayInput); - addBaseDeviceInfo(tr("Interface Type"), m_Interface); + if (Common::specialComType != 6 && Common::specialComType != 5 && Common::specialComType != 7) { + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Type"), m_Model); + addBaseDeviceInfo(("Display Input"), m_DisplayInput); + } + addBaseDeviceInfo(("Interface Type"), m_Interface); } void DeviceMonitor::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Support Resolution"), m_SupportResolution); + addOtherDeviceInfo(("Refresh Rate"), m_RefreshRate); + addOtherDeviceInfo(("Support Resolution"), m_SupportResolution); if (m_CurrentResolution != "@Hz") { - addOtherDeviceInfo(tr("Current Resolution"), m_CurrentResolution); - addOtherDeviceInfo(tr("Display Ratio"), m_AspectRatio); + addOtherDeviceInfo(("Current Resolution"), m_CurrentResolution); + addOtherDeviceInfo(("Display Ratio"), m_AspectRatio); + + if (Common::specialComType == 4) { + if (m_CurrentResolution.contains("@")) { + QStringList refreshList = m_CurrentResolution.split('@', QString::SkipEmptyParts); + if (refreshList.size() == 2) { + m_RefreshRate = refreshList.at(1).trimmed(); + } + } + } } - addOtherDeviceInfo(tr("Primary Monitor"), m_MainScreen); - addOtherDeviceInfo(tr("Size"), m_ScreenSize); - addOtherDeviceInfo(tr("Serial Number"), m_SerialNumber); -// addOtherDeviceInfo(tr("Product Date"), m_ProductionWeek); - + addOtherDeviceInfo(("Primary Monitor"), m_MainScreen); + addOtherDeviceInfo(("Size"), m_ScreenSize); + addOtherDeviceInfo(("Serial Number"), m_SerialNumber); +// addOtherDeviceInfo(("Product Date"), m_ProductionWeek); mapInfoToList(); } @@ -310,6 +356,13 @@ bool DeviceMonitor::setMainInfoFromXrandr(const QString &info, const QString &ra m_Interface = reStart.cap(1); } + if (info.contains("connected")) { + QStringList monitorInfoList = info.split(" ", QString::SkipEmptyParts); + if (monitorInfoList.size() > 0){ + m_RawInterface = monitorInfoList.at(0).trimmed(); + } + } + // wayland xrandr --verbose无primary信息 if (qApp->isDXcbPlatform()) { // 设置是否是主显示器 @@ -327,11 +380,22 @@ bool DeviceMonitor::setMainInfoFromXrandr(const QString &info, const QString &ra QRegExp rateStart("[a-zA-Z]"); int pos = curRate.indexOf(rateStart); if (pos > 0 && curRate.size() > pos && !Common::boardVendorType().isEmpty()) { - curRate = QString::number(ceil(curRate.left(pos).toDouble())) + curRate.right(curRate.size() - pos); + if (Common::specialComType == 1) { + curRate = QString::number(ceil(curRate.left(pos).toDouble())) + ".00" + curRate.right(curRate.size() - pos); + } else { + curRate = QString::number(ceil(curRate.left(pos).toDouble())) + curRate.right(curRate.size() - pos); + } + } + if (Common::specialComType == 1 || Common::specialComType == 5 || Common::specialComType == 6 || Common::specialComType == 7) { + m_RefreshRate = QString("%1").arg(curRate); + } + if (Common::specialComType == 5 || Common::specialComType == 6 || Common::specialComType == 7) { + m_CurrentResolution = QString("%1").arg(reScreenSize.cap(1)).replace("x", "×", Qt::CaseInsensitive); + } else { + m_CurrentResolution = QString("%1 @%2").arg(reScreenSize.cap(1)).arg(curRate).replace("x", "×", Qt::CaseInsensitive); } - m_CurrentResolution = QString("%1@%2").arg(reScreenSize.cap(1)).arg(curRate); } else - m_CurrentResolution = QString("%1").arg(reScreenSize.cap(1)); + m_CurrentResolution = QString("%1").arg(reScreenSize.cap(1)).replace("x", "×", Qt::CaseInsensitive); } return true; @@ -392,7 +456,7 @@ void DeviceMonitor::caculateScreenSize() m_Height = re.cap(2).toInt(); double inch = std::sqrt((m_Width / 2.54) * (m_Width / 2.54) + (m_Height / 2.54) * (m_Height / 2.54)) / 10.0; - m_ScreenSize = QString("%1 %2(%3mm X %4mm)").arg(QString::number(inch, '0', 1)).arg(QObject::tr("inch")).arg(m_Width).arg(m_Height); + m_ScreenSize = QString("%1 %2(%3mm×%4mm)").arg(QString::number(inch, '0', 1)).arg(translateStr("inch")).arg(m_Width).arg(m_Height); } } @@ -422,6 +486,66 @@ bool DeviceMonitor::caculateScreenSize(const QString &edid) return true; double inch = std::sqrt(height * height + width * width) / 2.54 / 10; - m_ScreenSize = QString("%1 %2(%3mm X %4mm)").arg(QString::number(inch, '0', 1)).arg(QObject::tr("inch")).arg(width).arg(height); + m_ScreenSize = QString("%1 %2(%3mm×%4mm)").arg(QString::number(inch, '0', 1)).arg(translateStr("inch")).arg(width).arg(height); return true; } + +QMap DeviceMonitor::getMonitorResolutionMap(QString rawText, QString key, bool round) +{ + QMap monitorResolutionMap; + + if (!rawText.isEmpty()) { + QStringList rawLines = rawText.split("\n", QString::SkipEmptyParts); + + // get the resolution + for (auto line : rawLines) { + + // handel disconnected monitor + if (line.contains("disconnected", Qt::CaseInsensitive)) + continue; + + // handel connected monitor + if (!line.startsWith(" ") && line.contains("connected")) { + QStringList monitorInfoList = line.split(" ", QString::SkipEmptyParts); + if (monitorInfoList.size() > 0){ + monitorResolutionMap.insert(monitorInfoList.at(0).trimmed(), QStringList()); + } + } + + // handel resolution + if (line.startsWith(" ") && !line.contains("connect") && !line.contains(":")){ + QStringList resolutions = line.trimmed().replace("*", "").replace("+", "").split(" ", QString::SkipEmptyParts); + if (resolutions.size() >= 2 && monitorResolutionMap.size() > 0) { + QString resolution = resolutions.at(0); + resolutions.pop_front(); + + for(auto rate : resolutions) { + QString realResolution; + + if (round) { + bool ok = false; + double realRate = rate.toDouble(&ok); + if (ok) { + realResolution = tr("%1@%2Hz").arg(resolution).arg(QString::number(realRate, 'g', realRate >=100 ? 3 : 2)); + } + } else { + realResolution = tr("%1@%2Hz").arg(resolution).arg(rate); + } + + if (!monitorResolutionMap.value(monitorResolutionMap.lastKey()).contains(realResolution)) { + monitorResolutionMap[monitorResolutionMap.lastKey()].append(realResolution); + } + } + } + } + } + } + + if (monitorResolutionMap.keys().contains(key)) { + return QMap{{key, monitorResolutionMap.value(key)}}; + } else { + monitorResolutionMap.clear(); + } + + return monitorResolutionMap; +} diff --git a/deepin-devicemanager/src/DeviceManager/DeviceMonitor.h b/deepin-devicemanager/src/DeviceManager/DeviceMonitor.h index e2261173c..22bdb222f 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceMonitor.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceMonitor.h @@ -38,7 +38,7 @@ class DeviceMonitor : public DeviceBaseInfo * @param edid:edid信息 * @return 布尔值,true:信息设置成功;false:信息设置失败 */ - bool setInfoFromXradr(const QString &main, const QString &edid, const QString &rate); + bool setInfoFromXradr(const QString &main, const QString &edid, const QString &rate, const QString &xrandr); // 将年周转化为年月 /** @@ -59,12 +59,6 @@ class DeviceMonitor : public DeviceBaseInfo */ QString parseMonitorSize(const QString &sizeDescription, double &inch, QSize &retSize); - /**@brief:华为KLU项目里面的显示屏信息是写死的*/ - /** - * @brief setInfoFromSelfDefine:设置华为KLU项目里面的显示屏信息部分为固定的值 - * @param mapInfo:固定值信息map - */ - void setInfoFromSelfDefine(const QMap &mapInfo); /**@brief:华为PanGuV项目里面的显示屏信息是从edid里面获取的*/ /** @@ -73,6 +67,8 @@ class DeviceMonitor : public DeviceBaseInfo */ void setInfoFromEdid(const QMap &mapInfo); + void setInfoFromEdidForCustom(const QMap &mapInfo); + /**@brief:华为PanGuV项目里面的显示屏信息是从dbus里面获取的*/ /** * @brief setInfoFromDbus:设置华为PanGuV项目里面的显示屏信息 @@ -184,7 +180,14 @@ class DeviceMonitor : public DeviceBaseInfo */ bool caculateScreenSize(const QString &edid); - + /** + * @brief getMonitorResolutionMap:从xrandr字符串获取格式化 + * @param rawText:原始xrandr输出字符串 + * @param key:显示器编号:如 HDMI-0, VGA-1 + * @param round:是否保留整数,如60.00Hz保留后为60Hz + * @return 显示器编号键值对,如{"HDMI-0": ["1920x1080@60Hz, "1920x1080@50Hz",..]} + */ + QMap getMonitorResolutionMap(QString rawText, QString key = "", bool round = true); private: QString m_Model; // &mapInfo) { - if (!matchToLshw(mapInfo) - && Common::boardVendorType() != "KLVV" && Common::boardVendorType() != "KLVU" - && Common::boardVendorType() != "PGUW" && Common::boardVendorType() != "PGUV") { - return; - } // 设置由lshw获取的信息 setAttribute(mapInfo, "description", m_Model); setAttribute(mapInfo, "product", m_Name); setAttribute(mapInfo, "vendor", m_Vendor); - if (m_SysPath.contains("usb")) { - QProcess process; - QString vendorId = getVendorOrModelId(m_SysPath, true).trimmed(); - QString deviceId = getVendorOrModelId(m_SysPath, false).trimmed(); - process.start("lsusb -v -d " + vendorId + ":" + deviceId); - process.waitForFinished(-1); - - QString output = process.readAllStandardOutput(); - - foreach (QString out, output.split("\n")) { - if (!m_Vendor.isEmpty() && !m_Name.isEmpty()) - break; - // 从USB设备获取制造商和设备名称 - if (m_Vendor.isEmpty() && out.contains("idVendor", Qt::CaseSensitive)) { - m_Vendor = out.remove(0, out.indexOf(vendorId) + 4).trimmed(); - } else if (m_Name.isEmpty() && out.contains("idProduct", Qt::CaseSensitive)) { - m_Name = out.remove(0, out.indexOf(deviceId) + 4).trimmed(); - } - } - } else { - setAttribute(mapInfo, "description", m_Name, false); - } + if (m_Name.isEmpty()) + setAttribute(mapInfo, "description", m_Name); + setAttribute(mapInfo, "version", m_Version); setAttribute(mapInfo, "bus info", m_BusInfo); setAttribute(mapInfo, "logical name", m_LogicalName); @@ -97,7 +73,7 @@ void DeviceNetwork::setInfoFromLshw(const QMap &mapInfo) setAttribute(mapInfo, "ip", m_Ip); setAttribute(mapInfo, "size", m_Speed); setAttribute(mapInfo, "capacity", m_Capacity); - setAttribute(mapInfo, "latency", m_Latency); + setAttribute(mapInfo, "Latency", m_Latency); setAttribute(mapInfo, "multicast", m_Multicast); if (driverIsKernelIn(m_DriverModules) || driverIsKernelIn(m_Driver)) { m_CanUninstall = false; @@ -117,27 +93,27 @@ TomlFixMethod DeviceNetwork::setInfoFromTomlOneByOne(const QMap &mapInfo) return true; } setAttribute(mapInfo, "Device", m_Name); + setAttribute(mapInfo, "Vendor", m_Vendor); setAttribute(mapInfo, "Device File", m_LogicalName); setAttribute(mapInfo, "HW Address", m_MACAddress); setAttribute(mapInfo, "Permanent HW Address", m_UniqueID); @@ -167,6 +144,9 @@ bool DeviceNetwork::setInfoFromHwinfo(const QMap &mapInfo) setAttribute(mapInfo, "Module Alias", m_Modalias); setAttribute(mapInfo, "VID_PID", m_VID_PID); m_PhysID = m_VID_PID; + if (!m_VID_PID.isEmpty() && m_Modalias.contains("usb")) { + setVendorNameBylsusbLspci(m_VID_PID, m_Modalias); + } if (driverIsKernelIn(m_DriverModules) || driverIsKernelIn(m_Driver)) { m_CanUninstall = false; @@ -180,25 +160,9 @@ bool DeviceNetwork::setInfoFromHwinfo(const QMap &mapInfo) // 判断是否是无线网卡 setIsWireless(mapInfo["SysFS ID"]); - setHwinfoLshwKey(mapInfo); - return true; } -bool DeviceNetwork::setInfoFromWifiInfo(const QMap &mapInfo) -{ - // 机器自身蓝牙 - if (m_Name.contains("Huawei", Qt::CaseInsensitive)) { - setAttribute(mapInfo, "Chip Type", m_Name); - setAttribute(mapInfo, "Vendor", m_Vendor); - setAttribute(mapInfo, "Type", m_Model); - - return true; - } else { - return false; - } -} - void DeviceNetwork::setIsWireless(const QString &sysfs) { // 路径下包含 phy80211 或 wireless 是无线网卡 @@ -260,7 +224,7 @@ bool DeviceNetwork::enable() return m_Enable; } -void DeviceNetwork::correctCurrentLinkStatus(QString linkStatus) +void DeviceNetwork::correctCurrentLinkStatus(const QString &linkStatus) { if (m_Link != linkStatus) m_Link = linkStatus; @@ -284,45 +248,45 @@ QString DeviceNetwork::hwAddress() void DeviceNetwork::initFilterKey() { // 初始化可显示属性 - addFilterKey(QObject::tr("ioport")); - addFilterKey(QObject::tr("network")); + addFilterKey("ioport"); + addFilterKey("network"); } void DeviceNetwork::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Type"), m_Model); - addBaseDeviceInfo(tr("Version"), m_Version); - addBaseDeviceInfo(tr("Bus Info"), m_BusInfo); - addBaseDeviceInfo(tr("Capabilities"), m_Capabilities); - addBaseDeviceInfo(tr("Driver"), m_Driver); - addBaseDeviceInfo(tr("Driver Version"), m_DriverVersion); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Type"), m_Model); + addBaseDeviceInfo(("Version"), m_Version); + addBaseDeviceInfo(("Bus Info"), m_BusInfo); + addBaseDeviceInfo(("Capabilities"), m_Capabilities); + addBaseDeviceInfo(("Driver"), m_Driver); + addBaseDeviceInfo(("Driver Version"), m_DriverVersion); } void DeviceNetwork::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Module Alias"), m_Modalias); - addOtherDeviceInfo(tr("Physical ID"), m_PhysID); - addOtherDeviceInfo(tr("Maximum Rate"), m_Capacity); // 1050需求 容量改为最大速率 - addOtherDeviceInfo(tr("Negotiation Rate"), m_Speed); // 1050需求 速度改为协商速率 - addOtherDeviceInfo(tr("Port"), m_Port); - addOtherDeviceInfo(tr("Multicast"), m_Multicast); - addOtherDeviceInfo(tr("Link"), m_Link); - addOtherDeviceInfo(tr("Latency"), m_Latency); - addOtherDeviceInfo(tr("IP"), m_Ip); - addOtherDeviceInfo(tr("Firmware"), m_Firmware); - addOtherDeviceInfo(tr("Duplex"), m_Duplex); - addOtherDeviceInfo(tr("Broadcast"), m_Broadcast); - addOtherDeviceInfo(tr("Auto Negotiation"), m_Autonegotiation); -// addOtherDeviceInfo(tr("Clock"), m_Clock); -// addOtherDeviceInfo(tr("Width"), m_Width); - addOtherDeviceInfo(tr("Memory Address"), m_Memory); // 1050需求 内存改为内存地址 - addOtherDeviceInfo(tr("IRQ"), m_Irq); - addOtherDeviceInfo(tr("MAC Address"), m_MACAddress); - addOtherDeviceInfo(tr("Logical Name"), m_LogicalName); + addOtherDeviceInfo(("Module Alias"), m_Modalias); + addOtherDeviceInfo(("Physical ID"), m_PhysID); + addOtherDeviceInfo(("Maximum Rate"), m_Capacity); // 1050需求 容量改为最大速率 + addOtherDeviceInfo(("Negotiation Rate"), m_Speed); // 1050需求 速度改为协商速率 + addOtherDeviceInfo(("Port"), m_Port); + addOtherDeviceInfo(("Multicast"), m_Multicast); + addOtherDeviceInfo(("Link"), m_Link); + addOtherDeviceInfo(("Latency"), m_Latency); + addOtherDeviceInfo(("IP"), m_Ip); + addOtherDeviceInfo(("Firmware"), m_Firmware); + addOtherDeviceInfo(("Duplex"), m_Duplex); + addOtherDeviceInfo(("Broadcast"), m_Broadcast); + addOtherDeviceInfo(("Auto Negotiation"), m_Autonegotiation); +// addOtherDeviceInfo(("Clock"), m_Clock); +// addOtherDeviceInfo(("Width"), m_Width); + addOtherDeviceInfo(("Memory Address"), m_Memory); // 1050需求 内存改为内存地址 + addOtherDeviceInfo(("IRQ"), m_Irq); + addOtherDeviceInfo(("MAC Address"), m_MACAddress); + addOtherDeviceInfo(("Logical Name"), m_LogicalName); // 将QMap内容转存为QList> mapInfoToList(); @@ -330,9 +294,9 @@ void DeviceNetwork::loadOtherDeviceInfo() void DeviceNetwork::loadTableHeader() { - m_TableHeader.append(tr("Name")); - m_TableHeader.append(tr("Vendor")); - m_TableHeader.append(tr("Type")); + m_TableHeader.append("Name"); + m_TableHeader.append("Vendor"); + m_TableHeader.append("Type"); } void DeviceNetwork::loadTableData() @@ -341,11 +305,11 @@ void DeviceNetwork::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } // 加载表格数据信息 diff --git a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h index 5e02a2183..1bbda454d 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h @@ -39,13 +39,6 @@ class DeviceNetwork : public DeviceBaseInfo */ bool setInfoFromHwinfo(const QMap &mapInfo); - /** - * @brief setInfoFromWifiInfo:设置从cat /sys/hisys/wal/wifi_devices_info里面获取的信息 - * @param mapInfo: 由cat /sys/hisys/wal/wifi_devices_info获取的信息map - * @return 布尔值,true:信息设置成功;false:信息设置失败 - */ - bool setInfoFromWifiInfo(const QMap &mapInfo); - /** * @brief setIsWireless: 设置是否是无线网 * @param sysFSID: SysFS ID: /class/net/enp2s0 @@ -99,7 +92,7 @@ class DeviceNetwork : public DeviceBaseInfo * @brief correctCurrentLinkStatus * @param linkStatus */ - void correctCurrentLinkStatus(QString linkStatus); + void correctCurrentLinkStatus(const QString &linkStatus); /** * @brief logicalName: 获取网卡逻辑名称 diff --git a/deepin-devicemanager/src/DeviceManager/DeviceOtherPCI.cpp b/deepin-devicemanager/src/DeviceManager/DeviceOtherPCI.cpp index 519dfd72d..2b234b7d9 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceOtherPCI.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceOtherPCI.cpp @@ -23,17 +23,17 @@ DeviceOtherPCI::DeviceOtherPCI() TomlFixMethod DeviceOtherPCI::setInfoFromTomlOneByOne(const QMap &mapInfo) { TomlFixMethod ret = TOML_None; - // 添加基本信息 - ret = setTomlAttribute(mapInfo, "Model", m_Model); - ret = setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); + // 添加基本信息 + setTomlAttribute(mapInfo, "Model", m_Model); + setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); // 添加其他信息,成员变量 - ret = setTomlAttribute(mapInfo, "Input/Output", m_InputOutput); - ret = setTomlAttribute(mapInfo, "Memory", m_Memory); - ret = setTomlAttribute(mapInfo, "IRQ", m_Irq); - ret = setTomlAttribute(mapInfo, "Latency", m_Latency); + setTomlAttribute(mapInfo, "Input/Output", m_InputOutput); + setTomlAttribute(mapInfo, "Memory", m_Memory); + setTomlAttribute(mapInfo, "IRQ", m_Irq); + setTomlAttribute(mapInfo, "Latency", m_Latency); ret = setTomlAttribute(mapInfo, "Capabilities", m_Version); -//3. 获取设备的其它信息 + //3. 获取设备的其它信息 getOtherMapInfo(mapInfo); return ret; } @@ -71,24 +71,24 @@ void DeviceOtherPCI::initFilterKey() void DeviceOtherPCI::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name.isEmpty() ? m_Vendor + m_Model : m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Model"), m_Model); - addBaseDeviceInfo(tr("Bus Info"), m_BusInfo); - addBaseDeviceInfo(tr("Version"), m_Version); + addBaseDeviceInfo(("Name"), m_Name.isEmpty() ? m_Vendor + m_Model : m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Model"), m_Model); + addBaseDeviceInfo(("Bus Info"), m_BusInfo); + addBaseDeviceInfo(("Version"), m_Version); } void DeviceOtherPCI::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Input/Output"), m_InputOutput); - addOtherDeviceInfo(tr("Memory"), m_Memory); - addOtherDeviceInfo(tr("IRQ"), m_Irq); - addOtherDeviceInfo(tr("Latency"), m_Latency); -// addOtherDeviceInfo(tr("Clock"), m_Clock); -// addOtherDeviceInfo(tr("Width"), m_Width); - addOtherDeviceInfo(tr("Driver"), m_Driver); - addOtherDeviceInfo(tr("Capabilities"), m_Version); + addOtherDeviceInfo(("Input/Output"), m_InputOutput); + addOtherDeviceInfo(("Memory"), m_Memory); + addOtherDeviceInfo(("IRQ"), m_Irq); + addOtherDeviceInfo(("Latency"), m_Latency); +// addOtherDeviceInfo(("Clock"), m_Clock); +// addOtherDeviceInfo(("Width"), m_Width); + addOtherDeviceInfo(("Driver"), m_Driver); + addOtherDeviceInfo(("Capabilities"), m_Version); // 将QMap内容转存为QList> mapInfoToList(); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp b/deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp index b800edd81..e049ac577 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp @@ -53,14 +53,14 @@ TomlFixMethod DeviceOthers::setInfoFromTomlOneByOne(const QMap { TomlFixMethod ret = TOML_None; // 添加基本信息 - ret = setTomlAttribute(mapInfo, "Model", m_Model); - ret = setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); - ret = setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); - ret = setTomlAttribute(mapInfo, "Maximum Power", m_MaximumPower); - ret = setTomlAttribute(mapInfo, "Speed", m_Speed); -////Others + setTomlAttribute(mapInfo, "Model", m_Model); + setTomlAttribute(mapInfo, "Bus Info", m_BusInfo); + setTomlAttribute(mapInfo, "Capabilities", m_Capabilities); + setTomlAttribute(mapInfo, "Maximum Power", m_MaximumPower); + setTomlAttribute(mapInfo, "Speed", m_Speed); + // Others ret = setTomlAttribute(mapInfo, "Serial Number", m_SerialID); -//3. 获取设备的其它信息 + // 3. 获取设备的其它信息 getOtherMapInfo(mapInfo); return ret; } @@ -174,28 +174,28 @@ bool DeviceOthers::available() void DeviceOthers::initFilterKey() { - addFilterKey(QObject::tr("Device File")); - addFilterKey(QObject::tr("Hardware Class")); + addFilterKey("Device File"); + addFilterKey("Hardware Class"); } void DeviceOthers::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Model"), m_Model); - addBaseDeviceInfo(tr("Version"), m_Version); - addBaseDeviceInfo(tr("Bus Info"), m_BusInfo); - addBaseDeviceInfo(tr("Capabilities"), m_Capabilities); - addBaseDeviceInfo(tr("Driver"), m_Driver); - addBaseDeviceInfo(tr("Maximum Power"), m_MaximumPower); - addBaseDeviceInfo(tr("Speed"), m_Speed); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Model"), m_Model); + addBaseDeviceInfo(("Version"), m_Version); + addBaseDeviceInfo(("Bus Info"), m_BusInfo); + addBaseDeviceInfo(("Capabilities"), m_Capabilities); + addBaseDeviceInfo(("Driver"), m_Driver); + addBaseDeviceInfo(("Maximum Power"), m_MaximumPower); + addBaseDeviceInfo(("Speed"), m_Speed); } void DeviceOthers::loadOtherDeviceInfo() { if (m_SerialID != m_UniqueID) - addOtherDeviceInfo(tr("Serial Number"), m_SerialID); + addOtherDeviceInfo(("Serial Number"), m_SerialID); mapInfoToList(); } @@ -204,10 +204,10 @@ void DeviceOthers::loadTableData() // 加载表格数据 QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DevicePower.cpp b/deepin-devicemanager/src/DeviceManager/DevicePower.cpp index 781333202..c55070a46 100644 --- a/deepin-devicemanager/src/DeviceManager/DevicePower.cpp +++ b/deepin-devicemanager/src/DeviceManager/DevicePower.cpp @@ -4,6 +4,7 @@ // 项目自身文件 #include "DevicePower.h" +#include "commonfunction.h" // Qt库文件 #include @@ -43,19 +44,19 @@ TomlFixMethod DevicePower::setInfoFromTomlOneByOne(const QMap { TomlFixMethod ret = TOML_None; // 添加基本信息 - ret = setTomlAttribute(mapInfo, "Model", m_Model); - ret = setTomlAttribute(mapInfo, "Serial Number", m_SerialNumber); - ret = setTomlAttribute(mapInfo, "Type", m_Type); - ret = setTomlAttribute(mapInfo, "Status", m_Status); - ret = setTomlAttribute(mapInfo, "Capacity", m_Capacity); - ret = setTomlAttribute(mapInfo, "Voltage", m_Voltage); - ret = setTomlAttribute(mapInfo, "Slot", m_Slot); - ret = setTomlAttribute(mapInfo, "Design Capacity", m_DesignCapacity); - ret = setTomlAttribute(mapInfo, "Design Voltage", m_DesignVoltage); - ret = setTomlAttribute(mapInfo, "SBDS Version", m_SBDSVersion); - ret = setTomlAttribute(mapInfo, "SBDS Serial Number", m_SBDSSerialNumber); - ret = setTomlAttribute(mapInfo, "SBDS Manufacture Date", m_SBDSManufactureDate); - ret = setTomlAttribute(mapInfo, "SBDS Chemistry", m_SBDSChemistry); + setTomlAttribute(mapInfo, "Model", m_Model); + setTomlAttribute(mapInfo, "Serial Number", m_SerialNumber); + setTomlAttribute(mapInfo, "Type", m_Type); + setTomlAttribute(mapInfo, "Status", m_Status); + setTomlAttribute(mapInfo, "Capacity", m_Capacity); + setTomlAttribute(mapInfo, "Voltage", m_Voltage); + setTomlAttribute(mapInfo, "Slot", m_Slot); + setTomlAttribute(mapInfo, "Design Capacity", m_DesignCapacity); + setTomlAttribute(mapInfo, "Design Voltage", m_DesignVoltage); + setTomlAttribute(mapInfo, "SBDS Version", m_SBDSVersion); + setTomlAttribute(mapInfo, "SBDS Serial Number", m_SBDSSerialNumber); + setTomlAttribute(mapInfo, "SBDS Manufacture Date", m_SBDSManufactureDate); + setTomlAttribute(mapInfo, "SBDS Chemistry", m_SBDSChemistry); ret = setTomlAttribute(mapInfo, "Temperature", m_Temp); //3. 获取设备的其它信息 getOtherMapInfo(mapInfo); @@ -65,10 +66,11 @@ TomlFixMethod DevicePower::setInfoFromTomlOneByOne(const QMap bool DevicePower::setInfoFromUpower(const QMap &mapInfo) { // 设置upower中获取的信息 - if (mapInfo["Device"].contains("line_power", Qt::CaseInsensitive)) { + if (mapInfo["Device"].contains("line_power", Qt::CaseInsensitive) || + mapInfo["state"].contains("empty", Qt::CaseInsensitive) || + mapInfo["state"].contains("unknown", Qt::CaseInsensitive)) { return false; } - // m_Name = QObject::tr("battery"); setAttribute(mapInfo, "", m_Vendor); setAttribute(mapInfo, "", m_Model); @@ -82,8 +84,6 @@ bool DevicePower::setInfoFromUpower(const QMap &mapInfo) setAttribute(mapInfo, "capacity", m_Capacity); setAttribute(mapInfo, "voltage", m_Voltage); setAttribute(mapInfo, "", m_Slot); -// setAttribute(mapInfo, "capacity", m_DesignCapacity); -// setAttribute(mapInfo, "voltage", m_DesignVoltage); setAttribute(mapInfo, "", m_SBDSChemistry); setAttribute(mapInfo, "", m_SBDSManufactureDate); setAttribute(mapInfo, "", m_SBDSSerialNumber); @@ -108,7 +108,7 @@ bool DevicePower::setInfoFromUpower(const QMap &mapInfo) void DevicePower::setDaemonInfo(const QMap &mapInfo) { // 设置守护进程信息 - if (m_Name == QObject::tr("battery")) + if (m_Name == translateStr("battery")) getOtherMapInfo(mapInfo); } @@ -146,51 +146,55 @@ const QString DevicePower::getOverviewInfo() void DevicePower::initFilterKey() { // 初始化可显示属性 - addFilterKey(QObject::tr("native-path")); - addFilterKey(QObject::tr("power supply")); - addFilterKey(QObject::tr("updated")); - addFilterKey(QObject::tr("has history")); - addFilterKey(QObject::tr("has statistics")); - addFilterKey(QObject::tr("rechargeable")); - addFilterKey(QObject::tr("state")); - addFilterKey(QObject::tr("warning-level")); - addFilterKey(QObject::tr("energy")); - addFilterKey(QObject::tr("energy-empty")); - addFilterKey(QObject::tr("energy-full")); - addFilterKey(QObject::tr("energy-full-design")); - addFilterKey(QObject::tr("energy-rate")); - addFilterKey(QObject::tr("voltage")); - addFilterKey(QObject::tr("percentage")); -// addFilterKey(QObject::tr("temperature")); // 温度已经常规显示 - addFilterKey(QObject::tr("technology")); - addFilterKey(QObject::tr("icon-name")); - addFilterKey(QObject::tr("online")); - addFilterKey(QObject::tr("daemon-version")); - addFilterKey(QObject::tr("on-battery")); - addFilterKey(QObject::tr("lid-is-closed")); - addFilterKey(QObject::tr("lid-is-present")); - addFilterKey(QObject::tr("critical-action")); +// addFilterKey("native-path"); + addFilterKey("power supply"); +// addFilterKey("updated"); + addFilterKey("has history"); + addFilterKey("has statistics"); + addFilterKey("rechargeable"); + addFilterKey("state"); + addFilterKey("warning-level"); + addFilterKey("energy"); + addFilterKey("energy-empty"); + + QString type = Common::specialVendorType(); + if (type != Common::specialHString()) { + addFilterKey("energy-full"); + addFilterKey("energy-full-design"); + } + addFilterKey("energy-rate"); + // addFilterKey("voltage"); + addFilterKey("percentage"); +// addFilterKey("temperature")); // 温度已经常规显示-2 + addFilterKey("technology"); +// addFilterKey("icon-name"); + addFilterKey("online"); + addFilterKey("daemon-version"); + addFilterKey("on-battery"); + addFilterKey("lid-is-closed"); + addFilterKey("lid-is-present"); + addFilterKey("critical-action"); } void DevicePower::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Model"), m_Model); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Serial Number"), m_SerialNumber); - addBaseDeviceInfo(tr("Type"), m_Type); - addBaseDeviceInfo(tr("Status"), m_Status); - addBaseDeviceInfo(tr("Capacity"), m_Capacity); - addBaseDeviceInfo(tr("Voltage"), m_Voltage); - addBaseDeviceInfo(tr("Slot"), m_Slot); - addBaseDeviceInfo(tr("Design Capacity"), m_DesignCapacity); - addBaseDeviceInfo(tr("Design Voltage"), m_DesignVoltage); - addBaseDeviceInfo(tr("SBDS Version"), m_SBDSVersion); - addBaseDeviceInfo(tr("SBDS Serial Number"), m_SBDSSerialNumber); - addBaseDeviceInfo(tr("SBDS Manufacture Date"), m_SBDSManufactureDate); - addBaseDeviceInfo(tr("SBDS Chemistry"), m_SBDSChemistry); - addBaseDeviceInfo(tr("Temperature"), m_Temp); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Model"), m_Model); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Serial Number"), m_SerialNumber); + addBaseDeviceInfo(("Type"), m_Type); + addBaseDeviceInfo(("Status"), m_Status); + addBaseDeviceInfo(("Capacity"), m_Capacity); + addBaseDeviceInfo(("Voltage"), m_Voltage); + addBaseDeviceInfo(("Slot"), m_Slot); + addBaseDeviceInfo(("Design Capacity"), m_DesignCapacity); + addBaseDeviceInfo(("Design Voltage"), m_DesignVoltage); + addBaseDeviceInfo(("SBDS Version"), m_SBDSVersion); + addBaseDeviceInfo(("SBDS Serial Number"), m_SBDSSerialNumber); + addBaseDeviceInfo(("SBDS Manufacture Date"), m_SBDSManufactureDate); + addBaseDeviceInfo(("SBDS Chemistry"), m_SBDSChemistry); + addBaseDeviceInfo(("Temperature"), m_Temp.replace("degrees C", "℃", Qt::CaseInsensitive)); } void DevicePower::loadOtherDeviceInfo() diff --git a/deepin-devicemanager/src/DeviceManager/DevicePrint.cpp b/deepin-devicemanager/src/DeviceManager/DevicePrint.cpp index f829e21e8..5da2da2e4 100644 --- a/deepin-devicemanager/src/DeviceManager/DevicePrint.cpp +++ b/deepin-devicemanager/src/DeviceManager/DevicePrint.cpp @@ -31,15 +31,15 @@ TomlFixMethod DevicePrint::setInfoFromTomlOneByOne(const QMap { TomlFixMethod ret = TOML_None; // 添加基本信息 - ret = setTomlAttribute(mapInfo, "Model", m_Model); - ret = setTomlAttribute(mapInfo, "Serial Number", m_SerialNumber); + setTomlAttribute(mapInfo, "Model", m_Model); + setTomlAttribute(mapInfo, "Serial Number", m_SerialNumber); // 添加其他信息,成员变量 - ret = setTomlAttribute(mapInfo, "Shared", m_Shared); - ret = setTomlAttribute(mapInfo, "URI", m_URI); - ret = setTomlAttribute(mapInfo, "Status", m_Status); - ret = setTomlAttribute(mapInfo, "Interface Type", m_InterfaceType); + setTomlAttribute(mapInfo, "Shared", m_Shared); + setTomlAttribute(mapInfo, "URI", m_URI); + setTomlAttribute(mapInfo, "Status", m_Status); + setTomlAttribute(mapInfo, "Interface Type", m_InterfaceType); ret = setTomlAttribute(mapInfo, "printer-make-and-model", m_MakeAndModel); -//3. 获取设备的其它信息 + // 3. 获取设备的其它信息 getOtherMapInfo(mapInfo); return ret; } @@ -125,42 +125,42 @@ bool DevicePrint::enable() void DevicePrint::initFilterKey() { // 初始化可显示属性 - addFilterKey(QObject::tr("copies")); - addFilterKey(QObject::tr("job-cancel-after")); - addFilterKey(QObject::tr("job-hold-until")); - addFilterKey(QObject::tr("job-priority")); - addFilterKey(QObject::tr("marker-change-time")); - addFilterKey(QObject::tr("number-up")); - addFilterKey(QObject::tr("orientation-requested")); - addFilterKey(QObject::tr("print-color-mode")); - addFilterKey(QObject::tr("printer-is-accepting-jobs")); - addFilterKey(QObject::tr("printer-is-shared")); - addFilterKey(QObject::tr("printer-is-temporary")); -// addFilterKey(QObject::tr("printer-make-and-model")); - addFilterKey(QObject::tr("printer-state-change-time")); - addFilterKey(QObject::tr("printer-state-reasons")); - addFilterKey(QObject::tr("printer-type")); - addFilterKey(QObject::tr("printer-uri-supported")); - addFilterKey(QObject::tr("sides")); + addFilterKey("copies"); + addFilterKey("job-cancel-after"); + addFilterKey("job-hold-until"); + addFilterKey("job-priority"); + addFilterKey("marker-change-time"); + addFilterKey("number-up"); + addFilterKey("orientation-requested"); + addFilterKey("print-color-mode"); + addFilterKey("printer-is-accepting-jobs"); + addFilterKey("printer-is-shared"); + addFilterKey("printer-is-temporary"); +// addFilterKey("printer-make-and-model"); + addFilterKey("printer-state-change-time"); + addFilterKey("printer-state-reasons"); + addFilterKey("printer-type"); + addFilterKey("printer-uri-supported"); + addFilterKey("sides"); } void DevicePrint::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Model"), m_Model); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Serial Number"), m_SerialNumber); + addBaseDeviceInfo(("Name"), m_Name); + addBaseDeviceInfo(("Model"), m_Model); + addBaseDeviceInfo(("Vendor"), m_Vendor); + addBaseDeviceInfo(("Serial Number"), m_SerialNumber); } void DevicePrint::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Shared"), m_Shared); - addOtherDeviceInfo(tr("URI"), m_URI); - addOtherDeviceInfo(tr("Status"), m_Status); - addOtherDeviceInfo(tr("Interface Type"), m_InterfaceType); - addOtherDeviceInfo(QObject::tr("printer-make-and-model"), m_MakeAndModel); + addOtherDeviceInfo(("Shared"), m_Shared); + addOtherDeviceInfo(("URI"), m_URI); + addOtherDeviceInfo(("Status"), m_Status); + addOtherDeviceInfo(("Interface Type"), m_InterfaceType); + addOtherDeviceInfo(("printer-make-and-model"), m_MakeAndModel); // 将QMap内容转存为QList> mapInfoToList(); } @@ -170,7 +170,7 @@ void DevicePrint::loadTableData() // 加载表格数据 QString tName = m_Name; if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp b/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp index 81050546f..dfd91d3f7 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp @@ -5,6 +5,7 @@ // 项目自身文件 #include "DeviceStorage.h" #include "commonfunction.h" +#include #include // Qt库文件 @@ -40,16 +41,16 @@ TomlFixMethod DeviceStorage::setInfoFromTomlOneByOne(const QMap 0) m_Size = decimalkilos(m_SizeBytes); - - quint64 gbyte = 1000000000; - if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { - if(m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) { - m_Size = "256 GB"; - } else if(m_SizeBytes > 511*gbyte && m_SizeBytes < 513*gbyte) { - m_Size = "512 GB"; - } else if(m_SizeBytes > 999*gbyte && m_SizeBytes < 1001*gbyte) { - m_Size = "1 TB"; - } - } } bool DeviceStorage::setHwinfoInfo(const QMap &mapInfo) @@ -144,7 +134,9 @@ bool DeviceStorage::setHwinfoInfo(const QMap &mapInfo) if (mapInfo.find("SysFS BusID") == mapInfo.end()) return false; - setAttribute(mapInfo, "Model", m_Name); + if (Common::specialComType <= 0) { + setAttribute(mapInfo, "Model", m_Name); + } setAttribute(mapInfo, "Vendor", m_Vendor); // 希捷硬盘为ATA硬盘,无法直接获取厂商信息,只能特殊处理 @@ -220,11 +212,13 @@ bool DeviceStorage::setHwinfoInfo(const QMap &mapInfo) QString Path = "/sys/block/" + logicalName + "/device/spec_version"; QFile file(Path); if (file.open(QIODevice::ReadOnly)) { - QString output2 = file.readAll(); - if (output2.contains("310", Qt::CaseInsensitive)) { + QString output = file.readAll(); + if (output.contains("310", Qt::CaseInsensitive)) { m_Interface = "UFS 3.1"; - } else if (output2.contains("300", Qt::CaseInsensitive)) { + } else if (output.contains("300", Qt::CaseInsensitive)) { m_Interface = "UFS 3.0"; + } else if (output.contains("400", Qt::CaseInsensitive)) { + m_Interface = "UFS 4.0"; } file.close(); } @@ -283,56 +277,14 @@ QString DeviceStorage::getSerialID(QString &strDeviceLink) return strSerialNumber; } -bool DeviceStorage::setKLUHwinfoInfo(const QMap &mapInfo) +const QString &DeviceStorage::mediaType() const { - // 龙芯机器中 hwinfo --disk会列出所有的分区信息 - // 存储设备不应包含分区,根据SysFS BusID 来确定是否是分区信息 - if (mapInfo.find("SysFS BusID") == mapInfo.end()) - return false; - - setAttribute(mapInfo, "Model", m_Name); - setAttribute(mapInfo, "Vendor", m_Vendor); - setAttribute(mapInfo, "Driver", m_Driver); // 驱动 - - setAttribute(mapInfo, "Attached to", m_Interface); - QRegExp re(".*\\((.*)\\).*"); - if (re.exactMatch(m_Interface)) { - m_Interface = re.cap(1); - m_Interface.replace("Controller", ""); - m_Interface.replace("controller", ""); - } - - setAttribute(mapInfo, "Revision", m_Version); - setAttribute(mapInfo, "Hardware Class", m_Description); - setAttribute(mapInfo, "Capacity", m_Size); - - // hwinfo里面显示的内容是 14 GB (15376000000 bytes) 需要处理 - QRegExp reSize(".*\\((.*)bytes\\).*"); - if (reSize.exactMatch(m_Size)) { - bool ok = false; - quint64 bytesSize = reSize.cap(1).trimmed().toULongLong(&ok); - if (ok) { - m_Size = decimalkilos(bytesSize); - } else { - m_Size.replace(QRegExp("\\(.*\\)"), "").replace(" ", ""); - } - } else { - m_Size.replace(QRegExp("\\(.*\\)"), "").replace(" ", ""); - } - if (m_Size.startsWith("0") || m_Size == "") - return false; - - setAttribute(mapInfo, "Serial ID", m_SerialNumber); -// setDiskSerialID(mapInfo["Device Files"]); - setAttribute(mapInfo, "SysFS BusID", m_KeyToLshw); - setAttribute(mapInfo, "Device File", m_DeviceFile); - - // KLU里面的介质类型的处理方式比较特殊 - if (mapInfo["Driver"].contains("usb-storage")) - m_MediaType = "USB"; + return m_MediaType; +} - getOtherMapInfo(mapInfo); - return true; +const QString &DeviceStorage::interface() const +{ + return m_Interface; } bool DeviceStorage::addInfoFromlshw(const QMap &mapInfo) @@ -405,29 +357,11 @@ bool DeviceStorage::setMediaType(const QString &name, const QString &value) return false; if (QString("0") == value) - m_MediaType = QObject::tr("SSD"); + m_MediaType = "SSD"; else if (QString("1") == value) - m_MediaType = QObject::tr("HDD"); + m_MediaType = "HDD"; else - m_MediaType = QObject::tr("Unknown"); - - return true; -} - -bool DeviceStorage::setKLUMediaType(const QString &name, const QString &value) -{ - if (!m_DeviceFile.contains(name)) - return false; - - if (m_MediaType == "USB") - return true; - - if (QString("0") == value) - m_MediaType = QObject::tr("SSD"); - else if (QString("1") == value) - m_MediaType = QObject::tr("HDD"); - else - m_MediaType = QObject::tr("Unknown"); + m_MediaType = "Unknown"; return true; } @@ -484,7 +418,7 @@ void DeviceStorage::appendDisk(DeviceStorage *device) } quint64 size2 = device->getDiskSizeByte(); - if(m_SizeBytes == 0) + if (m_SizeBytes == 0) m_SizeBytes = size2; else if (size2 > 0) { m_SizeBytes += size2; @@ -503,11 +437,10 @@ void DeviceStorage::appendDisk(DeviceStorage *device) } QStringList keyList; - keyList.append(QObject::tr("bus info")); - keyList.append(QObject::tr("Device File")); - // keyList.append(QObject::tr("physical id")); - keyList.append(QObject::tr("Device Number")); - keyList.append(QObject::tr("logical name")); + keyList.append(translateStr("bus info")); + keyList.append(translateStr("Device File")); + keyList.append(translateStr("Device Number")); + keyList.append(translateStr("logical name")); for (QString keyStr : keyList) { QString curBusInfo = curAllOtherAttribMaps[keyStr]; QString busInfo = allAttribMaps[keyStr]; @@ -521,16 +454,31 @@ void DeviceStorage::appendDisk(DeviceStorage *device) void DeviceStorage::checkDiskSize() { - QRegExp reg("[0-9]*.?[0-9]*"); - int index = reg.indexIn(m_Size); - // index>0时,对于"32GB"(数字开头的字符串,index=0)无法获取正确的数据32 - // 所以要改为index >= 0 - if (index >= 0) { - double num = reg.cap(0).toDouble(); - double num1 = num - int(num); - QString type = m_Size.right(m_Size.length() - reg.cap(0).size()).trimmed(); - if (!qFuzzyCompare(num1, 0.0) && type == "GB") { - m_Size = QString::number(int(num) + 1) + " " + type; + if (Common::specialComType <= 0) { + return; //定制机型专用,其它慎用 + } + + quint64 gbyte = 1000000000; +// if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { // TODO Ignore ufs disk + if (m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) { + m_Size = "256 GB"; + } else if (m_SizeBytes > 511*gbyte && m_SizeBytes < 513*gbyte) { + m_Size = "512 GB"; + } else if (m_SizeBytes > 999*gbyte && m_SizeBytes < 1025*gbyte) { + m_Size = "1 TB"; + } else if (m_SizeBytes > 1999*gbyte && m_SizeBytes < 2049*gbyte) { + m_Size = "2 TB"; + } +// } + if (m_Interface.contains("USB", Qt::CaseInsensitive)) { + if (m_SizeBytes > 15*gbyte && m_SizeBytes < 17*gbyte) { + m_Size = "16 GB"; + } else if (m_SizeBytes > 31*gbyte && m_SizeBytes < 33*gbyte) { + m_Size = "32 GB"; + } else if (m_SizeBytes > 63*gbyte && m_SizeBytes < 65*gbyte) { + m_Size = "64 GB"; + } else if (m_SizeBytes > 127*gbyte && m_SizeBytes < 129*gbyte) { + m_Size = "128 GB"; } } } @@ -542,16 +490,16 @@ QString DeviceStorage::compareSize(const QString &size1, const QString &size2) return size1 + size2; // 将字符串转为数字大小进行比较 - int num1 = 0; - int num2 = 0; - QRegExp reg(".*\\[(\\d*).*\\]$"); + float num1 = 0; + float num2 = 0; + QRegExp reg(".*\\[(\\d+\\.?\\d+).*\\]"); if (reg.exactMatch(size1)) - num1 = reg.cap(1).toInt(); + num1 = reg.cap(1).toFloat(); if (reg.exactMatch(size2)) - num2 = reg.cap(1).toInt(); + num2 = reg.cap(1).toFloat(); // 返回较大值 - if (num1 > num2) + if ((num1 - num2) > FLT_EPSILON * fmaxf(fabsf(num1), fabsf(num2))) return size1; else return size2; @@ -584,44 +532,56 @@ QString DeviceStorage::subTitle() const QString DeviceStorage::getOverviewInfo() { - return QString("%1 (%2)").arg(m_Name).arg(m_Size);; + QString overViewInfo; + + if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { + overViewInfo = QString("%1 %2").arg(m_Size).arg("UFS"); + } else if (m_Interface.contains("USB", Qt::CaseInsensitive)) { + overViewInfo = QString("%1 %2").arg(m_Size).arg("USB"); + } else { + overViewInfo = QString("%1 %2").arg(m_Size).arg(m_MediaType); + } + + return overViewInfo; } void DeviceStorage::initFilterKey() { // hwinfo --disk - addFilterKey(QObject::tr("Hardware Class")); - addFilterKey(QObject::tr("Device File")); - addFilterKey(QObject::tr("ansiversion")); - addFilterKey(QObject::tr("bus info")); - addFilterKey(QObject::tr("logical name")); - addFilterKey(QObject::tr("logicalsectorsize")); - // addFilterKey(QObject::tr("physical id")); - addFilterKey(QObject::tr("sectorsize")); - addFilterKey(QObject::tr("guid")); - addFilterKey(QObject::tr("Config Status")); - addFilterKey(QObject::tr("Device Number")); - addFilterKey(QObject::tr("Geometry (Logical)")); + addFilterKey("Hardware Class"); + addFilterKey("Device File"); + addFilterKey("ansiversion"); + addFilterKey("bus info"); + addFilterKey("logical name"); + addFilterKey("logicalsectorsize"); + // addFilterKey("physical id"); + addFilterKey("sectorsize"); + addFilterKey("guid"); + addFilterKey("Config Status"); + addFilterKey("Device Number"); + addFilterKey("Geometry (Logical)"); } void DeviceStorage::loadBaseDeviceInfo() { // 添加基本信息 - addBaseDeviceInfo(tr("Name"), m_Name); - addBaseDeviceInfo(tr("Vendor"), m_Vendor); - addBaseDeviceInfo(tr("Media Type"), m_MediaType); - addBaseDeviceInfo(tr("Size"), m_Size); - addBaseDeviceInfo(tr("Version"), m_Version); - addBaseDeviceInfo(tr("Capabilities"), m_Capabilities); + addBaseDeviceInfo(("Name"), m_Name); + if (Common::specialComType <= 0) { + addBaseDeviceInfo(("Vendor"), m_Vendor); + } + addBaseDeviceInfo(("Media Type"), translateStr(m_MediaType)); + addBaseDeviceInfo(("Size"), m_Size); + addBaseDeviceInfo(("Version"), m_Version); + addBaseDeviceInfo(("Capabilities"), m_Capabilities); } void DeviceStorage::loadOtherDeviceInfo() { // 添加其他信息,成员变量 - addOtherDeviceInfo(tr("Firmware Version"), m_FirmwareVersion); - addOtherDeviceInfo(tr("Speed"), m_Speed); - addOtherDeviceInfo(tr("Description"), m_Description); + addOtherDeviceInfo(("Firmware Version"), m_FirmwareVersion); + addOtherDeviceInfo(("Speed"), m_Speed); + addOtherDeviceInfo(("Description"), m_Description); for(int i = 0 ; i < m_SerialNumber.count(); i++) { QChar cha = m_SerialNumber.at(i); @@ -633,14 +593,14 @@ void DeviceStorage::loadOtherDeviceInfo() } } - addOtherDeviceInfo(tr("Serial Number"), m_SerialNumber); - addOtherDeviceInfo(tr("Interface"), m_Interface); - addOtherDeviceInfo(tr("Rotation Rate"), m_RotationRate); - addOtherDeviceInfo(tr("Module Alias"), m_Modalias); - addOtherDeviceInfo(tr("Physical ID"), m_PhysID); + addOtherDeviceInfo(("Serial Number"), m_SerialNumber); + addOtherDeviceInfo(("Interface"), m_Interface); + addOtherDeviceInfo(("Rotation Rate"), m_RotationRate); + addOtherDeviceInfo(("Module Alias"), m_Modalias); + addOtherDeviceInfo(("Physical ID"), m_PhysID); if (m_RotationRate == QString("Solid State Device")) { - m_MediaType = QObject::tr("SSD"); + m_MediaType = "SSD"; } // 将QMap内容转存为QList> @@ -650,10 +610,10 @@ void DeviceStorage::loadOtherDeviceInfo() void DeviceStorage::loadTableHeader() { // 加载表头信息 - m_TableHeader.append(tr("Name")); - m_TableHeader.append(tr("Vendor")); - m_TableHeader.append(tr("Media Type")); - m_TableHeader.append(tr("Size")); + m_TableHeader.append("Name"); + m_TableHeader.append("Vendor"); + m_TableHeader.append("Media Type"); + m_TableHeader.append("Size"); } void DeviceStorage::loadTableData() @@ -661,11 +621,11 @@ void DeviceStorage::loadTableData() // 加载表格数据 QString model = m_Name; if (!available()) { - model = "(" + tr("Unavailable") + ") " + m_Name; + model = "(Unavailable) " + m_Name; } m_TableData.append(model); m_TableData.append(m_Vendor); - m_TableData.append(m_MediaType); + m_TableData.append(translateStr(m_MediaType)); m_TableData.append(m_Size); } @@ -701,7 +661,7 @@ void DeviceStorage::getInfoFromsmartctl(const QMap &mapInfo) { if (mapInfo.size() < 5) { if (!mapInfo.isEmpty() && m_Interface.contains("USB", Qt::CaseInsensitive)) { - m_MediaType = QObject::tr("SSD"); + m_MediaType = "SSD"; } return; } @@ -716,12 +676,9 @@ void DeviceStorage::getInfoFromsmartctl(const QMap &mapInfo) setAttribute(mapInfo, "Rotation Rate", m_RotationRate); // 解决Bug45428,INTEL SSDSA2BW160G3L 这个型号的硬盘通过lsblk获取的rota是1,所以这里需要特殊处理 - if (m_RotationRate == QString("Solid State Device")) - m_MediaType = QObject::tr("SSD"); - - // 按照HW的需求,如果是固态硬盘就不显示转速 - if (m_RotationRate == QString("HW_SSD")) { - m_MediaType = QObject::tr("SSD"); + // 按照H的需求,如果是固态硬盘就不显示转速 + if (m_RotationRate == QString("Solid State Device")) { + m_MediaType = "SSD"; m_RotationRate = ""; } @@ -737,6 +694,9 @@ void DeviceStorage::getInfoFromsmartctl(const QMap &mapInfo) capacity.replace(",","").replace(" ",""); QRegExp re("(\\d+)bytes*"); //取值格式如: User Capacity: 1,000,204,886,016 bytes [1.00 TB] Total NVM Capacity: 256,060,514,304 [256 GB] + if (!capacity.contains("bytes", Qt::CaseInsensitive)) { + re.setPattern("(\\d+)"); + } int pos = re.indexIn(capacity); if (pos != -1) { QString byteSize = re.cap(1); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceStorage.h b/deepin-devicemanager/src/DeviceManager/DeviceStorage.h index 7d14aad17..2d89749bd 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceStorage.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceStorage.h @@ -6,6 +6,7 @@ #ifndef DEVICESTORAGE_H #define DEVICESTORAGE_H #include"DeviceInfo.h" +#include "commonfunction.h" /** * @brief The DeviceStorage class @@ -38,13 +39,6 @@ class DeviceStorage: public DeviceBaseInfo */ bool setHwinfoInfo(const QMap &mapInfo); - /** - * @brief setKLUHwinfoInfo:设置由hwinfo --disk命令获取的设备信息,KLU专用 - * @param mapInfo:由hwinfo获取的信息map - * @return 尔值,true:信息设置成功;false:信息设置失败 - */ - bool setKLUHwinfoInfo(const QMap &mapInfo); - /** * @brief setMediaType:设置存储设备的介质类型 * @param name:存储设备逻辑名称 @@ -53,14 +47,6 @@ class DeviceStorage: public DeviceBaseInfo */ bool setMediaType(const QString &name, const QString &value); - /** - * @brief setKLUMediaType:设置存储设备的介质类型,KLU专用 - * @param name:存储设备逻辑名称 - * @param value:类型值0/1 - * @return 布尔值:true-设置成功;false--设置失败 - */ - bool setKLUMediaType(const QString &name, const QString &value); - /** * @brief addInfoFromlshw:将lshw获取的信息与存储设备进行匹配 * @param mapInfo:由lshw获取的信息map @@ -166,6 +152,10 @@ class DeviceStorage: public DeviceBaseInfo */ const QString getOverviewInfo() override; + const QString &interface() const; + + const QString &mediaType() const; + protected: /** diff --git a/deepin-devicemanager/src/DriverControl/DBusDriverInterface.cpp b/deepin-devicemanager/src/DriverControl/DBusDriverInterface.cpp index 5948f8c62..62b55faec 100644 --- a/deepin-devicemanager/src/DriverControl/DBusDriverInterface.cpp +++ b/deepin-devicemanager/src/DriverControl/DBusDriverInterface.cpp @@ -113,12 +113,12 @@ DBusDriverInterface::~DBusDriverInterface() } -void DBusDriverInterface::slotProcessChange(qint32 value, QString detail) +void DBusDriverInterface::slotProcessChange(qint32 value, const QString &detail) { emit processChange(value, detail); } -void DBusDriverInterface::slotProcessEnd(bool success, QString msg) +void DBusDriverInterface::slotProcessEnd(bool success, const QString &msg) { if (success) { emit processChange(100, ""); @@ -133,7 +133,7 @@ void DBusDriverInterface::slotCallFinished(QDBusPendingCallWatcher *watcher) watcher->deleteLater(); } -void DBusDriverInterface::slotDownloadProgressChanged(QStringList msg) +void DBusDriverInterface::slotDownloadProgressChanged(const QStringList &msg) { emit downloadProgressChanged(msg); } diff --git a/deepin-devicemanager/src/DriverControl/DBusDriverInterface.h b/deepin-devicemanager/src/DriverControl/DBusDriverInterface.h index bd221158e..709b32f70 100644 --- a/deepin-devicemanager/src/DriverControl/DBusDriverInterface.h +++ b/deepin-devicemanager/src/DriverControl/DBusDriverInterface.h @@ -123,13 +123,13 @@ private slots: * @param value 当前处理的进度 * @param detail 发送过来的时时信息 */ - void slotProcessChange(qint32 value, QString detail); + void slotProcessChange(qint32 value, const QString &detail); /** * @brief slotProcessEnd 接收后台结束信号 * @param success */ - void slotProcessEnd(bool success, QString msg); + void slotProcessEnd(bool success, const QString &msg); /** * @brief slotCallFinished 更新结束结束的回调 @@ -139,7 +139,7 @@ private slots: /** * @brief slotDownloadProgressChanged 驱动下载时回调,返回驱动下载进度、速度、已下载大小信息 */ - void slotDownloadProgressChanged(QStringList msg); + void slotDownloadProgressChanged(const QStringList &msg); /** * @brief slotDownloadFinished 驱动下载完成 diff --git a/deepin-devicemanager/src/DriverControl/DriverScanner.cpp b/deepin-devicemanager/src/DriverControl/DriverScanner.cpp index 76fc09026..e3ec41d40 100644 --- a/deepin-devicemanager/src/DriverControl/DriverScanner.cpp +++ b/deepin-devicemanager/src/DriverControl/DriverScanner.cpp @@ -81,7 +81,7 @@ void DriverScanner::run() // emit scanFinished(SR_SUCESS); } -void DriverScanner::setDriverList(QList lstInfo) +void DriverScanner::setDriverList(const QList &lstInfo) { m_ListDriverInfo = lstInfo; m_IsStop = false; diff --git a/deepin-devicemanager/src/DriverControl/DriverScanner.h b/deepin-devicemanager/src/DriverControl/DriverScanner.h index ae1d7ddce..7439cba3b 100644 --- a/deepin-devicemanager/src/DriverControl/DriverScanner.h +++ b/deepin-devicemanager/src/DriverControl/DriverScanner.h @@ -25,7 +25,7 @@ class DriverScanner : public QThread * @brief setDriverList * @param lstInfo */ - void setDriverList(QList lstInfo); + void setDriverList(const QList &lstInfo); signals: void scanInfo(const QString &info, int progress); diff --git a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp index 0faae52a1..529e43a55 100644 --- a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp +++ b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp @@ -7,6 +7,7 @@ #include #include #include "DDLog.h" +#include "commonfunction.h" // Qt库文件 #include @@ -183,7 +184,7 @@ QString CmdTool::loadOemTomlFileName(const QMap &mapInfo) return QString(); } -bool CmdTool::parseOemTomlInfo(const QString filename) +bool CmdTool::parseOemTomlInfo(const QString &filename) { bool tomlFileRead = false; bool tomlPars = false; @@ -204,6 +205,16 @@ bool CmdTool::parseOemTomlInfo(const QString filename) file.close(); } } + QString curPathFile2 = "/usr/share/deepin-devicemanager/" + filename; + if (QFile::exists(curPathFile2) && !tomlFileRead) { + QFile file(curPathFile2); + if (file.open(QIODevice::ReadOnly)) { + info = file.readAll().data(); + tomlFileRead = true; + file.close(); + } + } + if (!tomlFileRead) { curPathFile = "/etc/deepin/hardware/oeminfodebug.toml"; //方便调试,并不开放给用户用 QFile file(curPathFile); @@ -240,8 +251,18 @@ bool CmdTool::parseOemTomlInfo(const QString filename) itemMap.clear(); ValueKeyList.clear(); deviceClassesList.append(regClass.cap(2)); -// } else if (regKeyValue.exactMatch(line)) { //键值对= - } else if (line.contains("=")) { + } else if (line.contains("=") && line.contains("{") && line.contains("}")) { //内联表 + int start = line.indexOf("{") + 1; + int end = line.indexOf("}"); + QString value = line.mid(start, end - start).trimmed(); + wordlst = line.split("="); + if (2 <= wordlst.size()) { + QString key = wordlst[0].remove('"').trimmed(); + itemMap.insert(key, value); + ValueKeyList.append(key); + } + + } else if (line.contains("=")) { //键值对= wordlst = line.split("="); if (2 == wordlst.size()) { @@ -310,7 +331,7 @@ void CmdTool::loadLshwInfo(const QString &debugFile) } else if (item.startsWith("multimedia")) { // 音频信息 getMapInfoFromLshw(item, mapInfo); addMapInfo("lshw_multimedia", mapInfo); - } else if (item.startsWith("network")) { // 网卡信息 + } else if (item.startsWith("network") || item.startsWith("communication")) { // 网卡信息 getMapInfoFromLshw(item, mapInfo); addMapInfo("lshw_network", mapInfo); } else if (item.startsWith("usb")) { // USB 设备信息 @@ -564,16 +585,11 @@ void CmdTool::getMulHwinfoInfo(const QString &info) continue; QMap mapInfo; getMapInfoFromHwinfo(item, mapInfo); - if (mapInfo["Hardware Class"] == "sound" || mapInfo["Device"].contains("USB Audio")) { + if (mapInfo["Hardware Class"] == "sound" || (mapInfo["Device"].contains("USB Audio") && mapInfo["Device"].contains("snd-usb-audio"))) { // mapInfo["Device"].contains("USB Audio") 是为了处理未识别的USB声卡 Bug-118773 addMapInfo("hwinfo_sound", mapInfo); } else if (mapInfo["Hardware Class"].contains("network")) { - //if (mapInfo.find("SysFS Device Link") != mapInfo.end() && mapInfo["SysFS Device Link"].contains("/devices/platform")) - bool hasAddress = mapInfo.find("HW Address") != mapInfo.end() || mapInfo.find("Permanent HW Address") != mapInfo.end(); - bool hasPath = mapInfo.find("path") != mapInfo.end(); - if (hasPath || hasAddress) { - addMapInfo("hwinfo_network", mapInfo); - } + addMapInfo("hwinfo_network", mapInfo); } else if ("keyboard" == mapInfo["Hardware Class"]) { addMouseKeyboardInfoMapInfo("hwinfo_keyboard", mapInfo); } else if ("mouse" == mapInfo["Hardware Class"]) { @@ -643,6 +659,12 @@ void CmdTool::loadDmidecodeInfo(const QString &key, const QString &debugfile) if (("dmidecode1" == key) && (mapInfo.size() > 0)) { QString filename = loadOemTomlFileName(mapInfo); parseOemTomlInfo(filename); + + QString tomlFilesName = Common::tomlFilesNameGet(); + if (!tomlFilesName.isEmpty() && tomlFilesName != "tomlFilesName") { + if (parseOemTomlInfo(tomlFilesName)) + qCInfo(appLog) << "config Toml File name is: /usr/share/deepin-devicemanager/" << tomlFilesName ; + } } // 过滤空cpu卡槽信息 @@ -947,9 +969,9 @@ void CmdTool::loadNvidiaSettingInfo(const QString &key, const QString &debugfile QRegExp reg("[\\s\\S]*VideoRam[\\s\\S]*([0-9]{4,})[\\s\\S]*"); QStringList list = deviceInfo.split("\n"); - foreach (QString item, list) { + foreach (QString tmpInfo, list) { // Attribute 'VideoRam' (jixiaomei-PC:0.0): 2097152. 正则表达式获取2097152 - if (reg.exactMatch(item)) { + if (reg.exactMatch(tmpInfo)) { QString gpuSize = reg.cap(1); int numSize = gpuSize.toInt(); numSize /= 1024; diff --git a/deepin-devicemanager/src/GenerateDevice/CmdTool.h b/deepin-devicemanager/src/GenerateDevice/CmdTool.h index f838f9d81..61ceb888a 100644 --- a/deepin-devicemanager/src/GenerateDevice/CmdTool.h +++ b/deepin-devicemanager/src/GenerateDevice/CmdTool.h @@ -61,7 +61,7 @@ class CmdTool /** * @brief parseOemTomlInfo: 解析并加载厂商适配信息 */ - bool parseOemTomlInfo(const QString filename); + bool parseOemTomlInfo(const QString &filename); private: diff --git a/deepin-devicemanager/src/GenerateDevice/CustomGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/CustomGenerator.cpp new file mode 100644 index 000000000..f7f661ce0 --- /dev/null +++ b/deepin-devicemanager/src/GenerateDevice/CustomGenerator.cpp @@ -0,0 +1,92 @@ +// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "CustomGenerator.h" +#include "DeviceGpu.h" +#include "DBusInterface.h" +#include "commontools.h" + +#include +#include +#include +#include +#include + +CustomGenerator::CustomGenerator(QObject *parent) + : DeviceGenerator(parent) +{ +} + +void CustomGenerator::generatorGpuDevice() +{ + QString cmd = CommonTools::getGpuInfoCommandFromDConfig(); + if (cmd.isEmpty()) { + DeviceGenerator::generatorGpuDevice(); + return; + } + + QStringList arguments; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + QString display = env.value("DISPLAY"); + QString xauthority = env.value("XAUTHORITY"); + if (display.isEmpty() || xauthority.isEmpty()) { + qWarning() << "DISPLAY or XAUTHORITY is not set!"; + } else { + arguments << display << xauthority; + } + + QString tmpGpuInfo; + DBusInterface::getInstance()->getGpuInfoByCustom(cmd, arguments, tmpGpuInfo); + if (tmpGpuInfo.isEmpty()) { + qCritical() << "Failed to get gpu info by commad " << cmd; + return; + } + + QList> gpuInfo; + QStringList mapBlocks = tmpGpuInfo.split("\n\n"); + for (const QString &block : mapBlocks) { + QMap infoMap; + QStringList lines = block.split("\n"); + for (const QString &line : lines) { + int colonIndex = line.indexOf(':'); + if (colonIndex != -1) { + QString key = line.left(colonIndex).trimmed(); + QString value = line.mid(colonIndex + 1).trimmed(); + infoMap.insert(key, value); + } + } + if (!infoMap.isEmpty()) + gpuInfo.push_back(infoMap); + } + + for(int i = 0; i < gpuInfo.count(); ++i) { + DeviceGpu *device = new DeviceGpu(); + device->setCanUninstall(false); + device->setForcedDisplay(true); + device->setGpuInfoByCustom(gpuInfo.at(i)); + DeviceManager::instance()->addGpuDevice(device); + } +} + +void CustomGenerator::generatorMonitorDevice() +{ + QString toDir = "/sys/class/drm"; + QDir toDir_(toDir); + + if (!toDir_.exists()) + return; + + QFileInfoList fileInfoList = toDir_.entryInfoList(QDir::NoFilter, QDir::Name); + foreach(QFileInfo fileInfo, fileInfoList) { + if (fileInfo.fileName() == "." || fileInfo.fileName() == ".." || !fileInfo.fileName().startsWith("card")) + continue; + + if (QFile::exists(fileInfo.filePath() + "/" + "edid")) { + QStringList allEDIDS_all; + allEDIDS_all.append(fileInfo.filePath() + "/" + "edid"); + QString interface = fileInfo.fileName().remove("card0-").remove("card1-").remove("card2-"); + CommonTools::parseEDID(allEDIDS_all, interface, false); + } + } +} diff --git a/deepin-devicemanager/src/GenerateDevice/CustomGenerator.h b/deepin-devicemanager/src/GenerateDevice/CustomGenerator.h new file mode 100644 index 000000000..4ef8f2422 --- /dev/null +++ b/deepin-devicemanager/src/GenerateDevice/CustomGenerator.h @@ -0,0 +1,27 @@ +// Copyright (C) 2025 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef CUSTOMGENERATOR_H +#define CUSTOMGENERATOR_H + +#include "DeviceGenerator.h" + +class CustomGenerator : public DeviceGenerator +{ +public: + explicit CustomGenerator(QObject *parent = nullptr); + + /** + * @brief generatorGpuDevice:生成显卡信息 + */ + void generatorGpuDevice() override; + + /** + * @brief generatorMonitorDevice:生成显示设备信息 + */ + void generatorMonitorDevice() override; +}; + +#endif // CUSTOMGENERATOR_H diff --git a/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp b/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp index 59ba79bcb..f08eb45f0 100644 --- a/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DBusInterface.cpp @@ -46,6 +46,18 @@ void DBusInterface::refreshInfo() mp_Iface->asyncCall("refreshInfo"); } +bool DBusInterface::getGpuInfoByCustom(const QString &cmd, const QStringList &arguments, QString &gpuInfo) +{ + QDBusReply replyList = mp_Iface->call("getGpuInfoByCustom", cmd, arguments); + if (replyList.isValid()) { + gpuInfo = replyList.value(); + return true; + } else { + qCritical() << "Error: failed to call dbus to get gpu memery info! "; + return false; + } +} + void DBusInterface::init() { // 1. 连接到dbus diff --git a/deepin-devicemanager/src/GenerateDevice/DBusInterface.h b/deepin-devicemanager/src/GenerateDevice/DBusInterface.h index a154a3377..c6a01898c 100644 --- a/deepin-devicemanager/src/GenerateDevice/DBusInterface.h +++ b/deepin-devicemanager/src/GenerateDevice/DBusInterface.h @@ -47,6 +47,8 @@ class DBusInterface */ void refreshInfo(); + bool getGpuInfoByCustom(const QString &cmd, const QStringList &arguments, QString &gpuInfo); + protected: DBusInterface(); diff --git a/deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp b/deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp index 38d9f6aee..30102c9b9 100644 --- a/deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp @@ -7,13 +7,9 @@ #include "X86Generator.h" #include "MipsGenerator.h" #include "ArmGenerator.h" -#include "KLUGenerator.h" -#include "PanguGenerator.h" -#include "PanguVGenerator.h" #include "HWGenerator.h" -#include "KLVGenerator.h" +#include "CustomGenerator.h" #include "commonfunction.h" -#include "PanguxGenerator.h" // Qt库文件 #include @@ -39,13 +35,15 @@ DeviceGenerator *DeviceFactory::getDeviceGenerator() QString type = Common::boardVendorType(); if (!type.isEmpty()) { if (type == "KLVV") - generator = new KLVGenerator(); + generator = new HWGenerator(); else if (type == "PGUV" || type == "PGUW") - generator = new PanguVGenerator(); + generator = new HWGenerator(); else if (type == "KLVU") - generator = new KLUGenerator(); + generator = new HWGenerator(); else if (type == "PGUX") - generator = new PanguXGenerator(); + generator = new HWGenerator(); + else if (type == "CustomType") + generator = new CustomGenerator(); else generator = new HWGenerator(); } else diff --git a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp index 2de58751b..e8a585386 100644 --- a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp @@ -25,12 +25,17 @@ #include "DeviceManager/DevicePrint.h" #include "DeviceManager/DeviceInput.h" #include "MacroDefinition.h" +#include "DDLog.h" // Dtk头文件 #include // Qt库文件 #include +#include +#include + +using namespace DDLog; DeviceGenerator::DeviceGenerator(QObject *parent) : QObject(parent) @@ -226,6 +231,8 @@ void DeviceGenerator::generatorDiskDevice() getDiskInfoFromLsblk(); getDiskInfoFromSmartCtl(); DeviceManager::instance()->mergeDisk(); + + DeviceManager::instance()->orderDiskByType(); } void DeviceGenerator::generatorGpuDevice() @@ -242,52 +249,105 @@ void DeviceGenerator::generatorMonitorDevice() getMonitorInfoFromHwinfo(); } +bool isValidLogicalName(const QString& logicalName) +{ + if (logicalName.contains("p2p", Qt::CaseInsensitive) || logicalName.isEmpty()) + return false; + + QString addressFilePath = "/sys/class/net/" + logicalName; + QDir dir(addressFilePath); + if (dir.exists()) + return true; + + qCInfo(appLog) << dir << "not exist in /sys/class/net/"; + return false; +} + +bool isValidMAC(const QString& macAddress) +{ + if (macAddress.contains("00:00:00:00:00:00", Qt::CaseInsensitive) || macAddress.contains("ff:ff:ff:ff:ff:ff", Qt::CaseInsensitive) || macAddress.isEmpty()) + return false; + + QRegularExpression macRegex("([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})"); + if (!macRegex.match(macAddress).hasMatch()) + return false; + + return true; +} + void DeviceGenerator::generatorNetworkDevice() { + bool hasWlan =false; QList lstDevice; + // 设置从lshw中获取的信息 + const QList> &lstLshw = DeviceManager::instance()->cmdInfo("lshw_network"); + for (QList >::const_iterator it = lstLshw.begin(); it != lstLshw.end(); ++it) { + if ((*it).find("serial") == (*it).end() || (*it).find("logical name") == (*it).end()) + continue; + + const QString &logicalNameLshw = (*it)["logical name"]; + const QString &macAddressLshw = (*it)["serial"]; + if (!isValidLogicalName(logicalNameLshw)) + continue; + if (!isValidMAC(macAddressLshw)) + continue; + + if (logicalNameLshw.contains("wlan", Qt::CaseInsensitive) && hasWlan) //common sense: one PC only have 1 wlan device + continue; + + DeviceNetwork *device = new DeviceNetwork(); + device->setInfoFromLshw(*it); + lstDevice.append(device); + if (logicalNameLshw.contains("wlan", Qt::CaseInsensitive)) + hasWlan = true; + + } + const QList> &lstHWInfo = DeviceManager::instance()->cmdInfo("hwinfo_network"); for (QList >::const_iterator it = lstHWInfo.begin(); it != lstHWInfo.end(); ++it) { - // Hardware Class 类型为 network interface -// if ("network" == (*it)["Hardware Class"]) { //去掉, 并与service端同步"hwinfo --network"改为 "hwinfo --netcard"获取网卡信息 -// continue; -// } - // 先判断是否是有效网卡信息 - // 符合两种情况中的一种 1. "HW Address" 和 "Permanent HW Address" 都必须有 2. 有 "unique_id" + // 先判断是否是有效网卡信息 + // 符合两种情况中的一种 1. "HW Address" 和 "Permanent HW Address" 都必须有 2. 有 "unique_id" if (((*it).find("HW Address") == (*it).end() && (*it).find("Permanent HW Address") == (*it).end()) && ((*it).find("unique_id") == (*it).end())) { - continue; + continue; } - // 如果(*it)中包含unique_id属性,则说明是从数据库里面获取的,否则是从hwinfo中获取的 - if ((*it).find("unique_id") == (*it).end()) { - DeviceNetwork *device = new DeviceNetwork(); - device->setInfoFromHwinfo(*it); - lstDevice.append(device); - } else { - DeviceNetwork *device = nullptr; - const QString &unique_id = (*it)["unique_id"]; - for (QList::iterator itNet = lstDevice.begin(); itNet != lstDevice.end(); ++itNet) { - if (!unique_id.isEmpty() && (*itNet)->uniqueID() == unique_id) { - device = (*itNet); + const QString &macHwinfo = (*it)["Permanent HW Address"].isEmpty() ? (*it)["HW Address"] : (*it)["Permanent HW Address"]; + const QString &logicalNameHwinfo = (*it)["Device File"]; + bool hasMatchLogicalName = false; + for (QList::iterator itDevice = lstDevice.begin(); itDevice != lstDevice.end(); ++itDevice) { + const QString &serialNumberLst = (*itDevice)->hwAddress(); + const QString &logicalNameLst = (*itDevice)->logicalName(); + // 如果(*it)中包含unique_id属性,则说明是从数据库里面获取的,否则是从hwinfo中获取的 + if ((*it).find("unique_id") != (*it).end()) { + const QString &unique_id = (*it)["unique_id"]; + if (!unique_id.isEmpty() && (*itDevice)->uniqueID() == unique_id) { + (*itDevice)->setEnableValue(false); } - } - if (device) { - device->setEnableValue(false); + + } else if (macHwinfo == serialNumberLst || logicalNameHwinfo == logicalNameLst) { + (*itDevice)->setInfoFromHwinfo(*it); + hasMatchLogicalName = true; + } else { + (*itDevice)->setCanUninstall(false); + (*itDevice)->setForcedDisplay(true); } } - } - - // 设置从lshw中获取的信息 - const QList> &lstLshw = DeviceManager::instance()->cmdInfo("lshw_network"); - for (QList >::const_iterator it = lstLshw.begin(); it != lstLshw.end(); ++it) { - if ((*it).find("serial") == (*it).end()) - continue; - const QString &serialNumber = ((*it).find("logical name") != (*it).end()) ? (*it)["serial"] + (*it)["logical name"] : (*it)["serial"]; - for (QList::iterator itDevice = lstDevice.begin(); itDevice != lstDevice.end(); ++itDevice) { - const QString &ser2Number = (*itDevice)->logicalName().isEmpty() ? (*itDevice)->hwAddress() : (*itDevice)->hwAddress() + (*itDevice)->logicalName(); - if (!serialNumber.isEmpty() && ((*itDevice)->uniqueID() == serialNumber || ser2Number == serialNumber)) { - (*itDevice)->setInfoFromLshw(*it); - break; + //first check it's valid, if LogicalName not exist but valid please add it . + if (!hasMatchLogicalName && isValidMAC(macHwinfo) && isValidLogicalName(logicalNameHwinfo)) { + if (!logicalNameHwinfo.contains("wlan", Qt::CaseInsensitive)) {//add wired net + DeviceNetwork *device = new DeviceNetwork(); + device->setInfoFromHwinfo(*it); + lstDevice.append(device); + hasMatchLogicalName = true; + } else { //add wireless net + if (!hasWlan) { //common sense: one PC only have 1 wlan device + DeviceNetwork *device = new DeviceNetwork(); + device->setInfoFromHwinfo(*it); + lstDevice.append(device); + hasMatchLogicalName = true; + hasWlan = true; + } } } } @@ -577,6 +637,9 @@ void DeviceGenerator::getDiskInfoFromSmartCtl() const QList> &lstMap = DeviceManager::instance()->cmdInfo("smart"); QList >::const_iterator it = lstMap.begin(); for (; it != lstMap.end(); ++it) { + // 剔除未识别的磁盘 + if (!(*it).contains("ln")) + continue; DeviceManager::instance()->setStorageInfoFromSmartctl((*it)["ln"], *it); } } @@ -680,17 +743,21 @@ void DeviceGenerator::getAudioInfoFromHwinfo() QString path = pciPath(*it); DeviceAudio *device = dynamic_cast(DeviceManager::instance()->getAudioDevice(path)); - if (device) { + if (device && (*it).size() != 5) { device->setEnableValue(false); continue; } device = new DeviceAudio(); device->setInfoFromHwinfo(*it); + if ((*it).size() == 5 && (*it).find("unique_id") != (*it).end()) { + device->setEnableValue(false); + device->setUniqueID((*it)["unique_id"]); + } DeviceManager::instance()->addAudioDevice(device); addBusIDFromHwinfo((*it)["SysFS BusID"]); } - DeviceManager::instance()->deleteDisableDuplicate_AudioDevice(); +// DeviceManager::instance()->deleteDisableDuplicate_AudioDevice(); } void DeviceGenerator::getAudioInfoFrom_sysFS() @@ -789,7 +856,7 @@ void DeviceGenerator::getBlueToothInfoFromHwinfo() if ((*it)["Hardware Class"] == "hub" || (*it)["Hardware Class"] == "mouse" || (*it)["Hardware Class"] == "keyboard") continue; - if ((*it)["Model"].contains("bluetooth", Qt::CaseInsensitive) || (*it)["Hardware Class"] == "bluetooth" || (*it)["Driver"] == "btusb" || (*it)["Device"] == "BCM20702A0") { + if ((*it)["Model"].contains("bluetooth", Qt::CaseInsensitive) || (*it)["Hardware Class"] == "bluetooth" || (*it)["Driver"] == "btusb" || (*it)["Device"] == "BCM20702A0" || (*it)["Device"] == "SCM2625 BT 5.2 network adapter") { // 判断重复设备数据 QString unique_id = uniqueID(*it); diff --git a/deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h b/deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h index 7fe9d03e4..1de9195dc 100644 --- a/deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h +++ b/deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h @@ -45,7 +45,7 @@ class GenerateTask: public QObject, public QRunnable Q_OBJECT public: - GenerateTask(DeviceType deviceType); + explicit GenerateTask(DeviceType deviceType); ~GenerateTask(); signals: void finished(const QStringList &lst); diff --git a/deepin-devicemanager/src/GenerateDevice/GetInfoPool.cpp b/deepin-devicemanager/src/GenerateDevice/GetInfoPool.cpp index 1204c0131..33645eb0c 100644 --- a/deepin-devicemanager/src/GenerateDevice/GetInfoPool.cpp +++ b/deepin-devicemanager/src/GenerateDevice/GetInfoPool.cpp @@ -12,7 +12,7 @@ static QMutex mutex; -CmdTask::CmdTask(QString key, QString file, QString info, GetInfoPool *parent) +CmdTask::CmdTask(const QString &key, const QString &file, const QString &info, GetInfoPool *parent) : m_Key(key) , m_File(file) , m_Info(info) diff --git a/deepin-devicemanager/src/GenerateDevice/GetInfoPool.h b/deepin-devicemanager/src/GenerateDevice/GetInfoPool.h index 4582b1f8b..c207baa6c 100644 --- a/deepin-devicemanager/src/GenerateDevice/GetInfoPool.h +++ b/deepin-devicemanager/src/GenerateDevice/GetInfoPool.h @@ -19,8 +19,8 @@ class CmdTask: public QObject, public QRunnable { Q_OBJECT public: - CmdTask(QString key, QString file, QString info, GetInfoPool *parent); - ~CmdTask(); + CmdTask(const QString &key, const QString &file, const QString &info, GetInfoPool *parent); + ~CmdTask() override; protected: void run() override; diff --git a/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp index eb4d5f01f..a279be325 100644 --- a/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp +++ b/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp @@ -5,6 +5,9 @@ // 项目自身文件 #include "HWGenerator.h" #include "EDIDParser.h" +#include "commonfunction.h" +#include "DDLog.h" +#include "commontools.h" // Qt库文件 #include @@ -12,6 +15,7 @@ #include #include #include +#include // 其它头文件 #include "DeviceManager/DeviceManager.h" @@ -27,9 +31,12 @@ #include "DeviceManager/DeviceNetwork.h" #include "DeviceManager/DeviceMemory.h" +static QString boardVendorType; +using namespace DDLog; + HWGenerator::HWGenerator() { - + boardVendorType = Common::boardVendorType(); } void HWGenerator::generatorComputerDevice() @@ -92,12 +99,73 @@ void HWGenerator::generatorAudioDevice() getAudioInfoFromCatAudio(); } +QList > readFileSysWifi() +{ + QList > lstWifiInfo; + QString wifiDevicesInfoPath("/sys/hisys/wal/wifi_devices_info"); + QFile file(wifiDevicesInfoPath); + if (file.open(QIODevice::ReadOnly)) { + QMap wifiInfo; + QString allStr = file.readAll(); + file.close(); + + // 解析数据 + QStringList items = allStr.split("\n"); + foreach (const QString &item, items) { + if (item.isEmpty()) + continue; + + QStringList strList = item.split(':', QString::SkipEmptyParts); + if (strList.size() == 2) + wifiInfo[strList[0] ] = strList[1]; + } + + if (!wifiInfo.isEmpty()) + lstWifiInfo.append(wifiInfo); + } + return lstWifiInfo; +} void HWGenerator::generatorBluetoothDevice() { getBluetoothInfoFromHciconfig(); getBlueToothInfoFromHwinfo(); getBluetoothInfoFromLshw(); - getBluetoothInfoFromCatWifiInfo(); + + QList > lstWifiInfo = readFileSysWifi(); + if (lstWifiInfo.size() == 0) { + return; + } + QList >::const_iterator it = lstWifiInfo.begin(); + QMap tempMap; + for (; it != lstWifiInfo.end(); ++it) { + if ((*it).size() < 3) { + continue; + } + + // KLU的问题特殊处理 + foreach (const QString &key, (*it).keys()) { + tempMap.insert(key, (*it)[key]); + } + + // cat /sys/hisys/wal/wifi_devices_info 获取结果为 HI103 + if (tempMap["Chip Type"].contains(Common::specialHString(), Qt::CaseInsensitive)) { + tempMap["Chip Type"] = tempMap["Chip Type"].remove(Common::specialHString()).trimmed(); + } + + // 按照华为的需求,设置蓝牙制造商和类型 + tempMap["Vendor"] = Common::specialHString(); + tempMap["Type"] = "Bluetooth Device"; + tempMap["Name"] = tempMap["Chip Type"]; + } + + QList lst = DeviceManager::instance()->convertDeviceList(DT_Bluetoorh); + for (int i = 0; i < lst.size(); i++) { + DeviceBaseInfo *device = lst[i]; + QString bus = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Bluetoorh, device, "Bus"); //内置:UART 外接USB:USB + if (bus.contains("UART",Qt::CaseInsensitive)) { + DeviceManager::instance()->tomlDeviceMapSet(DT_Bluetoorh, device,tempMap); + } + } } void HWGenerator::generatorGpuDevice() @@ -141,69 +209,107 @@ void HWGenerator::generatorGpuDevice() DeviceManager::instance()->addGpuDevice(device); } + void HWGenerator::generatorNetworkDevice() { - QList lstDevice; - const QList> &lstHWInfo = DeviceManager::instance()->cmdInfo("hwinfo_network"); - for (QList >::const_iterator it = lstHWInfo.begin(); it != lstHWInfo.end(); ++it) { - // Hardware Class 类型为 network interface -// if ("network" == (*it)["Hardware Class"]) { -// continue; -// } - - // 先判断是否是有效网卡信息 - // 符合两种情况中的一种 1. "HW Address" 和 "Permanent HW Address" 都必须有 2. 有 "unique_id" - if (((*it).find("HW Address") == (*it).end() || (*it).find("Permanent HW Address") == (*it).end()) && ((*it).find("unique_id") == (*it).end())) { + DeviceGenerator::generatorNetworkDevice(); + + QList > lstWifiInfo = readFileSysWifi(); + if (lstWifiInfo.size() == 0) { + return; + } + + QList >::const_iterator it = lstWifiInfo.begin(); + for (; it != lstWifiInfo.end(); ++it) { + if ((*it).size() < 3) { continue; } - // 如果(*it)中包含unique_id属性,则说明是从数据库里面获取的,否则是从hwinfo中获取的 - if ((*it).find("unique_id") == (*it).end()) { - DeviceNetwork *device = new DeviceNetwork(); - device->setInfoFromHwinfo(*it); - if (!device->available()) { - device->setCanEnale(false); - device->setCanUninstall(false); - device->setForcedDisplay(true); - } - lstDevice.append(device); - } else { - DeviceNetwork *device = nullptr; - const QString &unique_id = (*it)["unique_id"]; - for (QList::iterator itNet = lstDevice.begin(); itNet != lstDevice.end(); ++itNet) { - if (!unique_id.isEmpty() && (*itNet)->uniqueID() == unique_id) { - device = (*itNet); - } - } - if (device) { - device->setEnableValue(false); - } + // cat /sys/hisys/wal/wifi_devices_info的问题特殊处理 获取结果为 HI103 + QMap tempMap; + foreach (const QString &key, (*it).keys()) { + tempMap.insert(key, (*it)[key]); } - } - // 设置从lshw中获取的信息 - const QList> &lstLshw = DeviceManager::instance()->cmdInfo("lshw_network"); - for (QList >::const_iterator it = lstLshw.begin(); it != lstLshw.end(); ++it) { - if ((*it).find("serial") == (*it).end()) - continue; - const QString &serialNumber = (*it)["serial"]; - for (QList::iterator itDevice = lstDevice.begin(); itDevice != lstDevice.end(); ++itDevice) { - if (!serialNumber.isEmpty() && (*itDevice)->uniqueID() == serialNumber) { - (*itDevice)->setInfoFromLshw(*it); - break; - } + tempMap["Name"] = tempMap["Chip Type"]; + if (tempMap["Chip Type"].contains(Common::specialHString(), Qt::CaseInsensitive)) { + tempMap["Name"] = tempMap["Chip Type"].remove(Common::specialHString()).trimmed(); + } + + if (tempMap["NIC Type"].contains("WLAN", Qt::CaseInsensitive)) { } - } - foreach (DeviceNetwork *device, lstDevice) { - DeviceManager::instance()->addNetworkDevice(device); + // 按照华为的需求,设置蓝牙制造商和类型 + tempMap["Vendor"] = "HISILICON"; + tempMap["Type"] = "Wireless network"; + + QList lst = DeviceManager::instance()->convertDeviceList(DT_Network); + for (int i = 0; i < lst.size(); i++) { + DeviceBaseInfo *device = lst[i]; + QString logicalName = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Network, device, "Logical Name"); + if (logicalName.contains("wlan", Qt::CaseInsensitive)) { + DeviceManager::instance()->tomlDeviceMapSet(DT_Network, device,tempMap); + } + } } } void HWGenerator::generatorDiskDevice() { DeviceGenerator::generatorDiskDevice(); - DeviceManager::instance()->checkDiskSize(); + + QString bootdevicePath("/proc/bootdevice/product_name"); + QString modelStr = ""; + QFile file(bootdevicePath); + if (file.open(QIODevice::ReadOnly)) { + modelStr = file.readLine().simplified(); + file.close(); + } + if (modelStr.isEmpty()) + return; + + QList lst = DeviceManager::instance()->convertDeviceList(DT_Storage); + for (int i = 0; i < lst.size(); i++) { + DeviceBaseInfo *device = lst[i]; + QString name = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Storage, device, "Name"); + QString vendor = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Storage, device, "Vendor"); + if (name == modelStr) { + QMap tempMap; + if (vendor.contains("WDC",Qt::CaseInsensitive)) + tempMap["Vendor"] = "nouse"; + if (name.contains("SDINFDO4-256G",Qt::CaseInsensitive)) + tempMap["Name"] = "nouse"; + + if (Common::specialComType == 2) { + tempMap["Interface"] = "UFS 3.1"; + } + + // 读取interface版本 + QProcess process; + process.start("cat /sys/devices/platform/f8200000.ufs/host0/scsi_host/host0/wb_en"); + process.waitForFinished(-1); + int exitCode = process.exitCode(); + if (exitCode != 127 && exitCode != 126) { + QString deviceInfo = process.readAllStandardOutput(); + if (deviceInfo.trimmed() == "true") { + process.start("cat /sys/block/sdd/device/spec_version"); + process.waitForFinished(-1); + exitCode = process.exitCode(); + if (exitCode != 127 && exitCode != 126) { + deviceInfo = process.readAllStandardOutput(); + if (deviceInfo.trimmed() == "310") { + tempMap["interface"] = "UFS 3.1"; + } else if (deviceInfo.trimmed() == "300") + tempMap["interface"] = "UFS 3.0"; + } + } + } + + DeviceManager::instance()->tomlDeviceMapSet(DT_Storage, device,tempMap); + } + } + + DeviceManager::instance()->checkDiskSize(); //place in the end } void HWGenerator::getAudioInfoFromCatAudio() @@ -216,12 +322,12 @@ void HWGenerator::getAudioInfoFromCatAudio() QMap tempMap = *it; if (tempMap["Name"].contains("da_combine_v5", Qt::CaseInsensitive)) { - tempMap["Name"] = "Hi6405"; - tempMap["Model"] = "Hi6405"; + tempMap["Name"] = "OnBoard Audio"; + tempMap["Model"] = "OnBoard Audio"; } if (tempMap.contains("Vendor")) { - tempMap["Vendor"]= "HUAWEI"; + tempMap["Vendor"]= Common::specialHString(); } DeviceAudio *device = new DeviceAudio(); @@ -233,64 +339,6 @@ void HWGenerator::getAudioInfoFromCatAudio() } } -void HWGenerator::getDiskInfoFromLshw() -{ - QString bootdevicePath("/proc/bootdevice/product_name"); - QString modelStr = ""; - QFile file(bootdevicePath); - if (file.open(QIODevice::ReadOnly)) { - modelStr = file.readLine().simplified(); - file.close(); - } - - const QList> lstDisk = DeviceManager::instance()->cmdInfo("lshw_disk"); - QList >::const_iterator dIt = lstDisk.begin(); - for (; dIt != lstDisk.end(); ++dIt) { - if ((*dIt).size() < 2) - continue; - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*dIt).keys()) { - tempMap.insert(key, (*dIt)[key]); - } - -// qCInfo(appLog) << tempMap["product"] << " ***** " << modelStr << " " << (tempMap["product"] == modelStr); - // HW写死 - if (tempMap["product"] == modelStr) { - // 应HW的要求,将描述固定为 Universal Flash Storage - tempMap["description"] = "Universal Flash Storage"; - // 应HW的要求,添加interface UFS 3.0 - tempMap["interface"] = "UFS 3.0"; - } - - DeviceManager::instance()->addLshwinfoIntoStorageDevice(tempMap); - } -} - -void HWGenerator::getDiskInfoFromSmartCtl() -{ - const QList> lstMap = DeviceManager::instance()->cmdInfo("smart"); - QList >::const_iterator it = lstMap.begin(); - for (; it != lstMap.end(); ++it) { - // 剔除未识别的磁盘 - if (!(*it).contains("ln")) - continue; - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - tempMap.insert(key, (*it)[key]); - } - - // 按照HW的需求,如果是固态硬盘就不显示转速 - if (tempMap["Rotation Rate"] == "Solid State Device") - tempMap["Rotation Rate"] = "HW_SSD"; - - DeviceManager::instance()->setStorageInfoFromSmartctl(tempMap["ln"], tempMap); - } -} - void HWGenerator::getBluetoothInfoFromHciconfig() { const QList> lstMap = DeviceManager::instance()->cmdInfo("hciconfig"); @@ -337,60 +385,6 @@ void HWGenerator::getBluetoothInfoFromLshw() } } -void HWGenerator::getBluetoothInfoFromCatWifiInfo() -{ - QList > lstWifiInfo; - QString wifiDevicesInfoPath("/sys/hisys/wal/wifi_devices_info"); - QFile file(wifiDevicesInfoPath); - if (file.open(QIODevice::ReadOnly)) { - QMap wifiInfo; - QString allStr = file.readAll(); - file.close(); - - // 解析数据 - QStringList items = allStr.split("\n"); - foreach (const QString &item, items) { - if (item.isEmpty()) - continue; - - QStringList strList = item.split(':', QString::SkipEmptyParts); - if (strList.size() == 2) - wifiInfo[strList[0] ] = strList[1]; - } - - if (!wifiInfo.isEmpty()) - lstWifiInfo.append(wifiInfo); - } - - if (lstWifiInfo.size() == 0) { - return; - } - QList >::const_iterator it = lstWifiInfo.begin(); - - for (; it != lstWifiInfo.end(); ++it) { - if ((*it).size() < 3) { - continue; - } - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - tempMap.insert(key, (*it)[key]); - } - - // cat /sys/hisys/wal/wifi_devices_info 获取结果为 HUAWEI HI103 - if (tempMap["Chip Type"].contains("HUAWEI", Qt::CaseInsensitive)) { - tempMap["Chip Type"] = tempMap["Chip Type"].remove("HUAWEI").trimmed(); - } - - // 按照华为的需求,设置蓝牙制造商和类型 - tempMap["Vendor"] = "HISILICON"; - tempMap["Type"] = "Bluetooth Device"; - - DeviceManager::instance()->setBluetoothInfoFromWifiInfo(tempMap); - } -} - void HWGenerator::getMemoryInfoFromLshw() { // 从lshw中获取内存信息 @@ -419,50 +413,6 @@ void HWGenerator::getMemoryInfoFromLshw() } } -static void parseEDID(QStringList allEDIDS,QString input) -{ - for (auto edid:allEDIDS) { - QProcess process; - process.start(QString("hexdump %1").arg(edid)); - process.waitForFinished(-1); - - QString deviceInfo = process.readAllStandardOutput(); - if(deviceInfo.isEmpty()) - continue; - - QString edidStr; - QStringList lines = deviceInfo.split("\n"); - for (auto line:lines) { - QStringList words = line.trimmed().split(" "); - if(words.size() != 9) - continue; - - words.removeAt(0); - QString l = words.join(""); - l.append("\n"); - edidStr.append(l); - } - - lines = edidStr.split("\n"); - if(lines.size() > 3){ - EDIDParser edidParser; - QString errorMsg; - edidParser.setEdid(edidStr,errorMsg,"\n", false); - - QMap mapInfo; - mapInfo.insert("Vendor",edidParser.vendor()); - mapInfo.insert("Model",edidParser.model()); - mapInfo.insert("Date",edidParser.releaseDate()); - mapInfo.insert("Size",edidParser.screenSize()); - mapInfo.insert("Display Input",input); - - DeviceMonitor *device = new DeviceMonitor(); - device->setInfoFromEdid(mapInfo); - DeviceManager::instance()->addMonitor(device); - } - } -} - void HWGenerator::generatorMonitorDevice() { QString toDir = "/sys/class/drm"; @@ -471,16 +421,47 @@ void HWGenerator::generatorMonitorDevice() if (!toDir_.exists()) return; - QFileInfoList fileInfoList = toDir_.entryInfoList(); + QFileInfoList fileInfoList = toDir_.entryInfoList(QDir::NoFilter, QDir::Name); foreach(QFileInfo fileInfo, fileInfoList) { - if(fileInfo.fileName() == "." || fileInfo.fileName() == ".." || !fileInfo.fileName().startsWith("card")) + if (fileInfo.fileName() == "." || fileInfo.fileName() == ".." || !fileInfo.fileName().startsWith("card")) continue; - if(QFile::exists(fileInfo.filePath() + "/" + "edid")) { + if (QFile::exists(fileInfo.filePath() + "/" + "edid")) { QStringList allEDIDS_all; allEDIDS_all.append(fileInfo.filePath() + "/" + "edid"); QString interface = fileInfo.fileName().remove("card0-").remove("card1-").remove("card2-"); - parseEDID(allEDIDS_all,interface); + CommonTools::parseEDID(allEDIDS_all, interface, true); } } } + +void HWGenerator::generatorPowerDevice() +{ + DeviceGenerator::generatorPowerDevice(); +} + +void HWGenerator::generatorKeyboardDevice() +{ + DeviceGenerator::generatorKeyboardDevice(); +} + +void HWGenerator::generatorMemoryDevice() +{ + DeviceGenerator::generatorMemoryDevice(); +} + +void HWGenerator::generatorCameraDevice() +{ + DeviceGenerator::generatorCameraDevice(); + + QList lst = DeviceManager::instance()->convertDeviceList(DT_Image); + for (int i = 0; i < lst.size(); i++) { + DeviceBaseInfo *device = lst[i]; + QString vendor = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Image, device, "Vendor"); + if (vendor.contains("0000058020",Qt::CaseInsensitive)) { + QMap tempMap; + tempMap["Vendor"] = "nouse"; + DeviceManager::instance()->tomlDeviceMapSet(DT_Image, device,tempMap); + } + } +} diff --git a/deepin-devicemanager/src/GenerateDevice/HWGenerator.h b/deepin-devicemanager/src/GenerateDevice/HWGenerator.h index 38fa27b48..45276e13b 100644 --- a/deepin-devicemanager/src/GenerateDevice/HWGenerator.h +++ b/deepin-devicemanager/src/GenerateDevice/HWGenerator.h @@ -54,21 +54,36 @@ class HWGenerator : public DeviceGenerator */ virtual void generatorDiskDevice() override; -protected: /** - * @brief getAudioInfoFromCatInput:从cat /proc/bus/input/devices获取音频设备信息 + * @brief generatorMonitorDevice:生成显示设备信息 */ - virtual void getAudioInfoFromCatAudio() ; + virtual void generatorMonitorDevice() override; + + /** + * @brief generatorPowerDevice:生成电池设备 + */ + virtual void generatorPowerDevice() override; + + /** + * @brief generatorKeyboardDevice:生成键盘设备 + */ + virtual void generatorKeyboardDevice() override; /** - * @brief getDiskInfoFromLshw:从lshw获取存储设备信息 + * @brief generatorMemoryDevice:生成内存设备 */ - virtual void getDiskInfoFromLshw() override; + virtual void generatorMemoryDevice() override; /** - * @brief getDiskInfoFromSmartCtl:从smartctl获取存储设备信息 + * @brief generatorCameraDevice:生成图像设备 */ - virtual void getDiskInfoFromSmartCtl() override; + virtual void generatorCameraDevice() override; + +protected: + /** + * @brief getAudioInfoFromCatInput:从cat /proc/bus/input/devices获取音频设备信息 + */ + virtual void getAudioInfoFromCatAudio() ; /** * @brief getBluetoothInfoFromHciconfig:hciconfig获取蓝牙信息 @@ -85,18 +100,12 @@ class HWGenerator : public DeviceGenerator */ virtual void getBluetoothInfoFromLshw() override; - /**@brief:generator bluetooth info*/ - virtual void getBluetoothInfoFromCatWifiInfo(); - /** * @brief getMemoryInfoFromLshw:从lshw获取内存信息 */ virtual void getMemoryInfoFromLshw() override; - /** - * @brief generatorMonitorDevice:生成显示设备信息 - */ - virtual void generatorMonitorDevice() override; + }; #endif // PANGUVGENERATOR_H diff --git a/deepin-devicemanager/src/GenerateDevice/KLUGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/KLUGenerator.cpp deleted file mode 100644 index 8fd6d862b..000000000 --- a/deepin-devicemanager/src/GenerateDevice/KLUGenerator.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -// 项目自身文件 -#include "KLUGenerator.h" - -// Qt库文件 -#include -#include - -// 其它头文件 -#include "DeviceManager/DeviceManager.h" -#include "DeviceManager/DeviceGpu.h" -#include "DeviceManager/DeviceMonitor.h" -#include "DeviceManager/DeviceOthers.h" -#include "DeviceManager/DeviceStorage.h" -#include "DeviceManager/DeviceAudio.h" -#include "DeviceManager/DeviceComputer.h" -#include "DeviceManager/DevicePower.h" -#include "DeviceManager/DeviceInput.h" -#include "DeviceManager/DeviceNetwork.h" - -KLUGenerator::KLUGenerator() -{ - -} - -void KLUGenerator::getDiskInfoFromLshw() -{ - QString bootdevicePath("/proc/bootdevice/product_name"); - QString modelStr = ""; - QFile file(bootdevicePath); - if (file.open(QIODevice::ReadOnly)) { - modelStr = file.readLine().simplified(); - file.close(); - } - - const QList> lstDisk = DeviceManager::instance()->cmdInfo("lshw_disk"); - QList >::const_iterator dIt = lstDisk.begin(); - for (; dIt != lstDisk.end(); ++dIt) { - if ((*dIt).size() < 2) - continue; - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*dIt).keys()) { - tempMap.insert(key, (*dIt)[key]); - } - -// qCInfo(appLog) << tempMap["product"] << " ***** " << modelStr << " " << (tempMap["product"] == modelStr); - // HW写死 - if (tempMap["product"] == modelStr) { - // 应HW的要求,将描述固定为 Universal Flash Storage - tempMap["description"] = "Universal Flash Storage"; - // 应HW的要求,添加interface UFS 3.0 - tempMap["interface"] = "UFS 3.0"; - - // 读取interface版本 - QProcess process; - process.start("cat /sys/devices/platform/f8200000.ufs/host0/scsi_host/host0/wb_en"); - process.waitForFinished(-1); - int exitCode = process.exitCode(); - if (exitCode != 127 && exitCode != 126) { - QString deviceInfo = process.readAllStandardOutput(); - if (deviceInfo.trimmed() == "true") { - process.start("cat /sys/block/sdd/device/spec_version"); - process.waitForFinished(-1); - exitCode = process.exitCode(); - if (exitCode != 127 && exitCode != 126) { - deviceInfo = process.readAllStandardOutput(); - if (deviceInfo.trimmed() == "310") { - tempMap["interface"] = "UFS 3.1"; - } - } - } - } - } - - DeviceManager::instance()->addLshwinfoIntoStorageDevice(tempMap); - } -} - -void KLUGenerator::generatorNetworkDevice() -{ - const QList> lstInfo = DeviceManager::instance()->cmdInfo("lshw_network"); - QList >::const_iterator it = lstInfo.begin(); - for (; it != lstInfo.end(); ++it) { - if ((*it).size() < 2) { - continue; - } - QMap tempMap = *it; - /* - capabilities: ethernet physical wireless - configuration: broadcast=yes ip=10.4.6.115 multicast=yes wireless=IEEE 802.11 - */ - if ((tempMap["configuration"].indexOf("wireless=IEEE 802.11") > -1) || - (tempMap["capabilities"].indexOf("wireless") > -1)) { - continue; - } - - DeviceNetwork *device = new DeviceNetwork(); - device->setInfoFromLshw(*it); - device->setCanEnale(false); - device->setCanUninstall(false); - device->setForcedDisplay(true); - DeviceManager::instance()->addNetworkDevice(device); - } - // HW 要求修改名称,制造商以及类型 - getNetworkInfoFromCatWifiInfo(); -} - -void KLUGenerator::getNetworkInfoFromCatWifiInfo() -{ - QList > lstWifiInfo; - QString wifiDevicesInfoPath("/sys/hisys/wal/wifi_devices_info"); - QFile file(wifiDevicesInfoPath); - if (file.open(QIODevice::ReadOnly)) { - QMap wifiInfo; - QString allStr = file.readAll(); - file.close(); - - // 解析数据 - QStringList items = allStr.split("\n"); - foreach (const QString &item, items) { - if (item.isEmpty()) - continue; - - QStringList strList = item.split(':', QString::SkipEmptyParts); - if (strList.size() == 2) - wifiInfo[strList[0] ] = strList[1]; - } - - if (!wifiInfo.isEmpty()) - lstWifiInfo.append(wifiInfo); - } - if (lstWifiInfo.size() == 0) { - return; - } - QList >::const_iterator it = lstWifiInfo.begin(); - - for (; it != lstWifiInfo.end(); ++it) { - if ((*it).size() < 3) { - continue; - } - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - tempMap.insert(key, (*it)[key]); - } - - // cat /sys/hisys/wal/wifi_devices_info 获取结果为 HUAWEI HI103 - if (tempMap["Chip Type"].contains("HUAWEI", Qt::CaseInsensitive)) { - tempMap["Chip Type"] = tempMap["Chip Type"].remove("HUAWEI").trimmed(); - } - - // 按照华为的需求,设置蓝牙制造商和类型 - tempMap["Vendor"] = "HISILICON"; - tempMap["Type"] = "Wireless network"; - - DeviceManager::instance()->setNetworkInfoFromWifiInfo(tempMap); - } -} - -void KLUGenerator::generatorMonitorDevice() -{ - QMap mapInfo; - mapInfo.insert("Name", "LCD"); -// mapInfo.insert("Vendor", "HUAWEI"); - mapInfo.insert("CurResolution", "2160x1440@60Hz"); - mapInfo.insert("SupportResolution", "2160x1440@60Hz"); - mapInfo.insert("Size", "14 Inch"); -// mapInfo.insert("Date", "2019年7月"); - - DeviceMonitor *monitor = new DeviceMonitor(); - monitor->setInfoFromSelfDefine(mapInfo); - DeviceManager::instance()->addMonitor(monitor); -} - diff --git a/deepin-devicemanager/src/GenerateDevice/KLUGenerator.h b/deepin-devicemanager/src/GenerateDevice/KLUGenerator.h deleted file mode 100644 index 6f5f10a25..000000000 --- a/deepin-devicemanager/src/GenerateDevice/KLUGenerator.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef KLUGENERATOR_H -#define KLUGENERATOR_H - -#include"HWGenerator.h" - -/** - * @brief The KLUGenerator class - * 将获取的设备信息生成设备对象,KLU笔记本下的生成器 - */ -class KLUGenerator : public HWGenerator -{ -public: - KLUGenerator(); - -protected: - - /** - * @brief getDiskInfoFromLshw:从lshw获取存储设备信息 - */ - virtual void getDiskInfoFromLshw() override; - - /**@brief:generator network info*/ - virtual void generatorNetworkDevice() override; - - /**@brief:generator network info*/ - virtual void getNetworkInfoFromCatWifiInfo(); - /**@brief:generatorMonitorDevice:生成显示设备*/ - virtual void generatorMonitorDevice(); -}; - -#endif // KLUGENERATOR_H diff --git a/deepin-devicemanager/src/GenerateDevice/KLVGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/KLVGenerator.cpp deleted file mode 100644 index cd2fae69d..000000000 --- a/deepin-devicemanager/src/GenerateDevice/KLVGenerator.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -// 项目自身文件 -#include "KLVGenerator.h" - -// Qt库文件 -#include -#include - -// 其它头文件 -#include "DeviceManager/DeviceManager.h" -#include "DeviceManager/DeviceMonitor.h" -#include "DeviceManager/DeviceNetwork.h" -#include "DeviceManager/DeviceImage.h" - -KLVGenerator::KLVGenerator() -{ - -} - -void KLVGenerator::generatorMonitorDevice() -{ - QMap mapInfo; - mapInfo.insert("Name", "LCD"); -// mapInfo.insert("Vendor", "HUAWEI"); - mapInfo.insert("CurResolution", "2160x1440@60Hz"); - mapInfo.insert("SupportResolution", "2160x1440@60Hz"); - mapInfo.insert("Size", "14 Inch"); -// mapInfo.insert("Date", "2019年7月"); - - DeviceMonitor *monitor = new DeviceMonitor(); - monitor->setInfoFromSelfDefine(mapInfo); - DeviceManager::instance()->addMonitor(monitor); - - HWGenerator::generatorMonitorDevice(); -} - -void KLVGenerator::generatorNetworkDevice() -{ - const QList> lstInfo = DeviceManager::instance()->cmdInfo("lshw_network"); - QList >::const_iterator it = lstInfo.begin(); - for (; it != lstInfo.end(); ++it) { - if ((*it).size() < 2) { - continue; - } - QMap tempMap = *it; - /* - capabilities: ethernet physical wireless - configuration: broadcast=yes ip=10.4.6.115 multicast=yes wireless=IEEE 802.11 - */ - if ((tempMap["configuration"].indexOf("wireless=IEEE 802.11") > -1) || - (tempMap["capabilities"].indexOf("wireless") > -1)) { - continue; - } - - DeviceNetwork *device = new DeviceNetwork(); - device->setInfoFromLshw(*it); - device->setCanEnale(false); - device->setCanUninstall(false); - device->setForcedDisplay(true); - DeviceManager::instance()->addNetworkDevice(device); - } - // HW 要求修改名称,制造商以及类型 - getNetworkInfoFromCatWifiInfo(); -} - -void KLVGenerator::getNetworkInfoFromCatWifiInfo() -{ - QList > lstWifiInfo; - QString wifiDevicesInfoPath("/sys/hisys/wal/wifi_devices_info"); - QFile file(wifiDevicesInfoPath); - if (file.open(QIODevice::ReadOnly)) { - QMap wifiInfo; - QString allStr = file.readAll(); - file.close(); - - // 解析数据 - QStringList items = allStr.split("\n"); - foreach (const QString &item, items) { - if (item.isEmpty()) - continue; - - QStringList strList = item.split(':', QString::SkipEmptyParts); - if (strList.size() == 2) - wifiInfo[strList[0] ] = strList[1]; - } - - if (!wifiInfo.isEmpty()) - lstWifiInfo.append(wifiInfo); - } - if (lstWifiInfo.size() == 0) { - return; - } - QList >::const_iterator it = lstWifiInfo.begin(); - - for (; it != lstWifiInfo.end(); ++it) { - if ((*it).size() < 3) { - continue; - } - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - tempMap.insert(key, (*it)[key]); - } - - // cat /sys/hisys/wal/wifi_devices_info 获取结果为 HUAWEI HI103 - if (tempMap["Chip Type"].contains("HUAWEI", Qt::CaseInsensitive)) { - tempMap["Chip Type"] = tempMap["Chip Type"].remove("HUAWEI").trimmed(); - } - - // 按照华为的需求,设置蓝牙制造商和类型 - tempMap["Vendor"] = "HISILICON"; - tempMap["Type"] = "Wireless network"; - - DeviceManager::instance()->setNetworkInfoFromWifiInfo(tempMap); - } -} - -void KLVGenerator::getDiskInfoFromLshw() -{ - QString bootdevicePath("/proc/bootdevice/product_name"); - QString modelStr = ""; - QFile file(bootdevicePath); - if (file.open(QIODevice::ReadOnly)) { - modelStr = file.readLine().simplified(); - file.close(); - } - - const QList> lstDisk = DeviceManager::instance()->cmdInfo("lshw_disk"); - QList >::const_iterator dIt = lstDisk.begin(); - for (; dIt != lstDisk.end(); ++dIt) { - if ((*dIt).size() < 2) - continue; - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*dIt).keys()) { - tempMap.insert(key, (*dIt)[key]); - } - -// qCInfo(appLog) << tempMap["product"] << " ***** " << modelStr << " " << (tempMap["product"] == modelStr); - // HW写死 - if (tempMap["product"] == modelStr) { - // 应HW的要求,将描述固定为 Universal Flash Storage - tempMap["description"] = "Universal Flash Storage"; - // 应HW的要求,添加interface UFS 3.1 - tempMap["interface"] = "UFS 3.1"; - } - - DeviceManager::instance()->addLshwinfoIntoStorageDevice(tempMap); - } -} - -void KLVGenerator::getImageInfoFromHwinfo() -{ - // 加载从hwinfo中获取的图像设备信息 - const QList> &lstMap = DeviceManager::instance()->cmdInfo("hwinfo_usb"); - QList >::const_iterator it = lstMap.begin(); - for (; it != lstMap.end(); ++it) { - if ((*it).size() < 3) - continue; - - // hwinfo中对camera的分类不明确,通过camera等关键字认定图像设备 - if (!(*it)["Model"].contains("camera", Qt::CaseInsensitive) && - !(*it)["Device"].contains("camera", Qt::CaseInsensitive) && - !(*it)["Driver"].contains("uvcvideo", Qt::CaseInsensitive) && - !(*it)["Model"].contains("webcam", Qt::CaseInsensitive) && - (*it)["Hardware Class"] != "camera") { - continue; - } - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - if ("Vendor" != key) - tempMap.insert(key, (*it)[key]); - } - - // 判断该摄像头是否存在,被禁用的和被拔出 - QString path = pciPath(tempMap); - if (path.contains("usb")) { - // 判断authorized是否存在,不存在则直接返回 - if (!QFile::exists("/sys" + path + "/authorized")) { - continue; - } - } - - // 判断重复设备数据 - QString unique_id = uniqueID(tempMap); - DeviceImage *device = dynamic_cast(DeviceManager::instance()->getImageDevice(unique_id)); - if (device) { - device->setEnableValue(false); - device->setInfoFromHwinfo(tempMap); - continue; - } else { - if (tempMap.contains("path")) { - continue; - } - } - - device = new DeviceImage(); - device->setInfoFromHwinfo(tempMap); - DeviceManager::instance()->addImageDevice(device); - addBusIDFromHwinfo(tempMap["SysFS BusID"]); - } -} - -void KLVGenerator::getImageInfoFromLshw() -{ - // 加载从lshw中获取的图像设备信息 - const QList> &lstMap = DeviceManager::instance()->cmdInfo("lshw_usb"); - QList >::const_iterator it = lstMap.begin(); - for (; it != lstMap.end(); ++it) { - if ((*it).size() < 2) - continue; - - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - if ("vendor" != key) - tempMap.insert(key, (*it)[key]); - } - - DeviceManager::instance()->setCameraInfoFromLshw(tempMap); - } -} - diff --git a/deepin-devicemanager/src/GenerateDevice/KLVGenerator.h b/deepin-devicemanager/src/GenerateDevice/KLVGenerator.h deleted file mode 100644 index 2338d8c4e..000000000 --- a/deepin-devicemanager/src/GenerateDevice/KLVGenerator.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef KLVGENERATOR_H -#define KLVGENERATOR_H - -#include"HWGenerator.h" - -/** - * @brief The KLVGenerator class - * 将获取的设备信息生成设备对象,KLU笔记本下的生成器 - */ -class KLVGenerator : public HWGenerator -{ -public: - KLVGenerator(); - -protected: - /** - * @brief generatorMonitorDevice:生成显示设备 - */ - virtual void generatorMonitorDevice() override; - - /**@brief:generator network info*/ - virtual void generatorNetworkDevice() override; - -protected: - /**@brief:generator network info*/ - virtual void getNetworkInfoFromCatWifiInfo(); - - /** - * @brief getDiskInfoFromLshw:从lshw获取存储设备信息 - */ - virtual void getDiskInfoFromLshw() override; - - /** - * @brief getImageInfoFromHwinfo:从hwinfo中获取图像设备信息 - */ - virtual void getImageInfoFromHwinfo() override; - - /** - * @brief getImageInfoFromLshw:从lshw中获取图像设备信息 - */ - virtual void getImageInfoFromLshw() override; -}; - -#endif // KLVGENERATOR_H diff --git a/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h b/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h index 051468d94..440f285b0 100644 --- a/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h +++ b/deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h @@ -16,7 +16,7 @@ class LoadInfoThread : public QThread Q_OBJECT public: LoadInfoThread(); - ~LoadInfoThread(); + ~LoadInfoThread() override; /** * @brief setFramework:设置架构 diff --git a/deepin-devicemanager/src/GenerateDevice/PanguGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/PanguGenerator.cpp deleted file mode 100644 index 3b226dc52..000000000 --- a/deepin-devicemanager/src/GenerateDevice/PanguGenerator.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -// 项目自身文件 -#include "PanguGenerator.h" - -// 其它头文件 -#include "../DeviceManager/DeviceManager.h" -#include "../DeviceManager/DeviceComputer.h" - -PanguGenerator::PanguGenerator() -{ - -} - -void PanguGenerator::generatorComputerDevice() -{ - const QList > &cmdInfo = DeviceManager::instance()->cmdInfo("cat_os_release"); - - DeviceComputer *device = new DeviceComputer(); - - // home url - if (cmdInfo.size() > 0) { - QString value = cmdInfo[0]["HOME_URL"]; - device->setHomeUrl(value.replace("\"", "")); - } - - // name type - const QList > &dmidecode1List = DeviceManager::instance()->cmdInfo("dmidecode1"); - const QList > &dmidecode2List = DeviceManager::instance()->cmdInfo("dmidecode2"); - const QList > &dmidecode3List = DeviceManager::instance()->cmdInfo("dmidecode3"); - - if (dmidecode1List.size() > 1) { - device->setVendor(dmidecode1List[1]["Manufacturer"], dmidecode2List[0]["Manufacturer"]); - device->setName(dmidecode1List[1]["Product Name"], dmidecode2List[0]["Product Name"], dmidecode1List[1]["Family"], dmidecode1List[1]["Version"]); - } - - if (dmidecode3List.size() > 1) { - device->setType(dmidecode3List[1]["Type"]); - } - - // setOsDescription - QString os = "UOS"; - DSysInfo::DeepinType type = DSysInfo::deepinType(); - if (DSysInfo::DeepinProfessional == type) - os = "UOS 20"; - else if (DSysInfo::DeepinPersonal == type) - os = "UOS 20 Home"; - else if (DSysInfo::DeepinDesktop == type) - os = "Deepin 20 Beta"; - - device->setOsDescription(os); - - // os - const QList > &verInfo = DeviceManager::instance()->cmdInfo("cat_version"); - if (verInfo.size() > 0) { - QString info = verInfo[0]["OS"].trimmed(); - info = info.trimmed(); - QRegExp reg("\\(gcc [\\s\\S]*(\\([\\s\\S]*\\))\\)", Qt::CaseSensitive); - int index = reg.indexIn(info); - if (index != -1) { - QString tmp = reg.cap(0); - info.remove(tmp); - info.insert(index, reg.cap(1)); - } - - reg.setPattern("(\\(root.*\\)) (\\(.*\\))"); - index = reg.indexIn(info); - if (index != -1) { - QString tmp = reg.cap(1); - info.remove(tmp); - } - - info.remove("version"); - device->setOS(info); - } - - DeviceManager::instance()->addComputerDevice(device); -} diff --git a/deepin-devicemanager/src/GenerateDevice/PanguGenerator.h b/deepin-devicemanager/src/GenerateDevice/PanguGenerator.h deleted file mode 100644 index 791f2c7fd..000000000 --- a/deepin-devicemanager/src/GenerateDevice/PanguGenerator.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef PANGUGENERATOR_H -#define PANGUGENERATOR_H -#include"DeviceGenerator.h" - -/** - * @brief The PanguGenerator class - * 将获取的设备信息生成设备对象,pangu下的生成器 - */ - -class PanguGenerator : public DeviceGenerator -{ -public: - PanguGenerator(); - - /** - * @brief generatorComputerDevice:生成概况设备信息 - */ - virtual void generatorComputerDevice() override; -}; - -#endif // PANGUGENERATOR_H diff --git a/deepin-devicemanager/src/GenerateDevice/PanguVGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/PanguVGenerator.cpp deleted file mode 100644 index c8c6bc34b..000000000 --- a/deepin-devicemanager/src/GenerateDevice/PanguVGenerator.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -// 项目自身文件 -#include "PanguVGenerator.h" - -// 其它头文件 -#include "../DeviceManager/DeviceManager.h" -#include "../DeviceManager/DeviceMonitor.h" -#include "EDIDParser.h" -#include "DeviceManager/DeviceNetwork.h" -#include - -PanguVGenerator::PanguVGenerator() -{ - -} - -void parseEDID(QStringList allEDIDS,QString input) -{ - for (auto edid:allEDIDS) { - QProcess process; - process.start(QString("hexdump %1").arg(edid)); - process.waitForFinished(-1); - - QString deviceInfo = process.readAllStandardOutput(); - if(deviceInfo.isEmpty()) - continue; - - QString edidStr; - QStringList lines = deviceInfo.split("\n"); - for (auto line:lines) { - QStringList words = line.trimmed().split(" "); - if(words.size() != 9) - continue; - - words.removeAt(0); - QString l = words.join(""); - l.append("\n"); - edidStr.append(l); - } - - lines = edidStr.split("\n"); - if(lines.size() > 3){ - EDIDParser edidParser; - QString errorMsg; - edidParser.setEdid(edidStr,errorMsg,"\n", false); - - QMap mapInfo; - mapInfo.insert("Vendor",edidParser.vendor()); - mapInfo.insert("Date",edidParser.releaseDate()); - mapInfo.insert("Size",edidParser.screenSize()); - mapInfo.insert("Display Input",input); - - DeviceMonitor *device = new DeviceMonitor(); - device->setInfoFromEdid(mapInfo); - DeviceManager::instance()->addMonitor(device); - } - } -} - -void PanguVGenerator::generatorMonitorDevice() -{ - QStringList allEDIDS1; - allEDIDS1.append("/sys/devices/platform/hisi-drm/drm/card0/card0-HDMI-A-1/edid"); - allEDIDS1.append("/sys/devices/platform/hldrm/drm/card0/card0-HDMI-A-1/edid"); - parseEDID(allEDIDS1,"HDMI-A-1"); - - QStringList allEDIDS2; - allEDIDS2.append("/sys/devices/platform/hisi-drm/drm/card0/card0-VGA-1/edid"); - allEDIDS2.append("/sys/devices/platform/hldrm/drm/card0/card0-VGA-1/edid"); - parseEDID(allEDIDS2,"VGA-1"); -} - -void PanguVGenerator::generatorNetworkDevice() -{ - QStringList ifconfigCardName = getNetworkInfoFromifconfig(); - const QList> lstInfo = DeviceManager::instance()->cmdInfo("lshw_network"); - QList >::const_iterator it = lstInfo.begin(); - for (; it != lstInfo.end(); ++it) { - if ((*it).size() < 2) { - continue; - } - QMap tempMap = *it; - /* - capabilities: ethernet physical wireless - configuration: broadcast=yes ip=10.4.6.115 multicast=yes wireless=IEEE 802.11 - */ -// if ((tempMap["configuration"].indexOf("wireless=IEEE 802.11") > -1) || -// (tempMap["capabilities"].indexOf("wireless") > -1)) { -// continue; -// } - - QString logicalName = tempMap["logical name"].trimmed(); - if(! ifconfigCardName.contains(logicalName)) - continue; - - DeviceNetwork *device = new DeviceNetwork(); - device->setInfoFromLshw(*it); - device->setCanEnale(false); - device->setCanUninstall(false); - device->setForcedDisplay(true); - DeviceManager::instance()->addNetworkDevice(device); - } - - -} - -QStringList PanguVGenerator::getNetworkInfoFromifconfig() -{ - //通过ifconfig 判断网络是否valiate - QStringList ret; - QProcess process; - QString cmd = "ifconfig -s"; - process.start(cmd); - QString ifconfigInfo; - bool re = process.waitForFinished(-1); - if (!re) - return ret; - ifconfigInfo = process.readAllStandardOutput(); - //截取查询到的各个网卡连接信息 - QStringList list = ifconfigInfo.split("\n"); - for (int i = 1; i < list.size(); i++) { //skip Iface - //filter "lo" 网卡 - if (list.at(i).contains("lo")) - continue; - - QStringList line = list.at(i).split(" ", QString::SkipEmptyParts); - { - if(line.size() < 2) - continue; - if(line.at(0).isEmpty()) - continue; - else - ret.append(line.at(0)); - } - } - return ret; -} diff --git a/deepin-devicemanager/src/GenerateDevice/PanguVGenerator.h b/deepin-devicemanager/src/GenerateDevice/PanguVGenerator.h deleted file mode 100644 index 4532cf6d9..000000000 --- a/deepin-devicemanager/src/GenerateDevice/PanguVGenerator.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef PANGUVGENERATOR_H -#define PANGUVGENERATOR_H - -#include -#include "HWGenerator.h" - -/** - * @brief The PanguVGenerator class - * 将获取的设备信息生成设备对象,panguV下的生成器 - */ - -class PanguVGenerator : public HWGenerator -{ -public: - PanguVGenerator(); - - /** - * @brief generatorMonitorDevice:生成显示设备信息 - */ - virtual void generatorMonitorDevice() override; -protected: - /**@brief:generator network info*/ - virtual void generatorNetworkDevice() override; - /**@brief:generator network info*/ - virtual QStringList getNetworkInfoFromifconfig(); -}; - -#endif // PANGUVGENERATOR_H diff --git a/deepin-devicemanager/src/GenerateDevice/PanguxGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/PanguxGenerator.cpp deleted file mode 100644 index d34bcdc09..000000000 --- a/deepin-devicemanager/src/GenerateDevice/PanguxGenerator.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -// 项目自身文件 -#include "PanguxGenerator.h" - -// 其它头文件 - -#include "../DeviceManager/DeviceAudio.h" -#include "../DeviceManager/DeviceBluetooth.h" -#include "DeviceManager/DeviceManager.h" - -PanguXGenerator::PanguXGenerator() -{ - -} - -void PanguXGenerator::getAudioInfoFromCatAudio() -{ - QMap tempMap; - tempMap["Name"] = "OnBoard Audio"; - tempMap["Vendor"]= "HUAWEI"; - DeviceAudio *device = new DeviceAudio(); - device->setCanEnale(false); - device->setCanUninstall(false); - device->setForcedDisplay(true); - device->setInfoFromCatAudio(tempMap); - DeviceManager::instance()->addAudioDevice(device); - - getAudioInfoFromHwinfo(); -} - -void PanguXGenerator::generatorBluetoothDevice() -{ - DeviceBluetooth *device0 = new DeviceBluetooth(); - QMap tempMap; - tempMap["Vendor"] = "HISILICON"; - tempMap["Name"] = "Hi1105C"; - tempMap["Model"] = "Hi1105C"; - device0->setCanEnale(false); - device0->setForcedDisplay(true); - device0->setInfoFromTomlOneByOne(tempMap); - DeviceManager::instance()->addBluetoothDevice(device0); - - const QList > lstMap = DeviceManager::instance()->cmdInfo("hwinfo_usb"); - QList >::const_iterator it = lstMap.begin(); - for (; it != lstMap.end(); ++it) { - if ((*it).size() < 1) { - continue; - } - if ((*it)["Hardware Class"] == "hub" || (*it)["Hardware Class"] == "mouse" || (*it)["Hardware Class"] == "keyboard") { - continue; - } - if ((*it)["Hardware Class"] == "bluetooth" || (*it)["Driver"] == "btusb" || (*it)["Device"] == "BCM20702A0"|| (*it)["Device"].contains("bluetooth", Qt::CaseInsensitive)) { - DeviceBluetooth *device = new DeviceBluetooth(); - device->setCanEnale(false); - device->setForcedDisplay(true); - device->setInfoFromHwinfo(*it); - DeviceManager::instance()->addBluetoothDevice(device); - - addBusIDFromHwinfo((*it)["SysFS BusID"]); - } - } -} -void PanguXGenerator::generatorCpuDevice() -{ - HWGenerator::generatorCpuDevice(); - - QFile file("/proc/cpuinfo"); - if (!file.open(QIODevice::ReadOnly)) - return; - - QMap mapInfo; - QString cpuInfo = file.readAll(); - QStringList infos = cpuInfo.split("\n\n"); - foreach (const QString &info, infos) { - if (info.isEmpty()) - continue; - - QStringList lines = info.split("\n"); - foreach (const QString &line, lines) { - if (line.isEmpty()) - continue; - QStringList words = line.split(QRegExp("[\\s]*:[\\s]*")); - if (words.size() != 2) - continue; - if ("Hardware" == words[0]) { - mapInfo.insert("Name", words[1]); - } - } - } - file.close(); - if (mapInfo.find("Name") == mapInfo.end()) - return; - - QList lst = DeviceManager::instance()->convertDeviceList(DT_Cpu); - for (int i = 0; i < lst.size(); i++) { - DeviceBaseInfo *device = lst[i]; - DeviceManager::instance()->tomlDeviceSet(DT_Cpu, device,mapInfo); - } -} diff --git a/deepin-devicemanager/src/GenerateDevice/PanguxGenerator.h b/deepin-devicemanager/src/GenerateDevice/PanguxGenerator.h deleted file mode 100644 index 4bd2e56b0..000000000 --- a/deepin-devicemanager/src/GenerateDevice/PanguxGenerator.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2019 ~ 2024 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef PANGUXGENERATOR_H -#define PANGUXGENERATOR_H - -#include "HWGenerator.h" - -/** - * @brief The PanguXGenerator class - * 将获取的设备信息生成设备对象,panguX下的生成器 - */ - -class PanguXGenerator : public HWGenerator -{ -public: - PanguXGenerator(); - -protected: - /** - * @brief generatorAudioDevice:生成音频适配器 - */ - virtual void getAudioInfoFromCatAudio() override; - /** - * @brief generatorBluetoothDevice:生成蓝牙设备 - */ - virtual void generatorBluetoothDevice() override; - /** - * @brief generatorCpuDevice:生成CPU设备 - */ - virtual void generatorCpuDevice() override; -}; - -#endif // PANGUXGENERATOR_H diff --git a/deepin-devicemanager/src/MacroDefinition.h b/deepin-devicemanager/src/MacroDefinition.h index d64e1caa0..59d68b19c 100644 --- a/deepin-devicemanager/src/MacroDefinition.h +++ b/deepin-devicemanager/src/MacroDefinition.h @@ -43,8 +43,8 @@ foreach (auto device, deviceLst) { \ out << "\n"; \ \ - device->getBaseAttribs(); \ - device->getOtherAttribs(); \ + device->getBaseTranslationAttribs(); \ + device->getOtherTranslationAttribs(); \ /**设备数目大于1,添加子标题**/ \ if (deviceLst.size() > 1) { \ out << device->subTitle(); \ @@ -86,8 +86,8 @@ \ /**添加每个设备的信息**/ \ foreach (auto device, deviceLst) { \ - device->getBaseAttribs(); \ - device->getOtherAttribs(); \ + device->getBaseTranslationAttribs(); \ + device->getOtherTranslationAttribs(); \ \ /**设备数目大于1,添加子标题**/ \ if (deviceLst.size() > 1) { \ @@ -132,8 +132,8 @@ /**添加每个设备的信息**/ \ foreach (auto device, deviceLst) { \ \ - device->getBaseAttribs(); \ - device->getOtherAttribs(); \ + device->getBaseTranslationAttribs(); \ + device->getOtherTranslationAttribs(); \ /**设备数目大于1,添加子标题**/ \ if (deviceLst.size() > 1) { \ doc.addParagraph(device->subTitle()); \ @@ -177,8 +177,8 @@ foreach (auto device, deviceLst) { \ QDomDocument doc; \ \ - device->getBaseAttribs(); \ - device->getOtherAttribs(); \ + device->getBaseTranslationAttribs(); \ + device->getOtherTranslationAttribs(); \ /**设备数目大于1,添加子标题**/ \ if (deviceLst.size() > 1) { \ device->subTitleToHTML(doc); \ diff --git a/deepin-devicemanager/src/Page/DeviceWidget.h b/deepin-devicemanager/src/Page/DeviceWidget.h index 4a79f5c26..586cf400f 100644 --- a/deepin-devicemanager/src/Page/DeviceWidget.h +++ b/deepin-devicemanager/src/Page/DeviceWidget.h @@ -26,7 +26,7 @@ class DeviceWidget : public DWidget Q_OBJECT public: explicit DeviceWidget(QWidget *parent = nullptr); - ~DeviceWidget(); + ~DeviceWidget() override; /** * @brief updateListView:更新ListView diff --git a/deepin-devicemanager/src/Page/MainWindow.cpp b/deepin-devicemanager/src/Page/MainWindow.cpp index b1ed0d939..3249cc747 100644 --- a/deepin-devicemanager/src/Page/MainWindow.cpp +++ b/deepin-devicemanager/src/Page/MainWindow.cpp @@ -43,6 +43,7 @@ #include #include #include +#include DWIDGET_USE_NAMESPACE using namespace DDLog; @@ -427,6 +428,12 @@ void MainWindow::initWindowTitle() Common::specialComType = dconfig->value("specialComType").toInt(); } qCInfo(appLog) << "Common::specialComType value is:" << Common::specialComType; + + if (dconfig && dconfig->isValid() && dconfig->keyList().contains("TomlFilesName")) { + QString tomlFilesName = dconfig->value("TomlFilesName").toString(); + Common::tomlFilesNameSet(tomlFilesName); + } + #endif // 特殊处理 if (!Common::boardVendorType().isEmpty()) @@ -467,7 +474,7 @@ void MainWindow::refreshDataBase() } } -void MainWindow::slotSetPage(QString page) +void MainWindow::slotSetPage(const QString &page) { if ("driver" == page) { if (m_IsFirstRefresh) { @@ -515,6 +522,17 @@ void MainWindow::slotLoadingFinish(const QString &message) if (ret && lst.size() > 0) {//当设备大小为0时,显示概况信息 mp_DeviceWidget->updateDevice(mp_DeviceWidget->currentIndex(), lst); + + // bug-325731 + if (Common::specialComType <= 0) { + if (mp_DeviceWidget->currentIndex() == QObject::tr("Monitor")) { + QtConcurrent::run([=](){ + QThread::msleep(700); + emit mp_DeviceWidget->itemClicked(mp_DeviceWidget->currentIndex()); + qWarning() << mp_DeviceWidget->currentIndex(); + }); + } + } } else { QMap overviewMap = DeviceManager::instance()->getDeviceOverview(); mp_DeviceWidget->updateOverview(overviewMap); diff --git a/deepin-devicemanager/src/Page/MainWindow.h b/deepin-devicemanager/src/Page/MainWindow.h index 2dcd93f72..6a60c8fd7 100644 --- a/deepin-devicemanager/src/Page/MainWindow.h +++ b/deepin-devicemanager/src/Page/MainWindow.h @@ -134,7 +134,7 @@ private slots: * @brief slotSetPage * @param page */ - void slotSetPage(QString page); + void slotSetPage(const QString &page); /** * @brief loadingFinishSlot:加载设备信息结束 槽 diff --git a/deepin-devicemanager/src/Page/PageBoardInfo.cpp b/deepin-devicemanager/src/Page/PageBoardInfo.cpp index 93bf7f079..662476fc8 100644 --- a/deepin-devicemanager/src/Page/PageBoardInfo.cpp +++ b/deepin-devicemanager/src/Page/PageBoardInfo.cpp @@ -55,8 +55,8 @@ void PageBoardInfo::updateInfo(const QList &lst) return; // 获取主板信息并加载 - QList> baseInfoMap = board->getBaseAttribs(); - QList> otherInfoMap = board->getOtherAttribs(); + QList> baseInfoMap = board->getBaseTranslationAttribs(); + QList> otherInfoMap = board->getOtherTranslationAttribs(); baseInfoMap = baseInfoMap + otherInfoMap; loadDeviceInfo(lstOther, baseInfoMap); } @@ -157,7 +157,7 @@ void PageBoardInfo::getOtherInfoPair(const QList &lst, QList pair; - pair.first = bios->name(); + pair.first = bios->nameTr(); getValueInfo(bios, pair); lstPair.append(pair); } @@ -166,8 +166,8 @@ void PageBoardInfo::getOtherInfoPair(const QList &lst, QList &pair) { // 获取信息并保存为pair - QList> baseInfoMap = device->getBaseAttribs(); - QList> otherInfoMap = device->getOtherAttribs(); + QList> baseInfoMap = device->getBaseTranslationAttribs(); + QList> otherInfoMap = device->getOtherTranslationAttribs(); baseInfoMap = baseInfoMap + otherInfoMap; QList>::iterator it = baseInfoMap.begin(); for (; it != baseInfoMap.end(); ++it) { diff --git a/deepin-devicemanager/src/Page/PageDetail.cpp b/deepin-devicemanager/src/Page/PageDetail.cpp index eedc18af1..fe9cf4b77 100644 --- a/deepin-devicemanager/src/Page/PageDetail.cpp +++ b/deepin-devicemanager/src/Page/PageDetail.cpp @@ -199,7 +199,7 @@ void PageDetail::showDeviceInfo(const QList &lstInfo) connect(txtBrowser, &TextBrowser::refreshInfo, this, &PageDetail::refreshInfo); connect(txtBrowser, &TextBrowser::exportInfo, this, &PageDetail::exportInfo); connect(txtBrowser, &TextBrowser::copyAllInfo, this, &PageDetail::slotCopyAllInfo); - addWidgets(txtBrowser, device->enable() && device->available() && !device->getOtherAttribs().isEmpty()); + addWidgets(txtBrowser, device->enable() && device->available() && !device->getOtherTranslationAttribs().isEmpty()); // 当添加到最后一个设备详细信息时,隐藏分隔符 if (device == lstInfo.last()) m_ListDetailSeperator[lstInfo.size() - 1]->setVisible(false); diff --git a/deepin-devicemanager/src/Page/PageListView.cpp b/deepin-devicemanager/src/Page/PageListView.cpp index 17bf91cbc..ff226cdfe 100644 --- a/deepin-devicemanager/src/Page/PageListView.cpp +++ b/deepin-devicemanager/src/Page/PageListView.cpp @@ -28,7 +28,7 @@ PageListView::PageListView(DWidget *parent) hLayout->setContentsMargins(0, 0, 0, 0); setLayout(hLayout); - this->setFixedWidth(152); + this->setFixedWidth(172); // 初始化右键菜单 mp_ListView->setContextMenuPolicy(Qt::CustomContextMenu); connect(mp_ListView, SIGNAL(customContextMenuRequested(const QPoint &)), diff --git a/deepin-devicemanager/src/Page/PageMultiInfo.cpp b/deepin-devicemanager/src/Page/PageMultiInfo.cpp index 88bded31d..b0742bbaf 100644 --- a/deepin-devicemanager/src/Page/PageMultiInfo.cpp +++ b/deepin-devicemanager/src/Page/PageMultiInfo.cpp @@ -13,6 +13,7 @@ #include "DeviceInput.h" #include "DeviceNetwork.h" #include "DDLog.h" +#include "commonfunction.h" // Dtk头文件 #include @@ -87,7 +88,15 @@ void PageMultiInfo::updateInfo(const QList &lst) getTableListInfo(lst, m_deviceList, m_menuControlList); // 更新表格 + mp_Table->setVisible(true); + mp_Table->setFixedHeight(TABLE_HEIGHT); mp_Table->updateTable(m_deviceList, m_menuControlList); + if (Common::specialComType >= 1) { + if (mp_Label->text() == tr("Storage") || mp_Label->text() == tr("Memory")) { + mp_Table->setVisible(false); + mp_Table->setFixedHeight(0); + } + } // 更新详细信息 mp_Detail->showDeviceInfo(lst); @@ -122,10 +131,20 @@ void PageMultiInfo::resizeEvent(QResizeEvent *e) int curHeight = this->height(); if (curHeight < LEAST_PAGE_HEIGHT) { // 获取多个设备界面表格信息 - mp_Table->updateTable(m_deviceList, m_menuControlList, true, (LEAST_PAGE_HEIGHT - curHeight) / TREE_ROW_HEIGHT + 1); + if (Common::specialComType <= 0) { + mp_Table->updateTable(m_deviceList, m_menuControlList, true, (LEAST_PAGE_HEIGHT - curHeight) / TREE_ROW_HEIGHT + 1); + } else { + if (mp_Label->text() != tr("Storage") && mp_Label->text() != tr("Memory")) + mp_Table->updateTable(m_deviceList, m_menuControlList, true, (LEAST_PAGE_HEIGHT - curHeight) / TREE_ROW_HEIGHT + 1); + } } else { // 获取多个设备界面表格信息 - mp_Table->updateTable(m_deviceList, m_menuControlList, true, 0); + if (Common::specialComType <= 0) { + mp_Table->updateTable(m_deviceList, m_menuControlList, true, 0); + } else { + if (mp_Label->text() != tr("Storage") && mp_Label->text() != tr("Memory")) + mp_Table->updateTable(m_deviceList, m_menuControlList, true, 0); + } } return PageInfo::resizeEvent(e); @@ -260,6 +279,10 @@ void PageMultiInfo::getTableListInfo(const QList &lst, QListcanWakeupMachine() ? "true" : "false"); menuControl.append(input->wakeupPath()); + if (info->name().contains("PS/2")) { + menuControl.append(input->getBusInfo()); + menuControl.append(input->name()); + } } DeviceNetwork *network = dynamic_cast(info); diff --git a/deepin-devicemanager/src/Page/PageSingleInfo.cpp b/deepin-devicemanager/src/Page/PageSingleInfo.cpp index 1c37da152..bd4b53c10 100644 --- a/deepin-devicemanager/src/Page/PageSingleInfo.cpp +++ b/deepin-devicemanager/src/Page/PageSingleInfo.cpp @@ -102,8 +102,8 @@ void PageSingleInfo::updateInfo(const QList &lst) clearContent(); //获取设备信息 - QList> baseInfoMap = lst[0]->getBaseAttribs(); - QList> otherInfoMap = lst[0]->getOtherAttribs(); + QList> baseInfoMap = lst[0]->getBaseTranslationAttribs(); + QList> otherInfoMap = lst[0]->getOtherTranslationAttribs(); baseInfoMap = baseInfoMap + otherInfoMap; // 加载设备信息 @@ -352,7 +352,10 @@ void PageSingleInfo::slotWakeupMachine() // 键盘鼠标唤醒机器 DeviceInput *input = qobject_cast(mp_Device); if (input && !input->wakeupID().isEmpty() && !input->sysPath().isEmpty()) { - DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(), input->sysPath(), mp_WakeupMachine->isChecked(), input->name()); + DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(), + input->sysPath(), + mp_WakeupMachine->isChecked(), + input->getInterface()); } // 网卡的远程唤醒 diff --git a/deepin-devicemanager/src/Tool/EDIDParser.cpp b/deepin-devicemanager/src/Tool/EDIDParser.cpp index 26dd3ea5e..634488ef3 100644 --- a/deepin-devicemanager/src/Tool/EDIDParser.cpp +++ b/deepin-devicemanager/src/Tool/EDIDParser.cpp @@ -78,7 +78,8 @@ bool EDIDParser::setEdid(const QString &edid, QString &errorMsg, const QString & parseReleaseDate(); // 解析屏幕尺寸 parseScreenSize(); - + // 解析监视器名称 + parseMonitorName(); return true; } @@ -103,6 +104,11 @@ const QString &EDIDParser::screenSize()const return m_ScreenSize; } +const QString &EDIDParser::monitorName() const +{ + return m_MonitorName; +} + int EDIDParser::width() { return m_Width; @@ -191,8 +197,86 @@ void EDIDParser::parseScreenSize() m_Height = height16; } + QString s66 = getBytes(4, m_LittleEndianMode ? 2 : 3), + s67 = getBytes(4, m_LittleEndianMode ? 3 : 2), + s68 = getBytes(4, m_LittleEndianMode ? 4 : 5); + + if (!s66.isEmpty() && !s67.isEmpty() && !s68.isEmpty()) { + int width_mm = hexToDec(s66).toInt() + ((hexToDec(s68).toInt() & 0xF0) << 4); + int height_mm = hexToDec(s67).toInt() + ((hexToDec(s68).toInt() & 0x0F) << 8); + + if (width_mm > 0 && height_mm > 0) { + m_Width = width_mm; + m_Height = height_mm; + } + } + + if (Common::specialComType == 7){ // sepcial task:378963 + m_Width = 296; + m_Height = 197; + } double inch = sqrt((m_Width / 2.54) * (m_Width / 2.54) + (m_Height / 2.54) * (m_Height / 2.54))/10; - m_ScreenSize = QString("%1 %2(%3mm X %4mm)").arg(QString::number(inch, '0', 1)).arg(QObject::tr("inch")).arg(m_Width).arg(m_Height); + m_ScreenSize = QString("%1 %2(%3mm×%4mm)").arg(QString::number(inch, '0', Common::specialComType == 7 ? 0 : 1)).arg(QObject::tr("inch")).arg(m_Width).arg(m_Height); +} + +void EDIDParser::parseMonitorName() +{ + // EDID中从字节54开始有4个18字节的Descriptor Block + // 每个Descriptor Block可能包含显示器名称信息 + // 显示器名称的标识符是0xFC(Display Product Name) 注意:部分机型有一些特殊,标识符为0xFE + + // 4个Descriptor Block的起始字节位置 + int descriptorStarts[4] = {54, 72, 90, 108}; + + for (int i = 0; i < 4; i++) { + int startByte = descriptorStarts[i]; + + // 计算行号和字节位置(每行16字节) + int line = startByte / 16; + int byteInLine = startByte % 16; + + // 获取Descriptor Block的关键字节 + QString byte0 = getBytes(line, byteInLine); // 第0字节 + QString byte1 = getBytes(line, byteInLine + 1); // 第1字节 + QString byte3 = getBytes(line, byteInLine + 3); // 第3字节(类型标识) + + // 检查是否为Display Descriptor (字节0-1为0x0000) 且类型为Display Product Name (字节3为0xFC) + if (byte0.toUpper() == "00" && byte1.toUpper() == "00" && (byte3.toUpper() == "FC" || byte3.toUpper() == "FE")) { + + // 找到显示器名称描述符,提取ASCII字符串(字节5-17) + QString monitorName; + + for (int j = 5; j <= 17; j++) { + int currentByte = startByte + j; + int currentLine = currentByte / 16; + int currentByteInLine = currentByte % 16; + + QString charByte = getBytes(currentLine, currentByteInLine); + + if (!charByte.isEmpty()) { + int asciiValue = hexToDec(charByte).toInt(); + + // ASCII可打印字符范围:32-126,0x0A为换行符,0x00为结束符 + if (asciiValue == 0x00 || asciiValue == 0x0A) { + break; // 遇到结束符或换行符,停止解析 + } else if (asciiValue >= 32 && asciiValue <= 126) { + monitorName.append(QChar(asciiValue)); + } + } + } + + // 去除首尾空白字符 + m_MonitorName = monitorName.trimmed(); + + // 如果找到有效的监视器名称,记录日志并返回 + if (!m_MonitorName.isEmpty()) + return; + } + } + + // 如果没有找到有效的监视器名称,设置默认值 + if (m_MonitorName.isEmpty()) + m_MonitorName = "Unknown Monitor"; } QString EDIDParser::binToDec(QString strBin) //二进制转十进制 diff --git a/deepin-devicemanager/src/Tool/EDIDParser.h b/deepin-devicemanager/src/Tool/EDIDParser.h index cdee3cee3..abc538d15 100644 --- a/deepin-devicemanager/src/Tool/EDIDParser.h +++ b/deepin-devicemanager/src/Tool/EDIDParser.h @@ -8,7 +8,7 @@ #include #include #include - +#include /** * @brief The EDIDParser class * 用于解析edid的类 @@ -52,6 +52,12 @@ class EDIDParser */ const QString &screenSize()const; + /** + * @brief screenSize:获取监视器名称 + * @return 监视器名称 + */ + const QString &monitorName()const; + /** * @brief width : get screen width * @return @@ -81,6 +87,11 @@ class EDIDParser */ void parseScreenSize(); + /** + * @brief parseScreenSize:从edid中获取监视器名称 + */ + void parseMonitorName(); + /** * @brief binToDec:将二进制转换成十进制 * @param strBin:二进制字符串 @@ -140,6 +151,7 @@ class EDIDParser QString m_Model; // 显示屏的型号信息 QString m_ReleaseDate; // 显示屏的生产日期 QString m_ScreenSize; // 屏幕大小 + QString m_MonitorName; // 监视器名称 bool m_LittleEndianMode; // 小端模式 int m_Width; // width int m_Height; // heigth diff --git a/deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp b/deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp index be53c4f8f..5d06b5f74 100644 --- a/deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp +++ b/deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp @@ -78,7 +78,7 @@ void ThreadExecXrandr::loadXrandrInfo(QList> &lstMap, con QRegExp re(".*([0-9]{1,5}\\sx\\s[0-9]{1,5}).*([0-9]{1,5}\\sx\\s[0-9]{1,5}).*([0-9]{1,5}\\sx\\s[0-9]{1,5}).*"); if (re.exactMatch(line)) { lstMap[lstMap.count() - 1].insert("minResolution", re.cap(1)); - lstMap[lstMap.count() - 1].insert("curResolution", re.cap(2)); + lstMap[lstMap.count() - 1].insert("curResolution", re.cap(2).replace(" ", "").replace("x", "×", Qt::CaseInsensitive)); lstMap[lstMap.count() - 1].insert("maxResolution", re.cap(3)); } continue; @@ -104,6 +104,8 @@ void ThreadExecXrandr::loadXrandrVerboseInfo(QList> &lstM { QString deviceInfo; runCmd(deviceInfo, cmd); + QString xrandInfo; + runCmd(xrandInfo, "xrandr"); QStringList lines = deviceInfo.split("\n"); QStringList::iterator it = lines.begin(); @@ -116,7 +118,12 @@ void ThreadExecXrandr::loadXrandrVerboseInfo(QList> &lstM if (reg.exactMatch(*it) && !(*it).contains("disconnected")) { // 新的显示屏 QMap newMap; - newMap.insert("mainInfo", (*it).trimmed()); + newMap.insert("mainInfo", (*it).trimmed()); + auto mainInfoList = (*it).trimmed().split(" "); + if (mainInfoList.size() > 0) { + newMap.insert("port", mainInfoList.at(0)); + newMap.insert("xrandr", xrandInfo); + } lstMap.append(newMap); continue; } @@ -145,7 +152,7 @@ void ThreadExecXrandr::loadXrandrVerboseInfo(QList> &lstM if ((*it).contains("*current")) { if ((it += 2) >= lines.end()) return; - QRegExp regRate(".*([0-9]{1,5}\\.[0-9]{1,5}Hz).*"); + QRegExp regRate(".*([0-9]{1,5}\\.[0-9]{1,5}Hz).*"); if (regRate.exactMatch(*it)) last.insert("rate", regRate.cap(1)); } @@ -231,13 +238,18 @@ void ThreadExecXrandr::getMonitorInfoFromXrandrVerbose() { QList> lstMap; loadXrandrVerboseInfo(lstMap, "xrandr --verbose"); - + std::sort(lstMap.begin(), lstMap.end(), [](const QMap &monintor1, const QMap &monintor2) { + if (monintor1.contains("port") && monintor2.contains("port")) + return monintor1.value("port") < monintor2.value("port"); + else + return false; + }); QList >::const_iterator it = lstMap.begin(); for (; it != lstMap.end(); ++it) { if ((*it).size() < 1) continue; - DeviceManager::instance()->setMonitorInfoFromXrandr((*it)["mainInfo"], (*it)["edid"], (*it)["rate"]); + DeviceManager::instance()->setMonitorInfoFromXrandr((*it)["mainInfo"], (*it)["edid"], (*it)["rate"], (*it)["xrandr"]); } } @@ -328,8 +340,8 @@ void ThreadExecXrandr::getResolutionFromDBus(QMap &lstMap) } if (maxResolutionWidth != -1) { - lstMap.insert("maxResolution", QString("%1 x %2").arg(maxResolutionWidth).arg(maxResolutionHeight)); - lstMap.insert("minResolution", QString("%1 x %2").arg(minResolutionWidth).arg(minResolutionHeight)); + lstMap.insert("maxResolution", QString("%1×%2").arg(maxResolutionWidth).arg(maxResolutionHeight)); + lstMap.insert("minResolution", QString("%1×%2").arg(minResolutionWidth).arg(minResolutionHeight)); } } @@ -407,7 +419,7 @@ void ThreadExecXrandr::getResolutionRateFromDBus(QList > curResolutionHeight = resolution.height; resRate = resolution.refreshRate; QMapinfoMap; - QString tmpS = QString("%1 x %2 @").arg(curResolutionWidth).arg(curResolutionHeight) + QString::number(resRate, 'f', 2); + QString tmpS = QString("%1×%2@").arg(curResolutionWidth).arg(curResolutionHeight) + QString::number(resRate, 'f', 2); infoMap.insert("CurResolution", tmpS + "Hz"); infoMap.insert("Name", tname.toString()); infoMap.insert("Display Input", tname.toString()); diff --git a/deepin-devicemanager/src/Tool/commontools.cpp b/deepin-devicemanager/src/Tool/commontools.cpp index 8b29bea71..dcebeec70 100644 --- a/deepin-devicemanager/src/Tool/commontools.cpp +++ b/deepin-devicemanager/src/Tool/commontools.cpp @@ -4,6 +4,8 @@ #include "commontools.h" #include "DDLog.h" +#include "EDIDParser.h" +#include "DeviceMonitor.h" #include #include @@ -11,6 +13,8 @@ #include #include #include +#include +#include DWIDGET_USE_NAMESPACE using namespace DDLog; @@ -162,3 +166,94 @@ QString CommonTools::getBackupPath() { return "/usr/share/deepin-devicemanager/"; } + +void CommonTools::parseEDID(const QStringList &allEDIDS, const QString &input, bool isHW) +{ + for (auto edid:allEDIDS) { + QString edidStr; + if (isHW) { + QProcess process; + process.start(QString("hexdump %1").arg(edid)); + process.waitForFinished(-1); + + QString deviceInfo = process.readAllStandardOutput(); + if (deviceInfo.isEmpty()) + continue; + + QStringList lines = deviceInfo.split("\n"); + for (auto line:lines) { + QStringList words = line.trimmed().split(" "); + if (words.size() != 9) + continue; + + words.removeAt(0); + QString l = words.join(""); + l.append("\n"); + edidStr.append(l); + } + } else { + QProcess process; + process.start(QString("hexdump -C %1").arg(edid)); + process.waitForFinished(-1); + QString deviceInfo = process.readAllStandardOutput(); + if (deviceInfo.isEmpty()) + continue; + + QStringList lines = deviceInfo.split("\n"); + for (auto line: lines) { + if (line.trimmed().isEmpty()) + continue; + int firstSpace = line.indexOf(" "); + int lastPipe = line.indexOf("|"); + + if (firstSpace == -1 || lastPipe == -1 || firstSpace >= lastPipe) + continue; + + QString hexPart = line.mid(firstSpace + 2, lastPipe - firstSpace -3).trimmed(); + + QStringList hexBytes = hexPart.split(QRegExp("\\s+")); + + QString lineData; + for (const QString &hexByte : hexBytes) { + if (hexByte.length() == 2 && hexByte != "") + lineData.append(hexByte); + } + + if (lineData.length() == 32) + edidStr.append(lineData + "\n"); + } + } + + QStringList lines = edidStr.split("\n"); + if (lines.size() > 3){ + EDIDParser edidParser; + QString errorMsg; + edidParser.setEdid(edidStr,errorMsg,"\n", isHW ? false : true); + + QMap mapInfo; + mapInfo.insert("Vendor",edidParser.vendor()); + if (isHW) + mapInfo.insert("Model",edidParser.model()); + else + mapInfo.insert("Model",edidParser.monitorName()); + mapInfo.insert("Size",edidParser.screenSize()); + mapInfo.insert("Display Input",input); + + DeviceMonitor *device = new DeviceMonitor(); + if (isHW) + device->setInfoFromEdid(mapInfo); + else + device->setInfoFromEdidForCustom(mapInfo); + DeviceManager::instance()->addMonitor(device); + } + } +} + +QString CommonTools::getGpuInfoCommandFromDConfig() +{ + QString cmd; + DConfig *dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager"); + if (dconfig && dconfig->isValid() && dconfig->keyList().contains("CommandToGetGPUInfo")) + cmd = dconfig->value("CommandToGetGPUInfo").toString(); + return cmd; +} diff --git a/deepin-devicemanager/src/Tool/commontools.h b/deepin-devicemanager/src/Tool/commontools.h index 6948c8f68..96ec149a5 100644 --- a/deepin-devicemanager/src/Tool/commontools.h +++ b/deepin-devicemanager/src/Tool/commontools.h @@ -78,6 +78,9 @@ class CommonTools : public QObject */ static QString getBackupPath(); + static void parseEDID(const QStringList &allEDIDS, const QString &input, bool isHW = true); + static QString getGpuInfoCommandFromDConfig(); + signals: public slots: diff --git a/deepin-devicemanager/src/Widget/TableWidget.cpp b/deepin-devicemanager/src/Widget/TableWidget.cpp index 33043fdb5..c9dd8a628 100644 --- a/deepin-devicemanager/src/Widget/TableWidget.cpp +++ b/deepin-devicemanager/src/Widget/TableWidget.cpp @@ -280,10 +280,18 @@ void TableWidget::slotShowMenu(const QPoint &point) bool isWakeup = false; if(file.open(QIODevice::ReadOnly)){ QString info = file.readAll(); - if(info.contains("disabled")) - isWakeup = false; - else - isWakeup = true; + if (wakeupPath.contains("/proc/acpi/wakeup")) { + bool wakedUp = DBusWakeupInterface::getInstance()->isInputWakeupMachine(item->data(Qt::UserRole+4).toString(), + item->data(Qt::UserRole+5).toString()); + isWakeup = wakedUp; + } else { + if(info.contains("disabled")) { + isWakeup = false; + } + else { + isWakeup = true; + } + } } mp_WakeupMachine->setChecked(isWakeup); }else{ diff --git a/deepin-devicemanager/src/Widget/TextBrowser.cpp b/deepin-devicemanager/src/Widget/TextBrowser.cpp index e2749fc63..c63f47ba6 100644 --- a/deepin-devicemanager/src/Widget/TextBrowser.cpp +++ b/deepin-devicemanager/src/Widget/TextBrowser.cpp @@ -62,7 +62,7 @@ void TextBrowser::showDeviceInfo(DeviceBaseInfo *info) // 添加一个表格 if (mp_Info->enable() && mp_Info->available()) { - const QList> &baseInfo = info->getBaseAttribs(); + const QList> &baseInfo = info->getBaseTranslationAttribs(); domTableInfo(doc, baseInfo); } @@ -87,10 +87,10 @@ void TextBrowser::updateInfo() // 添加一个表格 if (mp_Info->enable() && mp_Info->available()) { - const QList> &baseInfo = mp_Info->getBaseAttribs(); + const QList> &baseInfo = mp_Info->getBaseTranslationAttribs(); domTableInfo(doc, baseInfo); if (m_ShowOtherInfo) { - const QList> &otherInfo = mp_Info->getOtherAttribs(); + const QList> &otherInfo = mp_Info->getOtherTranslationAttribs(); domTableInfo(doc, otherInfo); } } diff --git a/deepin-devicemanager/src/commonfunction.cpp b/deepin-devicemanager/src/commonfunction.cpp index c83b43011..116b1ada5 100644 --- a/deepin-devicemanager/src/commonfunction.cpp +++ b/deepin-devicemanager/src/commonfunction.cpp @@ -32,7 +32,7 @@ static QMap mapArch = { {"aarch64", "arm64"} static bool initBoardVendorFlag = false; static QString boardVendorKey = ""; int Common::specialComType = -1; - +static QString tomlFilesName = "tomlFilesName"; QString Common::getArch() { QString arch; @@ -137,6 +137,9 @@ QString Common::checkBoardVendorFlag() case PGUX: boardVendorKey = "PGUX"; break; + case kCustomType: + boardVendorKey = "CustomType"; + break; default: boardVendorKey = "PGUW"; break; @@ -177,6 +180,36 @@ QString Common::boardVendorType() return initBoardVendorFlag ? boardVendorKey : checkBoardVendorFlag(); } +QString Common::specialVendorType() +{ + QString type = Common::boardVendorType(); + if (type == "KLVV" || type == "KLVU" || type == "PGUV" || type == "PGUW") + return specialHString(); + return QString("normalmagical"); +} + +QString Common::specialHString() +{ + int asciiValues[] = {72, 85, 65, 87, 69, 73}; // ASCII values for 'H' .... 'I' + QString result; + + // Convert ASCII values to characters and append to QString + for (int ascii : asciiValues) { + result.append(QChar(ascii)); // Convert ASCII to QChar and append to QString + } + return result; +} + +void Common::tomlFilesNameSet(QString name) +{ + tomlFilesName = name; +} + +QString Common::tomlFilesNameGet() +{ + return tomlFilesName; +} + QByteArray Common::executeClientCmd(const QString &cmd, const QStringList &args, const QString &workPath, int msecsWaiting/* = 30000*/) { QProcess process; diff --git a/deepin-devicemanager/src/commonfunction.h b/deepin-devicemanager/src/commonfunction.h index 37868856f..7f8ac14bf 100644 --- a/deepin-devicemanager/src/commonfunction.h +++ b/deepin-devicemanager/src/commonfunction.h @@ -22,7 +22,10 @@ class Common KLVV, KLVU, PGUV, - PGUX + PGUX, + kSpecialType6, + kSpecialType7, + kCustomType }; static QString getArch(); @@ -31,6 +34,10 @@ class Common static QString checkBoardVendorFlag(); static QString boardVendorType(); + static QString specialVendorType(); + static QString specialHString(); + static QString tomlFilesNameGet(); + static void tomlFilesNameSet(QString name); /** * @brief specialComType diff --git a/deepin-devicemanager/src/main.cpp b/deepin-devicemanager/src/main.cpp index b385d2f6f..c12e182c0 100644 --- a/deepin-devicemanager/src/main.cpp +++ b/deepin-devicemanager/src/main.cpp @@ -89,12 +89,13 @@ int main(int argc, char *argv[]) if (!DGuiApplicationHelper::instance()->setSingleInstance(app.applicationName(), DGuiApplicationHelper::UserScope)) { exit(0); } +#ifndef DISABLE_POLKIT Authority::Result result = Authority::instance()->checkAuthorizationSync("com.deepin.deepin-devicemanager.checkAuthentication", UnixProcessSubject(getpid()), Authority::AllowUserInteraction); if (result != Authority::Yes) return 0; - +#endif DApplicationSettings settinAgs; Dtk::Core::DLogManager::registerFileAppender(); diff --git a/deepin-devicemanager/tests/src/DeviceManager/ut_deviceinput.cpp b/deepin-devicemanager/tests/src/DeviceManager/ut_deviceinput.cpp index 4d7fd8a5e..96d9deb10 100644 --- a/deepin-devicemanager/tests/src/DeviceManager/ut_deviceinput.cpp +++ b/deepin-devicemanager/tests/src/DeviceManager/ut_deviceinput.cpp @@ -123,46 +123,6 @@ TEST_F(UT_DeviceInput, UT_DeviceInput_setInfoFromHwinfo_002) EXPECT_STREQ("usb@1:8", m_deviceInput->m_HwinfoToLshw.toStdString().c_str()); } -TEST_F(UT_DeviceInput, UT_DeviceInput_setKLUInfoFromHwinfo_001) -{ - QMap map; - setHwinfoMap(map); - map.insert("Device File", "/dev/input/mice (/dev/input/mouse1)"); - - m_deviceInput->setKLUInfoFromHwinfo(map); - EXPECT_STREQ("MX board 8.0", m_deviceInput->m_Name.toStdString().c_str()); - EXPECT_STREQ("Cherry GmbH", m_deviceInput->m_Vendor.toStdString().c_str()); - EXPECT_STREQ("Cherry MX board 8.0", m_deviceInput->m_Model.toStdString().c_str()); - EXPECT_STREQ("1.07", m_deviceInput->m_Version.toStdString().c_str()); - EXPECT_STREQ("USB", m_deviceInput->m_Interface.toStdString().c_str()); - EXPECT_STREQ("1-8:1.1", m_deviceInput->m_BusInfo.toStdString().c_str()); - EXPECT_STREQ("keyboard", m_deviceInput->m_Description.toStdString().c_str()); - EXPECT_STREQ("usbhid", m_deviceInput->m_Driver.toStdString().c_str()); - EXPECT_STREQ("12 Mbps", m_deviceInput->m_Speed.toStdString().c_str()); - EXPECT_STREQ("usb@1:8", m_deviceInput->m_KeyToLshw.toStdString().c_str()); -} - -TEST_F(UT_DeviceInput, UT_DeviceInput_setKLUInfoFromHwinfo_002) -{ - QMap map; - setHwinfoMap(map); - map.insert("Model", "Cherry MX board 8.0 Bluetooth"); - map.insert("Device", "MX board 8.0 Bluetooth"); - map.remove("Hotplug"); - - m_deviceInput->setKLUInfoFromHwinfo(map); - EXPECT_STREQ("MX board 8.0 Bluetooth", m_deviceInput->m_Name.toStdString().c_str()); - EXPECT_STREQ("Cherry GmbH", m_deviceInput->m_Vendor.toStdString().c_str()); - EXPECT_STREQ("Cherry MX board 8.0 Bluetooth", m_deviceInput->m_Model.toStdString().c_str()); - EXPECT_STREQ("1.07", m_deviceInput->m_Version.toStdString().c_str()); - EXPECT_STREQ("Bluetooth", m_deviceInput->m_Interface.toStdString().c_str()); - EXPECT_STREQ("1-8:1.1", m_deviceInput->m_BusInfo.toStdString().c_str()); - EXPECT_STREQ("keyboard", m_deviceInput->m_Description.toStdString().c_str()); - EXPECT_STREQ("usbhid", m_deviceInput->m_Driver.toStdString().c_str()); - EXPECT_STREQ("12 Mbps", m_deviceInput->m_Speed.toStdString().c_str()); - EXPECT_STREQ("usb@1:8", m_deviceInput->m_KeyToLshw.toStdString().c_str()); -} - bool ut_isValueValid() { return true; diff --git a/deepin-devicemanager/tests/src/DeviceManager/ut_devicemanager.cpp b/deepin-devicemanager/tests/src/DeviceManager/ut_devicemanager.cpp index ba6d7dd0f..f34489f27 100644 --- a/deepin-devicemanager/tests/src/DeviceManager/ut_devicemanager.cpp +++ b/deepin-devicemanager/tests/src/DeviceManager/ut_devicemanager.cpp @@ -257,20 +257,7 @@ TEST_F(UT_DeviceManager, UT_DeviceManager_setStorageDeviceMediaType) DeviceManager::instance()->m_ListDeviceStorage.clear(); delete device; } - -TEST_F(UT_DeviceManager, UT_DeviceManager_setKLUStorageDeviceMediaType) -{ - DeviceStorage *device = new DeviceStorage; - device->m_DeviceFile = "/dev/sda"; - DeviceManager::instance()->m_ListDeviceStorage.append(device); - - DeviceManager::instance()->setKLUStorageDeviceMediaType("sda", "1"); - EXPECT_STREQ("HDD", device->m_MediaType.toStdString().c_str()); - - DeviceManager::instance()->m_ListDeviceStorage.clear(); - delete device; -} - +S TEST_F(UT_DeviceManager, UT_DeviceManager_addGpuDevice) { DeviceGpu *gpu = new DeviceGpu; diff --git a/deepin-devicemanager/tests/src/DeviceManager/ut_devicemonitor.cpp b/deepin-devicemanager/tests/src/DeviceManager/ut_devicemonitor.cpp index fe360249c..1d27b7071 100644 --- a/deepin-devicemanager/tests/src/DeviceManager/ut_devicemonitor.cpp +++ b/deepin-devicemanager/tests/src/DeviceManager/ut_devicemonitor.cpp @@ -98,21 +98,6 @@ void ut_monitor_setselfmap(QMap &mapinfo) mapinfo.insert("Date", "Date"); } -TEST_F(UT_DeviceMonitor, UT_DeviceMonitor_setInfoFromSelfDefine) -{ - QMap mapinfo; - ut_monitor_setselfmap(mapinfo); - - m_deviceMonitor->setInfoFromSelfDefine(mapinfo); - EXPECT_STREQ("Name", m_deviceMonitor->m_Name.toStdString().c_str()); - EXPECT_STREQ("Vendor", m_deviceMonitor->m_Vendor.toStdString().c_str()); - EXPECT_STREQ("CurResolution", m_deviceMonitor->m_CurrentResolution.toStdString().c_str()); - EXPECT_STREQ("SupportResolution", m_deviceMonitor->m_SupportResolution.toStdString().c_str()); - EXPECT_STREQ("Size", m_deviceMonitor->m_ScreenSize.toStdString().c_str()); - EXPECT_STREQ("Date", m_deviceMonitor->m_ProductionWeek.toStdString().c_str()); - -} - void ut_monitor_setedidmap(QMap &mapinfo) { mapinfo.insert("Vendor", "Vendor"); diff --git a/deepin-devicemanager/tests/src/DeviceManager/ut_devicenetwork.cpp b/deepin-devicemanager/tests/src/DeviceManager/ut_devicenetwork.cpp index 5be2bdf7b..6465a0aee 100644 --- a/deepin-devicemanager/tests/src/DeviceManager/ut_devicenetwork.cpp +++ b/deepin-devicemanager/tests/src/DeviceManager/ut_devicenetwork.cpp @@ -57,7 +57,7 @@ void ut_network_setlshwinfo(QMap &mapinfo) mapinfo.insert("ip", "ip"); mapinfo.insert("size", "size"); mapinfo.insert("capacity", "capacity"); - mapinfo.insert("latency", "latency"); + mapinfo.insert("Latency", "Latency"); mapinfo.insert("multicast", "multicast"); } @@ -113,7 +113,7 @@ TEST_F(UT_DeviceNetwork, DeviceNetwork_UT_setInfoFromLshw) EXPECT_STREQ("ip", m_deviceNetwork->m_Ip.toStdString().c_str()); EXPECT_STREQ("size", m_deviceNetwork->m_Speed.toStdString().c_str()); EXPECT_STREQ("capacity", m_deviceNetwork->m_Capacity.toStdString().c_str()); - EXPECT_STREQ("latency", m_deviceNetwork->m_Latency.toStdString().c_str()); + EXPECT_STREQ("Latency", m_deviceNetwork->m_Latency.toStdString().c_str()); EXPECT_STREQ("multicast", m_deviceNetwork->m_Multicast.toStdString().c_str()); } diff --git a/deepin-devicemanager/tests/src/DeviceManager/ut_devicestorage.cpp b/deepin-devicemanager/tests/src/DeviceManager/ut_devicestorage.cpp index f2e65a603..fc1531784 100644 --- a/deepin-devicemanager/tests/src/DeviceManager/ut_devicestorage.cpp +++ b/deepin-devicemanager/tests/src/DeviceManager/ut_devicestorage.cpp @@ -127,53 +127,6 @@ TEST_F(UT_DeviceStorage, UT_DeviceStorage_setHwinfoInfo_003) EXPECT_STREQ("", m_deviceStorage->m_SerialNumber.toStdString().c_str()); } -TEST_F(UT_DeviceStorage, UT_DeviceStorage_setKLUHwinfoInfo_001) -{ - QMap mapinfo; - ut_storage_setHwinfoInfo(mapinfo); - mapinfo.insert("Driver", "usb-storage"); - mapinfo.insert("Vendor", "PASON"); - - ASSERT_TRUE(m_deviceStorage->setKLUHwinfoInfo(mapinfo)); - EXPECT_STREQ("ST240BX500SSD1", m_deviceStorage->m_Model.toStdString().c_str()); - EXPECT_STREQ("PASON", m_deviceStorage->m_Vendor.toStdString().c_str()); - EXPECT_STREQ("usb-storage", m_deviceStorage->m_Driver.toStdString().c_str()); - EXPECT_STREQ("SATA ", m_deviceStorage->m_Interface.toStdString().c_str()); - EXPECT_STREQ("R013", m_deviceStorage->m_Version.toStdString().c_str()); - EXPECT_STREQ("disk", m_deviceStorage->m_Description.toStdString().c_str()); - EXPECT_STREQ("223GB", m_deviceStorage->m_Size.toStdString().c_str()); - EXPECT_STREQ("2002E3E0B393", m_deviceStorage->m_SerialNumber.toStdString().c_str()); - EXPECT_STREQ("/dev/nvme0n1", m_deviceStorage->m_DeviceFile.toStdString().c_str()); - EXPECT_STREQ("nvme0n12:0:0:0", m_deviceStorage->m_KeyToLshw.toStdString().c_str()); - EXPECT_STREQ("USB", m_deviceStorage->m_MediaType.toStdString().c_str()); -} - -TEST_F(UT_DeviceStorage, UT_DeviceStorage_setKLUHwinfoInfo_002) -{ - QMap mapinfo; - ut_storage_setHwinfoInfo(mapinfo); - mapinfo.remove("SysFS BusID"); - - ASSERT_FALSE(m_deviceStorage->setKLUHwinfoInfo(mapinfo)); -} - -TEST_F(UT_DeviceStorage, UT_DeviceStorage_setKLUHwinfoInfo_003) -{ - QMap mapinfo; - ut_storage_setHwinfoInfo(mapinfo); - mapinfo.insert("Vendor", "PASON"); - mapinfo.remove("Capacity"); - - ASSERT_FALSE(m_deviceStorage->setKLUHwinfoInfo(mapinfo)); - EXPECT_STREQ("ST240BX500SSD1", m_deviceStorage->m_Model.toStdString().c_str()); - EXPECT_STREQ("PASON", m_deviceStorage->m_Vendor.toStdString().c_str()); - EXPECT_STREQ("ahci, sd", m_deviceStorage->m_Driver.toStdString().c_str()); - EXPECT_STREQ("SATA ", m_deviceStorage->m_Interface.toStdString().c_str()); - EXPECT_STREQ("R013", m_deviceStorage->m_Version.toStdString().c_str()); - EXPECT_STREQ("disk", m_deviceStorage->m_Description.toStdString().c_str()); - EXPECT_STREQ("", m_deviceStorage->m_Size.toStdString().c_str()); -} - TEST_F(UT_DeviceStorage, UT_DeviceStorage_addInfoFromlshw_001) { QMap mapinfo; @@ -273,37 +226,6 @@ TEST_F(UT_DeviceStorage, UT_DeviceStorage_setMediaType_004) EXPECT_TRUE(m_deviceStorage->setMediaType("sda", "2")); } -TEST_F(UT_DeviceStorage, UT_DeviceStorage_setKLUMediaType_001) -{ - m_deviceStorage->m_DeviceFile = "/dev/sda"; - EXPECT_FALSE(m_deviceStorage->setKLUMediaType("nvme0n1", "0")); -} - -TEST_F(UT_DeviceStorage, UT_DeviceStorage_setKLUMediaType_002) -{ - m_deviceStorage->m_DeviceFile = "/dev/sda"; - EXPECT_TRUE(m_deviceStorage->setKLUMediaType("sda", "0")); -} - -TEST_F(UT_DeviceStorage, UT_DeviceStorage_setKLUMediaType_003) -{ - m_deviceStorage->m_DeviceFile = "/dev/sda"; - EXPECT_TRUE(m_deviceStorage->setKLUMediaType("sda", "1")); -} - -TEST_F(UT_DeviceStorage, UT_DeviceStorage_setKLUMediaType_004) -{ - m_deviceStorage->m_DeviceFile = "/dev/sda"; - EXPECT_TRUE(m_deviceStorage->setKLUMediaType("sda", "2")); -} - -TEST_F(UT_DeviceStorage, UT_DeviceStorage_setKLUMediaType_005) -{ - m_deviceStorage->m_DeviceFile = "/dev/sda"; - m_deviceStorage->m_MediaType = "USB"; - EXPECT_TRUE(m_deviceStorage->setKLUMediaType("sda", "2")); -} - TEST_F(UT_DeviceStorage, UT_DeviceStorage_isValid_001) { m_deviceStorage->m_Size = "32GB"; diff --git a/deepin-devicemanager/tests/src/GenerateDevice/ut_klugenerator.cpp b/deepin-devicemanager/tests/src/GenerateDevice/ut_klugenerator.cpp index 597c295b7..192ff895d 100644 --- a/deepin-devicemanager/tests/src/GenerateDevice/ut_klugenerator.cpp +++ b/deepin-devicemanager/tests/src/GenerateDevice/ut_klugenerator.cpp @@ -3,11 +3,9 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -#include "KLUGenerator.h" #include "DeviceManager.h" #include "ut_Head.h" #include "stub.h" - #include #include #include diff --git a/deepin-devicemanager/translations/deepin-devicemanager.ts b/deepin-devicemanager/translations/deepin-devicemanager.ts index 03cf20f00..0d869b005 100644 --- a/deepin-devicemanager/translations/deepin-devicemanager.ts +++ b/deepin-devicemanager/translations/deepin-devicemanager.ts @@ -841,7 +841,7 @@ Mouse - Mouse + Mouse and Pointer Devices @@ -2199,8 +2199,8 @@ - latency - latency + Latency + Latency diff --git a/deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts b/deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts index d12fe7dfb..712acdba2 100644 --- a/deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts +++ b/deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts @@ -4,17 +4,17 @@ BtnLabel - + OK 确 定 - + Feedback 反馈 - + OK button 确 定 @@ -31,17 +31,17 @@ CommonTools - + EC_NOTIFY_NETWORK EC_NOTIFY_NETWORK - + EC_REINSTALL EC_REINSTALL - + EC_6 EC_6 @@ -90,3667 +90,2819 @@ - DeviceAudio + DeviceBaseInfo - - Device Name - 设备名称 + One + - - - Name - 名称 + Two + - - - Vendor - 制造商 + Four + - - Chip - 芯片 + Six + - - Capabilities - 功能 + Eight + - - - Module Alias - 模块别名 + Nine + - - - Physical ID - 物理ID + Ten + - - SysFS_Path - + Twelve + 十二 - - Description - 描述 + Fourteen + 十四 - - Revision - + Sixteen + 十六 - - KernelModeDriver - + Eighteen + 十八 - - Memory Address - 内存地址 + Twenty + 二十 - - IRQ - 中断 + Twenty-two + 二十二 - - Unavailable - 不可用 + Twenty-four + 二十四 - - Disable - 禁用 + Twenty-six + 二十六 - - - DeviceBaseInfo - - Name - 名称 + Twenty-eight + 二十八 - - Vendor - 制造商 + Thirty + 三十 - - Model - 型号 + Thirty-two + 三十二 - - - DeviceBios - - Vendor - 制造商 + Thirty-four + 三十四 - - Version - 版本 + Thirty-six + 三十六 - - Chipset - 芯片组 + Thirty-eight + 三十八 - - - DeviceBluetooth - - Name - 名称 + Forty + 四十 - - Vendor - 制造商 + Forty-two + 四十二 - - Version - 版本 + Forty-four + 四十四 - - Model - 型号 + Forty-six + 四十六 - - Module Alias - 模块别名 + Forty-eight + 四十八 - - Physical ID - 物理ID + Fifty + 五十 - - Speed - 速度 + Fifty-two + 五十二 - - Maximum Power - 最大功率 + Fifty-four + 五十四 - - Driver Version - 驱动版本 + Fifty-six + 五十六 - - Driver - 驱动 + Fifty-eight + 五十八 - - Capabilities - 功能 + Sixty + 六十 - - Bus Info - 总线信息 + Sixty-two + 六十二 - - Logical Name - 逻辑名称 + Sixty-four + 六十四 - - MAC Address - 物理地址 + Sixty-six + 六十六 - - Unavailable - 不可用 + Sixty-eight + 六十八 - - Disable - 禁用 + Seventy + 七十 - - - DeviceCdrom - - Name - 名称 + Seventy-two + 七十二 - - Vendor - 制造商 + Seventy-four + 七十四 - - Model - 型号 + Seventy-six + 七十六 - - Version - 版本 + Seventy-eight + 七十八 - - Bus Info - 总线信息 + Eighty + 八十 - - Capabilities - 功能 + Eighty-two + 八十二 - - Driver - 驱动 + Eighty-four + 八十四 - - Maximum Power - 最大功率 + Eighty-six + 八十六 - - Speed - 速度 + Eighty-eight + 八十八 - - Module Alias - 模块别名 + Ninety + 九十 - - Physical ID - 物理ID + Ninety-two + 九十二 - - Unavailable - 不可用 + Ninety-four + 九十四 - - Disable - 禁用 + Ninety-six + 九十六 - - - DeviceComputer - - Name - 名称 + Ninety-eight + 九十八 - - - DeviceCpu - - - Name - 名称 + One hundred + 一百 - - - Vendor - 制造商 + One hundred and Two + 一百零二 - - CPU ID - 处理器ID + One hundred and four + 一百零四 - - Core ID - 核心ID + One hundred and Six + 一百零六 - - Threads - 线程数 + One hundred and Eight + 一百零八 - - BogoMIPS - 运行速度(Bogomips) + One hundred and Ten + 一百一十 - - - Architecture - 架构 + One hundred and Twelve + 一百一十二 - - CPU Family - 家族 + One hundred and Fourteen + 一百一十四 - - Model - 型号 + One hundred and Sixteen + 一百一十六 + + + One hundred and Eighteen + 一百一十八 + + + One hundred and Twenty + 一百二十 + + + One hundred and Twenty-two + 一百二十二 + + + One hundred and Twenty-four + 一百二十四 + + + One hundred and Twenty-six + 一百二十六 + + + One hundred and Twenty-eight + 一百二十八 + + + One hundred and Ninety-two + 一百九十二 + + + Two hundred and fifty-six + 二百五十六 + + + + Device Name + 设备名称 + + + + + Vendor + 制造商 + + + + Chip + 芯片 + + + + Physical ID + 物理ID + + + + SysFS_Path + + + + + Revision + + + + + KernelModeDriver + + + + + IRQ + 中断 + + + + Disable + 禁用 + + + + Version + 版本 + + + + Chipset + 芯片组 + + + + + Module Alias + 模块别名 + + + + Speed + 速度 + + + + Maximum Power + 最大功率 + + + + Driver + 驱动 + + + + Driver Version + 驱动版本 + + + + Capabilities + 功能 + + + + logical name + 逻辑名称 + + + + Logical Name + 逻辑名称 + + + + MAC Address + 物理地址 + + + + CPU ID + 处理器ID + + + + Core ID + 核心ID + + + + Threads + 线程数 + + + + BogoMIPS + 运行速度(Bogomips) + + + + + Architecture + 架构 + + + + CPU Family + 家族 - - + + Processor 逻辑处理器 - + Core(s) - + Virtualization 虚拟化 - + Flags 特性 - + Extensions 扩展指令集 - + L3 Cache L3缓存 - + L4 Cache L4缓存 - + L2 Cache L2缓存 - + L1i Cache L1缓存(指令) - + L1d Cache L1缓存(数据) - + Stepping 步进 - - Speed + + Frequency 频率 - - - - Max Speed + + + Max Frequency 最大频率 - - - DeviceGpu - - - Name - 名称 - - - - Vendor - 制造商 - - - - Model - 型号 - - - - Version - 版本 - - + Graphics Memory 显存 - - Module Alias - 模块别名 - - - - Physical ID - 物理ID - - - + Memory Address 内存地址 - + IO Port I/O端口 - - Bus Info - 总线信息 - - - + Maximum Resolution 最大分辨率 - + Minimum Resolution 最小分辨率 - - Current Resolution - 当前分辨率 - - - - Driver - 驱动 - - - + Description 描述 - + DP DP - + eDP eDP - + HDMI HDMI - + + temperature + + + + + Type Detail + + + + VGA VGA - + DVI DVI - + DigitalOutput DigitalOutput - + Display Output 显示输出 - - Capabilities - 功能 + + Interface + 接口 - - IRQ - 中断 + + Bus Info + 总线信息 - - Unavailable - 不可用 + + bus info + 总线信息 - - - DeviceImage - - Name - 名称 + + Maximum Current + 最大电流 - - Vendor - 制造商 + + Unavailable + 不可用 - - Version - 版本 + + + Type + 类型 - - Model - 型号 + + Total Width + 总位宽 - - Bus Info - 总线信息 + + Locator + 插槽 - - Module Alias - 模块别名 + + Configured Voltage + 配置电压 - - Physical ID - 物理ID + + Maximum Voltage + 最高电压 - - Speed - 速度 + + Minimum Voltage + 最低电压 - - Maximum Power - 最大功率 + + Configured Speed + 配置速度 - - Driver - 驱动 + + Data Width + 数据位宽 - - Capabilities - 功能 + + Display Input + 显示输入 - - Serial Number - 序列号 + + Interface Type + 接口类型 - - Unavailable - 不可用 + + Support Resolution + 支持分辨率 - - Disable - 禁用 + + Current Resolution + 当前分辨率 - - - DeviceInput - - Name - 名称 + + Refresh Rate + 刷新率 - - Vendor - 制造商 + + Display Ratio + 显示比例 - - Model - 型号 + + Primary Monitor + 主显示器 - - Interface - 接口 + + + Size + 大小 - - Bus Info - 总线信息 + + Maximum Rate + 最大速率 - - Module Alias - 模块别名 + + Negotiation Rate + 协商速率 - - Physical ID - 物理ID + + Port + 端口 - - Speed - 频率 + + Multicast + 组播 - - Maximum Current - 最大电流 + + Link + 连接 - - Driver - 驱动 + + Latency + 延迟 - - Capabilities - 功能 + + IP + IP - - Version - 版本 + + Firmware + 固件 - - Unavailable - 不可用 + + Duplex + 双工 - - Disable - 禁用 + + Broadcast + 广播 - - - DeviceManager - - - - - - - - - - - Overview - 概况 + + Auto Negotiation + 自动协商 - - - - CPU - 处理器 + + Input/Output + 输入/输出 - - - CPU quantity - CPU数量 + + Memory + 内存 - - - Motherboard - 主板 + + Model + 型号 - - - Memory - 内存 + + Status + 状态 - - - Display Adapter - 显示适配器 + + Capacity + 最大容量 - - - Sound Adapter - 音频适配器 + + Voltage + 电压 - - - Storage - 存储设备 + + Slot + 插槽 - - - Other PCI Devices - 其他PCI设备 + + Design Capacity + 设计容量 - - - Battery - 电池 + + Design Voltage + 设计电压 - - - Bluetooth - 蓝牙 + + SBDS Version + SBDS版本 - - - Network Adapter - 网络适配器 + + SBDS Serial Number + SBDS序列号 - - - Mouse - 鼠标 + + SBDS Manufacture Date + SBDS制造日期 - - - Keyboard - 键盘 + + SBDS Chemistry + SBDS材料 - - - Monitor - 显示设备 + + Temperature + 温度 - - - CD-ROM - 光驱 + + + Name + 名称 - - - Printer - 打印机 + + Shared + 已共享 - - - Camera - 图像设备 + + URI + URI - - - Other Devices - Other Input Devices - 其他设备 + + + Media Type + 介质类型 - - - - Device - 设备 + + Firmware Version + 固件版本 - - - - OS - 操作系统 + + Serial Number + 序列号 - - - DeviceMemory - - - Name - 名称 + + Rotation Rate + 转速 - - - Vendor - 制造商 + + SubVendor + 子制造商 - - - Size - 大小 + + SubDevice + 子设备 - - - Type - 类型 + + Driver Status + 驱动状态 - - - Speed - 速度 + + Config Status + 配置状态 - - Total Width - 总位宽 + + Phys + Phys - - Locator - 插槽 + + Sysfs + Sysfs - - Serial Number - 序列号 + + Handlers + 处理程序 - - Configured Voltage - 配置电压 + + PROP + PROP - - Maximum Voltage - 最高电压 + + EV + EV - - Minimum Voltage - 最低电压 + + KEY + KEY - - Configured Speed - 配置频率 + + Bus + 总线 - - Data Width - 数据位宽 + + BIOS Information + BIOS信息 - - - DeviceMonitor - - Name - 名称 + + Base Board Information + 主板信息 - - Vendor - 制造商 + + System Information + 系统信息 - - Type - 类型 + + Chassis Information + 机箱信息 - - Display Input - 显示输入 + + Physical Memory Array + 内存插槽信息 - - Interface Type - 接口类型 + + Release Date + 发布日期 - - Support Resolution - 支持分辨率 + + Address + 地址 - - Current Resolution - 当前分辨率 + + Runtime Size + 运行内存大小 - - Display Ratio - 显示比例 + + ROM Size + ROM大小 - - Primary Monitor - 主显示器 + + Characteristics + 特性 - - Size - 大小 + + BIOS Revision + BIOS修订版本 - - Serial Number - 序列号 + + Firmware Revision + 固件修订版本 - - - DeviceNetwork - - - Name - 名称 + + Product Name + 产品名称 - - - Vendor - 制造商 + + Asset Tag + 资产编号 - - - Type - 类型 + + Features + 特征 - - Version - 版本 + + Location In Chassis + 机箱内位置 - - Bus Info - 总线信息 + + Chassis Handle + 机箱程序 - - Capabilities - 功能 + + Contained Object Handles + 包含对象程序 - - Driver - 驱动 + + UUID + UUID - - Driver Version - 驱动版本 + + Wake-up Type + 唤醒类型 - - Module Alias - 模块别名 + + SKU Number + SKU号 - - Physical ID - 物理ID + + Family + 家族 - - Maximum Rate - 最大速率 + + Lock + - - Negotiation Rate - 协商速率 + + Boot-up State + 开机状态 - - Port - 端口 + + Power Supply State + 供电状态 - - Multicast - 组播 + + Thermal State + 散热状态 - - Link - 连接 + + Security Status + 安全状态 - - Latency - 延迟 + + OEM Information + OEM信息 - - IP - IP + + Height + 高度 - - Firmware - 固件 + + Number Of Power Cords + 电源线数 - - Duplex - 双工 + + Contained Elements + 包含组件数 - - Broadcast - 广播 + + Location + 位置 - - Auto Negotiation - 自动协商 + + Error Correction Type + 纠错类型 - - Memory Address - 内存地址 + + Maximum Capacity + 最大容量 - - IRQ - 中断 + + Error Information Handle + 错误信息程序 - - MAC Address - 物理地址 + + Number Of Devices + 卡槽数量 - - Logical Name - 逻辑名称 + + BIOS ROMSIZE + BIOS ROM大小 - - Unavailable - 不可用 + + Release date + 发布日期 - - Disable - 禁用 + + Board name + 主板名称 - - - DeviceOtherPCI - - Name - 名称 + + SMBIOS Version + SMBIOS版本 - - Vendor - 制造商 + + Language Description Format + 语言描述格式 - - Model - 型号 + + Installable Languages + 可安装语言数 - - Bus Info - 总线信息 + + Currently Installed Language + 当前安装语言 - - Version - 版本 + + BD Address + 蓝牙设备地址 - - Input/Output - 输入/输出 + + ACL MTU + ACL MTU - - Memory - 内存 + + SCO MTU + SCO MTU - - IRQ - 中断 + + Packet type + 数据包类型 - - Latency - 延迟 + + Link policy + 连接策略 - - Driver - 驱动 + + Link mode + 连接模式 - - Capabilities - 功能 + + Class + 类别 - - - DeviceOthers - - Name - 名称 + + Service Classes + 服务类别 - - Vendor - 制造商 + + Device Class + 设备类别 - - Model - 型号 + + HCI Version + HCI版本 - - Version - 版本 + + LMP Version + LMP版本 - - Bus Info - 总线信息 + + Subversion + 子版本 - - Capabilities - 功能 + + Device + 设备 - - Driver - 驱动 + + Serial ID + 序列号 - - Maximum Power - 最大功率 + + product + 产品 - - Speed - 速度 + + Powered + 供电 - - Serial Number - 序列号 + + Discoverable + 可发现 - - Unavailable - 不可用 + + Pairable + 可配对 - - Disable - 禁用 + + Modalias + 设置命令别名 - - - DevicePower - - Name - 名称 + + Discovering + 搜索中 - - Model - 型号 + + Device File + 设备文件 - - Vendor - 制造商 + + Device Files + 设备文件 - - Serial Number - 序列号 + + Device Number + 设备编号 - - Type - 类型 + + Application + 应用 - - Status - 状态 + + ansiversion + ANSI版本 - - Capacity - 最大容量 + + CPU implementer + CPU程序 - - Voltage - 电压 + + CPU architecture + CPU架构 - - Slot - 插槽 + + CPU variant + CPU变量 - - Design Capacity - 设计容量 + + CPU part + CPU部件 - - Design Voltage - 设计电压 + + CPU revision + CPU版本 - - SBDS Version - SBDS版本 + + GDDR capacity + GDDR容量 - - SBDS Serial Number - SBDS序列号 + + GPU vendor + GPU供应商 - - SBDS Manufacture Date - SBDS制造日期 + + GPU type + GPU类型 - - SBDS Chemistry - SBDS材料 + + EGL version + EGL版本 - - Temperature - 温度 + + EGL client APIs + EGL接口 - - - DevicePrint - - Name - 名称 + + GL version + GL版本 - - Model - 型号 + + GLSL version + GLSL版本 - - Vendor - 制造商 + Unknown + 未知 - - Serial Number - 序列号 + + Uniq + Uniq - - Shared - 已共享 + + MSC + MSC - - URI - URI + + Hardware Class + 硬件类别 - - Status - 状态 + + Array Handle + 数组程序 - - Interface Type - 接口类型 + + Form Factor + 尺寸型号 - - Disable - 禁用 + + Set + 设置 - - - DeviceStorage - - - Vendor - 制造商 + + Bank Locator + 内存通道 - - - Media Type - 介质类型 + + Part Number + 部件号码 - - - - Size - 大小 + + Rank + 位列 - - - Name - 名称 + + Memory Technology + 内存技术 - - Version - 版本 + + Memory Operating Mode Capability + 内存操作模式 - - Capabilities - 功能 + + Module Manufacturer ID + 组件制造商 - - - Module Alias - 模块别名 + + Module Product ID + 组件产品ID - - - Physical ID - 物理ID + + Memory Subsystem Controller Manufacturer ID + 内存子系统控制器制造商 - - Firmware Version - 固件版本 + + Memory Subsystem Controller Product ID + 内存子系统控制器产品ID - - Speed - 速度 + + Non-Volatile Size + 不易丢失大小 - - Description - 描述 + + Volatile Size + 易丢失大小 - - Serial Number - 序列号 + + Cache Size + 缓存大小 - - Interface - 接口 + + Logical Size + 逻辑大小 - - Rotation Rate - 转速 + + inch + 英寸 - - Unavailable - 不可用 + + Date + 日期 - - - GetDriverNameWidget - - - Select a driver for update - 选择需要更新的驱动程序 + + ioport + I/O端口 - - No drivers found in this folder - 所选文件夹未检测到驱动文件 + + network + 网络 - - - GetInfoPool - - Loading Audio Device Info... - 获取音频设备信息... + + Width + - - Loading BIOS Info... - 获取BIOS信息... + + battery + 电池 - - Loading CD-ROM Info... - 获取光驱信息... + + native-path + 安装路径 - - Loading Operating System Info... - 获取操作系统信息... + + power supply + 供电 - - Loading CPU Info... - 获取处理器信息... + + updated + 更新时间 - - Loading Other Devices Info... - 获取其他设备信息... + + has history + 历史记录 - - Loading Power Info... - 获取电池信息... + + has statistics + 用电统计 - - Loading Printer Info... - 获取打印机信息... + + rechargeable + 可再充电 - - Loading Mouse Info... - 获取鼠标信息... + + state + 状态 - - Loading Network Adapter Info... - 获取网络适配器信息... + + voltage + - - - LogTreeView - - - - Disable - 禁用 + + warning-level + 警告等级 - - Unavailable - 不可用 + + energy + 容量 - - - LogViewItemDelegate - - Disable - 禁用 + + energy-empty + 最低容量 - - Unavailable - 不可用 + + energy-full + 完全充满容量 - - - MainWindow - - Device Info - export file's name - 设备信息 + + energy-full-design + 设计容量 - - Display shortcuts - 显示快捷键 + + energy-rate + 能量密度 - - Close - 关闭 + + percentage + 电量 - - Help - 帮助 + + status + - - Copy - 复制 + + technology + 电池技术 - - System - 系统 + + icon-name + 图标 - - Export - 导出 + + online + 在线 - - Refresh - 刷新 + + daemon-version + Daemon版本 - - Device Manager - 设备管理器 + + on-battery + 使用电池 - - Hardware - 硬件信息 + + lid-is-closed + 笔记本合盖 - - Drivers - 驱动管理 - - - - Monitor - 显示设备 - - - - Overview - 概况 - - - - Display Adapter - 显示适配器 - - - - CPU - 处理器 - - - - Network Adapter - 网络适配器 - - - - Battery - 电池 - - - - PageDetail - - - More - 更多 - - - - PageDriverBackupInfo - - - - Name - 名称 - - - - - Current Version - 当前版本 - - - - - Driver Platform Version - 驱动平台版本 - - - - Status - 状态 - - - - Action - 操作 - - - - Backupable Drivers - 可备份驱动 - - - - Backed up Drivers - 已备份驱动 - - - - PageDriverControl - - - - Updating - 正在更新 - - - - - - Cancel - button - 取 消 - - - - Next - 下一步 - - - - Warning - 注意 - - - - The device will be unavailable after the driver uninstallation - 将从系统中卸载此驱动程序,卸载后该设备不可用 - - - - Uninstall - button - 卸 载 - - - - Uninstalling - 正在卸载 - - - - Update successful - 驱动更新成功 - - - - Uninstallation successful - 驱动卸载成功 - - - - Update failed - 驱动更新失败 - - - - Uninstallation failed - 驱动卸载失败 - - - - OK - button - 确 定 - - - - Next - button - 下一步 - - - - The selected folder does not exist, please select again - 所选文件夹不存在,请重新选择 - - - - Update - button - 更 新 - - - - Previous - button - 上一步 - - - - Broken package - 包文件损坏 - - - - Unmatched package architecture - 包文件与系统架构不匹配 - - - - - The selected file does not exist, please select again - 所选文件不存在,请重新选择 - - - - It is not a driver - 该文件不是驱动文件 - - - - Unable to install - no digital signature - 无法安装,安装包无数字签名 - - - - Unknown error - 未知错误 - - - - The driver module was not found - 未发现该驱动模块 - - - - Invalid module format - 模块格式无效 - - - - The driver module has dependencies - 驱动模块被依赖 - - - - PageDriverInstallInfo - - - - - Device Name - 设备名称 - - - - Version Available - 可安装版本 - - - - - Size - 大小 - - - - - Status - 状态 - - - - - Action - 操作 - - - - New Version - 可更新版本 - - - - Current Version - 当前版本 - - - - Missing drivers (%1) - 可安装驱动 (%1) - - - - Outdated drivers (%1) - 可更新驱动 (%1) - - - - Up-to-date drivers (%1) - 无需更新驱动 (%1) - - - - PageDriverManager - - - - - Driver Install - 驱动安装 - - - - - - - Driver Backup - 驱动备份 - - - - - Driver Restore - 驱动还原 - - - - OK - 确 定 - - - - Feedback - 反馈 - - - - PageDriverRestoreInfo - - - You do not have any drivers to restore, please backup first - 您没有驱动可以还原,请先备份 - - - - Go to Backup Driver - 前往备份驱动 - - - - Name - 名称 - - - - Current Version - 当前版本 - - - - Backup Version - 备份版本 - - - - Action - 操作 - - - - Restorable Drivers - 可还原驱动 - - - - PageListView - - - Refresh - 刷新 - - - - Export - 导出 - - - - Overview - 概况 - - - - Driver Install - 驱动安装 - - - - Driver Backup - 驱动备份 - - - - Driver Restore - 驱动还原 - - - - PageMultiInfo - - - Failed to enable the device - 启用失败 - - - - Failed to disable the device - 禁用失败 - - - - Failed to disable it: unable to get the device SN - 无法获取设备序列号,禁用失败 - - - - Update Drivers - 更新驱动 - - - - Uninstall Drivers - 卸载驱动 - - - - PageOverview - - - Refresh - 刷新 - - - - Export - 导出 - - - - Copy - 复制 - - - - Overview - 概况 - - - - PageSingleInfo - - - Refresh - 刷新 - - - - Export - 导出 - - - - Copy - 复制 - - - - - Enable - 启用 - - - - Update drivers - 更新驱动 - - - - Uninstall drivers - 卸载驱动 - - - - Allow it to wake the computer - 允许唤起电脑 - - - - Disable - 禁用 - - - - - Failed to disable it: unable to get the device SN - 无法获取设备序列号,禁用失败 - - - - Failed to disable the device - 禁用失败 - - - - Failed to enable the device - 启用失败 - - - - Update Drivers - 更新驱动 - - - - Uninstall Drivers - 卸载驱动 - - - - QObject - - - - SubVendor - 子制造商 - - - - - SubDevice - 子设备 - - - - Driver - 驱动 - - - - Driver Status - 驱动状态 - - - - Driver Activation Cmd - 驱动激活命令 - - - - - - - Config Status - 配置状态 - - - - - latency - 延迟 - - - - Phys - Phys - - - - Sysfs - Sysfs - - - - Handlers - 处理程序 - - - - - PROP - PROP - - - - - EV - EV - - - - - KEY - KEY - - - - Version - 版本 - - - - - - Bus - 总线 - - - - - BIOS Information - BIOS信息 - - - - - Base Board Information - 主板信息 - - - - - System Information - 系统信息 - - - - - Chassis Information - 机箱信息 - - - - - Physical Memory Array - 内存插槽信息 - - - - Release Date - 发布日期 - - - - Address - 地址 - - - - Runtime Size - 运行内存大小 - - - - ROM Size - ROM大小 - - - - Characteristics - 特性 - - - - BIOS Revision - BIOS修订版本 - - - - Firmware Revision - 固件修订版本 - - - - - Product Name - 产品名称 - - - - - - Serial Number - 序列号 - - - - - - Asset Tag - 资产编号 - - - - - Features - 特征 - - - - Location In Chassis - 机箱内位置 - - - - Chassis Handle - 机箱程序 - - - - - Type - 类型 - - - - Contained Object Handles - 包含对象程序 - - - - - UUID - UUID - - - - Wake-up Type - 唤醒类型 - - - - - SKU Number - SKU号 - - - - - Family - 家族 - - - - Lock - - - - - Boot-up State - 开机状态 - - - - Power Supply State - 供电状态 - - - - Thermal State - 散热状态 - - - - Security Status - 安全状态 - - - - OEM Information - OEM信息 - - - - Height - 高度 - - - - Number Of Power Cords - 电源线数 - - - - Contained Elements - 包含组件数 - - - - Location - 位置 - - - - Error Correction Type - 纠错类型 - - - - Maximum Capacity - 最大容量 - - - - - Error Information Handle - 错误信息程序 - - - - Number Of Devices - 卡槽数量 - - - - BIOS ROMSIZE - BIOS ROM大小 - - - - Release date - 发布日期 - - - - Board name - 主板名称 - - - - SMBIOS Version - SMBIOS版本 - - - - Language Description Format - 语言描述格式 - - - - Installable Languages - 可安装语言数 - - - - Currently Installed Language - 当前安装语言 - - - - BD Address - 蓝牙设备地址 - - - - ACL MTU - ACL MTU - - - - SCO MTU - SCO MTU - - - - Packet type - 数据包类型 - - - - Link policy - 连接策略 - - - - Link mode - 连接模式 - - - - - Class - 类别 - - - - Service Classes - 服务类别 - - - - Device Class - 设备类别 - - - - HCI Version - HCI版本 - - - - LMP Version - LMP版本 + + lid-is-present + 打开笔记本盖子 - - Subversion - 子版本 + + critical-action + 电量极低时执行 - - - Device - 设备 + + Alias + - - - Serial ID - 序列号 + + Clock + - - product - 产品 + + copies + 复印数量 - + description - 描述 - - - - Powered - 供电 + - - Discoverable - 可发现 + + Driver Activation Cmd + - - Pairable - 可配对 + + Driver Modules + 驱动模块 - - Modalias - 设置命令别名 + + job-cancel-after + 此时取消打印任务 - - Discovering - 搜索中 + + job-hold-until + 保留打印任务直至 - - - Driver Modules - 驱动模块 + + job-priority + 任务优先级 - - - - - - Device File - 设备文件 + + latency + - - Device Files - 设备文件 + + marker-change-time + 标记修改次数 - - - - Device Number - 设备编号 + + number-up + 编号 - - Application - 应用 + + orientation-requested + 打印方向 - - status - 状态 + + physical id + - - - - logical name - 逻辑地址 + + print-color-mode + 颜色模式 - - - ansiversion - ANSI版本 + + printer-is-accepting-jobs + 当前可打印 - - CPU implementer - CPU程序 + + printer-is-shared + 打印机已共享 - - CPU architecture - CPU架构 + + printer-is-temporary + 临时打印机 - - CPU variant - CPU变量 + + printer-make-and-model + 制造商和型号 - - CPU part - CPU部件 + + printer-state-change-time + 打印机状态修改时间 - - CPU revision - CPU版本 + + printer-state-reasons + 打印机状态信息 - - One - + + printer-type + 打印机类型 - - Two - + + printer-uri-supported + 支持的URI - - Four - + + Product Date + 产品日子 - - Six - + + sides + 打印面数 - - Eight - + SSD + 固态 - - Nine - + HDD + 机械 - - Ten - + + logicalsectorsize + 逻辑分区大小 - - Twelve - 十二 + + sectorsize + 扇区大小 - - Fourteen - 十四 + + guid + 全局唯一标识符 - - Sixteen - 十六 + + Geometry (Logical) + 几何数据(逻辑) + + + DeviceManager - - Eighteen - 十八 + + + + + + + + + + + Overview + 概况 - - Twenty - 二十 + + + + CPU + 处理器 - - Twenty-two - 二十二 + + + CPU quantity + CPU数量 - - Twenty-four - 二十四 + + + Motherboard + 主板 - - Twenty-six - 二十六 + + + Memory + 内存 - - Twenty-eight - 二十八 + + + Display Adapter + 显示适配器 - - Thirty - 三十 + + + Sound Adapter + 音频适配器 - - Thirty-two - 三十二 + + + Storage + 存储设备 - - Thirty-four - 三十四 + + + Other PCI Devices + 其他PCI设备 - - Thirty-six - 三十六 + + + Battery + 电池 - - Thirty-eight - 三十八 + + + Bluetooth + 蓝牙 - - Forty - 四十 + + + Network Adapter + 网络适配器 - - Forty-two - 四十二 + + + Mouse + 鼠标与指针设备 - - Forty-four - 四十四 + + + Keyboard + 键盘 - - Forty-six - 四十六 + + + Monitor + 显示设备 - - Forty-eight - 四十八 + + + CD-ROM + 光驱 - - Fifty - 五十 + + + Printer + 打印机 - - Fifty-two - 五十二 + + + Camera + 图像设备 - - Fifty-four - 五十四 + + + Other Devices + Other Input Devices + 其他设备 - - Fifty-six - 五十六 + + + + Device + 设备 - - Fifty-eight - 五十八 + + + + OS + 操作系统 + + + DeviceMonitor - - Sixty - 六十 + + + + + inch + 英寸 + + + GetDriverNameWidget - - Sixty-two - 六十二 + + + Select a driver for update + 选择需要更新的驱动程序 - - Sixty-four - 六十四 + + No drivers found in this folder + 所选文件夹未检测到驱动文件 + + + GetInfoPool - - Sixty-six - 六十六 + + Loading Audio Device Info... + 获取音频设备信息... - - Sixty-eight - 六十八 + + Loading BIOS Info... + 获取BIOS信息... - - Seventy - 七十 + + Loading CD-ROM Info... + 获取光驱信息... - - Seventy-two - 七十二 + + Loading Operating System Info... + 获取操作系统信息... - - Seventy-four - 七十四 + + Loading CPU Info... + 获取处理器信息... - - Seventy-six - 七十六 + + Loading Other Devices Info... + 获取其他设备信息... - - Seventy-eight - 七十八 + + Loading Power Info... + 获取电池信息... - - - Eighty - 八十 + + + Loading Printer Info... + 获取打印机信息... - - Eighty-two - 八十二 + + Loading Mouse Info... + 获取鼠标信息... - - Eighty-four - 八十四 + + Loading Network Adapter Info... + 获取网络适配器信息... + + + LogTreeView - - Eighty-six - 八十六 + + + + Disable + 禁用 - - Eighty-eight - 八十八 + + Unavailable + 不可用 + + + LogViewItemDelegate - - Ninety - 九十 + + Disable + 禁用 - - Ninety-two - 九十二 + + Unavailable + 不可用 + + + MainWindow - - Ninety-four - 九十四 + + Device Info + export file's name + 设备信息 - - Ninety-six - 九十六 + + Display shortcuts + 显示快捷键 - - Ninety-eight - 九十八 + + Close + 关闭 - - One hundred - 一百 + + Help + 帮助 - - One hundred and Two - 一百零二 + + Copy + 复制 - - One hundred and four - 一百零四 + + System + 系统 - - One hundred and Six - 一百零六 + + Export + 导出 - - One hundred and Eight - 一百零八 + + Refresh + 刷新 - - One hundred and Ten - 一百一十 + + Device Manager + 设备管理器 - - One hundred and Twelve - 一百一十二 + + Hardware + 硬件信息 - - One hundred and Fourteen - 一百一十四 + + Drivers + 驱动管理 - - One hundred and Sixteen - 一百一十六 + + Monitor + 显示设备 - - One hundred and Eighteen - 一百一十八 + + Overview + 概况 - - One hundred and Twenty - 一百二十 + + Display Adapter + 显示适配器 - - One hundred and Twenty-two - 一百二十二 + + CPU + 处理器 - - One hundred and Twenty-four - 一百二十四 + + Network Adapter + 网络适配器 - - One hundred and Twenty-six - 一百二十六 + + Battery + 电池 + + + PageDetail - - One hundred and Twenty-eight - 一百二十八 + + More + 更多 + + + PageDriverBackupInfo - - One hundred and Ninety-two - 一百九十二 + + + Name + 名称 - - Two hundred and fifty-six - 二百五十六 + + + Current Version + 当前版本 - - GDDR capacity - GDDR容量 + + + Driver Platform Version + 驱动平台版本 - - GPU vendor - GPU供应商 + + Status + 状态 - - GPU type - GPU类型 + + Action + 操作 - - EGL version - EGL版本 + + Backupable Drivers + 可备份驱动 - - EGL client APIs - EGL接口 + + Backed up Drivers + 已备份驱动 + + + PageDriverControl - - GL version - GL版本 + + + Updating + 正在更新 - - GLSL version - GLSL版本 + + + + Cancel + button + 取 消 - - - - Unknown - 未知 + + Next + 下一步 - - Uniq - Uniq + + Warning + 注意 - - MSC - MSC + + The device will be unavailable after the driver uninstallation + 将从系统中卸载此驱动程序,卸载后该设备不可用 - - - - Hardware Class - 硬件类别 + + Uninstall + button + 卸 载 - - - - - CPU - 处理器 + + Uninstalling + 正在卸载 - - - - - No CPU found - 未发现处理器 + + Update successful + 驱动更新成功 - - - - - Motherboard - 主板 + + Uninstallation successful + 驱动卸载成功 - - - - - No motherboard found - 未发现主板 + + Update failed + 驱动更新失败 - - - - - Memory - 内存 + + Uninstallation failed + 驱动卸载失败 - - - - - No memory found - 未发现内存 + + OK + button + 确 定 - - - - - Storage - 存储设备 + + Next + button + 下一步 - - - - - No disk found - 未发现磁盘 + + The selected folder does not exist, please select again + 所选文件夹不存在,请重新选择 - - Driver restore failed! - 驱动还原失败! + + Update + button + 更 新 - - - Please try again or give us feedback - 请重试,或反馈给我们 + + Previous + button + 上一步 - - Driver backup failed! - 驱动备份失败! + + Broken package + 包文件损坏 - - - - - - Display Adapter - 显示适配器 + + Unmatched package architecture + 包文件与系统架构不匹配 - - - - - No GPU found - 未发现GPU + + + The selected file does not exist, please select again + 所选文件不存在,请重新选择 - - - - - Monitor - 显示设备 + + It is not a driver + 该文件不是驱动文件 - - - - - No monitor found - 未发现显示设备 + + Unable to install - no digital signature + 无法安装,安装包无数字签名 - - - - - - Network Adapter - 网络适配器 + + Unknown error + 未知错误 - - - - - No network adapter found - 未发现网络适配器 + + The driver module was not found + 未发现该驱动模块 - - - - - - Sound Adapter - 音频适配器 + + Invalid module format + 模块格式无效 - - - - - No audio device found - 未发现音频设备 + + The driver module has dependencies + 驱动模块被依赖 + + + PageDriverInstallInfo - - - - - - Bluetooth - 蓝牙 + + + + Device Name + 设备名称 - - - - - No Bluetooth device found - 未发现蓝牙设备 + + Version Available + 可安装版本 - - - - - Other PCI Devices - 其他PCI设备 + + + Size + 大小 - - - - - No other PCI devices found - 未发现其他PCI设备 + + + Status + 状态 - - - - - Power - 电池 + + + Action + 操作 - - - - - No battery found - 未发现电池 + + New Version + 可更新版本 - - - - - - Keyboard - 键盘 + + Current Version + 当前版本 - - - - - No keyboard found - 未发现键盘 + + Missing drivers (%1) + 可安装驱动 (%1) - - - - - - Mouse - 鼠标 + + Outdated drivers (%1) + 可更新驱动 (%1) - - - - - No mouse found - 未发现鼠标 + + Up-to-date drivers (%1) + 无需更新驱动 (%1) + + + PageDriverManager - - - - - - - Printer - 打印机 + + + + Driver Install + 驱动安装 - - - - - No printer found - 未发现打印机 + + + + + Driver Backup + 驱动备份 - - - - - Camera - 图像设备 + + + Driver Restore + 驱动还原 - - - - - No camera found - 未发现图像设备 + + OK + 确 定 - - - - - CD-ROM - 光驱 + + Feedback + 反馈 + + + PageDriverRestoreInfo - - - - - No CD-ROM found - 未发现光驱 + + You do not have any drivers to restore, please backup first + 您没有驱动可以还原,请先备份 - - - - - - Other Devices - 其他设备 + + Go to Backup Driver + 前往备份驱动 - - - - - No other devices found - 未发现其他设备 + + Name + 名称 - - Array Handle - 数组程序 + + Current Version + 当前版本 - - Form Factor - 尺寸型号 + + Backup Version + 备份版本 - - Set - 设置 + + Action + 操作 - - Bank Locator - 内存通道 + + Restorable Drivers + 可还原驱动 + + + PageListView - - Type Detail - 类型详情 + + Refresh + 刷新 - - Part Number - 部件号码 + + Export + 导出 - - Rank - 位列 + + Overview + 概况 - - Memory Technology - 内存技术 + + Driver Install + 驱动安装 - - Memory Operating Mode Capability - 内存操作模式 + + Driver Backup + 驱动备份 - - Firmware Version - 固件版本 + + Driver Restore + 驱动还原 + + + PageMultiInfo - - Module Manufacturer ID - 组件制造商 + + + + Storage + 存储设备 - - Module Product ID - 组件产品ID + + + + Memory + 内存 - - Memory Subsystem Controller Manufacturer ID - 内存子系统控制器制造商 + + Failed to enable the device + 启用失败 - - Memory Subsystem Controller Product ID - 内存子系统控制器产品ID + + Failed to disable the device + 禁用失败 - - Non-Volatile Size - 不易丢失大小 + + Failed to disable it: unable to get the device SN + 无法获取设备序列号,禁用失败 - - Volatile Size - 易丢失大小 + + Update Drivers + 更新驱动 - - Cache Size - 缓存大小 + + Uninstall Drivers + 卸载驱动 + + + PageOverview - - Logical Size - 逻辑大小 + + Refresh + 刷新 - - - - - - inch - 英寸 + + Export + 导出 - - Date - 日期 + + Copy + 复制 - - ioport - I/O端口 + + Overview + 概况 + + + PageSingleInfo - - network - 网络 + + Refresh + 刷新 - - battery - 电池 + + Export + 导出 + + + + Copy + 复制 - - native-path - 安装路径 + + + Enable + 启用 - - power supply - 供电 + + Update drivers + 更新驱动 - - updated - 更新时间 + + Uninstall drivers + 卸载驱动 - - has history - 历史记录 + + Allow it to wake the computer + 允许唤起电脑 - - has statistics - 用电统计 + + Disable + 禁用 - - rechargeable - 可再充电 + + + Failed to disable it: unable to get the device SN + 无法获取设备序列号,禁用失败 - - state - 状态 + + Failed to disable the device + 禁用失败 - - warning-level - 警告等级 + + Failed to enable the device + 启用失败 - - energy - 容量 + + Update Drivers + 更新驱动 - - energy-empty - 最低容量 + + Uninstall Drivers + 卸载驱动 + + + QObject - - energy-full - 完全充满容量 + + + + + CPU + 处理器 - - energy-full-design - 设计容量 + + + + + No CPU found + 未发现处理器 - - energy-rate - 能量密度 + + + + + Motherboard + 主板 - - voltage - 电压 + + + + + No motherboard found + 未发现主板 - - percentage - 电量 + + + + + No memory found + 未发现内存 - - technology - 电池技术 + + + + + Memory + 内存 - - icon-name - 图标 + + + + + Storage + 存储设备 - - online - 在线 + + + + + No disk found + 未发现磁盘 - - daemon-version - Daemon版本 + + Driver restore failed! + 驱动还原失败! - - on-battery - 使用电池 + + + Please try again or give us feedback + 请重试,或反馈给我们 - - lid-is-closed - 笔记本合盖 + + Driver backup failed! + 驱动备份失败! - - lid-is-present - 打开笔记本盖子 + + + + + + Display Adapter + 显示适配器 - - critical-action - 电量极低时执行 + + + + + No GPU found + 未发现GPU - - copies - 复印数量 + + + + + Monitor + 显示设备 - - job-cancel-after - 此时取消打印任务 + + + + + No monitor found + 未发现显示设备 - - job-hold-until - 保留打印任务直至 + + + + + + Network Adapter + 网络适配器 - - job-priority - 任务优先级 + + + + + No network adapter found + 未发现网络适配器 - - marker-change-time - 标记修改次数 + + + + + + Sound Adapter + 音频适配器 - - number-up - 编号 + + + + + No audio device found + 未发现音频设备 - - orientation-requested - 打印方向 + + + + + + Bluetooth + 蓝牙 - - print-color-mode - 颜色模式 + + + + + No Bluetooth device found + 未发现蓝牙设备 - - printer-is-accepting-jobs - 当前可打印 + + + + + Other PCI Devices + 其他PCI设备 - - printer-is-shared - 打印机已共享 + + + + + No other PCI devices found + 未发现其他PCI设备 - - printer-is-temporary - 临时打印机 + + + + + Power + 电池 - - printer-make-and-model - 制造商和型号 + + + + + No battery found + 未发现电池 - - printer-state-change-time - 打印机状态修改时间 + + + + + + Keyboard + 键盘 - - printer-state-reasons - 打印机状态信息 + + + + + No keyboard found + 未发现键盘 - - printer-type - 打印机类型 + + + + + + Mouse + 鼠标 - - printer-uri-supported - 支持的URI + + + + + No mouse found + 未发现鼠标 - - sides - 打印面数 + + + + + + Printer + 打印机 - - - - - - - SSD - 固态 + + + + + No printer found + 未发现打印机 - - - HDD - 机械 + + + + + Camera + 图像设备 - - - bus info - 总线信息 + + + + + No camera found + 未发现图像设备 - - logicalsectorsize - 逻辑分区大小 + + + + + CD-ROM + 光驱 - - sectorsize - 扇区大小 + + + + + No CD-ROM found + 未发现光驱 - - guid - 全局唯一标识符 + + + + + + + Other Devices + 其他设备 - - Geometry (Logical) - 几何数据(逻辑) + + + + + No other devices found + 未发现其他设备 - - + + Device Manager 设备管理器 - + Device Manager is a handy tool for viewing hardware information and managing the devices. 设备管理器是查看、管理硬件设备的工具软件。 - + New drivers available! Install or update them now. 您有驱动可进行安装/更新 - + View 查看 @@ -3765,171 +2917,171 @@ 选择驱动所在位置 - + %1 driver updates available 发现%1个驱动可安装更新 - - + + Time checked: %1 检测时间: %1 - + Downloading drivers for %1... 正在下载%1驱动… - + Download speed: %1 Downloaded %2/%3 下载速度:%1 已完成 %2/%3 - + Installing drivers for %1... 正在安装%1驱动… - + %1 drivers installed, %2 drivers failed 驱动安装成功%1个,失败%2个 - + %1 drivers installed 共成功安装%1个驱动 - + Failed to install drivers 驱动安装失败 - + Network error. Reconnecting... 网络异常,重试中 - + Download speed: %1 下载速度:%1 - + Your drivers are up to date 驱动已是最新 - + All drivers have been backed up 驱动已全部备份 - - + + A total of %1 drivers, of which %2 have been backed up 总计%1个驱动,其中%2个已备份 - + You have %1 drivers that can be backed up, it is recommended to do so immediately 您有%1个驱动可以备份,建议立即备份 - + You have %1 drivers that can be backed up 您有%1个驱动可以备份 - + Backing up the %1 driver, a total of %2 drivers 正在备份第%1个驱动,共%2个 - + Backing up: %1 正在备份:%1 - + %1 drivers backed up, %2 drivers failed 驱动备份成功%1个,失败%2个 - + Failed to backup drivers 备份失败 - + %1 drivers backed up %1个驱动已备份 - + You have %1 drivers that can be restored 您有%1个驱动可以还原 - + Please select a driver to restore 请选择驱动还原 - + Driver is restoring... 驱动还原中… - + Restoring: %1 正在还原:%1 - + reboot 重启电脑 - + Please %1 for the installed drivers to take effect 驱动已安装完成,请稍后%1生效 - + View backup path 查看备份路径 - + Backup All 一键备份 + - submit feedback 反馈 - + Please try again or %1 to us 驱动未安装成功,请重试或%1给我们 - + Install All 一键安装 + - Scan Again 重新检测 - + Cancel 取 消 @@ -3965,151 +3117,151 @@ 请重新检测或%1给我们 - + You are installing a driver, which will be interrupted if you exit. 当前正在安装驱动,退出应用后任务将会中断 - - - + + + Are you sure you want to exit? 确认是否退出应用? - - - + + + Exit button 退 出 - - - + + + Cancel button 取 消 - + You are backing up drivers, which will be interrupted if you exit. 当前正在备份驱动,退出应用后任务将会中断 - + You are restoring drivers, which will be interrupted if you exit. 当前正在还原驱动,退出应用后任务将会中断 - + Bluetooth adapter 蓝牙适配器 - - + + Imaging device 图像设备 - + Display adapter 显卡 - + Sound card 声卡 - + Network adapter 网卡 - + Wireless network adapter 无线网卡 - + Installation successful 安装成功 - + Installation failed 安装失败 - + Downloading 下载中 - + Installing 安装中 - + Not installed 驱动未安装 - + Out-of-date 驱动可更新 - + Waiting 等待中 - + Not backed up 驱动未备份 - + Backing up 正在备份 - + Backup failed 备份失败 - + Backup successful 备份成功 - + Restoring 还原中 - + Unknown error 未知错误 - + Network error 网络异常 - + Canceled 已取消 - + Failed to get driver files 驱动文件获取异常 @@ -4133,6 +3285,12 @@ Install 安装 + + + + inch + 英寸 + TableWidget @@ -4205,7 +3363,7 @@ UrlChooserEdit - + Select a local folder please 请选择本地文件夹