ThemeSupport
#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:
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;
}
}
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)
}
}
BlackBerry 10.0.0
QML properties
| theme | : bb::cascades::Theme [read-only] |
QML signals
| onThemeChanged | : {} |
Properties Index
| bb::cascades::Theme | theme [read-only] |
Public Functions Index
| bb::cascades::Theme * | theme () const |
Signals Index
| void | themeChanged (const bb::cascades::Theme *theme) |
Properties
bb::cascades::Theme
Provides access to the current theme used in the application.
QObject::connect((Application*)Application::instance()->themeSupport(),
SIGNAL(themeChanged(const bb::cascades::Theme*)),
this,
SLOT(onThemeChanged(const bb::cascades::Theme*)));
BlackBerry 10.0.0
Public Functions
bb::cascades::Theme *
Retrieves the current theme.
Ownership of the returned object is not transferred.
Signals
void
Emitted when the theme for this application has changed.
| Parameters | |
|---|---|
| theme |
a new theme or 0 if there was an error |
BlackBerry 10.0.0