ensured totalTimePlayed is allways greater than 0
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
2ab48a43dd
commit
b075711be0
@ -278,6 +278,8 @@ void BaseInstance::setRunning(bool running)
|
|||||||
QDateTime timeEnded = QDateTime::currentDateTime();
|
QDateTime timeEnded = QDateTime::currentDateTime();
|
||||||
|
|
||||||
qint64 current = settings()->get("totalTimePlayed").toLongLong();
|
qint64 current = settings()->get("totalTimePlayed").toLongLong();
|
||||||
|
if (current < 0)
|
||||||
|
current = 0;
|
||||||
settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded));
|
settings()->set("totalTimePlayed", current + m_timeStarted.secsTo(timeEnded));
|
||||||
settings()->set("lastTimePlayed", m_timeStarted.secsTo(timeEnded));
|
settings()->set("lastTimePlayed", m_timeStarted.secsTo(timeEnded));
|
||||||
|
|
||||||
@ -290,6 +292,8 @@ void BaseInstance::setRunning(bool running)
|
|||||||
int64_t BaseInstance::totalTimePlayed() const
|
int64_t BaseInstance::totalTimePlayed() const
|
||||||
{
|
{
|
||||||
qint64 current = m_settings->get("totalTimePlayed").toLongLong();
|
qint64 current = m_settings->get("totalTimePlayed").toLongLong();
|
||||||
|
if (current < 0)
|
||||||
|
current = 0;
|
||||||
if (m_isRunning) {
|
if (m_isRunning) {
|
||||||
QDateTime timeNow = QDateTime::currentDateTime();
|
QDateTime timeNow = QDateTime::currentDateTime();
|
||||||
return current + m_timeStarted.secsTo(timeNow);
|
return current + m_timeStarted.secsTo(timeNow);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user