Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ bool DeviceMonitor::setInfoFromXradr(const QString &main, const QString &edid, c
qCDebug(appLog) << "Monitor info already set from TOML, skipping xrandr";
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()) {
qCDebug(appLog) << "Interface is not empty, checking current resolution";
Expand All @@ -265,10 +274,10 @@ 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(match.captured(1)).arg(curRate);
m_CurrentResolution = QString("%1@%2").arg(match.captured(1)).arg(curRate).replace("x", "×", Qt::CaseInsensitive);
} else {
qCDebug(appLog) << "Rate is empty";
m_CurrentResolution = QString("%1").arg(match.captured(1));
m_CurrentResolution = QString("%1").arg(match.captured(1)).replace("x", "×", Qt::CaseInsensitive);
}
}
}
Expand Down Expand Up @@ -359,11 +368,12 @@ void DeviceMonitor::loadBaseDeviceInfo()
{
qCDebug(appLog) << "Loading base device info for monitor";
// 添加基本信息
if (Common::specialComType != 6)
if (Common::specialComType != 6 && Common::specialComType != 5) {
addBaseDeviceInfo("Name", m_Name);
addBaseDeviceInfo("Vendor", m_Vendor);
addBaseDeviceInfo("Type", m_Model);
addBaseDeviceInfo("Display Input", m_DisplayInput);
addBaseDeviceInfo("Vendor", m_Vendor);
addBaseDeviceInfo("Type", m_Model);
addBaseDeviceInfo("Display Input", m_DisplayInput);
}
addBaseDeviceInfo("Interface Type", m_Interface);
}

Expand Down Expand Up @@ -451,13 +461,13 @@ bool DeviceMonitor::setMainInfoFromXrandr(const QString &info, const QString &ra
m_RefreshRate = QString("%1").arg(curRate);
}
if (Common::specialComType == 5 || Common::specialComType == 6) {
m_CurrentResolution = QString("%1").arg(QT_REGEXP_CAPTURE(reScreenSize, 1, info));
m_CurrentResolution = QString("%1").arg(QT_REGEXP_CAPTURE(reScreenSize, 1, info)).replace("x", "×", Qt::CaseInsensitive);
} else {
m_CurrentResolution = QString("%1 @%2").arg(QT_REGEXP_CAPTURE(reScreenSize, 1, info)).arg(curRate);
m_CurrentResolution = QString("%1 @%2").arg(QT_REGEXP_CAPTURE(reScreenSize, 1, info)).arg(curRate).replace("x", "×", Qt::CaseInsensitive);
}
} else {
qCDebug(appLog) << "Rate is empty, setting current resolution without rate";
m_CurrentResolution = QString("%1").arg(match.captured(1));
m_CurrentResolution = QString("%1").arg(match.captured(1).replace("x", "×", Qt::CaseInsensitive));
}
}

Expand Down Expand Up @@ -531,8 +541,9 @@ void DeviceMonitor::caculateScreenSize()
m_Height = match.captured(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(translateStr("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);
qCDebug(appLog) << "Calculated screen size:" << m_ScreenSize;

}
}

Expand Down Expand Up @@ -567,6 +578,6 @@ 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(translateStr("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;
}
5 changes: 3 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

// 项目自身文件
#include "DeviceStorage.h"
#include "commonfunction.h"

Check warning on line 7 in deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commonfunction.h" not found.
#include <cfloat>

Check warning on line 8 in deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <cfloat> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <cmath>

Check warning on line 9 in deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <cmath> not found. Please note: Cppcheck does not need standard library headers to get proper results.

// Qt库文件
#include <QDir>
Expand Down Expand Up @@ -561,7 +562,7 @@
// 将字符串转为数字大小进行比较
int num1 = 0;
int num2 = 0;
QRegularExpression reg(".*\\[(\\d*).*\\]$");
QRegularExpression reg(".*\\[(\\d+\\.?\\d+).*\\]");
if (reg.match(size1).hasMatch())
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
num1 = reg.cap(1).toInt(); // Qt 5 使用 cap
Expand All @@ -576,7 +577,7 @@
#endif

// 返回较大值
if (num1 > num2) {
if ((num1 - num2) > FLT_EPSILON * fmaxf(fabsf(num1), fabsf(num2))) {
qCDebug(appLog) << "DeviceStorage::compareSize, num1 > num2";
return size1;
} else {
Expand Down
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static void parseEDID(QStringList allEDIDS,QString input)
QMap<QString, QString> mapInfo;
mapInfo.insert("Vendor",edidParser.vendor());
mapInfo.insert("Model",edidParser.model());
mapInfo.insert("Date",edidParser.releaseDate());
//mapInfo.insert("Date",edidParser.releaseDate());
mapInfo.insert("Size",edidParser.screenSize());
mapInfo.insert("Display Input",input);

Expand All @@ -511,7 +511,7 @@ void HWGenerator::generatorMonitorDevice()
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"))
continue;
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Tool/EDIDParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void EDIDParser::parseScreenSize()
}

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', 1)).arg(QObject::tr("inch")).arg(m_Width).arg(m_Height);
qCDebug(appLog) << "Screen size parsed:" << m_ScreenSize << "Width:" << m_Width << "Height:" << m_Height;
}

Expand Down
10 changes: 6 additions & 4 deletions deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@

QList<QMap<QString, QString>> lstMap;
loadXrandrVerboseInfo(lstMap, "xrandr --verbose");
std::reverse(lstMap.begin(), lstMap.end());
if (Common::specialComType == Common::SpecialComputerType::NormalCom) {
std::reverse(lstMap.begin(), lstMap.end());
}
QList<QMap<QString, QString> >::const_iterator it = lstMap.begin();
for (; it != lstMap.end(); ++it) {
if ((*it).size() < 1)
Expand Down Expand Up @@ -383,8 +385,8 @@
}

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));
}
}

Expand Down Expand Up @@ -470,10 +472,10 @@
arg >> resolution;

curResolutionWidth = resolution.width;
curResolutionHeight = resolution.height;

Check warning on line 475 in deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Uninitialized struct member: resolution.height
resRate = resolution.refreshRate;

Check warning on line 476 in deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Uninitialized struct member: resolution.refreshRate
QMap<QString,QString>infoMap;
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());
Expand Down