From d4aeda942540952a90e8f88813b85203259400ac Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Tue, 24 Sep 2024 23:37:05 +0300 Subject: Superkaramba: add memory sensor percentage format strings The strings which end in 'p' represent percentage value variants of the following pre-existing format strings: %fmb(p) %fm(p) %umb(p) %um(p) %fs(p) %us(p) Signed-off-by: Mavridis Philippe --- superkaramba/src/memsensor.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/superkaramba/src/memsensor.cpp b/superkaramba/src/memsensor.cpp index 1d6c4dc..8da5d58 100644 --- a/superkaramba/src/memsensor.cpp +++ b/superkaramba/src/memsensor.cpp @@ -319,17 +319,24 @@ void MemSensor::update() format = "%um"; } - format.replace( TQRegExp("%fmb", false), TQString::number( (int)(( totalMem - usedMemNoBuffers)/1024.0+0.5))); - format.replace( TQRegExp("%fm", false), TQString::number( (int)( ( totalMem - usedMem )/1024.0+0.5) )); + format.replace( TQRegExp("%fmbp", false), TQString::number( (int)((totalMem - usedMemNoBuffers) * 100.0 / totalMem) )); + format.replace( TQRegExp("%fmb", false), TQString::number( (int)((totalMem - usedMemNoBuffers) / 1024.0 + 0.5) )); + format.replace( TQRegExp("%fmp", false), TQString::number( (int)((totalMem - usedMem) * 100.0 / totalMem) )); + format.replace( TQRegExp("%fm", false), TQString::number( (int)((totalMem - usedMem) / 1024.0 + 0.5) )); - format.replace( TQRegExp("%umb", false), TQString::number( (int)((usedMemNoBuffers)/1024.0+0.5))); - format.replace( TQRegExp("%um", false), TQString::number( (int)((usedMem)/1024.0+0.5 ))); + format.replace( TQRegExp("%umbp", false), TQString::number( (int)(usedMemNoBuffers * 100.0 / totalMem) )); + format.replace( TQRegExp("%umb", false), TQString::number( (int)(usedMemNoBuffers / 1024.0 + 0.5) )); + format.replace( TQRegExp("%ump", false), TQString::number( (int)(usedMem * 100.0 / totalMem) )); + format.replace( TQRegExp("%um", false), TQString::number( (int)(usedMem / 1024.0 + 0.5) )); - format.replace( TQRegExp("%tm", false), TQString::number( (int)( (totalMem)/1024.0+0.5))); + format.replace( TQRegExp("%tm", false), TQString::number( (int)(totalMem / 1024.0 + 0.5) )); - format.replace( TQRegExp("%fs", false), TQString::number( (int)((totalSwap - usedSwap)/1024.0+0.5))); - format.replace( TQRegExp("%us", false), TQString::number( (int)(usedSwap/1024.0+0.5))); - format.replace( TQRegExp("%ts", false), TQString::number( (int)(totalSwap/1024.0+0.5))); + format.replace( TQRegExp("%fsp", false), TQString::number( (int)((totalSwap - usedSwap) * 100.0 / totalSwap) )); + format.replace( TQRegExp("%fs", false), TQString::number( (int)((totalSwap - usedSwap) / 1024.0 + 0.5) )); + format.replace( TQRegExp("%usp", false), TQString::number( (int)(usedSwap * 100.0 / totalSwap) )); + format.replace( TQRegExp("%us", false), TQString::number( (int)(usedSwap / 1024.0 + 0.5) )); + + format.replace( TQRegExp("%ts", false), TQString::number( (int)(totalSwap / 1024.0 + 0.5) )); meter->setValue(format); ++it; -- cgit v1.2.1