KIdleTime Class Reference
from PyKDE4.kutils import *
Inherits: QObject
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
- Since:
- 4.4
Signals | |
resumingFromIdle () | |
timeoutReached (int identifier) | |
timeoutReached (int identifier, int msec) | |
Methods | |
__init__ (self) | |
int | addIdleTimeout (self, int msec) |
catchNextResumeEvent (self) | |
int | idleTime (self) |
{int:int} | idleTimeouts (self) |
removeAllIdleTimeouts (self) | |
removeIdleTimeout (self, int identifier) | |
simulateUserActivity (self) | |
stopCatchingResumeEvent (self) | |
Static Methods | |
KIdleTime | instance () |
Signal Documentation
resumingFromIdle | ( | ) |
Triggered, if KIdleTime is catching resume events, when the system resumes from an idle state. This means that either simulateUserActivity was called or the user sent an input to the system.
- See also:
- catchNextResumeEvent
- Signal syntax:
QObject.connect(source, SIGNAL("resumingFromIdle()"), target_slot)
timeoutReached | ( | int | identifier | |
) |
Overload. Streams the duration as well. It is guaranteed that msec will exactly correspond to the timeout registered with addIdleTimeout
- Parameters:
-
msec the time, in milliseconds, the system has been idle for
- See also:
- addIdleTimeout
- See also:
- removeIdleTimeout
- Signal syntax:
QObject.connect(source, SIGNAL("timeoutReached(int)"), target_slot)
timeoutReached | ( | int | identifier, | |
int | msec | |||
) |
Overload. Streams the duration as well. It is guaranteed that msec will exactly correspond to the timeout registered with addIdleTimeout
- Parameters:
-
msec the time, in milliseconds, the system has been idle for
- See also:
- addIdleTimeout
- See also:
- removeIdleTimeout
- Signal syntax:
QObject.connect(source, SIGNAL("timeoutReached(int, int)"), target_slot)
Method Documentation
__init__ | ( | self ) |
int addIdleTimeout | ( | self, | ||
int | msec | |||
) |
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:
-
msec the 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
- See also:
- removeAllIdleTimeouts
- See also:
- timeoutReached
catchNextResumeEvent | ( | self ) |
Catches the next resume from idle event. This means that whenever user activity will be registered, or simulateUserActivity 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
- See also:
- simulateUserActivity
int idleTime | ( | self ) |
Retrieves the idle time of the system, in milliseconds
- Returns:
- the idle time of the system
{int:int} idleTimeouts | ( | self ) |
Returns the list of timeout identifiers associated with their duration, in milliseconds, the library is currently listening to.
- See also:
- addIdleTimeout
- See also:
- removeIdleTimeout
- See also:
- timeoutReached
removeAllIdleTimeouts | ( | self ) |
Stops catching every set timeout (if any). This means that after calling this method, the signal timeoutReached won't be called again until you will add another timeout
- See also:
- timeoutReached
- See also:
- addIdleTimeout
removeIdleTimeout | ( | self, | ||
int | identifier | |||
) |
Stops catching the idle timeout identified by the token identifier, if it was registered earlier with addIdleTimeout. Otherwise does nothing.
- Parameters:
-
identifier the token returned from addIdleTimeout of the timeout you want to stop listening to
simulateUserActivity | ( | self ) |
Attempts to simulate user activity. This implies that after calling this method, the idle time of the system will become 0 and eventually resumingFromIdle will be triggered
- See also:
- resumingFromIdle
stopCatchingResumeEvent | ( | self ) |
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
- See also:
- catchNextResumeEvent
Static Method Documentation
KIdleTime instance | ( | ) |
Returns the singleton instance. Use this method to access KIdleTime
- Returns:
- the instance of KIdleTime