Skip to content

Commit

Permalink
Simplify pixmapIndexFromPercentage function
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrapha committed Aug 7, 2019
1 parent 6a19697 commit ab59a23
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/widget/wbattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ QString formatMinutes(int minutes) {

int pixmapIndexFromPercentage(double dPercentage, int numPixmaps) {
// See WDisplay::getActivePixmapIndex for more info on this.
int result = static_cast<int>(dPercentage * numPixmaps - 0.00001) / 100;
int result = static_cast<int>(dPercentage / 100.0 * numPixmaps);
result = math_min(numPixmaps - 1, math_max(0, result));
return result;
}
Expand Down

0 comments on commit ab59a23

Please sign in to comment.