summaryrefslogtreecommitdiffstats
path: root/src/detaileddialog.cpp
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2020-02-16 14:34:08 +0100
committerSlávek Banko <[email protected]>2020-02-16 14:34:08 +0100
commitfa0e4e246ccb8f436598db4deee1777decfbc702 (patch)
tree3e9950b80df1bf908589c94b596d14c351423c62 /src/detaileddialog.cpp
parent80c12d8a765e1afb7b9d0d67df0117a95578595c (diff)
downloadtdepowersave-fa0e4e246ccb8f436598db4deee1777decfbc702.tar.gz
tdepowersave-fa0e4e246ccb8f436598db4deee1777decfbc702.zip
Fix units of current consumption value.
Previously it was not clear whether the units in tdehwlib are in Wh and W or Ah and A. Now the units are always Ah and A. Because power consumption is usually given in W, the value is converted from A to W. If it is less than 100 W, it is displayed as a decimal number. This is related to issue TDE/tdelibs#68. Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'src/detaileddialog.cpp')
-rw-r--r--src/detaileddialog.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/detaileddialog.cpp b/src/detaileddialog.cpp
index 76340b5..851d844 100644
--- a/src/detaileddialog.cpp
+++ b/src/detaileddialog.cpp
@@ -273,12 +273,17 @@ void detaileddialog::setPowerConsumption() {
// refresh battery collection
primaryBatteries = hwinfo->getPrimaryBatteries();
- int rate = primaryBatteries->getCurrentRate();
+ double rate = primaryBatteries->getCurrentRate();
- if (rate > 0 && !primaryBatteries->getChargeLevelUnit().isEmpty()) {
+ if (rate > 0 && !primaryBatteries->getChargeLevelUnit().isEmpty()) {
TQString _val;
- _val.setNum(rate);
+ if (rate > 100) {
+ _val = TQString("%L1").arg((int)rate);
+ }
+ else {
+ _val = TQString("%L1").arg(rate, 0, 'g', 3);
+ }
_val += " " + primaryBatteries->getChargeLevelUnit().remove('h');
tl_powerConsValue->setText(_val);