[vlc-commits] qml: show distinct hours text in playlist header

Fatih Uzunoglu git at videolan.org
Thu Oct 15 10:32:33 CEST 2020


vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Oct  9 19:56:25 2020 +0300| [5aec4f2675404dbf9eb7cbc1437daa9be539eeb4] | committer: Pierre Lamot

qml: show distinct hours text in playlist header

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5aec4f2675404dbf9eb7cbc1437daa9be539eeb4
---

 modules/gui/qt/playlist/qml/PlaylistListView.qml | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index d0f27c796a..7c6c7eebdf 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -167,9 +167,27 @@ Widgets.NavigableFocusScope {
                 }
 
                 Widgets.CaptionLabel {
+                    function getHoursMinutesText(duration) {
+                        var hours = duration.toHours()
+                        var minutes = duration.toMinutes()
+                        var text
+                        if (hours >= 1) {
+                            minutes = minutes % 60
+                            text = i18n.qtr("%1h %2min").arg(hours).arg(minutes)
+                        }
+                        else if (minutes > 0) {
+                            text = i18n.qtr("%1 min").arg(minutes)
+                        }
+                        else {
+                            text = i18n.qtr("%1 sec").arg(duration.toSeconds())
+                        }
+
+                        return text
+                    }
+
                     anchors.topMargin: VLCStyle.margin_small
                     visible: plmodel.count !== 0
-                    text: i18n.qtr("%1 elements, %2 min").arg(root.plmodel.count).arg(plmodel.duration.toMinutes())
+                    text: i18n.qtr("%1 elements, %2").arg(root.plmodel.count).arg(getHoursMinutesText(plmodel.duration))
                     color: _colors.caption
                 }
             }



More information about the vlc-commits mailing list