From ddbd7b9eeb00b671ca02d9cc6e44517791c0add6 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 27 Aug 2024 21:22:37 +0200 Subject: [PATCH] GUI: status bar: differentiate between current & old warnings/errors implements #3732 --- NEWS.md | 3 + src/mkvtoolnix-gui/app.cpp | 8 +++ src/mkvtoolnix-gui/app.h | 3 + src/mkvtoolnix-gui/jobs/model.cpp | 19 ++++-- src/mkvtoolnix-gui/jobs/model.h | 2 +- .../status_bar_progress_widget.cpp | 60 +++++++++++++------ .../main_window/status_bar_progress_widget.h | 4 +- src/mkvtoolnix-gui/watch_jobs/tab.cpp | 8 ++- src/mkvtoolnix-gui/watch_jobs/tab.h | 2 +- 9 files changed, 78 insertions(+), 31 deletions(-) diff --git a/NEWS.md b/NEWS.md index c78c16792..4dd3cde18 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,9 @@ * MKVToolNix GUI: multiplexer: added a progress dialog that is shown during file identification. +* MKVToolNix GUI: jobs: the status bar now differentiates between numbers of + warnings/errors that occurred in the current session and those that occurred + before the current session. Implements #3732. ## Bug fixes diff --git a/src/mkvtoolnix-gui/app.cpp b/src/mkvtoolnix-gui/app.cpp index fce9c4dd5..076d997f8 100644 --- a/src/mkvtoolnix-gui/app.cpp +++ b/src/mkvtoolnix-gui/app.cpp @@ -62,6 +62,7 @@ static RegionList s_regions, s_commonRegions; static CharacterSetList s_characterSets, s_commonCharacterSets; static QHash s_iso639_2LanguageCodeToDescription, s_regionToDescription; static QStringList s_originalCLIArgs; +static std::optional s_appStartTimestamp; static std::optional s_is_installed; @@ -87,6 +88,8 @@ App::App(int &argc, : QApplication{argc, argv} , p_ptr{new AppPrivate{}} { + s_appStartTimestamp = QDateTime::currentDateTime(); + // The routines for handling unique numbers cannot cope with // multiple chapters being worked on at the same time as they safe // already-used numbers in one static container. So just disable them. @@ -650,4 +653,9 @@ App::event(QEvent *event) { } #endif +QDateTime +App::appStartTimestamp() { + return *s_appStartTimestamp; +} + } diff --git a/src/mkvtoolnix-gui/app.h b/src/mkvtoolnix-gui/app.h index fbd57b809..be54865a0 100644 --- a/src/mkvtoolnix-gui/app.h +++ b/src/mkvtoolnix-gui/app.h @@ -3,6 +3,7 @@ #include "common/common_pch.h" #include +#include #include #include "mkvtoolnix-gui/gui_cli_parser.h" @@ -71,6 +72,8 @@ public: Util::NetworkAccessManager &networkAccessManager(); + QDateTime appStartTimestamp(); + #if defined(SYS_APPLE) virtual bool event(QEvent *event) override; #endif diff --git a/src/mkvtoolnix-gui/jobs/model.cpp b/src/mkvtoolnix-gui/jobs/model.cpp index 28df60936..254537085 100644 --- a/src/mkvtoolnix-gui/jobs/model.cpp +++ b/src/mkvtoolnix-gui/jobs/model.cpp @@ -436,15 +436,24 @@ Model::onNumUnacknowledgedWarningsOrErrorsChanged(uint64_t id, void Model::updateNumUnacknowledgedWarningsOrErrors() { - auto numWarnings = 0; - auto numErrors = 0; + auto const appStart = App::instance()->appStartTimestamp(); + auto numCurrentWarnings = 0; + auto numCurrentErrors = 0; + auto numOldWarnings = 0; + auto numOldErrors = 0; for (auto const &job : m_jobsById) { - numWarnings += job->numUnacknowledgedWarnings(); - numErrors += job->numUnacknowledgedErrors(); + if (job->dateStarted().isValid() && (job->dateStarted() >= appStart)) { + numCurrentWarnings += job->numUnacknowledgedWarnings(); + numCurrentErrors += job->numUnacknowledgedErrors(); + + } else { + numOldWarnings += job->numUnacknowledgedWarnings(); + numOldErrors += job->numUnacknowledgedErrors(); + } } - Q_EMIT numUnacknowledgedWarningsOrErrorsChanged(numWarnings, numErrors); + Q_EMIT numUnacknowledgedWarningsOrErrorsChanged(numOldWarnings, numCurrentWarnings, numOldErrors, numCurrentErrors); } void diff --git a/src/mkvtoolnix-gui/jobs/model.h b/src/mkvtoolnix-gui/jobs/model.h index 066f48897..4dcd2c23d 100644 --- a/src/mkvtoolnix-gui/jobs/model.h +++ b/src/mkvtoolnix-gui/jobs/model.h @@ -87,7 +87,7 @@ public: Q_SIGNALS: void progressChanged(int progress, int totalProgress); void jobStatsChanged(int numPendingAutomatic, int numPendingManual, int numRunning, int numOther); - void numUnacknowledgedWarningsOrErrorsChanged(int numWarnings, int numErrors); + void numUnacknowledgedWarningsOrErrorsChanged(int numOldWarnings, int numCurrentWarnings, int numOldErrors, int numCurrentErrors); void queueStatusChanged(QueueStatus status); diff --git a/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.cpp b/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.cpp index bfbf0a647..faf9e456e 100644 --- a/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.cpp +++ b/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.cpp @@ -18,7 +18,7 @@ class StatusBarProgressWidgetPrivate { friend class StatusBarProgressWidget; std::unique_ptr ui; - int m_numPendingAuto{}, m_numPendingManual{}, m_numRunning{}, m_numWarnings{}, m_numErrors{}, m_timerStep{}; + int m_numPendingAuto{}, m_numPendingManual{}, m_numRunning{}, m_numOldWarnings{}, m_numCurrentWarnings{}, m_numOldErrors{}, m_numCurrentErrors{}, m_timerStep{}; QTimer m_timer; QList m_pixmaps; @@ -73,51 +73,73 @@ StatusBarProgressWidget::setJobStats(int numPendingAuto, p->m_numPendingManual = numPendingManual; p->m_numRunning = numRunning; - setLabelTexts(); + setLabelTextsAndToolTip(); } void -StatusBarProgressWidget::setNumUnacknowledgedWarningsOrErrors(int numWarnings, - int numErrors) { - auto p = p_func(); - p->m_numWarnings = numWarnings; - p->m_numErrors = numErrors; +StatusBarProgressWidget::setNumUnacknowledgedWarningsOrErrors(int numOldWarnings, + int numCurrentWarnings, + int numOldErrors, + int numCurrentErrors) { + auto p = p_func(); + p->m_numOldWarnings = numOldWarnings; + p->m_numCurrentWarnings = numCurrentWarnings; + p->m_numOldErrors = numOldErrors; + p->m_numCurrentErrors = numCurrentErrors; - auto isActive = p->m_timer.isActive(); + auto isActive = p->m_timer.isActive(); - if (!isActive && (p->m_numWarnings || p->m_numErrors)) { + if (!isActive && (p->m_numOldWarnings || p->m_numCurrentWarnings || p->m_numOldErrors || p->m_numCurrentErrors)) { p->m_timerStep = 0; p->m_timer.start(); - } else if (isActive && !p->m_numWarnings && !p->m_numErrors) { + } else if (isActive && !p->m_numOldWarnings && !p->m_numCurrentWarnings && !p->m_numOldErrors && !p->m_numCurrentErrors) { p->m_timer.stop(); updateWarningsAndErrorsIcons(); } - setLabelTexts(); + setLabelTextsAndToolTip(); } void StatusBarProgressWidget::retranslateUi() { p_func()->ui->retranslateUi(this); - setLabelTexts(); + setLabelTextsAndToolTip(); } void -StatusBarProgressWidget::setLabelTexts() { +StatusBarProgressWidget::setLabelTextsAndToolTip() { auto p = p_func(); p->ui->numJobsLabel->setText(QY("%1 automatic, %2 manual, %3 running").arg(p->m_numPendingAuto).arg(p->m_numPendingManual).arg(p->m_numRunning)); - p->ui->warningsLabel->setText(QNY("%1 warning", "%1 warnings", p->m_numWarnings).arg(p->m_numWarnings)); - p->ui->errorsLabel ->setText(QNY("%1 error", "%1 errors", p->m_numErrors) .arg(p->m_numErrors)); + p->ui->warningsLabel->setText(QNY("%1+%2 warning", "%1+%2 warnings", p->m_numCurrentWarnings + p->m_numOldWarnings).arg(p->m_numCurrentWarnings).arg(p->m_numOldWarnings)); + p->ui->errorsLabel->setText(QNY("%1+%2 error", "%1+%2 errors", p->m_numCurrentErrors + p->m_numOldErrors).arg(p->m_numCurrentErrors).arg(p->m_numOldErrors)); + + auto format = Q("

%1

" + "
    " + "
  • %2
  • " + "
  • %3
  • " + "
"); + + auto toolTipWarnings = format + .arg(QY("Number of warnings:")) + .arg(QY("%1 since starting the program").arg(p->m_numCurrentWarnings)) + .arg(QY("%1 from earlier runs").arg(p->m_numOldWarnings)); + + auto toolTipErrors = format + .arg(QY("Number of errors:")) + .arg(QY("%1 since starting the program").arg(p->m_numCurrentErrors)) + .arg(QY("%1 from earlier runs").arg(p->m_numOldErrors)); + + setToolTip(toolTipWarnings + toolTipErrors); } void StatusBarProgressWidget::updateWarningsAndErrorsIcons() { auto p = p_func(); - auto warningOffset = !p->m_numWarnings || !(p->m_timerStep % 2) ? 1 : 0; - auto errorOffset = !p->m_numErrors || !(p->m_timerStep % 2) ? 1 : 0; + auto warningOffset = !(p->m_numOldWarnings + p->m_numCurrentWarnings) || !(p->m_timerStep % 2) ? 1 : 0; + auto errorOffset = !(p->m_numOldErrors + p->m_numCurrentErrors) || !(p->m_timerStep % 2) ? 1 : 0; p->ui->warningsIconLabel->setPixmap(p->m_pixmaps[0 + warningOffset]); p->ui->errorsIconLabel ->setPixmap(p->m_pixmaps[2 + errorOffset]); @@ -143,8 +165,8 @@ StatusBarProgressWidget::mouseReleaseEvent(QMouseEvent *event) { showJobQueue->setText(QY("Show job queue && access job logs")); showJobOutput->setText(QY("Show job output")); - acknowledgeWarnings->setEnabled(!!p->m_numWarnings); - acknowledgeErrors->setEnabled(!!p->m_numErrors); + acknowledgeWarnings->setEnabled(!!(p->m_numOldWarnings + p->m_numCurrentWarnings)); + acknowledgeErrors->setEnabled(!!(p->m_numOldErrors + p->m_numCurrentErrors)); connect(acknowledgeWarnings, &QAction::triggered, MainWindow::jobTool()->model(), &mtx::gui::Jobs::Model::acknowledgeAllWarnings); connect(acknowledgeErrors, &QAction::triggered, MainWindow::jobTool()->model(), &mtx::gui::Jobs::Model::acknowledgeAllErrors); diff --git a/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.h b/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.h index 6a6bde1bc..9b5da8356 100644 --- a/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.h +++ b/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.h @@ -34,13 +34,13 @@ public: public Q_SLOTS: void setProgress(int progress, int totalProgress); void setJobStats(int numPendingAutomatic, int numPendingManual, int numRunning, int numOther); - void setNumUnacknowledgedWarningsOrErrors(int numWarnings, int numErrors); + void setNumUnacknowledgedWarningsOrErrors(int numOldWarnings, int numCurrentWarnings, int numOldErrors, int numCurrentErrors); void updateWarningsAndErrorsIcons(); void reset(); protected: - void setLabelTexts(); + void setLabelTextsAndToolTip(); virtual void mouseReleaseEvent(QMouseEvent *event) override; }; diff --git a/src/mkvtoolnix-gui/watch_jobs/tab.cpp b/src/mkvtoolnix-gui/watch_jobs/tab.cpp index 42ccba9f4..2005d9542 100644 --- a/src/mkvtoolnix-gui/watch_jobs/tab.cpp +++ b/src/mkvtoolnix-gui/watch_jobs/tab.cpp @@ -379,11 +379,13 @@ Tab::setInitialDisplay(Jobs::Job const &job) { } void -Tab::disableButtonIfAllWarningsAndErrorsButtonAcknowledged(int numWarnings, - int numErrors) { +Tab::disableButtonIfAllWarningsAndErrorsButtonAcknowledged(int numOldWarnings, + int numCurrentWarnings, + int numOldErrors, + int numCurrentErrors) { auto p = p_func(); - if (!numWarnings && !numErrors) + if (!numOldWarnings && !numCurrentWarnings && !numOldErrors && !numCurrentErrors) p->ui->acknowledgeWarningsAndErrorsButton->setEnabled(false); } diff --git a/src/mkvtoolnix-gui/watch_jobs/tab.h b/src/mkvtoolnix-gui/watch_jobs/tab.h index 14ddc72e2..f1abe4b2a 100644 --- a/src/mkvtoolnix-gui/watch_jobs/tab.h +++ b/src/mkvtoolnix-gui/watch_jobs/tab.h @@ -60,7 +60,7 @@ public Q_SLOTS: void openFolder(); void acknowledgeWarningsAndErrors(); - void disableButtonIfAllWarningsAndErrorsButtonAcknowledged(int numWarnings, int numErrors); + void disableButtonIfAllWarningsAndErrorsButtonAcknowledged(int numOldWarnings, int numCurrentWarnings, int numOldErrors, int numCurrentErrors); void updateRemainingTime();