File indexing completed on 2024-04-21 04:49:01
0001 /* 0002 SPDX-FileCopyrightText: 2016 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr> 0003 0004 SPDX-License-Identifier: LGPL-3.0-or-later 0005 */ 0006 0007 #include "progressindicator.h" 0008 0009 #include <QTime> 0010 0011 ProgressIndicator::ProgressIndicator(QObject *parent) : QObject(parent) 0012 { 0013 } 0014 0015 ProgressIndicator::~ProgressIndicator() 0016 = default; 0017 0018 int ProgressIndicator::position() const 0019 { 0020 return mPosition; 0021 } 0022 0023 QString ProgressIndicator::progressDuration() const 0024 { 0025 return mProgressDuration; 0026 } 0027 0028 void ProgressIndicator::setPosition(int position) 0029 { 0030 if (mPosition == position) 0031 return; 0032 0033 mPosition = position; 0034 0035 QTime currentProgress = QTime::fromMSecsSinceStartOfDay(mPosition); 0036 if (currentProgress.hour() == 0) { 0037 mProgressDuration = currentProgress.toString(QStringLiteral("m:ss")); 0038 } else { 0039 mProgressDuration = currentProgress.toString(QStringLiteral("h:mm:ss")); 0040 } 0041 0042 Q_EMIT positionChanged(); 0043 Q_EMIT progressDurationChanged(); 0044 } 0045 0046 0047 #include "moc_progressindicator.cpp"