Notices


Reply
Thread Tools
Posts: 118 | Thanked: 45 times | Joined on Dec 2009 @ Germany
#1
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?

Last edited by emesem; 2010-08-15 at 19:11.
 
Posts: 237 | Thanked: 193 times | Joined on Feb 2010 @ Brighton, UK
#2
Basically, I have the same set of questions?

Anyone know any good resources for this?
 

The Following User Says Thank You to mr id For This Useful Post:
Posts: 180 | Thanked: 76 times | Joined on May 2010
#3
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
    
}


Last edited by Diph; 2010-08-19 at 05:29.
 

The Following 3 Users Say Thank You to Diph For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 05:32.