From fce034d2ce0ef3aa4e130df594474f2d3d986b13 Mon Sep 17 00:00:00 2001 From: Emir SARI Date: Mon, 5 Feb 2024 01:12:22 +0300 Subject: [PATCH] notification_server: Use automatic percent formatting This uses automatic percent formatting for the BStatusBar progress text, instead of appending the sign manually. Change-Id: I435220dd774822b60e376972a0f379a0e2b7359e Reviewed-on: https://review.haiku-os.org/c/haiku/+/7375 Reviewed-by: Adrien Destugues Tested-by: Commit checker robot --- src/servers/notification/NotificationView.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/servers/notification/NotificationView.cpp b/src/servers/notification/NotificationView.cpp index f6234bd6d5..de5c5ea335 100644 --- a/src/servers/notification/NotificationView.cpp +++ b/src/servers/notification/NotificationView.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -95,10 +96,14 @@ NotificationView::NotificationView(BNotification* notification, bigtime_t timeou progress->SetMaxValue(1.0f); progress->Update(fNotification->Progress()); - BString label = ""; - label << (int)(fNotification->Progress() * 100) << " %"; - progress->SetTrailingText(label); + BNumberFormat numberFormat; + BString label; + double progressPercent = fNotification->Progress(); + if (numberFormat.FormatPercent(label, progressPercent) != B_OK) + label.SetToFormat("%d%%", (int)(progressPercent * 100)); + + progress->SetTrailingText(label.String()); layout->AddView(progress); } // fall through.