diff --git a/assets/BookmarksTab.qml b/assets/BookmarksTab.qml index 4ce889c..e030900 100644 --- a/assets/BookmarksTab.qml +++ b/assets/BookmarksTab.qml @@ -83,7 +83,7 @@ NavigationPane ListView { id: listView - property alias formatter: textUtils + property alias formatter: app property alias activeImage: activePaint verticalAlignment: VerticalAlignment.Fill diff --git a/assets/NotesDialog.qml b/assets/NotesDialog.qml index 4f5b780..05b2257 100644 --- a/assets/NotesDialog.qml +++ b/assets/NotesDialog.qml @@ -8,7 +8,7 @@ Dialog property variant position onPositionChanged: { - textArea.hintText = formatter.formatTime(position); + textArea.hintText = app.formatTime(position); } Container diff --git a/assets/PlaybackControl.qml b/assets/PlaybackControl.qml index 4e4d9e5..8ef2e07 100644 --- a/assets/PlaybackControl.qml +++ b/assets/PlaybackControl.qml @@ -47,7 +47,7 @@ Container timer.refresh(); touchedDown = false; } else if ( event.isMove() ) { - seekerLabel.positionText = textUtils.formatTime(immediateValue); + seekerLabel.positionText = app.formatTime(immediateValue); } else if ( event.isDown() ) { timer.stop(); touchedDown = true; @@ -79,11 +79,11 @@ Container onCreationCompleted: { player.durationChanged.connect( function(duration) { - durationText = textUtils.formatTime(duration); + durationText = app.formatTime(duration); }); player.positionChanged.connect( function(position) { - positionText = textUtils.formatTime(position); + positionText = app.formatTime(position); }); } } diff --git a/assets/RecentTab.qml b/assets/RecentTab.qml index 89cc433..01ca186 100644 --- a/assets/RecentTab.qml +++ b/assets/RecentTab.qml @@ -67,7 +67,7 @@ NavigationPane ListView { id: listView - property alias formatter: textUtils + property alias formatter: app verticalAlignment: VerticalAlignment.Fill horizontalAlignment: HorizontalAlignment.Fill diff --git a/src/BackgroundVideo.cpp b/src/BackgroundVideo.cpp index 2a90ee9..d229cb9 100644 --- a/src/BackgroundVideo.cpp +++ b/src/BackgroundVideo.cpp @@ -239,7 +239,7 @@ QString BackgroundVideo::exportAllBookmarks(QObject* q) result += last.mid( last.lastIndexOf("/")+1 )+"\n"; } - QString t = TextUtils::formatTime( current.value("position").toInt() ); + QString t = formatTime( current.value("position").toInt() ); result += QString("%1: %2").arg(t).arg( current.value("body").toString() )+"\n"; } } @@ -265,4 +265,20 @@ void BackgroundVideo::clearAllBookmarks() fetchAllBookmarks(); } + +QString BackgroundVideo::formatTime(unsigned int duration) +{ + unsigned int secs = floor(duration / 1000); + secs %= 60; + unsigned int mins = floor( (duration / (1000 * 60) ) % 60); + unsigned int hrs = floor( (duration / (1000 * 60 * 60) ) % 24); + + QString seconds = QString::number(secs).rightJustified(2,'0'); + QString minutes = QString::number(mins).rightJustified(2,'0'); + QString hours = hrs > 0 ? QString("%1:").arg(hrs) : ""; + + return QString("%1%2:%3").arg(hours).arg(minutes).arg(seconds); +} + + } diff --git a/src/BackgroundVideo.hpp b/src/BackgroundVideo.hpp index caafaa3..496070b 100644 --- a/src/BackgroundVideo.hpp +++ b/src/BackgroundVideo.hpp @@ -57,6 +57,12 @@ private slots: Q_INVOKABLE void clearAllRecent(); Q_INVOKABLE void clearAllBookmarks(); Q_INVOKABLE QString exportAllBookmarks(QObject* gdm); + + /** + * @param A duration in milliseconds. + * @return 15:12:04 + */ + Q_INVOKABLE static QString formatTime(unsigned int duration); }; }