Home · All Classes · Main Classes · Deprecated
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

MApplication Class Reference

MApplication manages the GUI application's control flow and main settings. More...

Inheritance diagram for MApplication:
Inheritance graph
[legend]
Collaboration diagram for MApplication:
Collaboration graph
[legend]

List of all members.

Signals

void localeSettingsChanged ()
void prestartReleased ()
void prestartRestored ()

Public Member Functions

 MApplication (int &argc, char **argv, const QString &appIdentifier=QString(), MApplicationService *service=0)
 MApplication (int &argc, char **argv, MApplicationService *service)
virtual ~MApplication ()
virtual void restorePrestart ()
virtual void releasePrestart ()

Static Public Member Functions

static MApplicationinstance ()
static QString deviceName ()
static bool softwareRendering ()
static bool fullScreen ()
static bool showBoundingRect ()
static bool showFps ()
static bool logFps ()
static bool showSize ()
static bool showPosition ()
static bool showMargins ()
static bool showObjectNames ()
static bool showStyleNames ()
static bool showCursor ()
static bool emulateTwoFingerGestures ()
static void setShowPosition (bool show)
static void setShowMargins (bool show)
static void setShowObjectNames (bool show)
static void setShowStyleNames (bool show)
static void setShowSize (bool show)
static void setShowBoundingRect (bool show)
static void setShowFps (bool show)
static void setLogFps (bool show)
static void setShowCursor (bool show)
static MApplicationWindowactiveApplicationWindow ()
static MWindowactiveWindow ()
static QList< MWindow * > windows ()
static QString appName ()
static QString binaryName ()
static MFeedbackPlayerfeedbackPlayer ()
static bool isLoadMInputContextEnabled ()
static void setLoadMInputContext (bool enable)
static void setPrestartMode (M::PrestartMode mode)
static M::PrestartMode prestartMode ()
static bool isPrestarted ()
static void setPrestarted (bool enable)

Protected Member Functions

 MApplication (MApplicationPrivate &dd, int &argc, char **argv, const QString &appIdentifier=QString())

Protected Attributes

MApplicationPrivate *const d_ptr

Detailed Description

MApplication manages the GUI application's control flow and main settings.

MApplication instance automatically extracts application name from the arguments given in the constructor. It also loads css - stylesheet, svg file and adds application specific image paths to the pixmap search paths used by the current MTheme instance.

CSS and SVG files are searched for in order from the following places:

  1. Directory in which application was launched.
  2. Application specific theme path (global theme path appended with the application name)
  3. Global theme path (Qt data path appended by themes/m)

When first instance of CSS or SVG file is found it is loaded to the current MTheme. Also image - subdirectory of each of the aforementioned paths is appended to the pixmap search paths used by MTheme.

MApplication will also create a QDBus service with name made by prepending 'com.nokia.' to the application name provided in the constructor (or the binary name if no name is provided in the constructor). It will provide an interface called MApplicationIf which calls service methods in an instance of MApplicationService. By default, MApplication will construct an instance of MApplicationService, but the application programmer can derive a class from MApplicationService and provide a pointer to that in the constructor for MApplication to use instead. This way, the application programmer can override the methods in MApplicationService and change the behaviour of the application's interface.

The default behaviour is to only allow a single instance of any application. When an application is launched, it attempts to register itself as a dbus service (as above). Only the first instance of the application will be successful, and subsequent attempts will fail. When dbus registration fails, the default behaviour is to call the first instance's MApplicationService launch() method, and then quit. This causes the first instance to become visible (raises the window).

If other behaviour is required, for example if you want multiple instances of an application, then it is necessary to derive a class from MApplicationService and override its methods.

Definition at line 79 of file corelib/core/mapplication.h.


Constructor & Destructor Documentation

MApplication::MApplication ( int &  argc,
char **  argv,
const QString appIdentifier = QString(),
MApplicationService service = 0 
)

Initializes the window system and constructs an application object.

Parameters:
argc number of arguments passed to the application from the command line
argv argument strings passed to the application from the command line
appIdentifier an optional identifier for the application. Can contain alphabetical characters, numbers, dashes and underscores. If an empty string is given (the default) the application binary file name is used.
Note:
Warning: The data referred to by argc and argv must stay valid for the entire lifetime of the MApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string.

Definition at line 145 of file mapplication.cpp.

    : QApplication(argc, argv),
      d_ptr(new MApplicationPrivate)
{
    Q_D(MApplication);
    d->q_ptr = this;

    d->init(argc, argv, appIdentifier, service);
}

MApplication::MApplication ( int &  argc,
char **  argv,
MApplicationService service 
)

Definition at line 155 of file mapplication.cpp.

                                                                               :
    QApplication(argc, argv),
    d_ptr(new MApplicationPrivate)
{
    Q_D(MApplication);
    d->q_ptr = this;

    d->init(argc, argv, QString(), service);
}

MApplication::~MApplication (  )  [virtual]

Cleans up any window system resources that were allocated by this application.

Definition at line 244 of file mapplication.cpp.

{
    delete d_ptr;
}

MApplication::MApplication ( MApplicationPrivate &  dd,
int &  argc,
char **  argv,
const QString appIdentifier = QString() 
) [protected]

Member Function Documentation

MApplicationWindow * MApplication::activeApplicationWindow (  )  [static]

Returns the currently active application window.

Note:
If the active window is of type MWindow (and not MApplicationWindow) this method will return a null pointer.
See also:
activeWindow()

Definition at line 359 of file mapplication.cpp.

MWindow * MApplication::activeWindow (  )  [static]

Returns the currently active window.

Note:
In comparison to QApplication::activeWindow(), this method will return a pointer to the MWindow even if it doesn't have focus. For single-window applications this method will return a pointer to the window once it's created (even before it's shown). For multiple-window applications this method will return a pointer to the current topmost window.

Reimplemented from QApplication.

Definition at line 364 of file mapplication.cpp.

QString MApplication::appName (  )  [static]

Returns the application's app name.

Definition at line 536 of file mapplication.cpp.

QString MApplication::binaryName (  )  [static]

Returns the application's binary name.

Definition at line 541 of file mapplication.cpp.

QString MApplication::deviceName (  )  [static]

Target device name.

Definition at line 249 of file mapplication.cpp.

bool MApplication::emulateTwoFingerGestures (  )  [static]

Emulate two finger gestures.

Definition at line 309 of file mapplication.cpp.

MFeedbackPlayer * MApplication::feedbackPlayer (  )  [static]

Returns object which provide interface for nonvisual feedback or NULL.

Definition at line 374 of file mapplication.cpp.

bool MApplication::fullScreen (  )  [static]

Full screen command line option set.

Definition at line 259 of file mapplication.cpp.

MApplication * MApplication::instance (  )  [static]

Returns a pointer to the application's MApplication instance. If no instance has been allocated, null is returned.

See also:
QCoreApplication::instance()

Definition at line 140 of file mapplication.cpp.

{
    return qobject_cast<MApplication *>(QCoreApplication::instance());
}

bool MApplication::isLoadMInputContextEnabled (  )  [static]

Returns whether automatic loading of MInputContext is enabled.

Definition at line 379 of file mapplication.cpp.

bool MApplication::isPrestarted (  )  [static]

Return true if application is in the prestarted state.

Returns:
true if application is in the prestarted state.

Definition at line 593 of file mapplication.cpp.

Here is the call graph for this function:

void MApplication::localeSettingsChanged (  )  [signal]

Signal emitted when the default system locale changes.

bool MApplication::logFps (  )  [static]

Log frame rate command line option set.

Definition at line 274 of file mapplication.cpp.

{
    return MComponentData::logFps();
}

M::PrestartMode MApplication::prestartMode (  )  [static]

Return the current prestart mode.

Returns:
prestart mode

Definition at line 566 of file mapplication.cpp.

void MApplication::prestartReleased (  )  [signal]

Signal that is emitted when the application has been released from the prestarted state. Next the application should show a window.

void MApplication::prestartRestored (  )  [signal]

Signal that is emitted when the application has been restored to the prestarted state.

void MApplication::releasePrestart (  )  [virtual]

Called when MApplication is released from the prestarted state. Effectively this method just shows MApplication::activeWindow(). Does nothing by default if multi-windowed prestart is selected. Re-imp this if desired.

Definition at line 571 of file mapplication.cpp.

{
    // Show the window only if we are not in a multi-windowed mode.
    // In that case the user must re-implement this, because we don't know which
    // window needs to be shown.

    if (!MApplicationPrivate::prestartModeIsMultiWindowed()) {
        if (MApplication::activeWindow()) {
            MApplication::activeWindow()->show();
            MApplication::activeWindow()->activateWindow();
            MApplication::activeWindow()->raise();
        }
    }
}

Here is the call graph for this function:

void MApplication::restorePrestart (  )  [virtual]

Called when MApplication returns to prestarted state (if supported by the mode). Hides all windows by default. Re-imp this if desired.

Definition at line 586 of file mapplication.cpp.

{
    if (MApplicationPrivate::prestartModeIsLazyShutdown()) {
        MApplicationPrivate::hideWindows();
    }
}

void MApplication::setLoadMInputContext ( bool  enable  )  [static]

Sets whether MApplication should automatically load m input context.

Definition at line 384 of file mapplication.cpp.

void MApplication::setLogFps ( bool  show  )  [static]

Enables or disables logging of frames.

Definition at line 349 of file mapplication.cpp.

void MApplication::setPrestarted ( bool  enable  )  [static]

Manually release/restore the application from/to the prestarted state. Multi-window applications may need this if they want to show some specific window using some other D-Bus service than MApplicationService. This triggers corresponding signals and handlers if the state changes.

Parameters:
enable If set to true, prestart is restored if lazy shutdown selected. If set to false, prestart is released (equals to MApplicationService::lauch()).

Definition at line 223 of file mapplication.cpp.

Here is the call graph for this function:

void MApplication::setPrestartMode ( M::PrestartMode  mode  )  [static]

Select the prestart mode.

Parameters:
mode Prestart mode

Definition at line 551 of file mapplication.cpp.

{
    // Set prestart mode only if the app was started with -prestart.
    // This way we can later check if the app was originally prestarted or not.
    // Prevent application from exiting after the last window has been closed if
    // lazy shutdown was set.

    if (MComponentData::prestarted()) {
        MComponentData::setPrestartMode(mode);
        if (MApplicationPrivate::prestartModeIsLazyShutdown()) {
            MApplication::setQuitOnLastWindowClosed(false);
        }
    }
}

Here is the call graph for this function:

void MApplication::setShowBoundingRect ( bool  show  )  [static]

Sets if bounding rects of widgets should be shown or not.

Definition at line 339 of file mapplication.cpp.

void MApplication::setShowCursor ( bool  show  )  [static]

Sets if the cursor should be shown or not.

Definition at line 354 of file mapplication.cpp.

void MApplication::setShowFps ( bool  show  )  [static]

Sets if a frames-per-second counter should be shown or not.

Definition at line 344 of file mapplication.cpp.

void MApplication::setShowMargins ( bool  show  )  [static]

Sets if margins of widgets should be shown or not.

Definition at line 324 of file mapplication.cpp.

void MApplication::setShowObjectNames ( bool  show  )  [static]

Sets if names of objects should be shown or not.

Definition at line 329 of file mapplication.cpp.

void MApplication::setShowPosition ( bool  show  )  [static]

Sets if position of widgets should be shown or not.

Definition at line 314 of file mapplication.cpp.

void MApplication::setShowSize ( bool  show  )  [static]

Sets if sizes of widgets should be shown or not.

Definition at line 319 of file mapplication.cpp.

void MApplication::setShowStyleNames ( bool  show  )  [static]

Sets if names of styles should be shown or not.

Definition at line 334 of file mapplication.cpp.

bool MApplication::showBoundingRect (  )  [static]

Show bounding rectangles command line option set.

Definition at line 264 of file mapplication.cpp.

bool MApplication::showCursor (  )  [static]

Show cursor.

Definition at line 304 of file mapplication.cpp.

bool MApplication::showFps (  )  [static]

Show frame rate command line option set.

Definition at line 269 of file mapplication.cpp.

bool MApplication::showMargins (  )  [static]

Show widgets margins.

Definition at line 289 of file mapplication.cpp.

bool MApplication::showObjectNames (  )  [static]

Show object names.

Definition at line 294 of file mapplication.cpp.

bool MApplication::showPosition (  )  [static]

Show widgets positions.

Definition at line 284 of file mapplication.cpp.

bool MApplication::showSize (  )  [static]

Show widgets sizes.

Definition at line 279 of file mapplication.cpp.

bool MApplication::showStyleNames (  )  [static]

Show style names.

Definition at line 299 of file mapplication.cpp.

bool MApplication::softwareRendering (  )  [static]

Software rendering command line option set.

Definition at line 254 of file mapplication.cpp.

QList< MWindow * > MApplication::windows (  )  [static]

Returns a list of all windows in the application.

Definition at line 369 of file mapplication.cpp.


Member Data Documentation

MApplicationPrivate* const MApplication::d_ptr [protected]

Definition at line 262 of file corelib/core/mapplication.h.


Copyright © 2010 Nokia Corporation Generated on Thu Nov 4 2010 18:14:24 (PDT)
Doxygen 1.7.1
MeeGo Touch