ThemeSupport

Since: BlackBerry 10.0.0

#include <bb/cascades/ThemeSupport>

A class containing theme related functionality.

This class offers functionality to obtain the current theme and listen for theme related changes. At this point in time, no support exists for setting the theme at run time.

Each theme has a VisualStyle that determines the colors used for controls and the default container background. The two visual styles are VisualStyle::Bright and VisualStyle::Dark, the default being Bright.

To change the application's theme to Dark specify the following configuration value in the application's bar-descriptor.xml file.

<env var="CASCADES_THEME" value="dark"/>

Here are some examples for how to check the VisualStyle of the currently set theme for the application:

C++:
void ThemeTest()
{
    Label* pLabel = Label::create();

    ThemeSupport* pThemeSupport = Application::instance()->themeSupport();
    Theme* pTheme = pThemeSupport->theme();
    ColorTheme* pColTheme = pTheme->colorTheme();

    switch(pColTheme->style()) {
        case VisualStyle::Bright:
            pLabel->setText("Theme: Bright");
            break;

        case VisualStyle::Dark:
            pLabel->setText("Theme: Dark");
            break;

        default:
            pLabel->setText("Theme: Unknown");
            break;
    }
}
QML:
Container {
    id: cont1

    function themeStyleToString(style){
        switch(style) {
            case VisualStyle.Bright:    return "Theme: Bright"
            case VisualStyle.Dark:      return "Theme: Dark"
        }
        return "Theme: UNKNOWN :("
    }

    Label {
        id: themeLabel;
        text: cont1.themeStyleToString(Application.themeSupport.theme.colorTheme.style)
    }
}


Overview

QML properties

theme: bb::cascades::Theme [read-only]

QML signals

Properties Index

Public Functions Index

Signals Index

voidthemeChanged (const bb::cascades::Theme *theme)

Properties

bb::cascades::Theme theme[read-only]

Provides access to the current theme used in the application.

Typically connected from Application:
QObject::connect((Application*)Application::instance()->themeSupport(),
                 SIGNAL(themeChanged(const bb::cascades::Theme*)),
                 this,
                 SLOT(onThemeChanged(const bb::cascades::Theme*)));
See also:

Theme

Since:

BlackBerry 10.0.0

Public Functions

bb::cascades::Theme * theme ()

Retrieves the current theme.

Ownership of the returned object is not transferred.

Return:

The application's theme.

See also:

Theme

Since:

BlackBerry 10.0.0

Signals

void themeChanged (

Emitted when the theme for this application has changed.

Parameters
theme

a new theme or 0 if there was an error

Since:

BlackBerry 10.0.0

Last modified: 2014-03-13

comments powered by Disqus