KIdleTime 5.109.0
|
KIdleTime is a singleton reporting information on idle time. More...
#include <KIdleTime>
Signals | |
void | resumingFromIdle () |
Triggered, if KIdleTime is catching resume events, when the system resumes from an idle state. | |
void | timeoutReached (int identifier) |
Triggered when the system has been idle for x milliseconds, identified by the previously set timeout. | |
void | timeoutReached (int identifier, int msec) |
Triggered when the system has been idle for x milliseconds, identified by the previously set timeout. | |
Public Slots | |
int | addIdleTimeout (int msec) |
Adds a new timeout to catch. | |
void | catchNextResumeEvent () |
Catches the next resume from idle event. | |
void | removeAllIdleTimeouts () |
Stops catching every set timeout (if any). | |
void | removeIdleTimeout (int identifier) |
Stops catching the idle timeout identified by the token identifier , if it was registered earlier with addIdleTimeout. | |
void | stopCatchingResumeEvent () |
Stops listening for resume event. | |
Public Member Functions | |
~KIdleTime () override | |
The destructor. | |
int | idleTime () const |
Retrieves the idle time of the system, in milliseconds. | |
QHash< int, int > | idleTimeouts () const |
Returns the list of timeout identifiers associated with their duration, in milliseconds, the library is currently listening to. | |
void | simulateUserActivity () |
Attempts to simulate user activity. | |
Static Public Member Functions | |
static KIdleTime * | instance () |
Returns the singleton instance. | |
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.
|
override |
The destructor.
|
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.
msec | the time, in milliseconds, after which the signal will be triggered |
|
slot |
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.
int KIdleTime::idleTime | ( | ) | const |
Retrieves the idle time of the system, in milliseconds.
QHash< int, int > KIdleTime::idleTimeouts | ( | ) | const |
Returns the list of timeout identifiers associated with their duration, in milliseconds, the library is currently listening to.
|
static |
|
slot |
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
|
slot |
Stops catching the idle timeout identified by the token identifier
, if it was registered earlier with addIdleTimeout.
Otherwise does nothing.
identifier | the token returned from addIdleTimeout of the timeout you want to stop listening to |
|
signal |
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.
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 resumingFromIdle will be triggered
|
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
|
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 addIdleTimeout is reached.
identifier | the identifier of the timeout the system has reached |
|
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 addIdleTimeout(int) is reached. It is guaranteed that msec
will exactly correspond to the identified timeout.
identifier | the identifier of the timeout the system has reached |
msec | the time, in milliseconds, the system has been idle for |