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
24 changes: 12 additions & 12 deletions deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,18 @@ const QString DeviceMonitor::getOverviewInfo()
{
qCDebug(appLog) << "Getting monitor overview information";
QString ov;

if (Common::specialComType == 6 || Common::specialComType == 7) {
ov = QString("(%1)").arg(m_ScreenSize);
if (Common::isShowScreenSize()) {
if (Common::specialComType == 6 || Common::specialComType == 7) {
Comment thread
GongHeng2017 marked this conversation as resolved.
ov = QString("(%1)").arg(m_ScreenSize);
} else {
ov = QString("%1(%2)").arg(m_Name).arg(m_ScreenSize);
}
} else {
ov = QString("%1(%2)").arg(m_Name).arg(m_ScreenSize);
if (Common::specialComType == 6 || Common::specialComType == 7) {
ov = "";
} else {
ov = QString("%1").arg(m_Name);
}
}
qCDebug(appLog) << "Monitor overview:" << ov;
return ov;
Expand Down Expand Up @@ -403,14 +410,7 @@ void DeviceMonitor::loadOtherDeviceInfo()
}
}
addOtherDeviceInfo("Primary Monitor", m_MainScreen);
bool showScreenSize { true };
#ifdef DTKCORE_CLASS_DConfigFile
DConfig *dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager");
if(dconfig && dconfig->isValid() && dconfig->keyList().contains("showScreenSize")){
showScreenSize = dconfig->value("showScreenSize").toBool();
}
#endif
if (showScreenSize)
if (Common::isShowScreenSize())
addOtherDeviceInfo("Size", m_ScreenSize);
addOtherDeviceInfo("Serial Number", m_SerialNumber);
// addOtherDeviceInfo("Product Date", m_ProductionWeek);
Expand Down
12 changes: 12 additions & 0 deletions deepin-devicemanager/src/commonfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,15 @@ QByteArray Common::executeClientCmd(const QString &cmd, const QStringList &args,
}
return outPut;
}

bool Common::isShowScreenSize()
{
bool showScreenSize { true };
#ifdef DTKCORE_CLASS_DConfigFile
DConfig *dconfig = DConfig::create("org.deepin.devicemanager","org.deepin.devicemanager");
if(dconfig && dconfig->isValid() && dconfig->keyList().contains("showScreenSize")){
Comment on lines +307 to +308
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Clarify and enforce ownership of the DConfig instance to avoid potential leaks.

The raw pointer from DConfig::create isn’t freed here. Unless DTK guarantees ownership via a parent or other mechanism, this risks leaking on each call. Consider assigning a parent, wrapping it in a smart pointer, or reusing a shared instance if repeated calls are expected.

showScreenSize = dconfig->value("showScreenSize").toBool();
}
#endif
return showScreenSize;
}
2 changes: 2 additions & 0 deletions deepin-devicemanager/src/commonfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ class Common
static int specialComType;

static QByteArray executeClientCmd(const QString& cmd, const QStringList& args = QStringList(), const QString& workPath = QString(), int msecsWaiting = 30000, bool useEnv = true);

static bool isShowScreenSize();
};
#endif // COMMONFUNCTION_H
Loading