Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (56 sloc) 1.98 KB
#include "applicationui.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/cascades/LocaleHandler>
#include <QSettings>
using namespace bb::cascades;
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
// prepare the localization
m_pTranslator = new QTranslator(this);
m_pLocaleHandler = new LocaleHandler(this);
if(!QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()))) {
// This is an abnormal situation! Something went wrong!
// Add own code to recover here
qWarning() << "Recovering from a failed connect()";
// initial load
// Create scene document from main.qml asset, the parent is set
// to ensure the document gets destroyed properly at shut down.
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("_app", this);
// Create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// Set created root object as the application scene
void ApplicationUI::onSystemLanguageChanged()
// Initiate, load and install the application translation files.
QString locale_string = QLocale().name();
QString file_name = QString("QSettingsExample_%1").arg(locale_string);
if (m_pTranslator->load(file_name, "app/native/qm")) {
QString ApplicationUI::getValueFor(const QString &objectName, const QString &defaultValue)
QSettings settings;
if (settings.value(objectName).isNull()) {
return defaultValue;
return settings.value(objectName).toString();
void ApplicationUI::saveValueFor(const QString &objectName, const QString &inputValue)
QSettings settings;
settings.setValue(objectName, QVariant(inputValue));