• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KUtils

Public Slots | Signals | Public Member Functions | Static Public Member Functions

KIdleTime Class Reference

KIdleTime is a singleton reporting information on idle time. More...

#include <kidletime.h>

Inheritance diagram for KIdleTime:
Inheritance graph
[legend]

List of all members.

Public Slots

int addIdleTimeout (int msec)
void catchNextResumeEvent ()
void removeAllIdleTimeouts ()
void removeIdleTimeout (int identifier)
void stopCatchingResumeEvent ()

Signals

void resumingFromIdle ()
void timeoutReached (int identifier, int msec)
void timeoutReached (int identifier)

Public Member Functions

virtual ~KIdleTime ()
int idleTime () const
QHash< int, int > idleTimeouts () const
void simulateUserActivity ()

Static Public Member Functions

static KIdleTime * instance ()

Detailed Description

KIdleTime is a singleton reporting information on idle time.

It is useful not only for finding out about the current idle time of the PC, but also for getting notified upon idle time events, such as custom timeouts, or user activity.

Note:
All the intervals and times in this library are in milliseconds, unless specified otherwise
Author:
Dario Freddi
Since:
4.4

Definition at line 39 of file kidletime.h.


Constructor & Destructor Documentation

KIdleTime::~KIdleTime ( ) [virtual]

The destructor.

Definition at line 99 of file kidletime.cpp.


Member Function Documentation

int KIdleTime::addIdleTimeout ( int  msec) [slot]

Adds a new timeout to catch.

When calling this method, after the system will be idle for msec milliseconds, the signal timeoutReached will be triggered. Please note that until you will call removeIdleTimeout or removeAllIdleTimeouts, the signal will be triggered every time the system will be idle for msec milliseconds. This function also returns an unique token for the timeout just added to allow easier identification.

Parameters:
msecthe time, in milliseconds, after which the signal will be triggered
Returns:
an unique identifier for the timeout being added, that will be streamed by timeoutReached
See also:
removeIdleTimeout
removeAllIdleTimeouts
timeoutReached

Definition at line 126 of file kidletime.cpp.

void KIdleTime::catchNextResumeEvent ( ) [slot]

Catches the next resume from idle event.

This means that whenever user activity will be registered, or is called, the signal resumingFromIdle will be triggered. Please note that this method will trigger the signal just for the very first resume event after the call: this means you explicitly have to request to track every single resume event you are interested in.

Note:
This behavior is due to the fact that a resume event happens whenever the user sends an input to the system. This would lead to a massive amount of signals being delivered when the PC is being used. Moreover, you are usually interested in catching just significant resume events, such as the ones after a significant period of inactivity. For tracking user input, you can use the more efficient methods provided by Qt. The purpose of this library is just monitoring the activity of the user.
See also:
resumingFromIdle
simulateUserActivity

Definition at line 106 of file kidletime.cpp.

int KIdleTime::idleTime ( ) const

Retrieves the idle time of the system, in milliseconds.

Returns:
the idle time of the system

Definition at line 255 of file kidletime.cpp.

QHash< int, int > KIdleTime::idleTimeouts ( ) const

Returns the list of timeout identifiers associated with their duration, in milliseconds, the library is currently listening to.

See also:
addIdleTimeout
removeIdleTimeout
timeoutReached

Definition at line 262 of file kidletime.cpp.

KIdleTime * KIdleTime::instance ( ) [static]

Returns the singleton instance.

Use this method to access KIdleTime

Returns:
the instance of KIdleTime

Definition at line 55 of file kidletime.cpp.

void KIdleTime::removeAllIdleTimeouts ( ) [slot]

Stops catching every set timeout (if any).

This means that after calling this method, the signal won't be called again until you will add another timeout timeoutReached addIdleTimeout

Definition at line 155 of file kidletime.cpp.

void KIdleTime::removeIdleTimeout ( int  identifier) [slot]

Stops catching the idle timeout identified by the token identifier, if it was registered earlier with addIdleTimeout.

Otherwise does nothing.

Parameters:
identifierthe token returned from addIdleTimeout of the timeout you want to stop listening to

Definition at line 138 of file kidletime.cpp.

void KIdleTime::resumingFromIdle ( ) [signal]

Triggered, if KIdleTime is catching resume events, when the system resumes from an idle state.

This means that either was called or the user sent an input to the system. catchNextResumeEvent

void KIdleTime::simulateUserActivity ( )

Attempts to simulate user activity.

This implies that after calling this method, the idle time of the system will become 0 and eventually will be triggered resumingFromIdle

Definition at line 248 of file kidletime.cpp.

void KIdleTime::stopCatchingResumeEvent ( ) [slot]

Stops listening for resume event.

This function serves for canceling catchNextResumeEvent, as it will have effect just when catchNextResumeEvent has been called and resumingFromIdle not yet triggered

See also:
resumingFromIdle
catchNextResumeEvent

Definition at line 116 of file kidletime.cpp.

void KIdleTime::timeoutReached ( int  identifier) [signal]

Triggered when the system has been idle for x milliseconds, identified by the previously set timeout.

This signal is triggered whenever each timeout previously registered with is reached. identifier the identifier of the timeout the system has reached addIdleTimeout removeIdleTimeout

void KIdleTime::timeoutReached ( int  identifier,
int  msec 
) [signal]

Overload.

Streams the duration as well. It is guaranteed that msec will exactly correspond to the timeout registered with msec the time, in milliseconds, the system has been idle for addIdleTimeout removeIdleTimeout


The documentation for this class was generated from the following files:
  • kidletime.h
  • kidletime.cpp

KUtils

Skip menu "KUtils"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal