KARM: Non negative busy counter and Item Reset

Signed-off-by: Roman Savochenko <roman@home.home>
feat/karm-busyCntr-itemReset
Roman Savochenko 1 year ago
parent d470e73134
commit c5804975ec

@ -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

@ -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" />

@ -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.") );

@ -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;

@ -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" );

@ -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);

@ -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();

Loading…
Cancel
Save