MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QmSystem2 Library

Introduction

QmSystem2 is a library that provides interfaces to different system functionalities and hardware through the Qt API. Examples of such functionalities are energy management, system state management, device mode, accessories, display backlight control, and time management.

To access the sensors such as accelerometer, compass, magnetometer, orientation, proximity, rotation and ambient light sensor, it is recommended that you use the Qt Mobility Sensors API.

List of classes/functions the QmSystem API provides:

Name Content
MeeGo::QmActivity provides information about device activity.
MeeGo::QmBattery provides information on device battery status.
MeeGo::QmCABC provides methods to set and get Content Adaptive Display Control settings.
MeeGo::QmDeviceMode provides information and actions on device operation mode and power save mode.
MeeGo::QmDisplayState provides information and actions on device display state.
MeeGo::QmHeartbeat provides system heartbeat service.
MeeGo::QmKeys provides access to hardware key states.
MeeGo::QmLocks provides information and actions on device locks.
MeeGo::QmSystemInformation provides an interface to the system information service.
MeeGo::QmSystemState provides information and actions on device state.
MeeGo::QmThermal provides information on device thermal states.
MeeGo::QmTime provides interface for interacting with system clock.

Getting started

To get library compiler and linker parameters, use the following:
QMake:

 CONFIG += qmsystem2 


Pkg-Config:

 pkg-config --libs --cflags qmsystem2 


Examples

The following example retrieves the display state to check if the display is on:

#include <qmdisplaystate.h>

MeeGo::QmDisplayState displayState;

MeeGo::QmDisplayState::DisplayState state = displayState.get();
if (MeeGo::QmDisplayState::On == state) {
   // The display is on!
}

In this example, the keyEvent() signal in QmKeys is listened to know when the power key was pressed.

#include <qmkeys.h>

class MyKeyReceiver : public QObject {
    Q_OBJECT

public Q_SLOTS:
    void keyEvent(MeeGo::QmKeys::Key key, MeeGo::QmKeys::State state) {
        if (MeeGo::QmKeys::PowerKey == key &&
            MeeGo::QmKeys::KeyDown == state) {
            // the power key was pressed!
        }
    }
};

void listenKeyPresses()
{
    MyKeyReceiver keyReceiver;
    MeeGo::QmKeys keys;

    QObject::connect(&keys, SIGNAL(keyEvent(MeeGo::QmKeys::Key, MeeGo::QmKeys::State)),
                     &keyReceiver, SLOT(keyEvent(MeeGo::QmKeys::Key, MeeGo::QmKeys::State)));

}

(C) 2009-2011 Nokia Corporation
LGPL Lesser General Public License
MeeGo 1.2 Harmattan API