Skip to content

Commit

Permalink
fix: 某为定制CPU名字显示
Browse files Browse the repository at this point in the history
 为某机定制CPU名字显示

Log:  某为定制CPU名字显示

Bug: https://pms.uniontech.com/bug-view-244199.html
  • Loading branch information
shuaijie authored and justforlxz committed Feb 27, 2024
1 parent e20250a commit 76f057d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
39 changes: 38 additions & 1 deletion deepin-devicemanager/src/GenerateDevice/PanguxGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "../DeviceManager/DeviceAudio.h"
#include "../DeviceManager/DeviceBluetooth.h"

#include "DeviceManager/DeviceManager.h"

PanguXGenerator::PanguXGenerator()
{
Expand Down Expand Up @@ -63,3 +63,40 @@ void PanguXGenerator::generatorBluetoothDevice()
}
}
}
void PanguXGenerator::generatorCpuDevice()
{
HWGenerator::generatorCpuDevice();

QFile file("/proc/cpuinfo");
if (!file.open(QIODevice::ReadOnly))
return;

QMap<QString, QString> 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<DeviceBaseInfo *> 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);
}
}
4 changes: 4 additions & 0 deletions deepin-devicemanager/src/GenerateDevice/PanguxGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class PanguXGenerator : public HWGenerator
* @brief generatorBluetoothDevice:生成蓝牙设备
*/
virtual void generatorBluetoothDevice() override;
/**
* @brief generatorCpuDevice:生成CPU设备
*/
virtual void generatorCpuDevice() override;
};

#endif // PANGUXGENERATOR_H

0 comments on commit 76f057d

Please sign in to comment.