Skip to content
Merged
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
21 changes: 19 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DevicePower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commonfunction.h" not found.

// Qt库文件
#include<QFileInfo>
#include <QFileInfo>

Check warning on line 10 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 11 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

// Dtk头文件
#include <DApplication>

Check warning on line 14 in deepin-devicemanager/src/DeviceManager/DevicePower.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

constexpr const char* kPowerService = "com.deepin.system.Power";
constexpr const char* kPowerPath = "/com/deepin/system/Power";
constexpr const char* kPowerInterface = "com.deepin.system.Power";

DWIDGET_USE_NAMESPACE

DevicePower::DevicePower()
Expand Down Expand Up @@ -101,7 +106,19 @@
m_Temp = QString("%1 degrees C").arg(temp);
}*/

getOtherMapInfo(mapInfo);
// 当前电池容量修改成通过DDE接口获得,目的是与状态栏的当前电池容量保持一致(bug#333825)
QMap<QString, QString> tmpMapInfo = mapInfo;
if (tmpMapInfo.contains("percentage")) {
QDBusInterface interface(kPowerService, kPowerPath, kPowerInterface, QDBusConnection::systemBus());
if (interface.isValid()) {
double tmpValue = interface.property("BatteryPercentage").toDouble();
tmpMapInfo["percentage"] = QString("%1%").arg(static_cast<int>(tmpValue));
} else {
qCritical() << QString("Dbus %1 is not valid!").arg(kPowerService);
}
}

getOtherMapInfo(tmpMapInfo);
return true;
}

Expand Down