From aaf87a077c22cb2491480c8802595edb3e41c944 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 24 Nov 2018 17:28:12 +0100 Subject: Change playlist duration display If the total duration is > 1d, say so. --- beetplayer.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'beetplayer.cpp') diff --git a/beetplayer.cpp b/beetplayer.cpp index c1ecc38..4371108 100644 --- a/beetplayer.cpp +++ b/beetplayer.cpp @@ -121,10 +121,20 @@ void BeetPlayer::setNumFiles(int numFiles){ } void BeetPlayer::setPlayListLength(quint64 seconds){ - int h = (seconds / 60 / 60); + int h = static_cast((seconds / 60 / 60)); + int days = 0; + if(h > 24){ + days = h / 24; + h = h % 24; + } int min = (seconds / 60) % 60; int secs = seconds % 60; - QString r = QString("%1:%2:%3").arg(h, 3, 10, QChar('0')).arg(min, 2, 10, QChar('0')).arg(secs, 2, 10, QChar('0')); + QString r; + if(days > 0){ + r = QString("%1d, %2:%3:%4h").arg(days, 1, 10, QChar('0')).arg(h, 2, 10, QChar('0')).arg(min, 2, 10, QChar('0')).arg(secs, 2, 10, QChar('0')); + }else{ + r = QString("%1:%2:%3h").arg(h, 2, 10, QChar('0')).arg(min, 2, 10, QChar('0')).arg(secs, 2, 10, QChar('0')); + } mPlaylistDurL->setText(r); } -- cgit v1.2.3-70-g09d2