From dae087ed53b874dafa4fc2ec96fe24de7213309c Mon Sep 17 00:00:00 2001 From: Emir SARI Date: Thu, 28 Mar 2024 14:28:24 +0300 Subject: [PATCH] ShowImage: Apply i18n to number values Also use multiplication sign for a nicer look Change-Id: I526204832d4826f44a326f44037173418d8e2885 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7556 Haiku-Format: Haiku-format Bot Reviewed-by: Niels Sascha Reedijk Tested-by: Commit checker robot --- src/apps/showimage/ShowImageStatusView.cpp | 4 +--- src/apps/showimage/ShowImageWindow.cpp | 20 +++++++++++++------- src/apps/showimage/ShowImageWindow.h | 2 ++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/apps/showimage/ShowImageStatusView.cpp b/src/apps/showimage/ShowImageStatusView.cpp index bad2d726e2..80cc5ddc23 100644 --- a/src/apps/showimage/ShowImageStatusView.cpp +++ b/src/apps/showimage/ShowImageStatusView.cpp @@ -177,9 +177,7 @@ ShowImageStatusView::_SetZoomText(float zoom) { BNumberFormat numberFormat; BString data; - - if (numberFormat.FormatPercent(data, zoom) != B_OK) - data.SetToFormat("%.0f%%", zoom * 100); + numberFormat.FormatPercent(data, zoom); fCellText[kZoomCell] = data; } diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index 5d73da6f7d..2541f963e0 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -407,7 +407,7 @@ ShowImageWindow::_BuildRatingMenu() for (int32 i = 1; i <= 10; i++) { BMessage* message = new BMessage(MSG_SET_RATING); BString label; - label << i; + fNumberFormat.Format(label, i); message->AddInt32("rating", i); fRatingMenu->AddItem(new BMenuItem(label.String(), message)); } @@ -1149,15 +1149,21 @@ ShowImageWindow::_GetFileInfo(const entry_ref& ref) void ShowImageWindow::_UpdateStatusText(const BMessage* message) { - BString frameText; + BString frameText, height, width; if (fImageView->Bitmap() != NULL) { BRect bounds = fImageView->Bitmap()->Bounds(); - frameText << bounds.IntegerWidth() + 1 - << "x" << bounds.IntegerHeight() + 1; + fNumberFormat.Format(width, bounds.IntegerWidth() + 1); + fNumberFormat.Format(height, bounds.IntegerHeight() + 1); + frameText.SetToFormat("%s × %s", width.String(), height.String()); } - BString pages; - if (fNavigator.PageCount() > 1) - pages << fNavigator.CurrentPage() << "/" << fNavigator.PageCount(); + + BString currentPage, pageCount, pages; + if (fNavigator.PageCount() > 1) { + fNumberFormat.Format(currentPage, fNavigator.CurrentPage()); + fNumberFormat.Format(pageCount, fNavigator.PageCount()); + pages.SetToFormat("%s / %s", currentPage.String(), pageCount.String()); + } + fStatusView->Update(fNavigator.CurrentRef(), frameText, pages, fImageType, fImageView->Zoom()); } diff --git a/src/apps/showimage/ShowImageWindow.h b/src/apps/showimage/ShowImageWindow.h index e69339e342..cc7d846a37 100644 --- a/src/apps/showimage/ShowImageWindow.h +++ b/src/apps/showimage/ShowImageWindow.h @@ -11,6 +11,7 @@ #define SHOW_IMAGE_WINDOW_H +#include #include #include @@ -127,6 +128,7 @@ private: BMenu* fRatingMenu; BMenu* fOpenWithMenu; BMenuItem* fResetRatingItem; + BNumberFormat fNumberFormat; BToolBar* fToolBar; bool fToolBarVisible; BView* fScrollArea;