mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-02-26 08:22:31 +00:00
GUI: jobs: add setting for removing output files of failed/aborted jobs
Implements #2614.
This commit is contained in:
parent
fd1b21175b
commit
28cf5441d1
7
NEWS.md
7
NEWS.md
@ -1,5 +1,12 @@
|
|||||||
# Version ?
|
# Version ?
|
||||||
|
|
||||||
|
## New features and enhancements
|
||||||
|
|
||||||
|
* MKVToolNix GUI: job queue: added a new setting in the preferences' "job
|
||||||
|
queue & job status" section that, when enabled, will cause the GUI to remove
|
||||||
|
all output files created by jobs that are either aborted by the user or that
|
||||||
|
end in an error. Implements #2614.
|
||||||
|
|
||||||
## Bug fixes
|
## Bug fixes
|
||||||
|
|
||||||
* MKVToolNix GUI: Hebrew was added to the list of often-used languages so that
|
* MKVToolNix GUI: Hebrew was added to the list of often-used languages so that
|
||||||
|
@ -1678,6 +1678,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbGuiRemoveOutputFileOnJobFailure">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove the output &file when a job ends with errors or when it is aborted</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout_7">
|
<layout class="QGridLayout" name="gridLayout_7">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
@ -2033,6 +2040,7 @@
|
|||||||
<tabstop>cbGuiUseDefaultJobDescription</tabstop>
|
<tabstop>cbGuiUseDefaultJobDescription</tabstop>
|
||||||
<tabstop>cbGuiShowOutputOfAllJobs</tabstop>
|
<tabstop>cbGuiShowOutputOfAllJobs</tabstop>
|
||||||
<tabstop>cbGuiResetJobWarningErrorCountersOnExit</tabstop>
|
<tabstop>cbGuiResetJobWarningErrorCountersOnExit</tabstop>
|
||||||
|
<tabstop>cbGuiRemoveOutputFileOnJobFailure</tabstop>
|
||||||
<tabstop>cbGuiRemoveJobs</tabstop>
|
<tabstop>cbGuiRemoveJobs</tabstop>
|
||||||
<tabstop>cbGuiJobRemovalPolicy</tabstop>
|
<tabstop>cbGuiJobRemovalPolicy</tabstop>
|
||||||
<tabstop>cbGuiRemoveOldJobs</tabstop>
|
<tabstop>cbGuiRemoveOldJobs</tabstop>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "common/common_pch.h"
|
#include "common/common_pch.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
@ -9,6 +11,7 @@
|
|||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "common/qt.h"
|
#include "common/qt.h"
|
||||||
#include "mkvtoolnix-gui/app.h"
|
#include "mkvtoolnix-gui/app.h"
|
||||||
|
#include "mkvtoolnix-gui/info/job_settings.h"
|
||||||
#include "mkvtoolnix-gui/jobs/info_job.h"
|
#include "mkvtoolnix-gui/jobs/info_job.h"
|
||||||
#include "mkvtoolnix-gui/jobs/job.h"
|
#include "mkvtoolnix-gui/jobs/job.h"
|
||||||
#include "mkvtoolnix-gui/jobs/job_p.h"
|
#include "mkvtoolnix-gui/jobs/job_p.h"
|
||||||
@ -457,6 +460,11 @@ void
|
|||||||
Job::runProgramsAfterCompletion() {
|
Job::runProgramsAfterCompletion() {
|
||||||
auto p = p_func();
|
auto p = p_func();
|
||||||
|
|
||||||
|
if (p->status == Aborted) {
|
||||||
|
maybeRemoveOutputFile();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mtx::included_in(p->status, DoneOk, DoneWarnings, Failed))
|
if (!mtx::included_in(p->status, DoneOk, DoneWarnings, Failed))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -467,6 +475,8 @@ Job::runProgramsAfterCompletion() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
App::programRunner().executeActionsAfterJobFinishes(*this);
|
App::programRunner().executeActionsAfterJobFinishes(*this);
|
||||||
|
|
||||||
|
maybeRemoveOutputFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -480,4 +490,20 @@ Job::runProgramSetupVariables(ProgramRunner::VariableMap &variables)
|
|||||||
variables[Q("JOB_EXIT_CODE")] << QString::number(p->exitCode);
|
variables[Q("JOB_EXIT_CODE")] << QString::number(p->exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Job::maybeRemoveOutputFile() {
|
||||||
|
auto p = p_func();
|
||||||
|
|
||||||
|
if ( !Util::Settings::get().m_removeOutputFileOnJobFailure
|
||||||
|
|| !mtx::included_in(p->status, Aborted, Failed))
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto fileName = destinationFileName();
|
||||||
|
|
||||||
|
qDebug() << "maybeRemoveOutputFile:" << fileName;
|
||||||
|
|
||||||
|
if (!fileName.isEmpty())
|
||||||
|
QFile::remove(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
@ -112,6 +112,7 @@ protected:
|
|||||||
virtual void loadJobBasis(Util::ConfigFile &settings);
|
virtual void loadJobBasis(Util::ConfigFile &settings);
|
||||||
virtual void runProgramsAfterCompletion();
|
virtual void runProgramsAfterCompletion();
|
||||||
void setupJobConnections();
|
void setupJobConnections();
|
||||||
|
virtual void maybeRemoveOutputFile();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setStatus(Job::Status status);
|
virtual void setStatus(Job::Status status);
|
||||||
|
@ -63,6 +63,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,
|
|||||||
ui->cbGuiShowOutputOfAllJobs->setChecked(m_cfg.m_showOutputOfAllJobs);
|
ui->cbGuiShowOutputOfAllJobs->setChecked(m_cfg.m_showOutputOfAllJobs);
|
||||||
ui->cbGuiSwitchToJobOutputAfterStarting->setChecked(m_cfg.m_switchToJobOutputAfterStarting);
|
ui->cbGuiSwitchToJobOutputAfterStarting->setChecked(m_cfg.m_switchToJobOutputAfterStarting);
|
||||||
ui->cbGuiResetJobWarningErrorCountersOnExit->setChecked(m_cfg.m_resetJobWarningErrorCountersOnExit);
|
ui->cbGuiResetJobWarningErrorCountersOnExit->setChecked(m_cfg.m_resetJobWarningErrorCountersOnExit);
|
||||||
|
ui->cbGuiRemoveOutputFileOnJobFailure->setChecked(m_cfg.m_removeOutputFileOnJobFailure);
|
||||||
ui->cbGuiRemoveOldJobs->setChecked(m_cfg.m_removeOldJobs);
|
ui->cbGuiRemoveOldJobs->setChecked(m_cfg.m_removeOldJobs);
|
||||||
ui->sbGuiRemoveOldJobsDays->setValue(m_cfg.m_removeOldJobsDays);
|
ui->sbGuiRemoveOldJobsDays->setValue(m_cfg.m_removeOldJobsDays);
|
||||||
adjustRemoveOldJobsControls();
|
adjustRemoveOldJobsControls();
|
||||||
@ -246,6 +247,7 @@ PreferencesDialog::setupToolTips() {
|
|||||||
Util::setToolTip(ui->cbGuiShowOutputOfAllJobs, QY("If enabled, the first tab in the \"job output\" tool will not be cleared when a new job starts."));
|
Util::setToolTip(ui->cbGuiShowOutputOfAllJobs, QY("If enabled, the first tab in the \"job output\" tool will not be cleared when a new job starts."));
|
||||||
Util::setToolTip(ui->cbGuiSwitchToJobOutputAfterStarting, QY("If enabled, the GUI will automatically switch to the job output tool whenever you start a job (e.g. by pressing \"start multiplexing\")."));
|
Util::setToolTip(ui->cbGuiSwitchToJobOutputAfterStarting, QY("If enabled, the GUI will automatically switch to the job output tool whenever you start a job (e.g. by pressing \"start multiplexing\")."));
|
||||||
Util::setToolTip(ui->cbGuiResetJobWarningErrorCountersOnExit, QY("If enabled, the warning and error counters of all jobs and the global counters in the status bar will be reset to 0 when the program exits."));
|
Util::setToolTip(ui->cbGuiResetJobWarningErrorCountersOnExit, QY("If enabled, the warning and error counters of all jobs and the global counters in the status bar will be reset to 0 when the program exits."));
|
||||||
|
Util::setToolTip(ui->cbGuiRemoveOutputFileOnJobFailure, QY("If enabled, the GUI will remove the output file created by a job if that job ends with an error or if the user aborts the job."));
|
||||||
Util::setToolTip(ui->cbGuiRemoveOldJobs, QY("If enabled, the GUI will remove completed jobs older than the configured number of days no matter their status on exit."));
|
Util::setToolTip(ui->cbGuiRemoveOldJobs, QY("If enabled, the GUI will remove completed jobs older than the configured number of days no matter their status on exit."));
|
||||||
Util::setToolTip(ui->sbGuiRemoveOldJobsDays, QY("If enabled, the GUI will remove completed jobs older than the configured number of days no matter their status on exit."));
|
Util::setToolTip(ui->sbGuiRemoveOldJobsDays, QY("If enabled, the GUI will remove completed jobs older than the configured number of days no matter their status on exit."));
|
||||||
|
|
||||||
@ -788,6 +790,7 @@ PreferencesDialog::save() {
|
|||||||
m_cfg.m_showOutputOfAllJobs = ui->cbGuiShowOutputOfAllJobs->isChecked();
|
m_cfg.m_showOutputOfAllJobs = ui->cbGuiShowOutputOfAllJobs->isChecked();
|
||||||
m_cfg.m_switchToJobOutputAfterStarting = ui->cbGuiSwitchToJobOutputAfterStarting->isChecked();
|
m_cfg.m_switchToJobOutputAfterStarting = ui->cbGuiSwitchToJobOutputAfterStarting->isChecked();
|
||||||
m_cfg.m_resetJobWarningErrorCountersOnExit = ui->cbGuiResetJobWarningErrorCountersOnExit->isChecked();
|
m_cfg.m_resetJobWarningErrorCountersOnExit = ui->cbGuiResetJobWarningErrorCountersOnExit->isChecked();
|
||||||
|
m_cfg.m_removeOutputFileOnJobFailure = ui->cbGuiRemoveOutputFileOnJobFailure->isChecked();
|
||||||
auto idx = !ui->cbGuiRemoveJobs->isChecked() ? 0 : ui->cbGuiJobRemovalPolicy->currentIndex() + 1;
|
auto idx = !ui->cbGuiRemoveJobs->isChecked() ? 0 : ui->cbGuiJobRemovalPolicy->currentIndex() + 1;
|
||||||
m_cfg.m_jobRemovalPolicy = static_cast<Util::Settings::JobRemovalPolicy>(idx);
|
m_cfg.m_jobRemovalPolicy = static_cast<Util::Settings::JobRemovalPolicy>(idx);
|
||||||
m_cfg.m_removeOldJobs = ui->cbGuiRemoveOldJobs->isChecked();
|
m_cfg.m_removeOldJobs = ui->cbGuiRemoveOldJobs->isChecked();
|
||||||
|
@ -327,6 +327,7 @@ Settings::load() {
|
|||||||
m_showOutputOfAllJobs = reg.value(s_valShowOutputOfAllJobs, true).toBool();
|
m_showOutputOfAllJobs = reg.value(s_valShowOutputOfAllJobs, true).toBool();
|
||||||
m_switchToJobOutputAfterStarting = reg.value(s_valSwitchToJobOutputAfterStarting, false).toBool();
|
m_switchToJobOutputAfterStarting = reg.value(s_valSwitchToJobOutputAfterStarting, false).toBool();
|
||||||
m_resetJobWarningErrorCountersOnExit = reg.value(s_valResetJobWarningErrorCountersOnExit, false).toBool();
|
m_resetJobWarningErrorCountersOnExit = reg.value(s_valResetJobWarningErrorCountersOnExit, false).toBool();
|
||||||
|
m_removeOutputFileOnJobFailure = reg.value(s_valRemoveOutputFileOnJobFailure, false).toBool();
|
||||||
m_jobRemovalPolicy = static_cast<JobRemovalPolicy>(reg.value(s_valJobRemovalPolicy, static_cast<int>(JobRemovalPolicy::Never)).toInt());
|
m_jobRemovalPolicy = static_cast<JobRemovalPolicy>(reg.value(s_valJobRemovalPolicy, static_cast<int>(JobRemovalPolicy::Never)).toInt());
|
||||||
m_removeOldJobs = reg.value(s_valRemoveOldJobs, true).toBool();
|
m_removeOldJobs = reg.value(s_valRemoveOldJobs, true).toBool();
|
||||||
m_removeOldJobsDays = reg.value(s_valRemoveOldJobsDays, 14).toInt();
|
m_removeOldJobsDays = reg.value(s_valRemoveOldJobsDays, 14).toInt();
|
||||||
@ -664,6 +665,7 @@ Settings::save()
|
|||||||
reg.setValue(s_valShowOutputOfAllJobs, m_showOutputOfAllJobs);
|
reg.setValue(s_valShowOutputOfAllJobs, m_showOutputOfAllJobs);
|
||||||
reg.setValue(s_valSwitchToJobOutputAfterStarting, m_switchToJobOutputAfterStarting);
|
reg.setValue(s_valSwitchToJobOutputAfterStarting, m_switchToJobOutputAfterStarting);
|
||||||
reg.setValue(s_valResetJobWarningErrorCountersOnExit, m_resetJobWarningErrorCountersOnExit);
|
reg.setValue(s_valResetJobWarningErrorCountersOnExit, m_resetJobWarningErrorCountersOnExit);
|
||||||
|
reg.setValue(s_valRemoveOutputFileOnJobFailure, m_removeOutputFileOnJobFailure);
|
||||||
reg.setValue(s_valJobRemovalPolicy, static_cast<int>(m_jobRemovalPolicy));
|
reg.setValue(s_valJobRemovalPolicy, static_cast<int>(m_jobRemovalPolicy));
|
||||||
reg.setValue(s_valRemoveOldJobs, m_removeOldJobs);
|
reg.setValue(s_valRemoveOldJobs, m_removeOldJobs);
|
||||||
reg.setValue(s_valRemoveOldJobsDays, m_removeOldJobsDays);
|
reg.setValue(s_valRemoveOldJobsDays, m_removeOldJobsDays);
|
||||||
|
@ -174,6 +174,7 @@ public:
|
|||||||
bool m_removeOldJobs;
|
bool m_removeOldJobs;
|
||||||
int m_removeOldJobsDays;
|
int m_removeOldJobsDays;
|
||||||
bool m_useDefaultJobDescription, m_showOutputOfAllJobs, m_switchToJobOutputAfterStarting, m_resetJobWarningErrorCountersOnExit;
|
bool m_useDefaultJobDescription, m_showOutputOfAllJobs, m_switchToJobOutputAfterStarting, m_resetJobWarningErrorCountersOnExit;
|
||||||
|
bool m_removeOutputFileOnJobFailure;
|
||||||
|
|
||||||
bool m_uiDisableHighDPIScaling;
|
bool m_uiDisableHighDPIScaling;
|
||||||
bool m_checkForUpdates;
|
bool m_checkForUpdates;
|
||||||
|
@ -89,6 +89,7 @@ char const * const s_valRecognizedTrackLanguagesInFileNames = "recognizedTrackLa
|
|||||||
char const * const s_valRelativeOutputDir = "relativeOutputDir";
|
char const * const s_valRelativeOutputDir = "relativeOutputDir";
|
||||||
char const * const s_valRemoveOldJobs = "removeOldJobs";
|
char const * const s_valRemoveOldJobs = "removeOldJobs";
|
||||||
char const * const s_valRemoveOldJobsDays = "removeOldJobsDays";
|
char const * const s_valRemoveOldJobsDays = "removeOldJobsDays";
|
||||||
|
char const * const s_valRemoveOutputFileOnJobFailure = "removeOutputFileOnJobFailure";
|
||||||
char const * const s_valResetJobWarningErrorCountersOnExit = "resetJobWarningErrorCountersOnExit";
|
char const * const s_valResetJobWarningErrorCountersOnExit = "resetJobWarningErrorCountersOnExit";
|
||||||
char const * const s_valScanForPlaylistsPolicy = "scanForPlaylistsPolicy";
|
char const * const s_valScanForPlaylistsPolicy = "scanForPlaylistsPolicy";
|
||||||
char const * const s_valSetAudioDelayFromFileName = "setAudioDelayFromFileName";
|
char const * const s_valSetAudioDelayFromFileName = "setAudioDelayFromFileName";
|
||||||
|
Loading…
Reference in New Issue
Block a user