View Single Post
Posts: 237 | Thanked: 193 times | Joined on Feb 2010 @ Brighton, UK
#90
Originally Posted by Xawotihs View Post
@Nnexxus, it's an interesting idea. I've heard about such feature required for each application on Android. On Maemo, it would make sense to have the same thing. Everything in Wagic works with a timer that refreshes the UI and performs all the computation.

I could perfectly stop/start this timer up reception of some system events (Phone locked or app in the background). Anybody who has already developed such feature for its app with a pointer on how to do that with Qt on Maemo ?
I never got around to finding out how to capture the 'app backgrounded' signal, so if you do let me know. However, I track the screen-off signal in a separate project (vlc-remote) through Qt which works well.

On a semi related note, how much work would be involved in a full save game state approach? That way rather than just giving you a power saving feature you could also introduce a save / load game state.

Couple of thoughts on it. You probably don't want a full save / restore at any time (don't want to encourage using it as an undo feature to remove any challange), perhaps a save last state that overwrites per game so actions are still premanent in a game. Secondly, this would allow people to create 'challenge situations' for people to share / create. (like chess puzzles I guess).

Edit: I guess 'save and exit to menu' as a new option would restrict this nicely.

.h
https://garage.maemo.org/plugins/ggi...cf1bf2;hb=HEAD
.cpp
https://garage.maemo.org/plugins/ggi...14ccc1;hb=HEAD

Code:
#include <mce/dbus-names.h>
#include <mce/mode-names.h>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusInterface>

QDBusConnection CLASS_NAME::dBusConnection = QDBusConnection::systemBus();
QDBusInterface* CLASS_NAME::dBusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH,
                                    MCE_REQUEST_IF, dBusConnection);

// in constructor
// Handle screen state on / off
dBusConnection.connect(MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_DISPLAY_SIG, this, SLOT(displayStateChanged(const QDBusMessage &)));

// SLOT
   void CLASS_NAME::displayStateChanged(const QDBusMessage &message)
   {
       QString state = message.arguments().at(0).toString();
       if (!state.isEmpty()) {
           if (state == MCE_DISPLAY_ON_STRING) {
               // DO SOMETHING TO START TIMER
           }
           else if (state == MCE_DISPLAY_OFF_STRING) {
               // DO SOMETHING TO STOP TIMER
           }
       }
  }
you'll need to add dbus to your.pro QT += as well.

LMK if I can explain it more clearly.

Last edited by mr id; 2010-10-11 at 16:04. Reason: Clearer explanation.
 

The Following 2 Users Say Thank You to mr id For This Useful Post: