summaryrefslogtreecommitdiffstats
path: root/karm
diff options
context:
space:
mode:
authorRoman Savochenko <roman@home.home>2023-11-22 09:45:36 +0200
committerRoman Savochenko <roman@home.home>2023-11-22 09:45:36 +0200
commitc5804975ec535433effc1dbecefa1b51910b1b67 (patch)
tree593b0e8117f78e2946bc19a7dbb9fb68f5c9fe49 /karm
parentd470e73134c09daf33a87bd80920fc278bf2b3c2 (diff)
downloadtdepim-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')
-rw-r--r--karm/idletimedetector.cpp20
-rw-r--r--karm/karmui.rc2
-rw-r--r--karm/mainwindow.cpp9
-rw-r--r--karm/mainwindow.h1
-rw-r--r--karm/preferences.cpp2
-rw-r--r--karm/taskview.cpp5
-rw-r--r--karm/taskview.h3
7 files changed, 34 insertions, 8 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
diff --git a/karm/karmui.rc b/karm/karmui.rc
index 77818aeb9..34efa9cb0 100644
--- a/karm/karmui.rc
+++ b/karm/karmui.rc
@@ -19,6 +19,7 @@
<text>&amp;Clock</text>
<Action name="start" />
<Action name="stop" />
+ <Action name="reset_times" />
<Action name="stopAll" />
</Menu>
<Menu name="task" >
@@ -50,6 +51,7 @@
<Menu name="task_popup">
<Action name="start" />
<Action name="stop" />
+ <Action name="reset_times" />
<Action name="stopAll" />
<Separator />
<Action name="new_task" />
diff --git a/karm/mainwindow.cpp b/karm/mainwindow.cpp
index 8265db055..13879e622 100644
--- a/karm/mainwindow.cpp
+++ b/karm/mainwindow.cpp
@@ -123,6 +123,7 @@ void MainWindow::slotSelectionChanged()
actionEdit->setEnabled(item);
actionStart->setEnabled(item && !item->isRunning() && !item->isComplete());
actionStop->setEnabled(item && item->isRunning());
+ actionResetTime->setEnabled(item && !item->isRunning());
actionMarkAsComplete->setEnabled(item && !item->isComplete());
actionMarkAsIncomplete->setEnabled(item && item->isComplete());
}
@@ -281,6 +282,11 @@ void MainWindow::makeMenus()
TQT_TQOBJECT(_taskView),
TQT_SLOT( stopCurrentTimer() ), actionCollection(),
"stop");
+ actionResetTime = new TDEAction( i18n("Re&set Time"),
+ 0,
+ TQT_TQOBJECT(_taskView),
+ TQT_SLOT( resetTimeCurrentTask() ), actionCollection(),
+ "reset_times");
actionStopAll = new TDEAction( i18n("Stop &All Timers"),
Key_Escape,
TQT_TQOBJECT(_taskView),
@@ -406,6 +412,9 @@ void MainWindow::makeMenus()
actionStopAll->setToolTip( i18n("Stop all of the active timers") );
actionStopAll->setWhatsThis( i18n("Stop all of the active timers") );
+ actionResetTime->setToolTip( i18n("Reset times of the selected task") );
+ actionResetTime->setWhatsThis( i18n("Reset times of the selected task") );
+
actionNew->setToolTip( i18n("Create new top level task") );
actionNew->setWhatsThis( i18n("This will create a new top level task.") );
diff --git a/karm/mainwindow.h b/karm/mainwindow.h
index 7d055802b..0ca6021bf 100644
--- a/karm/mainwindow.h
+++ b/karm/mainwindow.h
@@ -42,6 +42,7 @@ class MainWindow : public KParts::MainWindow, virtual public KarmDCOPIface
KarmTray* _tray;
TDEAction* actionStart;
TDEAction* actionStop;
+ TDEAction* actionResetTime;
TDEAction* actionStopAll;
TDEAction* actionDelete;
TDEAction* actionEdit;
diff --git a/karm/preferences.cpp b/karm/preferences.cpp
index 29b242cfc..8a81d260d 100644
--- a/karm/preferences.cpp
+++ b/karm/preferences.cpp
@@ -58,7 +58,7 @@ void Preferences::makeBehaviorPage()
( i18n("Detect desktop as idle after"), behaviorPage, "_doIdleDetectionW");
_idleDetectValueW = new TQSpinBox
(1,60*24, 1, behaviorPage, "_idleDetectValueW");
- _idleDetectValueW->setSuffix(i18n(" min"));
+ _idleDetectValueW->setSuffix(i18n(" sec"));
_promptDeleteW = new TQCheckBox
( i18n( "Prompt before deleting tasks" ), behaviorPage, "_promptDeleteW" );
diff --git a/karm/taskview.cpp b/karm/taskview.cpp
index d1b80bf86..9d4e1ad78 100644
--- a/karm/taskview.cpp
+++ b/karm/taskview.cpp
@@ -479,6 +479,11 @@ void TaskView::stopCurrentTimer()
stopTimerFor( current_item());
}
+void TaskView::resetTimeCurrentTask()
+{
+ if(current_item()) current_item()->resetTimes();
+}
+
void TaskView::minuteUpdate()
{
addTimeToActiveTasks(1, false);
diff --git a/karm/taskview.h b/karm/taskview.h
index c74f86cfc..f5e329079 100644
--- a/karm/taskview.h
+++ b/karm/taskview.h
@@ -101,6 +101,9 @@ class TaskView : public TDEListView
/** Stop all running timers as if it was qdt */
void stopAllTimersAt(TQDateTime qdt);
+ /** Reset session and total time to zero for the current item in the view. */
+ void resetTimeCurrentTask();
+
/** Calls newTask dialog with caption "New Task". */
void newTask();