forked from qt-creator/qt-creator
CMakeProjectManager: Add elapsed timer
Change-Id: I1e7bcd60cae0193b4d16f20175b76550aaefbf9c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
@@ -149,6 +150,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
||||
|
||||
process->setCommand(commandLine);
|
||||
emit started();
|
||||
m_elapsed.start();
|
||||
process->start();
|
||||
|
||||
m_process = std::move(process);
|
||||
@@ -234,6 +236,12 @@ void CMakeProcess::handleProcessFinished(int code, QProcess::ExitStatus status)
|
||||
m_future->reportFinished();
|
||||
|
||||
emit finished(code, status);
|
||||
|
||||
const QTime format = QTime(0, 0, 0, 0).addMSecs(m_elapsed.elapsed() + 500);
|
||||
QString time = format.toString("h:mm:ss");
|
||||
if (time.startsWith("0:"))
|
||||
time.remove(0, 2); // Don't display zero hours
|
||||
Core::MessageManager::write(tr("Elapsed time: %1.") .arg(time));
|
||||
}
|
||||
|
||||
void CMakeProcess::checkForCancelled()
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QFutureInterface>
|
||||
#include <QTimer>
|
||||
|
||||
@@ -73,6 +74,7 @@ private:
|
||||
std::unique_ptr<QFutureInterface<void>> m_future;
|
||||
bool m_processWasCanceled = false;
|
||||
QTimer m_cancelTimer;
|
||||
QElapsedTimer m_elapsed;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user