mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-30 05:08:35 +00:00
PICARD-1488: Display player position 0 as 0:00 instead of ?:??
This commit is contained in:
@@ -218,7 +218,7 @@ class PlayerToolbar(QtWidgets.QToolBar):
|
||||
|
||||
def on_position_changed(self, position):
|
||||
self.progress_slider.setValue(position)
|
||||
self.position_label.setText(format_time(position))
|
||||
self.position_label.setText(format_time(position, display_zero=True))
|
||||
|
||||
def on_media_changed(self, media):
|
||||
if media.isNull():
|
||||
|
||||
@@ -112,10 +112,10 @@ def pathcmp(a, b):
|
||||
return os.path.normcase(a) == os.path.normcase(b)
|
||||
|
||||
|
||||
def format_time(ms):
|
||||
def format_time(ms, display_zero=False):
|
||||
"""Formats time in milliseconds to a string representation."""
|
||||
ms = float(ms)
|
||||
if ms == 0:
|
||||
if ms == 0 and not display_zero:
|
||||
return "?:??"
|
||||
duration_seconds = round(ms / 1000)
|
||||
if duration_seconds < 3600:
|
||||
|
||||
@@ -89,6 +89,7 @@ class FormatTimeTest(PicardTestCase):
|
||||
|
||||
def test(self):
|
||||
self.assertEqual("?:??", util.format_time(0))
|
||||
self.assertEqual("0:00", util.format_time(0, display_zero=True))
|
||||
self.assertEqual("3:00", util.format_time(179750))
|
||||
self.assertEqual("3:00", util.format_time(179500))
|
||||
self.assertEqual("2:59", util.format_time(179499))
|
||||
|
||||
Reference in New Issue
Block a user