summaryrefslogtreecommitdiffstats
path: root/qt-models/divepicturemodel.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2019-04-14 16:19:23 +0200
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2019-04-16 20:38:19 +0200
commit52105e521720c87e64dbd2519be7bbe5dc243439 (patch)
treec8483c1d7163a9bf6b40b6f984467ccfd549c7d9 /qt-models/divepicturemodel.cpp
parent0573b19b653d0b4963fe11efdc2303289d2b7994 (diff)
downloadsubsurface-52105e521720c87e64dbd2519be7bbe5dc243439.tar.gz
Write dive data as video subtitles
This commit adds an entry to the dive media context menu which offers to write a subtitle file. This creates an .ass file for the selected videos. In an attempt to to clutter the screen too much, don't show irrelevant entries (zero temperature or NDL and show TTS only for dives with stops). VLC is able to show these subtitles directly, they can be integrated into the video file with ffmpeg. Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'qt-models/divepicturemodel.cpp')
-rw-r--r--qt-models/divepicturemodel.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index babd404f5..8156693ef 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -59,7 +59,7 @@ void DivePictureModel::updateDivePictures()
if (dive->selected) {
int first = pictures.count();
FOR_EACH_PICTURE(dive)
- pictures.push_back({ dive->id, picture, picture->filename, {}, picture->offset.seconds });
+ pictures.push_back({ dive->id, picture, picture->filename, {}, picture->offset.seconds, {.seconds = 0}});
// Sort pictures of this dive by offset.
// Thus, the list will be sorted by (diveId, offset).
@@ -101,6 +101,11 @@ QVariant DivePictureModel::data(const QModelIndex &index, int role) const
case Qt::UserRole:
ret = entry.diveId;
break;
+ case Qt::UserRole + 1:
+ ret = entry.offsetSeconds;
+ break;
+ case Qt::UserRole + 2:
+ ret = entry.length.seconds;
}
} else if (index.column() == 1) {
switch (role) {
@@ -197,8 +202,10 @@ void DivePictureModel::updateThumbnail(QString filename, QImage thumbnail, durat
{
int i = findPictureId(filename);
if (i >= 0) {
- if (duration.seconds > 0)
+ if (duration.seconds > 0) {
addDurationToThumbnail(thumbnail, duration); // If we know the duration paint it on top of the thumbnail
+ pictures[i].length = duration;
+ }
pictures[i].image = thumbnail;
emit dataChanged(createIndex(i, 0), createIndex(i, 1));
}