This forum has been archived. All content is frozen. Please use KDE Discuss instead.

QML plasmoid: Can I use the KIdleTime class?

Tags: None
(comma "," separated)
kdea
Registered Member
Posts
23
Karma
0
Hi, I'm doing a QML plasmoid that should detect that the user is idle. I see that the "Tier 1" of KDE Frameworks has a KIdleTime class with methods to read the user idle time, for example:

Code: Select all
int idle_time = KIdleTime.instance().idleTime();

Can I use the KIdleTime class from a QML plasmoid? I have tried things like:

Code: Select all
import QtQuick 2.0
import org.kde.KIdleTime 1.0     as idle_time

Item
{
    property int idle

    ...

    // event handler
        ...
        idle = idle_time.instance().idleTime()
        ...
}

but they don't work. What exactly do I have to write?

If the KIdleTime class is not reachable from a QML plasmoid, is there any other way to read the user idle time?

Thank you

Last edited by kdea on Sun Nov 29, 2015 1:54 pm, edited 2 times in total.
kdea
Registered Member
Posts
23
Karma
0
Solved: You can use a plasma datasource to get the idle time:

Code: Select all
    PlasmaCore.DataSource
    {
        id:                 idle_src

        engine:             "powermanagement"
        connectedSources:   ["UserActivity"]
        interval:           1000                    // poll every second

        onNewData:          idle_updated()
    }

    function idle_updated()
    {
        var idle_time = idle_src.data.UserActivity.IdleTime
        ...
    }


I have used it to create my "Take a break" plasmoid: http://kde-apps.org/content/show.php/Ta ... ent=174127

Why nobody suggested me to use the datasource? Perhaps I made the question in a wrong forum? Is there any forum specific for plasmoid development?

Thank you


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]