mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Preferences: warn if ffmpeg can't be loaded
In the preferences widget warn the user when they enter a non-executable path to ffmpeg. Thus they don't have to start thumbnailing just to find out that the path is wrong. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9eb860d45d
commit
66a5b394d7
2 changed files with 29 additions and 1 deletions
|
@ -8,6 +8,8 @@
|
||||||
#include "core/settings/qPrefDiveComputer.h"
|
#include "core/settings/qPrefDiveComputer.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
PreferencesDefaults::PreferencesDefaults(): AbstractPreferencesWidget(tr("General"), QIcon(":preferences-other-icon"), 0 ), ui(new Ui::PreferencesDefaults())
|
PreferencesDefaults::PreferencesDefaults(): AbstractPreferencesWidget(tr("General"), QIcon(":preferences-other-icon"), 0 ), ui(new Ui::PreferencesDefaults())
|
||||||
{
|
{
|
||||||
|
@ -45,13 +47,37 @@ void PreferencesDefaults::on_localDefaultFile_toggled(bool toggle)
|
||||||
ui->chooseFile->setEnabled(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()
|
void PreferencesDefaults::on_ffmpegFile_clicked()
|
||||||
{
|
{
|
||||||
QFileInfo fi(system_default_filename());
|
QFileInfo fi(system_default_filename());
|
||||||
QString ffmpegFileName = QFileDialog::getOpenFileName(this, tr("Select ffmpeg executable"));
|
QString ffmpegFileName = QFileDialog::getOpenFileName(this, tr("Select ffmpeg executable"));
|
||||||
|
|
||||||
if (!ffmpegFileName.isEmpty())
|
if (!ffmpegFileName.isEmpty()) {
|
||||||
ui->ffmpegExecutable->setText(ffmpegFileName);
|
ui->ffmpegExecutable->setText(ffmpegFileName);
|
||||||
|
checkFfmpegExecutable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDefaults::on_ffmpegExecutable_editingFinished()
|
||||||
|
{
|
||||||
|
checkFfmpegExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDefaults::on_extractVideoThumbnails_toggled(bool toggled)
|
void PreferencesDefaults::on_extractVideoThumbnails_toggled(bool toggled)
|
||||||
|
|
|
@ -21,12 +21,14 @@ public slots:
|
||||||
void on_btnUseDefaultFile_toggled(bool toggled);
|
void on_btnUseDefaultFile_toggled(bool toggled);
|
||||||
void on_localDefaultFile_toggled(bool toggled);
|
void on_localDefaultFile_toggled(bool toggled);
|
||||||
void on_ffmpegFile_clicked();
|
void on_ffmpegFile_clicked();
|
||||||
|
void on_ffmpegExecutable_editingFinished();
|
||||||
void on_extractVideoThumbnails_toggled(bool toggled);
|
void on_extractVideoThumbnails_toggled(bool toggled);
|
||||||
void on_resetSettings_clicked();
|
void on_resetSettings_clicked();
|
||||||
void on_resetRememberedDCs_clicked();
|
void on_resetRememberedDCs_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PreferencesDefaults *ui;
|
Ui::PreferencesDefaults *ui;
|
||||||
|
void checkFfmpegExecutable();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue