GUI: status bar: differentiate between current & old warnings/errors

implements #3732
This commit is contained in:
Moritz Bunkus 2024-08-27 21:22:37 +02:00
parent 75c9035df2
commit ddbd7b9eeb
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
9 changed files with 78 additions and 31 deletions

View File

@ -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

View File

@ -62,6 +62,7 @@ static RegionList s_regions, s_commonRegions;
static CharacterSetList s_characterSets, s_commonCharacterSets;
static QHash<QString, QString> s_iso639_2LanguageCodeToDescription, s_regionToDescription;
static QStringList s_originalCLIArgs;
static std::optional<QDateTime> s_appStartTimestamp;
static std::optional<bool> 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;
}
}

View File

@ -3,6 +3,7 @@
#include "common/common_pch.h"
#include <QApplication>
#include <QDateTime>
#include <QStringList>
#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

View File

@ -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

View File

@ -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);

View File

@ -18,7 +18,7 @@ class StatusBarProgressWidgetPrivate {
friend class StatusBarProgressWidget;
std::unique_ptr<Ui::StatusBarProgressWidget> 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<QPixmap> 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("<p>%1</p>"
"<ul>"
"<li>%2</li>"
"<li>%3</li>"
"</ul>");
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);

View File

@ -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;
};

View File

@ -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);
}

View File

@ -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();