diff options
author | Roman Savochenko <roman@home.home> | 2023-11-22 09:45:36 +0200 |
---|---|---|
committer | Roman Savochenko <roman@home.home> | 2023-11-22 09:45:36 +0200 |
commit | c5804975ec535433effc1dbecefa1b51910b1b67 (patch) | |
tree | 593b0e8117f78e2946bc19a7dbb9fb68f5c9fe49 /karm/idletimedetector.cpp | |
parent | d470e73134c09daf33a87bd80920fc278bf2b3c2 (diff) | |
download | tdepim-feat/karm-busyCntr-itemReset.tar.gz tdepim-feat/karm-busyCntr-itemReset.zip |
KARM: Non negative busy counter and Item Resetfeat/karm-busyCntr-itemReset
Signed-off-by: Roman Savochenko <roman@home.home>
Diffstat (limited to 'karm/idletimedetector.cpp')
-rw-r--r-- | karm/idletimedetector.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/karm/idletimedetector.cpp b/karm/idletimedetector.cpp index 110eacd06..dd2c4d565 100644 --- a/karm/idletimedetector.cpp +++ b/karm/idletimedetector.cpp @@ -1,3 +1,5 @@ +#include <time.h> + #include "idletimedetector.h" #include <tqdatetime.h> @@ -67,30 +69,34 @@ void IdleTimeDetector::informOverrun(int idleSeconds) _timer->stop(); - TQDateTime idleStart = TQDateTime::currentDateTime().addSecs(-idleSeconds); - TQString idleStartTQString = TDEGlobal::locale()->formatTime(idleStart.time()); + struct timespec tm; + + clock_gettime(CLOCK_MONOTONIC, &tm); + int start = tm.tv_sec - idleSeconds; + TQDateTime idleStart = TQDateTime::currentDateTime().addSecs(-idleSeconds); int id = TQMessageBox::warning( 0, i18n("Idle Detection"), i18n("Desktop has been idle since %1." - " What should we do?").arg(idleStartTQString), + " What should we do?").arg(TDEGlobal::locale()->formatTime(idleStart.time())), i18n("Revert && Stop"), i18n("Revert && Continue"), i18n("Continue Timing"),0,2); - TQDateTime end = TQDateTime::currentDateTime(); - int diff = idleStart.secsTo(end)/secsPerMinute; + + clock_gettime(CLOCK_MONOTONIC, &tm); + int diff = tm.tv_sec - start; if (id == 0) { // Revert And Stop kdDebug(5970) << "Now it is " << TQDateTime::currentDateTime() << endl; kdDebug(5970) << "Reverting timer to " << TDEGlobal::locale()->formatTime(idleStart.time()).ascii() << endl; - emit(extractTime(idleSeconds/60+diff)); // we need to subtract the time that has been added during idleness. + emit(extractTime(diff/60)); emit(stopAllTimersAt(idleStart)); } else if (id == 1) { // Revert and Continue - emit(extractTime(idleSeconds/60+diff)); + emit(extractTime(diff/60)); _timer->start(testInterval); } else |