Make the "Save dive data as subtitles" feature more configurable.

Previously, the subtitle generation was hardcoded, making it unsuitable
if you didn't want all of the displayed values. This has been replaced
by a format string that is configurable in the settings, using predefined
tags that are replaced with the values. The default value for this has
been set to (mostly) match the currently generated subtitle string. This
also provides a good starting point for users that want to modify the string.

Signed-off-by: Victor Arvidsson <victarv@gmail.com>
This commit is contained in:
Victor Arvidsson 2024-10-23 17:57:56 +02:00 committed by Michael Keller
parent 1a9b09682a
commit 6886c9ccf8
8 changed files with 535 additions and 15 deletions

View file

@ -11,6 +11,7 @@ class qPrefMedia : public QObject {
Q_PROPERTY(bool extract_video_thumbnails READ extract_video_thumbnails WRITE set_extract_video_thumbnails NOTIFY extract_video_thumbnailsChanged)
Q_PROPERTY(int extract_video_thumbnails_position READ extract_video_thumbnails_position WRITE set_extract_video_thumbnails_position NOTIFY extract_video_thumbnails_positionChanged)
Q_PROPERTY(QString ffmpeg_executable READ ffmpeg_executable WRITE set_ffmpeg_executable NOTIFY ffmpeg_executableChanged)
Q_PROPERTY(QString subtitles_format_string READ subtitles_format_string WRITE set_subtitles_format_string NOTIFY subtitles_format_stringChanged)
public:
static qPrefMedia *instance();
@ -25,18 +26,21 @@ public:
static bool extract_video_thumbnails() { return prefs.extract_video_thumbnails; }
static int extract_video_thumbnails_position() { return prefs.extract_video_thumbnails_position; }
static QString ffmpeg_executable() { return QString::fromStdString(prefs.ffmpeg_executable); }
static QString subtitles_format_string() { return QString::fromStdString(prefs.subtitles_format_string); }
public slots:
static void set_auto_recalculate_thumbnails(bool value);
static void set_extract_video_thumbnails(bool value);
static void set_extract_video_thumbnails_position(int value);
static void set_ffmpeg_executable(const QString& value);
static void set_subtitles_format_string(const QString& value);
signals:
void auto_recalculate_thumbnailsChanged(bool value);
void extract_video_thumbnailsChanged(bool value);
void extract_video_thumbnails_positionChanged(int value);
void ffmpeg_executableChanged(const QString& value);
void subtitles_format_stringChanged(const QString& value);
private:
qPrefMedia() {}
@ -45,6 +49,7 @@ private:
static void disk_extract_video_thumbnails(bool doSync);
static void disk_extract_video_thumbnails_position(bool doSync);
static void disk_ffmpeg_executable(bool doSync);
static void disk_subtitles_format_string(bool doSync);
};