KIdleTime

Search for usage in LXR

#include <KIdleTime>

Inheritance diagram for KIdleTime:

Signals

void resumingFromIdle ()
 
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

 ~KIdleTime () override
 
int idleTime () const
 
QHash< int, int > idleTimeouts () const
 
void simulateUserActivity ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
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 () const const
 
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 QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
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_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 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
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, 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 *context, Functor functor, 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)
 
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, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (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 36 of file kidletime.h.

Constructor & Destructor Documentation

◆ ~KIdleTime()

KIdleTime::~KIdleTime ( )
override

The destructor.

Definition at line 92 of file kidletime.cpp.

Member Function Documentation

◆ addIdleTimeout

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 118 of file kidletime.cpp.

◆ catchNextResumeEvent

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 98 of file kidletime.cpp.

◆ idleTime()

int KIdleTime::idleTime ( ) const

Retrieves the idle time of the system, in milliseconds.

Returns
the idle time of the system

Definition at line 311 of file kidletime.cpp.

◆ idleTimeouts()

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 320 of file kidletime.cpp.

◆ instance()

KIdleTime * KIdleTime::instance ( )
static

Returns the singleton instance.

Use this method to access KIdleTime

Returns
the instance of KIdleTime

Definition at line 39 of file kidletime.cpp.

◆ removeAllIdleTimeouts

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 159 of file kidletime.cpp.

◆ removeIdleTimeout

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 137 of file kidletime.cpp.

◆ resumingFromIdle

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

◆ simulateUserActivity()

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 302 of file kidletime.cpp.

◆ stopCatchingResumeEvent

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 108 of file kidletime.cpp.

◆ timeoutReached

void KIdleTime::timeoutReached ( int identifier,
int msec )
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.

Parameters
identifierthe identifier of the timeout the system has reached
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-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.