diff options
author | willemferguson <willemferguson@zoology.up.ac.za> | 2019-12-08 11:30:16 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-25 02:57:42 +0900 |
commit | 2ac279d12953ad840ade1c08d0eff5c2f4adb0b9 (patch) | |
tree | 9f2d70f50cb910803e260fa9d3bdad2687d820ad /desktop-widgets | |
parent | 3e853e37a5b0b9509fb92b1ddb3031f117578fb9 (diff) | |
download | subsurface-2ac279d12953ad840ade1c08d0eff5c2f4adb0b9.tar.gz |
Pereferences UI: add media tab
Remove the preference settings dealing with thumbnails (currently under
General preferences and Profile preferences) and put them in a newly-created
Media preference tab.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/preferences/CMakeLists.txt | 3 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_defaults.cpp | 50 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_defaults.h | 4 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_defaults.ui | 73 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_graph.cpp | 2 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_graph.ui | 7 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_media.cpp | 89 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_media.h | 30 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_media.ui | 192 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferencesdialog.cpp | 3 |
10 files changed, 317 insertions, 136 deletions
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, |