CVS commit by vkrause: Always check if the battery is present before displaying its data. Fixes the "-1% charged" message. M +14 -13 daemondock.cpp 1.58 --- kdeutils/klaptopdaemon/daemondock.cpp #1.57:1.58 @@ -366,15 +366,16 @@ void laptop_dock::mousePressEvent( QMous QString tmp; - if (pdaemon->left < 0) { // buggy BIOS if (pdaemon->val >= 0) { - tmp = i18n("%1% charged").arg(pdaemon->val); - } else { - tmp = i18n("No Battery"); - } - } else { + if (pdaemon->left >= 0) { QString num3; num3.setNum(pdaemon->left%60); num3 = num3.rightJustify(2, '0'); tmp = i18n("%1:%2 time left").arg(pdaemon->left/60).arg(num3); + } else { + // no remaining time available + tmp = i18n("%1% charged").arg(pdaemon->val); + } + } else { + tmp = i18n("No Battery"); } popup->insertItem(tmp); @@ -640,5 +641,5 @@ quit: if (pdaemon->val == 100) { tmp = i18n("Plugged in - fully charged");; - } else { + } else if (pdaemon->val >= 0) { if (pdaemon->left >= 0) { QString num3; @@ -647,10 +648,10 @@ quit: tmp = i18n("Plugged in - %1% charged (%2:%3 time left)") .arg(pdaemon->val).arg(pdaemon->left/60).arg(num3); - } else - if (pdaemon->val == -1) { - tmp = i18n("Plugged in - no battery"); } else { + // no remaining time available tmp = i18n("Plugged in - %1% charged").arg(pdaemon->val); } + } else { + tmp = i18n("Plugged in - no battery"); } } else {