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

@ -71,6 +71,7 @@ void PreferencesMedia::refreshSettings()
ui->extractVideoThumbnails->setChecked(qPrefMedia::extract_video_thumbnails());
ui->videoThumbnailPosition->setValue(qPrefMedia::extract_video_thumbnails_position());
ui->ffmpegExecutable->setText(qPrefMedia::ffmpeg_executable());
ui->subtitlesFormatString->setText(qPrefMedia::subtitles_format_string());
ui->auto_recalculate_thumbnails->setChecked(prefs.auto_recalculate_thumbnails);
}
@ -81,5 +82,6 @@ void PreferencesMedia::syncSettings()
media->set_extract_video_thumbnails(ui->extractVideoThumbnails->isChecked());
media->set_extract_video_thumbnails_position(ui->videoThumbnailPosition->value());
media->set_ffmpeg_executable(ui->ffmpegExecutable->text());
media->set_subtitles_format_string(ui->subtitlesFormatString->text());
qPrefMedia::set_auto_recalculate_thumbnails(ui->auto_recalculate_thumbnails->isChecked());
}

View file

@ -170,6 +170,319 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
<string>Dive data as subtitles</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="horizontalSpacing">
<number>5</number>
</property>
<property name="verticalSpacing">
<number>5</number>
</property>
<property name="margin">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="subtitlesFormatStringLabel">
<property name="text">
<string>Subtitle format string:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLineEdit" name="subtitlesFormatString"/>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_help_video_4">
<property name="toolTip">
<string extracomment="Help info 4"/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="text">
<string>Available tags:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="subtitlesTimeLabel">
<property name="text">
<string>Dive time: [time]</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="subtitlesDepthLabel">
<property name="text">
<string>Depth: [depth]</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="subtitlesTemperatureLabel">
<property name="text">
<string>Temperature: [temperature]</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="subtitlesCeilingLabel">
<property name="text">
<string>Ceiling: [ceiling]</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="subtitlesNdlLabel">
<property name="text">
<string>NDL: [ndl]</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="subtitlesTtsLabel">
<property name="text">
<string>TTS: [tts]</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="subtitlesRbtLabel">
<property name="text">
<string>RBT: [rbt]</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="subtitlesStoptimeLabel">
<property name="text">
<string>Stop time: [stoptime]</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="subtitlesStopdepthLabel">
<property name="text">
<string>Stop depth: [stopdepth]</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="subtitlesCnsLabel">
<property name="text">
<string>CNS: [cns]</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="subtitlesSacLabel">
<property name="text">
<string>SAC: [sac]</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="subtitlesPO2Label">
<property name="text">
<string>pO₂: [p_o2]</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="subtitlesPN2Label">
<property name="text">
<string>pN₂: [p_n2]</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="subtitlesPHeLabel">
<property name="text">
<string>pHe: [p_he]</string>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="subtitlesO2pressureLabel">
<property name="text">
<string>O₂ pressure (rebreather): [o2_pressure]</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="subtitlesO2setpointLabel">
<property name="text">
<string>O₂ setpoint: [o2_setpoint]</string>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="subtitlesScr_oc_p02Label">
<property name="text">
<string>SCR ΔpO₂: [scr_oc_po2]</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="subtitlesModLabel">
<property name="text">
<string>MOD: [mod]</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="subtitlesEadLabel">
<property name="text">
<string>EAD: [ead]</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="subtitlesEndLabel">
<property name="text">
<string>END: [end]</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="subtitlesEaddLabel">
<property name="text">
<string>EADD: [eadd]</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="subtitlesSpeedLabel">
<property name="text">
<string>Vertical speed: [speed]</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="subtitlesIn_deco_calcLabel">
<property name="text">
<string>In deco (calculated): [in_deco]</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="subtitlesNdlCalcLabel">
<property name="text">
<string>NDL (calculated): [ndl_calc]</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="subtitlesTts_calcLabel">
<property name="text">
<string>TTS (calculated): [tts_calc]</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLabel" name="subtitlesStoptime_calcLabel">
<property name="text">
<string>Stop time (calculated): [stoptime_calc]</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLabel" name="subtitlesStopdepth_calcLabel">
<property name="text">
<string>Stop depth (calculated): [stopdepth_calc]</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QLabel" name="subtitlesHeartrateLabel">
<property name="text">
<string>Heartrate: [heartrate]</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="subtitlesBearingLabel">
<property name="text">
<string>Bearing: [bearing]</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QLabel" name="subtitlesSurface_gfLabel">
<property name="text">
<string>Surface GF: [surface_gf]</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLabel" name="subtitlesCurrent_gfLabel">
<property name="text">
<string>Current GF: [current_gf]</string>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QLabel" name="subtitlesDensityLabel">
<property name="text">
<string>Density: [density]</string>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QLabel" name="subtitlesIcd_warningLabel">
<property name="text">
<string>ICD Warning: [icd_warning]</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
@ -186,6 +499,7 @@
</layout>
</widget>
<resources/>
<connections>
</connections>