KIdleTime

#include <KIdleTime>

Inheritance diagram for KIdleTime:

Signals

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

Public Slots

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

Public Member Functions

virtual ~KIdleTime ()
 
int idleTime () const
 
QHash< int, int > idleTimeouts () const
 
void simulateUserActivity ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static KIdleTimeinstance ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

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 29 of file kidletime.h.

Constructor & Destructor Documentation

KIdleTime::~KIdleTime ( )
virtual

The destructor.

Definition at line 80 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 107 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 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
simulateUserActivity

Definition at line 87 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 259 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 268 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 36 of file kidletime.cpp.

void KIdleTime::removeAllIdleTimeouts ( )
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

See also
timeoutReached
addIdleTimeout

Definition at line 139 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 122 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 simulateUserActivity was called or the user sent an input to the system.

See also
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 resumingFromIdle will be triggered

See also
resumingFromIdle

Definition at line 250 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 97 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 addIdleTimeout is reached.

Parameters
identifierthe identifier of the timeout the system has reached
See also
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 addIdleTimeout

Parameters
msecthe time, in milliseconds, the system has been idle for
See also
addIdleTimeout
removeIdleTimeout

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 22:47:43 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.