From ee8dae5da5b0c7244bb29d8593ec5da49beaf01c Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 14 Aug 2015 19:46:18 +0200 Subject: [PATCH] GUI: show number of running jobs in the status bar --- .../main_window/status_bar_progress_widget.ui | 2 +- src/mkvtoolnix-gui/jobs/model.cpp | 19 ++++++------------- src/mkvtoolnix-gui/jobs/model.h | 2 +- .../status_bar_progress_widget.cpp | 4 +++- .../main_window/status_bar_progress_widget.h | 4 ++-- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/mkvtoolnix-gui/forms/main_window/status_bar_progress_widget.ui b/src/mkvtoolnix-gui/forms/main_window/status_bar_progress_widget.ui index fac45d2b7..88adc37bc 100644 --- a/src/mkvtoolnix-gui/forms/main_window/status_bar_progress_widget.ui +++ b/src/mkvtoolnix-gui/forms/main_window/status_bar_progress_widget.ui @@ -55,7 +55,7 @@ - 0 automatic, 0 manual + 0 automatic, 0 manual, 0 running diff --git a/src/mkvtoolnix-gui/jobs/model.cpp b/src/mkvtoolnix-gui/jobs/model.cpp index c62220229..6944f5b4b 100644 --- a/src/mkvtoolnix-gui/jobs/model.cpp +++ b/src/mkvtoolnix-gui/jobs/model.cpp @@ -445,21 +445,14 @@ void Model::updateJobStats() { QMutexLocker locked{&m_mutex}; - auto numPendingAuto = 0; - auto numPendingManual = 0; - auto numOther = 0; + auto numJobs = std::map{ { Job::PendingAuto, 0 }, { Job::PendingManual, 0 }, { Job::Running, 0 }, { Job::Disabled, 0 } }; - for (auto const &job : m_jobsById) - if (mtx::included_in(job->status(), Job::PendingAuto, Job::Running)) - ++numPendingAuto; + for (auto const &job : m_jobsById) { + auto idx = mtx::included_in(job->status(), Job::PendingAuto, Job::PendingManual, Job::Running) ? job->status() : Job::Disabled; + ++numJobs[idx]; + } - else if (Job::PendingManual == job->status()) - ++numPendingManual; - - else - ++numOther; - - emit jobStatsChanged(numPendingAuto, numPendingManual, numOther); + emit jobStatsChanged(numJobs[ Job::PendingAuto ], numJobs[ Job::PendingManual ], numJobs[ Job::Running ], numJobs[ Job::Disabled ]); } void diff --git a/src/mkvtoolnix-gui/jobs/model.h b/src/mkvtoolnix-gui/jobs/model.h index 764df6ac5..676617759 100644 --- a/src/mkvtoolnix-gui/jobs/model.h +++ b/src/mkvtoolnix-gui/jobs/model.h @@ -83,7 +83,7 @@ public: signals: void progressChanged(int progress, int totalProgress); - void jobStatsChanged(int numPendingAutomatic, int numPendingManual, int numOther); + void jobStatsChanged(int numPendingAutomatic, int numPendingManual, int numRunning, int numOther); void numUnacknowledgedWarningsOrErrorsChanged(int numWarnings, int numErrors); 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 bf3bc177a..8070779cf 100644 --- a/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.cpp +++ b/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.cpp @@ -48,9 +48,11 @@ StatusBarProgressWidget::setProgress(int progress, void StatusBarProgressWidget::setJobStats(int numPendingAuto, int numPendingManual, + int numRunning, int) { m_numPendingAuto = numPendingAuto; m_numPendingManual = numPendingManual; + m_numRunning = numRunning; setLabelTexts(); } @@ -84,7 +86,7 @@ StatusBarProgressWidget::retranslateUi() { void StatusBarProgressWidget::setLabelTexts() { - ui->numJobsLabel->setText(QY("%1 automatic, %2 manual").arg(m_numPendingAuto).arg(m_numPendingManual)); + ui->numJobsLabel->setText(QY("%1 automatic, %2 manual, %3 running").arg(m_numPendingAuto).arg(m_numPendingManual).arg(m_numRunning)); ui->warningsLabel->setText(QNY("%1 warning", "%1 warnings", m_numWarnings).arg(m_numWarnings)); ui->errorsLabel ->setText(QNY("%1 error", "%1 errors", m_numErrors) .arg(m_numErrors)); } 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 55f5c9a01..d2a0f6878 100644 --- a/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.h +++ b/src/mkvtoolnix-gui/main_window/status_bar_progress_widget.h @@ -19,7 +19,7 @@ class StatusBarProgressWidget : public QWidget { protected: std::unique_ptr ui; - int m_numPendingAuto{}, m_numPendingManual{}, m_numWarnings{}, m_numErrors{}, m_timerStep{}; + int m_numPendingAuto{}, m_numPendingManual{}, m_numRunning{}, m_numWarnings{}, m_numErrors{}, m_timerStep{}; QTimer m_timer; QList m_pixmaps; @@ -31,7 +31,7 @@ public: public slots: void setProgress(int progress, int totalProgress); - void setJobStats(int numPendingAutomatic, int numPendingManual, int numOther); + void setJobStats(int numPendingAutomatic, int numPendingManual, int numRunning, int numOther); void setNumUnacknowledgedWarningsOrErrors(int numWarnings, int numErrors); void updateWarningsAndErrorsIcons();