Skip to content

Commit

Permalink
feat: hw机型判断适配dconfig
Browse files Browse the repository at this point in the history
Description: hw机型判断适配dconfig

Log: hw机型判断适配dconfig

Task: https://pms.uniontech.com/task-view-276433.html
  • Loading branch information
hundundadi authored and deepin-bot[bot] committed Jul 19, 2023
1 parent 906ac92 commit 309056f
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 21 deletions.
8 changes: 8 additions & 0 deletions deepin-devicemanager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions deepin-devicemanager/assets/org.deepin.devicemanager.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
12 changes: 12 additions & 0 deletions deepin-devicemanager/src/Page/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <DTitlebar>
#include <DDialog>
#include <QShortcut>
#ifdef DTKCORE_CLASS_DConfigFile
#include <DConfig>
#endif

// Qt库文件
#include <QResizeEvent>
Expand Down Expand Up @@ -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();
Expand Down
66 changes: 45 additions & 21 deletions deepin-devicemanager/src/commonfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static QMap<QString, QString> mapArch = { {"aarch64", "arm64"}

static bool initBoardVendorFlag = false;
static QString boardVendorKey = "";
int Common::specialComType = -1;

QString Common::getArch()
{
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 14 additions & 0 deletions deepin-devicemanager/src/commonfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@ class Common
public:
Common();
~Common();
enum SpecialComputerType{
Unknow = -1,
NormalCom,
PGUW,
KLVV,
KLVU,
PGUV
};
static QString getArch();

static QString getArchStore();

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

0 comments on commit 309056f

Please sign in to comment.