From cb67ac016364dc1ed7d947d52d9388f51bb9f086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 29 Sep 2013 11:41:24 +0200 Subject: [PATCH] HaikuDepot: Avoid showing ugly rating info when there are no ratings. --- src/apps/haiku-depot/PackageInfoView.cpp | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/apps/haiku-depot/PackageInfoView.cpp b/src/apps/haiku-depot/PackageInfoView.cpp index fe416907e0..bcb573a542 100644 --- a/src/apps/haiku-depot/PackageInfoView.cpp +++ b/src/apps/haiku-depot/PackageInfoView.cpp @@ -442,17 +442,22 @@ public: fRatingView->SetRating(ratingSummary.averageRating); - BString avgRating; - avgRating.SetToFormat("%.1f", ratingSummary.averageRating); - fAvgRating->SetText(avgRating); + if (ratingSummary.ratingCount > 0) { + BString avgRating; + avgRating.SetToFormat("%.1f", ratingSummary.averageRating); + fAvgRating->SetText(avgRating); + + BString votes; + votes.SetToFormat("%d", ratingSummary.ratingCount); + + BString voteInfo(B_TRANSLATE("(%Votes%)")); + voteInfo.ReplaceAll("%Votes%", votes); - BString votes; - votes.SetToFormat("%d", ratingSummary.ratingCount); - - BString voteInfo(B_TRANSLATE("(%Votes%)")); - voteInfo.ReplaceAll("%Votes%", votes); - - fVoteInfo->SetText(voteInfo); + fVoteInfo->SetText(voteInfo); + } else { + fAvgRating->SetText(""); + fVoteInfo->SetText(B_TRANSLATE("n/a")); + } InvalidateLayout(); Invalidate();