AboutSystem: Use BNumberFormat for percentage value
This provides automatic percentage formatting according to the locale setting Change-Id: I571d2bd9ffc53425c9633de3504d04f41acf0017 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6157 Tested-by: Automation <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include <LayoutBuilder.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Messenger.h>
|
||||
#include <NumberFormat.h>
|
||||
#include <ObjectList.h>
|
||||
#include <OS.h>
|
||||
#include <Path.h>
|
||||
@@ -269,6 +270,8 @@ private:
|
||||
|
||||
BDragger* fDragger;
|
||||
|
||||
BNumberFormat fNumberFormat;
|
||||
|
||||
float fCachedBaseWidth;
|
||||
float fCachedMinWidth;
|
||||
float fCachedBaseHeight;
|
||||
@@ -1149,8 +1152,13 @@ BString
|
||||
SysInfoView::_GetRamUsage(system_info* sysInfo)
|
||||
{
|
||||
BString ramUsage;
|
||||
ramUsage.SetToFormat(B_TRANSLATE("%d MiB used (%d%%)"), used_pages(sysInfo),
|
||||
(int)(100 * sysInfo->used_pages / sysInfo->max_pages));
|
||||
BString data;
|
||||
double usedMemoryPercent = double(sysInfo->used_pages) / sysInfo->max_pages;
|
||||
|
||||
if (fNumberFormat.FormatPercent(data, usedMemoryPercent) != B_OK)
|
||||
data.SetToFormat("%d%%", (int)(100 * usedMemoryPercent));
|
||||
|
||||
ramUsage.SetToFormat(B_TRANSLATE("%d MiB used (%s)"), used_pages(sysInfo), data.String());
|
||||
|
||||
return ramUsage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user