From 95f5c7c592adc2723bce253c5b2c179a0e7fc7e1 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 10 Oct 2015 17:04:16 +0200 Subject: [PATCH] GUI: job queue: optionally reset warning/error counters to 0 on exit Implements #1437. --- ChangeLog | 5 +++++ .../forms/main_window/preferences_dialog.ui | 8 ++++++++ src/mkvtoolnix-gui/jobs/job.cpp | 11 +++++++++-- src/mkvtoolnix-gui/main_window/preferences_dialog.cpp | 3 +++ src/mkvtoolnix-gui/util/settings.cpp | 2 ++ src/mkvtoolnix-gui/util/settings.h | 2 +- 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 281d0a547..f1b962dc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2015-10-10 Moritz Bunkus + * MKVToolNix GUI: new job queue feature: added an option in the + preferences for resetting the warning and error counters of all + jobs and the global counters in the status bar to 0 when exiting + the program. Implements #1437. + * MKVToolNix GUI: current job output enhancement: the separator lines for warnings and errors ("--- Warnings emitted by Job … started on … ---") are only shown when warnings/errors actually diff --git a/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui b/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui index 3a9f6cb7d..f834ba22e 100644 --- a/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui +++ b/src/mkvtoolnix-gui/forms/main_window/preferences_dialog.ui @@ -164,6 +164,13 @@ + + + + Reset the warning and error counters on exit + + + @@ -970,6 +977,7 @@ cbGuiSwitchToJobOutputAfterStarting cbGuiUseDefaultJobDescription cbGuiShowOutputOfAllJobs + cbGuiResetJobWarningErrorCountersOnExit cbGuiRemoveJobs cbGuiJobRemovalPolicy cbCEDropLastFromBlurayPlaylist diff --git a/src/mkvtoolnix-gui/jobs/job.cpp b/src/mkvtoolnix-gui/jobs/job.cpp index 35314899f..c78629e32 100644 --- a/src/mkvtoolnix-gui/jobs/job.cpp +++ b/src/mkvtoolnix-gui/jobs/job.cpp @@ -282,6 +282,8 @@ Job::saveQueueFile() { void Job::saveJob(Util::ConfigFile &settings) { + auto resetCounters = Util::Settings::get().m_resetJobWarningErrorCountersOnExit; + settings.setValue("uuid", m_uuid); settings.setValue("status", static_cast(m_status)); settings.setValue("description", m_description); @@ -291,8 +293,8 @@ Job::saveJob(Util::ConfigFile &settings) { settings.setValue("fullOutput", m_fullOutput); settings.setValue("progress", m_progress); settings.setValue("exitCode", m_exitCode); - settings.setValue("warningsAcknowledged", m_warningsAcknowledged); - settings.setValue("errorsAcknowledged", m_errorsAcknowledged); + settings.setValue("warningsAcknowledged", resetCounters ? m_warnings.count() : m_warningsAcknowledged); + settings.setValue("errorsAcknowledged", resetCounters ? m_errors.count() : m_errorsAcknowledged); settings.setValue("dateAdded", m_dateAdded); settings.setValue("dateStarted", m_dateStarted); settings.setValue("dateFinished", m_dateFinished); @@ -325,6 +327,11 @@ Job::loadJobBasis(Util::ConfigFile &settings) { if (Running == m_status) m_status = Aborted; + + if (Util::Settings::get().m_resetJobWarningErrorCountersOnExit) { + m_warningsAcknowledged = m_warnings.count(); + m_errorsAcknowledged = m_errors.count(); + } } JobPtr diff --git a/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp b/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp index 18362fc0f..c804f10fc 100644 --- a/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp +++ b/src/mkvtoolnix-gui/main_window/preferences_dialog.cpp @@ -43,6 +43,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) ui->cbGuiUseDefaultJobDescription->setChecked(m_cfg.m_useDefaultJobDescription); ui->cbGuiShowOutputOfAllJobs->setChecked(m_cfg.m_showOutputOfAllJobs); ui->cbGuiSwitchToJobOutputAfterStarting->setChecked(m_cfg.m_switchToJobOutputAfterStarting); + ui->cbGuiResetJobWarningErrorCountersOnExit->setChecked(m_cfg.m_resetJobWarningErrorCountersOnExit); setupJobRemovalPolicy(); setupCommonLanguages(); @@ -120,6 +121,7 @@ PreferencesDialog::setupToolTips() { Util::setToolTip(ui->cbGuiUseDefaultJobDescription, QY("If disabled the GUI will let you enter a description for a job when adding it to the queue.")); 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 muxing«).")); + 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->cbGuiRemoveJobs, Q("%1 %2") @@ -418,6 +420,7 @@ PreferencesDialog::save() { m_cfg.m_useDefaultJobDescription = ui->cbGuiUseDefaultJobDescription->isChecked(); m_cfg.m_showOutputOfAllJobs = ui->cbGuiShowOutputOfAllJobs->isChecked(); m_cfg.m_switchToJobOutputAfterStarting = ui->cbGuiSwitchToJobOutputAfterStarting->isChecked(); + m_cfg.m_resetJobWarningErrorCountersOnExit = ui->cbGuiResetJobWarningErrorCountersOnExit->isChecked(); auto idx = !ui->cbGuiRemoveJobs->isChecked() ? 0 : ui->cbGuiJobRemovalPolicy->currentIndex() + 1; m_cfg.m_jobRemovalPolicy = static_cast(idx); diff --git a/src/mkvtoolnix-gui/util/settings.cpp b/src/mkvtoolnix-gui/util/settings.cpp index f0dc2efea..cf00e7300 100644 --- a/src/mkvtoolnix-gui/util/settings.cpp +++ b/src/mkvtoolnix-gui/util/settings.cpp @@ -167,6 +167,7 @@ Settings::load() { m_useDefaultJobDescription = reg.value("useDefaultJobDescription", false).toBool(); m_showOutputOfAllJobs = reg.value("showOutputOfAllJobs", true).toBool(); m_switchToJobOutputAfterStarting = reg.value("switchToJobOutputAfterStarting", false).toBool(); + m_resetJobWarningErrorCountersOnExit = reg.value("resetJobWarningErrorCountersOnExit", false).toBool(); m_jobRemovalPolicy = static_cast(reg.value("jobRemovalPolicy", static_cast(JobRemovalPolicy::Never)).toInt()); m_disableAnimations = reg.value("disableAnimations", false).toBool(); @@ -284,6 +285,7 @@ Settings::save() reg.setValue("useDefaultJobDescription", m_useDefaultJobDescription); reg.setValue("showOutputOfAllJobs", m_showOutputOfAllJobs); reg.setValue("switchToJobOutputAfterStarting", m_switchToJobOutputAfterStarting); + reg.setValue("resetJobWarningErrorCountersOnExit", m_resetJobWarningErrorCountersOnExit); reg.setValue("jobRemovalPolicy", static_cast(m_jobRemovalPolicy)); reg.setValue("disableAnimations", m_disableAnimations); diff --git a/src/mkvtoolnix-gui/util/settings.h b/src/mkvtoolnix-gui/util/settings.h index 4d6e22cad..155bd13c0 100644 --- a/src/mkvtoolnix-gui/util/settings.h +++ b/src/mkvtoolnix-gui/util/settings.h @@ -82,7 +82,7 @@ public: unsigned int m_minimumPlaylistDuration; JobRemovalPolicy m_jobRemovalPolicy; - bool m_useDefaultJobDescription, m_showOutputOfAllJobs, m_switchToJobOutputAfterStarting; + bool m_useDefaultJobDescription, m_showOutputOfAllJobs, m_switchToJobOutputAfterStarting, m_resetJobWarningErrorCountersOnExit; bool m_checkForUpdates; QDateTime m_lastUpdateCheck;