mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
3e853e37a5
commit
2ac279d129
18 changed files with 398 additions and 226 deletions
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -177,79 +177,6 @@
|
|||
</layout>
|
||||
</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">
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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>
|
||||
|
|
89
desktop-widgets/preferences/preferences_media.cpp
Normal file
89
desktop-widgets/preferences/preferences_media.cpp
Normal file
|
@ -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());
|
||||
|
||||
}
|
30
desktop-widgets/preferences/preferences_media.h
Normal file
30
desktop-widgets/preferences/preferences_media.h
Normal file
|
@ -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
|
||||
|
192
desktop-widgets/preferences/preferences_media.ui
Normal file
192
desktop-widgets/preferences/preferences_media.ui
Normal file
|
@ -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>
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue