maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Qt DBus and Application state handling (action on screen on/off) (https://talk.maemo.org/showthread.php?t=60010)

emesem 2010-08-09 05:59

Qt DBus and Application state handling (action on screen on/off)
 
Hi,

I have an app which refreshs the output to the screen every 0.1seconds. But if the screen is turned of this is not necessary. Therefor I would like to "listen" to DBus for a sort of blanking message and reenabling screen message to reduce CPU time of my app. The only problem is, I've not yet figured out (nor was able to google it) how to do that.

I'm using Qt and C++.

I would think that I receive some signal from dbus which I can connect to a slot where I do all my necessary handling upon "application minimize" or "application restore". But what signals will I receive, which signals will tell me that the screen is off or on now, how to include/use QDBus etc...?

Can anyone give me an example how to do that? Or is there a Qt C++ program which is doing that and therefor I could use as an example?

mr id 2010-08-18 23:12

Re: Qt DBus and Application state handling (action on screen on/off)
 
Basically, I have the same set of questions?

Anyone know any good resources for this?

Diph 2010-08-19 05:27

Re: Qt DBus and Application state handling (action on screen on/off)
 
PHP Code:

#include <mce/dbus-names.h>
#include <mce/mode-names.h>

static QDBusConnection dBusConnection QDBusConnection::systemBus();

MCE::MCE(QObject *parent)
    : 
QObject(parent)
{

    
dBusInterface = new QDBusInterface(MCE_SERVICEMCE_REQUEST_PATH,
                                       
MCE_REQUEST_IFdBusConnectionthis);

    
dBusConnection.connect(MCE_SERVICEMCE_SIGNAL_PATHMCE_SIGNAL_IF,
                           
MCE_DISPLAY_SIGthisSLOT(displayStateChanged(const QDBusMessage &)));

    
dBusInterface->callWithCallback(MCE_DISPLAY_STATUS_GETQList<QVariant>(), this,
                                      
SLOT(setDisplayState(QString)),
                                      
SLOT(displayStateError(QDBusError)));
}

void MCE::displayStateChanged(const QDBusMessage &message)
{
    
QString state message.arguments().at(0).toString();
    
setDisplayState(state);
}

void MCE::displayStateError(const QDBusError &error)
{

}

void MCE::setDisplayState(const QString &state)
{
    if (!
state.isEmpty()) {
        if (
state == MCE_DISPLAY_ON_STRING)
            ;   
//Display on
        
else if (state == MCE_DISPLAY_OFF_STRING)
            ;   
//Display off
    
}




All times are GMT. The time now is 20:37.

vBulletin® Version 3.8.8