summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/CMakeLists.txt2
-rw-r--r--core/settings/qPrefGeneral.cpp13
-rw-r--r--core/settings/qPrefGeneral.h20
-rw-r--r--core/settings/qPrefMedia.cpp27
-rw-r--r--core/settings/qPrefMedia.h51
-rw-r--r--desktop-widgets/preferences/CMakeLists.txt3
-rw-r--r--desktop-widgets/preferences/preferences_defaults.cpp50
-rw-r--r--desktop-widgets/preferences/preferences_defaults.h4
-rw-r--r--desktop-widgets/preferences/preferences_defaults.ui73
-rw-r--r--desktop-widgets/preferences/preferences_graph.cpp2
-rw-r--r--desktop-widgets/preferences/preferences_graph.ui7
-rw-r--r--desktop-widgets/preferences/preferences_media.cpp89
-rw-r--r--desktop-widgets/preferences/preferences_media.h30
-rw-r--r--desktop-widgets/preferences/preferences_media.ui192
-rw-r--r--desktop-widgets/preferences/preferencesdialog.cpp3
-rw-r--r--icons/pref_media.pngbin0 -> 658 bytes
-rw-r--r--subsurface.qrc1
-rw-r--r--tests/testqPrefGeneral.cpp57
18 files changed, 398 insertions, 226 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index ce4e6027b..875d144f5 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -213,6 +213,8 @@ set(SUBSURFACE_CORE_LIB_SRCS
settings/qPrefUpdateManager.h
settings/qPrefEquipment.cpp
settings/qPrefEquipment.h
+ settings/qPrefMedia.cpp
+ settings/qPrefMedia.h
#Subsurface Qt have the Subsurface structs QObjectified for easy access via QML.
subsurface-qt/CylinderObjectHelper.cpp
diff --git a/core/settings/qPrefGeneral.cpp b/core/settings/qPrefGeneral.cpp
index b3e9fb761..e3d3e6e0a 100644
--- a/core/settings/qPrefGeneral.cpp
+++ b/core/settings/qPrefGeneral.cpp
@@ -20,14 +20,9 @@ qPrefGeneral *qPrefGeneral::instance()
void qPrefGeneral::loadSync(bool doSync)
{
- disk_auto_recalculate_thumbnails(doSync);
- disk_auto_recalculate_thumbnails(doSync);
disk_default_filename(doSync);
disk_default_file_behavior(doSync);
disk_defaultsetpoint(doSync);
- disk_extract_video_thumbnails(doSync);
- disk_extract_video_thumbnails_position(doSync);
- disk_ffmpeg_executable(doSync);
disk_o2consumption(doSync);
disk_pscr_ratio(doSync);
disk_use_default_file(doSync);
@@ -41,8 +36,6 @@ void qPrefGeneral::loadSync(bool doSync)
}
}
-HANDLE_PREFERENCE_BOOL(General, "auto_recalculate_thumbnails", auto_recalculate_thumbnails);
-
HANDLE_PREFERENCE_TXT(General, "default_filename", default_filename);
@@ -77,12 +70,6 @@ void qPrefGeneral::disk_default_file_behavior(bool doSync)
HANDLE_PREFERENCE_INT(General, "defaultsetpoint", defaultsetpoint);
-HANDLE_PREFERENCE_BOOL(General, "extract_video_thumbnails", extract_video_thumbnails);
-
-HANDLE_PREFERENCE_INT(General, "extract_video_thumbnails_position", extract_video_thumbnails_position);
-
-HANDLE_PREFERENCE_TXT(General, "ffmpeg_executable", ffmpeg_executable);
-
HANDLE_PREFERENCE_INT(General, "o2consumption", o2consumption);
HANDLE_PREFERENCE_INT(General, "pscr_ratio", pscr_ratio);
diff --git a/core/settings/qPrefGeneral.h b/core/settings/qPrefGeneral.h
index c55063bd2..bb91d6501 100644
--- a/core/settings/qPrefGeneral.h
+++ b/core/settings/qPrefGeneral.h
@@ -7,13 +7,9 @@
class qPrefGeneral : public QObject {
Q_OBJECT
- Q_PROPERTY(bool auto_recalculate_thumbnails READ auto_recalculate_thumbnails WRITE set_auto_recalculate_thumbnails NOTIFY auto_recalculate_thumbnailsChanged)
Q_PROPERTY(QString default_filename READ default_filename WRITE set_default_filename NOTIFY default_filenameChanged)
Q_PROPERTY(enum def_file_behavior default_file_behavior READ default_file_behavior WRITE set_default_file_behavior NOTIFY default_file_behaviorChanged)
Q_PROPERTY(int defaultsetpoint READ defaultsetpoint WRITE set_defaultsetpoint NOTIFY defaultsetpointChanged)
- 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(int o2consumption READ o2consumption WRITE set_o2consumption NOTIFY o2consumptionChanged)
Q_PROPERTY(int pscr_ratio READ pscr_ratio WRITE set_pscr_ratio NOTIFY pscr_ratioChanged)
Q_PROPERTY(bool use_default_file READ use_default_file WRITE set_use_default_file NOTIFY use_default_fileChanged)
@@ -33,13 +29,9 @@ public:
static void sync() { return loadSync(true); }
public:
- static bool auto_recalculate_thumbnails() { return prefs.auto_recalculate_thumbnails; }
static QString default_filename() { return prefs.default_filename; }
static enum def_file_behavior default_file_behavior() { return prefs.default_file_behavior; }
static int defaultsetpoint() { return prefs.defaultsetpoint; }
- 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 prefs.ffmpeg_executable; }
static int o2consumption() { return prefs.o2consumption; }
static int pscr_ratio() { return prefs.pscr_ratio; }
static bool use_default_file() { return prefs.use_default_file; }
@@ -50,13 +42,9 @@ public:
static bool extraEnvironmentalDefault() { return prefs.extraEnvironmentalDefault; }
public slots:
- static void set_auto_recalculate_thumbnails(bool value);
static void set_default_filename(const QString& value);
static void set_default_file_behavior(enum def_file_behavior value);
static void set_defaultsetpoint(int 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_o2consumption(int value);
static void set_pscr_ratio(int value);
static void set_use_default_file(bool value);
@@ -67,13 +55,9 @@ public slots:
static void set_extraEnvironmentalDefault(bool value);
signals:
- void auto_recalculate_thumbnailsChanged(bool value);
void default_filenameChanged(const QString& value);
void default_file_behaviorChanged(enum def_file_behavior value);
void defaultsetpointChanged(int value);
- void extract_video_thumbnailsChanged(bool value);
- void extract_video_thumbnails_positionChanged(int value);
- void ffmpeg_executableChanged(const QString& value);
void o2consumptionChanged(int value);
void pscr_ratioChanged(int value);
void use_default_fileChanged(bool value);
@@ -87,13 +71,9 @@ signals:
private:
qPrefGeneral() {}
- static void disk_auto_recalculate_thumbnails(bool doSync);
static void disk_default_filename(bool doSync);
static void disk_default_file_behavior(bool doSync);
static void disk_defaultsetpoint(bool doSync);
- 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_o2consumption(bool doSync);
static void disk_pscr_ratio(bool doSync);
static void disk_use_default_file(bool doSync);
diff --git a/core/settings/qPrefMedia.cpp b/core/settings/qPrefMedia.cpp
new file mode 100644
index 000000000..557b2124f
--- /dev/null
+++ b/core/settings/qPrefMedia.cpp
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "qPrefMedia.h"
+#include "qPrefPrivate.h"
+
+static const QString group = QStringLiteral("Media");
+
+qPrefMedia *qPrefMedia::instance()
+{
+ static qPrefMedia *self = new qPrefMedia;
+ return self;
+}
+
+void qPrefMedia::loadSync(bool doSync)
+{
+ disk_extract_video_thumbnails(doSync);
+ disk_extract_video_thumbnails_position(doSync);
+ disk_ffmpeg_executable(doSync);
+ disk_auto_recalculate_thumbnails(doSync);
+ disk_auto_recalculate_thumbnails(doSync);
+
+}
+
+HANDLE_PREFERENCE_BOOL(Media, "auto_recalculate_thumbnails", auto_recalculate_thumbnails);
+HANDLE_PREFERENCE_BOOL(Media, "extract_video_thumbnails", extract_video_thumbnails);
+HANDLE_PREFERENCE_INT(Media, "extract_video_thumbnails_position", extract_video_thumbnails_position);
+HANDLE_PREFERENCE_TXT(Media, "ffmpeg_executable", ffmpeg_executable);
+
diff --git a/core/settings/qPrefMedia.h b/core/settings/qPrefMedia.h
new file mode 100644
index 000000000..fab87f250
--- /dev/null
+++ b/core/settings/qPrefMedia.h
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef QPREFMEDIA_H
+#define QPREFMEDIA_H
+#include "core/pref.h"
+
+#include <QObject>
+
+class qPrefMedia : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool auto_recalculate_thumbnails READ auto_recalculate_thumbnails WRITE set_auto_recalculate_thumbnails NOTIFY auto_recalculate_thumbnailsChanged)
+ 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)
+
+public:
+ static qPrefMedia *instance();
+
+ // Load/Sync local settings (disk) and struct preference
+ static void loadSync(bool doSync);
+ static void load() { loadSync(false); }
+ static void sync() { loadSync(true); }
+
+public:
+ static bool auto_recalculate_thumbnails() { return prefs.auto_recalculate_thumbnails; }
+ 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 prefs.ffmpeg_executable; }
+
+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);
+
+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);
+
+private:
+ qPrefMedia() {}
+
+ static void disk_auto_recalculate_thumbnails(bool doSync);
+ static void disk_extract_video_thumbnails(bool doSync);
+ static void disk_extract_video_thumbnails_position(bool doSync);
+ static void disk_ffmpeg_executable(bool doSync);
+
+};
+
+#endif
diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt
index af6071934..c0b0de7ab 100644
--- a/desktop-widgets/preferences/CMakeLists.txt
+++ b/desktop-widgets/preferences/CMakeLists.txt
@@ -12,6 +12,7 @@ set(SUBSURFACE_PREFERENCES_UI
preferences_units.ui
preferences_georeference.ui
preferences_language.ui
+ preferences_media.ui
preferences_equipment.ui
)
@@ -32,6 +33,8 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS
preferences_graph.h
preferences_language.cpp
preferences_language.h
+ preferences_media.cpp
+ preferences_media.h
preferences_network.cpp
preferences_network.h
preferences_cloud.cpp
diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp
index e0df807b0..549475a23 100644
--- a/desktop-widgets/preferences/preferences_defaults.cpp
+++ b/desktop-widgets/preferences/preferences_defaults.cpp
@@ -47,46 +47,6 @@ void PreferencesDefaults::on_localDefaultFile_toggled(bool toggle)
ui->chooseFile->setEnabled(toggle);
}
-void PreferencesDefaults::checkFfmpegExecutable()
-{
- QString s = ui->ffmpegExecutable->text().trimmed();
-
- // If the user didn't provide a string they probably didn't intend to run ffmeg,
- // so let's not give an error message.
- if (s.isEmpty())
- return;
-
- // Try to execute ffmpeg. But wait at most 2 sec for startup and execution
- // so that the UI doesn't hang unnecessarily.
- QProcess ffmpeg;
- ffmpeg.start(s);
- if (!ffmpeg.waitForStarted(2000) || !ffmpeg.waitForFinished(3000))
- QMessageBox::warning(this, tr("Warning"), tr("Couldn't execute ffmpeg at given location. Thumbnailing will not work."));
-}
-
-void PreferencesDefaults::on_ffmpegFile_clicked()
-{
- QFileInfo fi(system_default_filename());
- QString ffmpegFileName = QFileDialog::getOpenFileName(this, tr("Select ffmpeg executable"));
-
- if (!ffmpegFileName.isEmpty()) {
- ui->ffmpegExecutable->setText(ffmpegFileName);
- checkFfmpegExecutable();
- }
-}
-
-void PreferencesDefaults::on_ffmpegExecutable_editingFinished()
-{
- checkFfmpegExecutable();
-}
-
-void PreferencesDefaults::on_extractVideoThumbnails_toggled(bool toggled)
-{
- ui->videoThumbnailPosition->setEnabled(toggled);
- ui->ffmpegExecutable->setEnabled(toggled);
- ui->ffmpegFile->setEnabled(toggled);
-}
-
void PreferencesDefaults::on_resetRememberedDCs_clicked()
{
qPrefDiveComputer::set_vendor1(QString());
@@ -125,13 +85,6 @@ void PreferencesDefaults::refreshSettings()
ui->btnUseDefaultFile->setEnabled(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE);
ui->chooseFile->setEnabled(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE);
- ui->videoThumbnailPosition->setEnabled(qPrefGeneral::extract_video_thumbnails());
- ui->ffmpegExecutable->setEnabled(qPrefGeneral::extract_video_thumbnails());
- ui->ffmpegFile->setEnabled(qPrefGeneral::extract_video_thumbnails());
-
- ui->extractVideoThumbnails->setChecked(qPrefGeneral::extract_video_thumbnails());
- ui->videoThumbnailPosition->setValue(qPrefGeneral::extract_video_thumbnails_position());
- ui->ffmpegExecutable->setText(qPrefGeneral::ffmpeg_executable());
ui->extraEnvironmentalDefault->setChecked(prefs.extraEnvironmentalDefault);
}
@@ -146,9 +99,6 @@ void PreferencesDefaults::syncSettings()
general->set_default_file_behavior(LOCAL_DEFAULT_FILE);
else if (ui->cloudDefaultFile->isChecked())
general->set_default_file_behavior(CLOUD_DEFAULT_FILE);
- general->set_extract_video_thumbnails(ui->extractVideoThumbnails->isChecked());
- general->set_extract_video_thumbnails_position(ui->videoThumbnailPosition->value());
- general->set_ffmpeg_executable(ui->ffmpegExecutable->text());
qPrefDisplay::set_divelist_font(ui->font->currentFont().toString());
qPrefDisplay::set_font_size(ui->fontsize->value());
diff --git a/desktop-widgets/preferences/preferences_defaults.h b/desktop-widgets/preferences/preferences_defaults.h
index 48e633ceb..4c18fcdd9 100644
--- a/desktop-widgets/preferences/preferences_defaults.h
+++ b/desktop-widgets/preferences/preferences_defaults.h
@@ -20,15 +20,11 @@ public slots:
void on_chooseFile_clicked();
void on_btnUseDefaultFile_toggled(bool toggled);
void on_localDefaultFile_toggled(bool toggled);
- void on_ffmpegFile_clicked();
- void on_ffmpegExecutable_editingFinished();
- void on_extractVideoThumbnails_toggled(bool toggled);
void on_resetSettings_clicked();
void on_resetRememberedDCs_clicked();
private:
Ui::PreferencesDefaults *ui;
- void checkFfmpegExecutable();
};
diff --git a/desktop-widgets/preferences/preferences_defaults.ui b/desktop-widgets/preferences/preferences_defaults.ui
index 60b478206..50cb95b35 100644
--- a/desktop-widgets/preferences/preferences_defaults.ui
+++ b/desktop-widgets/preferences/preferences_defaults.ui
@@ -178,79 +178,6 @@
</widget>
</item>
<item>
- <widget class="QGroupBox" name="groupBox_10">
- <property name="title">
- <string>Video thumbnails</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="1" column="0">
- <widget class="QLabel" name="ffmpegExectuableLabel">
- <property name="text">
- <string>ffmpeg executable</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QLineEdit" name="ffmpegExecutable"/>
- </item>
- <item>
- <widget class="QToolButton" name="ffmpegFile">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="videoThumbnailPositionLabel">
- <property name="text">
- <string>Extract at position</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QSlider" name="videoThumbnailPosition">
- <property name="maximum">
- <number>100</number>
- </property>
- <property name="value">
- <number>20</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="extractVideoThumbnailsLabel">
- <property name="text">
- <string>Extract video thumbnails</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QCheckBox" name="extractVideoThumbnails">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>Clear settings</string>
diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp
index 54a63fd71..cdead91e0 100644
--- a/desktop-widgets/preferences/preferences_graph.cpp
+++ b/desktop-widgets/preferences/preferences_graph.cpp
@@ -50,7 +50,6 @@ void PreferencesGraph::refreshSettings()
ui->pscrfactor->setValue(lrint(1000.0 / prefs.pscr_ratio));
ui->show_average_depth->setChecked(prefs.show_average_depth);
- ui->auto_recalculate_thumbnails->setChecked(prefs.auto_recalculate_thumbnails);
ui->show_icd->setChecked(prefs.show_icd);
}
@@ -59,7 +58,6 @@ void PreferencesGraph::syncSettings()
qPrefGeneral::set_defaultsetpoint(lrint(ui->defaultSetpoint->value() * 1000.0));
qPrefGeneral::set_o2consumption(lrint(ui->psro2rate->value() *1000.0));
qPrefGeneral::set_pscr_ratio(lrint(1000.0 / ui->pscrfactor->value()));
- qPrefGeneral::set_auto_recalculate_thumbnails(ui->auto_recalculate_thumbnails->isChecked());
qPrefPartialPressureGas::set_phe_threshold(ui->pheThreshold->value());
qPrefPartialPressureGas::set_po2_threshold_max(ui->po2ThresholdMax->value());
diff --git a/desktop-widgets/preferences/preferences_graph.ui b/desktop-widgets/preferences/preferences_graph.ui
index ab7e12f87..9fd3a11c7 100644
--- a/desktop-widgets/preferences/preferences_graph.ui
+++ b/desktop-widgets/preferences/preferences_graph.ui
@@ -361,13 +361,6 @@
</property>
</widget>
</item>
- <item row="1" column="0" colspan="2">
- <widget class="QCheckBox" name="auto_recalculate_thumbnails">
- <property name="text">
- <string>Recalculate thumbnails if older than media file</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
diff --git a/desktop-widgets/preferences/preferences_media.cpp b/desktop-widgets/preferences/preferences_media.cpp
new file mode 100644
index 000000000..47a6285dd
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_media.cpp
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "preferences_media.h"
+#include "ui_preferences_media.h"
+#include "core/settings/qPrefMedia.h"
+#include "core/qthelper.h"
+
+#include <QApplication>
+#include <QMessageBox>
+#include <QSortFilterProxyModel>
+#include <QFileDialog>
+#include <QProcess>
+
+#include "qt-models/models.h"
+
+PreferencesMedia::PreferencesMedia() : AbstractPreferencesWidget(tr("Media"), QIcon(":preferences-media-icon"), 8)
+{
+ ui = new Ui::PreferencesMedia();
+ ui->setupUi(this);
+
+}
+
+PreferencesMedia::~PreferencesMedia()
+{
+ delete ui;
+}
+
+void PreferencesMedia::checkFfmpegExecutable()
+{
+ QString s = ui->ffmpegExecutable->text().trimmed();
+
+ // If the user didn't provide a string they probably didn't intend to run ffmeg,
+ // so let's not give an error message.
+ if (s.isEmpty())
+ return;
+
+ // Try to execute ffmpeg. But wait at most 2 sec for startup and execution
+ // so that the UI doesn't hang unnecessarily.
+ QProcess ffmpeg;
+ ffmpeg.start(s);
+ if (!ffmpeg.waitForStarted(2000) || !ffmpeg.waitForFinished(3000))
+ QMessageBox::warning(this, tr("Warning"), tr("Couldn't execute ffmpeg at given location. Thumbnailing will not work."));
+}
+
+void PreferencesMedia::on_ffmpegFile_clicked()
+{
+ QFileInfo fi(system_default_filename());
+ QString ffmpegFileName = QFileDialog::getOpenFileName(this, tr("Select ffmpeg executable"));
+
+ if (!ffmpegFileName.isEmpty()) {
+ ui->ffmpegExecutable->setText(ffmpegFileName);
+ checkFfmpegExecutable();
+ }
+}
+
+void PreferencesMedia::on_ffmpegExecutable_editingFinished()
+{
+ checkFfmpegExecutable();
+}
+
+void PreferencesMedia::on_extractVideoThumbnails_toggled(bool toggled)
+{
+ ui->videoThumbnailPosition->setEnabled(toggled);
+ ui->ffmpegExecutable->setEnabled(toggled);
+ ui->ffmpegFile->setEnabled(toggled);
+}
+
+void PreferencesMedia::refreshSettings()
+{
+ ui->videoThumbnailPosition->setEnabled(qPrefMedia::extract_video_thumbnails());
+ ui->ffmpegExecutable->setEnabled(qPrefMedia::extract_video_thumbnails());
+ ui->ffmpegFile->setEnabled(qPrefMedia::extract_video_thumbnails());
+
+ ui->extractVideoThumbnails->setChecked(qPrefMedia::extract_video_thumbnails());
+ ui->videoThumbnailPosition->setValue(qPrefMedia::extract_video_thumbnails_position());
+ ui->ffmpegExecutable->setText(qPrefMedia::ffmpeg_executable());
+
+ ui->auto_recalculate_thumbnails->setChecked(prefs.auto_recalculate_thumbnails);
+
+}
+
+void PreferencesMedia::syncSettings()
+{
+ auto media = qPrefMedia::instance();
+ media->set_extract_video_thumbnails(ui->extractVideoThumbnails->isChecked());
+ media->set_extract_video_thumbnails_position(ui->videoThumbnailPosition->value());
+ media->set_ffmpeg_executable(ui->ffmpegExecutable->text());
+ qPrefMedia::set_auto_recalculate_thumbnails(ui->auto_recalculate_thumbnails->isChecked());
+
+}
diff --git a/desktop-widgets/preferences/preferences_media.h b/desktop-widgets/preferences/preferences_media.h
new file mode 100644
index 000000000..c328d184b
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_media.h
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef PREFERENCES_MEDIA_H
+#define PREFERENCES_MEDIA_H
+
+#include <QMap>
+#include "abstractpreferenceswidget.h"
+
+namespace Ui {
+ class PreferencesMedia;
+}
+
+class PreferencesMedia : public AbstractPreferencesWidget {
+ Q_OBJECT
+public:
+ PreferencesMedia();
+ ~PreferencesMedia();
+ void refreshSettings() override;
+ void syncSettings() override;
+public slots:
+ void on_ffmpegFile_clicked();
+ void on_ffmpegExecutable_editingFinished();
+ void on_extractVideoThumbnails_toggled(bool toggled);
+private:
+ Ui::PreferencesMedia *ui;
+ void checkFfmpegExecutable();
+
+};
+
+#endif
+
diff --git a/desktop-widgets/preferences/preferences_media.ui b/desktop-widgets/preferences/preferences_media.ui
new file mode 100644
index 000000000..f82e6fdcb
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_media.ui
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreferencesMedia</class>
+ <widget class="QWidget" name="PreferencesMedia">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>621</width>
+ <height>523</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+
+ <item>
+ <widget class="QLabel" name="label_help4">
+ <property name="toolTip">
+ <string extracomment="Help info 1"/>
+ </property>
+ <property name="text">
+ <string>UPDATE THUMBNAILS</string>
+ </property>
+ </widget>
+ </item>
+
+ <item>
+ <widget class="QLabel" name="label_help4">
+ <property name="toolTip">
+ <string extracomment="Help info 1"/>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Photographs or videos are sometimes edited. If a photo is more recent than its thumbnail, checking the checkbox below will allow creating a new thumbnail after the media has been edited.</string>
+ </property>
+ </widget>
+ </item>
+
+ <item>
+ <widget class="QCheckBox" name="auto_recalculate_thumbnails">
+ <property name="text">
+ <string>Recalculate thumbnail if older than media file</string>
+ </property>
+ </widget>
+ </item>
+
+ <item>
+ <widget class="QLabel" name="label_help4">
+ <property name="toolTip">
+ <string extracomment="Help info 1"/>
+ </property>
+ <property name="text">
+ <string> </string>
+ </property>
+ </widget>
+ </item>
+
+ <item>
+ <widget class="QLabel" name="label_help4">
+ <property name="toolTip">
+ <string extracomment="Help info 1"/>
+ </property>
+ <property name="text">
+ <string>VIDEOS</string>
+ </property>
+ </widget>
+ </item>
+
+ <item>
+ <widget class="QGroupBox" name="groupBox_10">
+ <property name="title">
+ <string>Video thumbnails</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" colspan="2">
+ <widget class="QLabel" name="label_help4">
+ <property name="toolTip">
+ <string extracomment="Help info 2"/>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>One can view video files through thumbnail(s) in the Media tab, created using the external programm FFmpeg which needs to be installed on your machine. Check the checkbox below to allow this. Then, in the text box below, specify the path to FFmpeg. In Linux, a typical path is: /usr/bin/ffmpeg. If FFmpeg is installed in the system area of your computer, just type ffmpeg in the text box below. For more info see Appendix F of the User Manual.</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="extractVideoThumbnails">
+ <property name="text">
+ <string>Extract video thumbnails</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="2" column="0">
+ <widget class="QLabel" name="ffmpegExectuableLabel">
+ <property name="text">
+ <string>Path to ffmpeg:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QLineEdit" name="ffmpegExecutable"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="ffmpegFile">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+
+ <item row="3" column="0" colspan="2">
+ <widget class="QLabel" name="label_help4">
+ <property name="toolTip">
+ <string extracomment="Help info 3"/>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>One can specify te relative position within the video from where the thumbnail is retrieved. Use the slider below do do that.</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="4" column="0">
+ <widget class="QLabel" name="videoThumbnailPositionLabel">
+ <property name="text">
+ <string>Extract at position</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="4" column="1">
+ <widget class="QSlider" name="videoThumbnailPosition">
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>20</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+
+ </layout>
+ </widget>
+ </item>
+
+ <item row="5" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ </connections>
+</ui>
diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp
index 508321ac5..dd5adeb7b 100644
--- a/desktop-widgets/preferences/preferencesdialog.cpp
+++ b/desktop-widgets/preferences/preferencesdialog.cpp
@@ -10,6 +10,7 @@
#include "preferences_network.h"
#include "preferences_cloud.h"
#include "preferences_equipment.h"
+#include "preferences_media.h"
#include "core/qthelper.h"
@@ -69,6 +70,8 @@ PreferencesDialog::PreferencesDialog()
addPreferencePage(new PreferencesNetwork());
addPreferencePage(new PreferencesCloud());
addPreferencePage(new PreferencesEquipment());
+ addPreferencePage(new PreferencesMedia());
+
refreshPages();
connect(pagesList, &QListWidget::currentRowChanged,
diff --git a/icons/pref_media.png b/icons/pref_media.png
new file mode 100644
index 000000000..84fd986a9
--- /dev/null
+++ b/icons/pref_media.png
Binary files differ
diff --git a/subsurface.qrc b/subsurface.qrc
index c360b5944..f7eef4908 100644
--- a/subsurface.qrc
+++ b/subsurface.qrc
@@ -14,6 +14,7 @@
<file alias="preferences-system-network-icon">icons/network.png</file>
<file alias="preferences-cloud-icon">icons/pref_cloud.png</file>
<file alias="preferences-equipment-icon">icons/pref_equipment.png</file>
+ <file alias="preferences-media-icon">icons/pref_media.png</file>
<file alias="scale-graph-icon">icons/graph.png</file>
<file alias="value-minimum-icon">icons/minimum.png</file>
<file alias="value-maximum-icon">icons/maximum.png</file>
diff --git a/tests/testqPrefGeneral.cpp b/tests/testqPrefGeneral.cpp
index 1463b914b..9718650ed 100644
--- a/tests/testqPrefGeneral.cpp
+++ b/tests/testqPrefGeneral.cpp
@@ -23,24 +23,16 @@ void TestQPrefGeneral::test_struct_get()
auto tst = qPrefGeneral::instance();
- prefs.auto_recalculate_thumbnails = true;
prefs.default_filename = copy_qstring("new base12");
prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
prefs.defaultsetpoint = 14;
- prefs.extract_video_thumbnails = true;
- prefs.extract_video_thumbnails_position = 15;
- prefs.ffmpeg_executable = copy_qstring("new base16");
prefs.o2consumption = 17;
prefs.pscr_ratio = 18;
prefs.use_default_file = true;
- QCOMPARE(tst->auto_recalculate_thumbnails(), prefs.auto_recalculate_thumbnails);
QCOMPARE(tst->default_filename(), QString(prefs.default_filename));
QCOMPARE(tst->default_file_behavior(), prefs.default_file_behavior);
QCOMPARE(tst->defaultsetpoint(), prefs.defaultsetpoint);
- QCOMPARE(tst->extract_video_thumbnails(), prefs.extract_video_thumbnails);
- QCOMPARE(tst->extract_video_thumbnails_position(), prefs.extract_video_thumbnails_position);
- QCOMPARE(tst->ffmpeg_executable(), QString(prefs.ffmpeg_executable));
QCOMPARE(tst->o2consumption(), prefs.o2consumption);
QCOMPARE(tst->pscr_ratio(), prefs.pscr_ratio);
QCOMPARE(tst->use_default_file(), prefs.use_default_file);
@@ -52,26 +44,18 @@ void TestQPrefGeneral::test_set_struct()
auto tst = qPrefGeneral::instance();
- tst->set_auto_recalculate_thumbnails(false);
tst->set_default_filename("new base22");
tst->set_default_file_behavior(LOCAL_DEFAULT_FILE);
tst->set_defaultsetpoint(24);
- tst->set_extract_video_thumbnails(false);
- tst->set_extract_video_thumbnails_position(25);
- tst->set_ffmpeg_executable("new base26");
tst->set_o2consumption(27);
tst->set_pscr_ratio(28);
tst->set_use_default_file(false);
tst->set_diveshareExport_uid("uid1");
tst->set_diveshareExport_private(false);
- QCOMPARE(prefs.auto_recalculate_thumbnails, false);
QCOMPARE(QString(prefs.default_filename), QString("new base22"));
QCOMPARE(prefs.default_file_behavior, LOCAL_DEFAULT_FILE);
QCOMPARE(prefs.defaultsetpoint, 24);
- QCOMPARE(prefs.extract_video_thumbnails, false);
- QCOMPARE(prefs.extract_video_thumbnails_position, 25);
- QCOMPARE(QString(prefs.ffmpeg_executable), QString("new base26"));
QCOMPARE(prefs.o2consumption, 27);
QCOMPARE(prefs.pscr_ratio, 28);
QCOMPARE(prefs.use_default_file, false);
@@ -85,38 +69,26 @@ void TestQPrefGeneral::test_set_load_struct()
auto tst = qPrefGeneral::instance();
- tst->set_auto_recalculate_thumbnails(true);
tst->set_default_filename("new base32");
tst->set_default_file_behavior(NO_DEFAULT_FILE);
tst->set_defaultsetpoint(34);
- tst->set_extract_video_thumbnails(true);
- tst->set_extract_video_thumbnails_position(35);
- tst->set_ffmpeg_executable("new base36");
tst->set_o2consumption(37);
tst->set_pscr_ratio(38);
tst->set_use_default_file(true);
tst->set_diveshareExport_uid("uid2");
tst->set_diveshareExport_private(true);
- prefs.auto_recalculate_thumbnails = false;
prefs.default_filename = copy_qstring("error");
prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
prefs.defaultsetpoint = 14;
- prefs.extract_video_thumbnails = false;
- prefs.extract_video_thumbnails_position = 15;
- prefs.ffmpeg_executable = copy_qstring("error");
prefs.o2consumption = 17;
prefs.pscr_ratio = 18;
prefs.use_default_file = false;
tst->load();
- QCOMPARE(prefs.auto_recalculate_thumbnails, true);
QCOMPARE(QString(prefs.default_filename), QString("new base32"));
QCOMPARE(prefs.default_file_behavior, NO_DEFAULT_FILE);
QCOMPARE(prefs.defaultsetpoint, 34);
- QCOMPARE(prefs.extract_video_thumbnails, true);
- QCOMPARE(prefs.extract_video_thumbnails_position, 35);
- QCOMPARE(QString(prefs.ffmpeg_executable), QString("new base36"));
QCOMPARE(prefs.o2consumption, 37);
QCOMPARE(prefs.pscr_ratio, 38);
QCOMPARE(prefs.use_default_file, true);
@@ -130,37 +102,25 @@ void TestQPrefGeneral::test_struct_disk()
auto tst = qPrefGeneral::instance();
- prefs.auto_recalculate_thumbnails = true;
prefs.default_filename = copy_qstring("base42");
prefs.default_file_behavior = CLOUD_DEFAULT_FILE;
prefs.defaultsetpoint = 44;
- prefs.extract_video_thumbnails = true;
- prefs.extract_video_thumbnails_position = 45;
- prefs.ffmpeg_executable = copy_qstring("base46");
prefs.o2consumption = 47;
prefs.pscr_ratio = 48;
prefs.use_default_file = true;
tst->sync();
- prefs.auto_recalculate_thumbnails = false;
prefs.default_filename = copy_qstring("error");
prefs.default_file_behavior = UNDEFINED_DEFAULT_FILE;
prefs.defaultsetpoint = 14;
- prefs.extract_video_thumbnails = false;
- prefs.extract_video_thumbnails_position = 15;
- prefs.ffmpeg_executable = copy_qstring("error");
prefs.o2consumption = 17;
prefs.pscr_ratio = 18;
prefs.use_default_file = false;
tst->load();
- QCOMPARE(prefs.auto_recalculate_thumbnails, true);
QCOMPARE(QString(prefs.default_filename), QString("base42"));
QCOMPARE(prefs.default_file_behavior, CLOUD_DEFAULT_FILE);
QCOMPARE(prefs.defaultsetpoint, 44);
- QCOMPARE(prefs.extract_video_thumbnails, true);
- QCOMPARE(prefs.extract_video_thumbnails_position, 45);
- QCOMPARE(QString(prefs.ffmpeg_executable), QString("base46"));
QCOMPARE(prefs.o2consumption, 47);
QCOMPARE(prefs.pscr_ratio, 48);
QCOMPARE(prefs.use_default_file, true);
@@ -223,44 +183,27 @@ void TestQPrefGeneral::test_oldPreferences()
void TestQPrefGeneral::test_signals()
{
- QSignalSpy spy1(qPrefGeneral::instance(), &qPrefGeneral::auto_recalculate_thumbnailsChanged);
QSignalSpy spy3(qPrefGeneral::instance(), &qPrefGeneral::default_filenameChanged);
QSignalSpy spy4(qPrefGeneral::instance(), &qPrefGeneral::default_file_behaviorChanged);
QSignalSpy spy5(qPrefGeneral::instance(), &qPrefGeneral::defaultsetpointChanged);
- QSignalSpy spy6(qPrefGeneral::instance(), &qPrefGeneral::extract_video_thumbnailsChanged);
- QSignalSpy spy7(qPrefGeneral::instance(), &qPrefGeneral::extract_video_thumbnails_positionChanged);
- QSignalSpy spy8(qPrefGeneral::instance(), &qPrefGeneral::ffmpeg_executableChanged);
QSignalSpy spy9(qPrefGeneral::instance(), &qPrefGeneral::o2consumptionChanged);
QSignalSpy spy10(qPrefGeneral::instance(), &qPrefGeneral::pscr_ratioChanged);
QSignalSpy spy11(qPrefGeneral::instance(), &qPrefGeneral::use_default_fileChanged);
QSignalSpy spy12(qPrefGeneral::instance(), &qPrefGeneral::diveshareExport_uidChanged);
QSignalSpy spy13(qPrefGeneral::instance(), &qPrefGeneral::diveshareExport_privateChanged);
- prefs.auto_recalculate_thumbnails = true;
- qPrefGeneral::set_auto_recalculate_thumbnails(false);
-
qPrefGeneral::set_default_filename("new base22");
qPrefGeneral::set_default_file_behavior(LOCAL_DEFAULT_FILE);
qPrefGeneral::set_defaultsetpoint(24);
- qPrefGeneral::set_extract_video_thumbnails(false);
- qPrefGeneral::set_extract_video_thumbnails_position(25);
- qPrefGeneral::set_ffmpeg_executable("new base26");
qPrefGeneral::set_o2consumption(27);
qPrefGeneral::set_pscr_ratio(28);
qPrefGeneral::set_use_default_file(false);
qPrefGeneral::set_diveshareExport_uid("uid1");
qPrefGeneral::set_diveshareExport_private(false);
- QCOMPARE(spy1.count(), 1);
-
- QVERIFY(spy1.takeFirst().at(0).toBool() == false);
-
qPrefGeneral::set_default_filename("new base22");
qPrefGeneral::set_default_file_behavior(LOCAL_DEFAULT_FILE);
qPrefGeneral::set_defaultsetpoint(24);
- qPrefGeneral::set_extract_video_thumbnails(false);
- qPrefGeneral::set_extract_video_thumbnails_position(25);
- qPrefGeneral::set_ffmpeg_executable("new base26");
qPrefGeneral::set_o2consumption(27);
qPrefGeneral::set_pscr_ratio(28);
qPrefGeneral::set_use_default_file(false);