From 309056ffdde05cf7c3b1a5b2a7b89bf2d8772c41 Mon Sep 17 00:00:00 2001 From: Wang Cong Date: Thu, 6 Jul 2023 21:42:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20hw=E6=9C=BA=E5=9E=8B=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=82=E9=85=8Ddconfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: hw机型判断适配dconfig Log: hw机型判断适配dconfig Task: https://pms.uniontech.com/task-view-276433.html --- deepin-devicemanager/CMakeLists.txt | 8 +++ .../assets/org.deepin.devicemanager.json | 16 +++++ deepin-devicemanager/src/Page/MainWindow.cpp | 12 ++++ deepin-devicemanager/src/commonfunction.cpp | 66 +++++++++++++------ deepin-devicemanager/src/commonfunction.h | 14 ++++ 5 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 deepin-devicemanager/assets/org.deepin.devicemanager.json diff --git a/deepin-devicemanager/CMakeLists.txt b/deepin-devicemanager/CMakeLists.txt index 000fadbe..c5e4d90a 100644 --- a/deepin-devicemanager/CMakeLists.txt +++ b/deepin-devicemanager/CMakeLists.txt @@ -150,6 +150,14 @@ install(DIRECTORY ${APP_RES_DIR}/deepin-devicemanager DESTINATION ${CMAKE_INSTAL install(FILES ${APP_AUTHENTICATION} DESTINATION ${CMAKE_INSTALL_DATADIR}/polkit-1/actions) install(FILES ${APP_SERVICE} DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services) +#hw机型增加DConfig配置 +set(APPID org.deepin.devicemanager) +set(configFile ${PROJECT_SOURCE_DIR}/assets/org.deepin.devicemanager.json) +if (DEFINED DSG_DATA_DIR) + message("-- DConfig is supported by DTK") + dconfig_meta_files(APPID ${APPID} FILES ${configFile}) +endif() + # Test--------deepin-devicemanager if (CMAKE_COVERAGE_ARG STREQUAL "CMAKE_COVERAGE_ARG_ON") add_subdirectory(./tests) diff --git a/deepin-devicemanager/assets/org.deepin.devicemanager.json b/deepin-devicemanager/assets/org.deepin.devicemanager.json new file mode 100644 index 00000000..8bbde56a --- /dev/null +++ b/deepin-devicemanager/assets/org.deepin.devicemanager.json @@ -0,0 +1,16 @@ +{ + "magic": "dsg.config.meta", + "version": "1.0", + "contents": { + "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)", + "permissions": "readwrite", + "visibility": "private" + } + } +} diff --git a/deepin-devicemanager/src/Page/MainWindow.cpp b/deepin-devicemanager/src/Page/MainWindow.cpp index cea954c7..db255db2 100644 --- a/deepin-devicemanager/src/Page/MainWindow.cpp +++ b/deepin-devicemanager/src/Page/MainWindow.cpp @@ -26,6 +26,9 @@ #include #include #include +#ifdef DTKCORE_CLASS_DConfigFile +#include +#endif // Qt库文件 #include @@ -345,6 +348,15 @@ void MainWindow::initWindowTitle() } }); titlebar()->addWidget(mp_ButtonBox); +#ifdef DTKCORE_CLASS_DConfigFile + //需要查询是否支持特殊机型静音恢复,例如hw机型 + DConfig *dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager"); + //需要判断Dconfig文件是否合法 + if(dconfig && dconfig->isValid() && dconfig->keyList().contains("specialComType")){ + Common::specialComType = dconfig->value("specialComType").toInt(); + } + qInfo() << "Common::specialComType value is:" << Common::specialComType; +#endif // 特殊处理 if (!Common::boardVendorType().isEmpty()) mp_ButtonBox->hide(); diff --git a/deepin-devicemanager/src/commonfunction.cpp b/deepin-devicemanager/src/commonfunction.cpp index d4324210..180960bd 100644 --- a/deepin-devicemanager/src/commonfunction.cpp +++ b/deepin-devicemanager/src/commonfunction.cpp @@ -27,6 +27,7 @@ static QMap mapArch = { {"aarch64", "arm64"} static bool initBoardVendorFlag = false; static QString boardVendorKey = ""; +int Common::specialComType = -1; QString Common::getArch() { @@ -93,29 +94,52 @@ static bool isModeW525(void) QString Common::checkBoardVendorFlag() { - QProcess process; - process.start("dmidecode", QStringList() << "-s" << "system-product-name"); - process.waitForFinished(-1); - QString info = process.readAllStandardOutput(); - if (info.isEmpty()) { - getDeviceInfo(info, "dmidecode_spn.txt"); - } - if (info.contains("KLVV", Qt::CaseInsensitive) || info.contains("L540", Qt::CaseInsensitive)) { - boardVendorKey = "KLVV"; - } else if (info.contains("KLVU", Qt::CaseInsensitive)) { - boardVendorKey = "KLVU"; - } else if (info.contains("PGUV", Qt::CaseInsensitive)|| info.contains("W585", Qt::CaseInsensitive)) { - boardVendorKey = "PGUV"; - } else if (info.contains("PGUW", Qt::CaseInsensitive)) { - boardVendorKey = "PGUW"; - } - process.close(); + if(specialComType != -1){ + switch (specialComType) { + case NormalCom: + boardVendorKey = ""; + break; + case PGUW: + boardVendorKey = "PGUW"; + break; + case KLVV: + boardVendorKey = "KLVV"; + break; + case KLVU: + boardVendorKey = "KLVU"; + break; + case PGUV: + boardVendorKey = "PGUV"; + break; + default: + boardVendorKey = "PGUW"; + break; + } + }else{ + QProcess process; + process.start("dmidecode", QStringList() << "-s" << "system-product-name"); + process.waitForFinished(-1); + QString info = process.readAllStandardOutput(); + if (info.isEmpty()) { + getDeviceInfo(info, "dmidecode_spn.txt"); + } + if (info.contains("KLVV", Qt::CaseInsensitive) || info.contains("L540", Qt::CaseInsensitive)) { + boardVendorKey = "KLVV"; + } else if (info.contains("KLVU", Qt::CaseInsensitive)) { + boardVendorKey = "KLVU"; + } else if (info.contains("PGUV", Qt::CaseInsensitive) || info.contains("W585", Qt::CaseInsensitive)) { + boardVendorKey = "PGUV"; + } else if (info.contains("PGUW", Qt::CaseInsensitive)) { + boardVendorKey = "PGUW"; + } + process.close(); - if(boardVendorKey.isEmpty() && (isModeM900() || isModeW525())){ - boardVendorKey = "PGUW"; + if(boardVendorKey.isEmpty() && (isModeM900() || isModeW525())){ + boardVendorKey = "PGUW"; + } + qInfo() << "boardVendorKey:" << boardVendorKey; } - qInfo() << "boardVendorKey:" << boardVendorKey; - + qInfo() << "Current special computer type is " << boardVendorKey; initBoardVendorFlag = true; return boardVendorKey; } diff --git a/deepin-devicemanager/src/commonfunction.h b/deepin-devicemanager/src/commonfunction.h index f2a10d85..9f350b3d 100644 --- a/deepin-devicemanager/src/commonfunction.h +++ b/deepin-devicemanager/src/commonfunction.h @@ -14,6 +14,14 @@ class Common public: Common(); ~Common(); + enum SpecialComputerType{ + Unknow = -1, + NormalCom, + PGUW, + KLVV, + KLVU, + PGUV + }; static QString getArch(); static QString getArchStore(); @@ -21,5 +29,11 @@ class Common static QString checkBoardVendorFlag(); static QString boardVendorType(); + + /** + * @brief specialComType + * special computer type:PGUW(value:1),KLVV/L540(value:2),KLVU(value:3),PGUV/W585(value:4) + */ + static int specialComType; }; #endif // COMMONFUNCTION_H