From 0ad115732e35f7bc44aa0ec57d9de790cda72e11 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 25 Feb 2019 06:39:50 -0500 Subject: [PATCH] [libcalamaresui] Report elapsed time as well. - While waiting on modules, report the elapsed time in seconds based on the number of progress-ticks that have passed. --- src/libcalamaresui/modulesystem/RequirementsChecker.cpp | 9 ++++++++- src/libcalamaresui/modulesystem/RequirementsChecker.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp b/src/libcalamaresui/modulesystem/RequirementsChecker.cpp index b6af4bcf4..68569635b 100644 --- a/src/libcalamaresui/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamaresui/modulesystem/RequirementsChecker.cpp @@ -66,6 +66,7 @@ RequirementsChecker::RequirementsChecker( QVector< Module* > modules, QObject* p : QObject( parent ) , m_modules( std::move( modules ) ) , m_progressTimer( nullptr ) + , m_progressTimeouts( 0 ) { m_watchers.reserve( m_modules.count() ); m_collectedRequirements.reserve( m_modules.count() ); @@ -135,9 +136,15 @@ RequirementsChecker::addCheckedRequirements( RequirementsList l ) void RequirementsChecker::reportProgress() { + m_progressTimeouts++; + auto remaining = std::count_if( m_watchers.cbegin(), m_watchers.cend(), []( const Watcher *w ) { return w && !w->isFinished(); } ); if ( remaining > 0 ) - emit requirementsProgress( tr( "Waiting for %n module(s).", "", remaining ) ); + { + QString waiting = tr( "Waiting for %n module(s).", "", remaining ); + QString elapsed = tr( "(%n second(s))", "", m_progressTimeouts * m_progressTimer->interval() / 1000 ); + emit requirementsProgress( waiting + QString( " " ) + elapsed ); + } else emit requirementsProgress( tr( "System-requirements checking is complete." ) ); } diff --git a/src/libcalamaresui/modulesystem/RequirementsChecker.h b/src/libcalamaresui/modulesystem/RequirementsChecker.h index af46a4ab2..6e681971c 100644 --- a/src/libcalamaresui/modulesystem/RequirementsChecker.h +++ b/src/libcalamaresui/modulesystem/RequirementsChecker.h @@ -79,6 +79,7 @@ private: RequirementsList m_collectedRequirements; QTimer *m_progressTimer; + unsigned m_progressTimeouts; } ; }