Ejemplo n.º 1
0
ApplicationUI::ApplicationUI() :
        QObject()
{
    // prepare the localization
    m_pTranslator = new QTranslator(this);
    m_pLocaleHandler = new LocaleHandler(this);

    bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
    // This is only available in Debug builds
    Q_ASSERT(res);
    // Since the variable is not used in the app, this is added to avoid a
    // compiler warning
    Q_UNUSED(res);

    // initial load
    onSystemLanguageChanged();

    // 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);
    Lista * list = new Lista();
    qml->setContextProperty("_app",this);
    qml->setContextProperty("_list", list);
    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Set created root object as the application scene
    Application::instance()->setScene(root);
}
Ejemplo n.º 2
0
/**
 * This sample applications shows how to access remote data via the FTP protocol.
 * It implements a simple browser to view the content of an FTP server and allows
 * the user to download files to the local disk.
 */
Q_DECL_EXPORT int main(int argc, char **argv)
{
    Application app(argc, argv);

    // Creates the FtpDownloader object that contains the business logic
    FtpDownloader downloader;

    // Creates the FtpItemProvider for the ListView
    FtpItemProvider itemProvider;

    // Load the UI description from main.qml
    QmlDocument *qml = QmlDocument::create("asset:///main.qml");

    // Make all the business logic objects available to the UI as context properties
    qml->setContextProperty("_model", downloader.model());
    qml->setContextProperty("_itemProvider", &itemProvider);
    qml->setContextProperty("_downloader", &downloader);
    qml->setContextProperty("_messageBox", downloader.messageBoxController());
    qml->setContextProperty("_progressDialog", downloader.progressDialogController());

    // Create the application scene
    AbstractPane *appPage = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(appPage);

    // Quit the application if 'Qt.quit()' is called in the UI
    QObject::connect(qml->documentContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));

    return Application::exec();
}
Ejemplo n.º 3
0
ApplicationUI::ApplicationUI(QObject *parent)
	: QObject(parent)
	, m_invokeManager(new InvokeManager(this))
	, m_model(new CustomGroupModel())
{
	qmlRegisterType<CustomGroupModel>("bb.mymodel", 1, 0, "CustomGroupModel");

	QString locale_string = QLocale().name();
	QString file_name = QString("WeekViewer_%1").arg(locale_string);
	if (m_pTranslator.load(file_name, "app/native/qm")) {
		QCoreApplication::instance()->installTranslator(&m_pTranslator);
	}

    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
	qml->setContextProperty("_app", this);

	ActiveCover* scene = new ActiveCover();
	Application::instance()->setCover(scene);
	qml->setContextProperty("activeFrame", scene);

    // create root object for the UI
	bb::cascades::AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
	Application::instance()->setScene(root);
}
Ejemplo n.º 4
0
ApplicationUI::ApplicationUI() :
        QObject()
{
    Settings *settings;

    m_pTranslator = new QTranslator(this);
    m_pLocaleHandler = new LocaleHandler(this);

    bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
    Q_ASSERT(res);
    Q_UNUSED(res);

    onSystemLanguageChanged();

    settings = new Settings();

    bb::data::DataSource::registerQmlTypes();

    qmlRegisterType<SceneCover>("bb.cascades", 1, 2, "SceneCover");
    qmlRegisterType<bb::ApplicationInfo>("bb.cascades", 1, 2, "ApplicationInfo");
    qmlRegisterUncreatableType<AbstractCover>("bb.cascades", 1, 2, "AbstractCover", "An AbstractCover cannot be created.");
    qmlRegisterType<QTimer>("org.tal", 1, 0, "Timer");
    qmlRegisterType<BBMHandler>("org.tal.bbm", 1, 0, "BBMHandler");
    qmlRegisterType<bb::system::phone::Phone>("bb.system.phone", 1, 0, "Phone");

    qmlRegisterType<SopoMygga>("org.tal.sopomygga", 1, 0, "MQTT");

    QCoreApplication::setOrganizationDomain("org.tal");
    QCoreApplication::setOrganizationName("TalOrg");
    QCoreApplication::setApplicationName("Y-Radio");
    QCoreApplication::setApplicationVersion("1.0.3");

    m_netconf=new QNetworkConfigurationManager();
    res = QObject::connect(m_netconf, SIGNAL(onlineStateChanged(bool)), this, SLOT(onNetworkOnlineChanged(bool)));
    Q_ASSERT(res);

    m_isonline=m_netconf->isOnline();
    emit isOnlineChanged(m_isonline);

    m_uuid=settings->getStr("GUID", "");
    if (m_uuid.isEmpty()) {
        QUuid tmp=QUuid::createUuid();
        m_uuid=tmp.toString();
        settings->setStr("GUID", m_uuid);
        qDebug() << "NEW UUID is " << m_uuid;
    } else {
        qDebug() << "Stored UUID: " << m_uuid;
    }

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("_yradio", this);
    qml->setContextProperty("settings", settings);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(root);
}
Ejemplo n.º 5
0
//! [3]
Q_DECL_EXPORT int main(int argc, char **argv)
{
    Application app(argc, argv);

    Factorial factorial;

    // Create the state machine
    QStateMachine machine;
//! [3]

//! [4]
    // Create the 'compute' state as child of the state machine
    QState *compute = new QState(&machine);

    // Initialize the 'fac', 'x' and 'xorig' properties of the Factorial object whenever the compute state is entered
    compute->assignProperty(&factorial, "fac", 1);
    compute->assignProperty(&factorial, "x", 6);
    compute->assignProperty(&factorial, "xorig", 6);

    /**
     * Add the custom transition to the compute state.
     * Note: This transition has the compute state as source and target state.
     */
    compute->addTransition(new FactorialLoopTransition(&factorial));
//! [4]

//! [5]
    // Create a final state
    QFinalState *done = new QFinalState(&machine);

    // Add a custom transition with the 'compute' state as source state and the 'done' state as target state
    FactorialDoneTransition *doneTransition = new FactorialDoneTransition(&factorial);
    doneTransition->setTargetState(done);
    compute->addTransition(doneTransition);
//! [5]

//! [6]
    // Set the 'compute' state as initial state of the state machine
    machine.setInitialState(compute);

    // Load the UI description from main.qml
    QmlDocument *qml = QmlDocument::create("asset:///main.qml");

    // Make the Factorial and StateMachine object available to the UI as context properties
    qml->setContextProperty("_factorial", &factorial);
    qml->setContextProperty("_machine", &machine);

    // Create the application scene
    AbstractPane *appPage = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(appPage);

    return Application::exec();
}
Ejemplo n.º 6
0
HomeLayout::HomeLayout(User *homeUser) :
                CustomControl()
{
	user = homeUser;

	QmlDocument *qml = QmlDocument::create("asset:///twitterhome.qml");
	qml->setContextProperty("homeView", this);
	qml->setContextProperty("twitterUser", user);

	Control *root = qml->createRootObject<Control>();
	bb::cascades::CustomControl::setRoot(root);
}
Ejemplo n.º 7
0
RundGangApp::RundGangApp(bb::cascades::Application *app) :
        QObject(app)
{
    // Localization: Make the initial call to set up the initial application language and
    // connect to the LocaleHandlers systemLanguaged change signal, this will
    // tell the application when it is time to load a new set of language strings.
    mTranslator = new QTranslator(this);
    mLocaleHandler = new LocaleHandler(this);
    onSystemLanguageChanged();
    bool connectResult = connect(mLocaleHandler, SIGNAL(systemLanguageChanged()), SLOT(onSystemLanguageChanged()));
    Q_ASSERT(connectResult);
    Q_UNUSED(connectResult);

    // Register objects for assisting the Control of the Photo feedback page.
    qmlRegisterType<PhotoController>("com.rundgang", 1, 0, "PhotosController");
    qmlRegisterType<AudioController>("com.rundgang", 1, 0, "AudioController");
    qmlRegisterType<CustomSqlDataSource>("com.rundgang", 1, 0, "CustomSqlDataSource");
    qmlRegisterType<EmailController>("com.rundgang", 1, 0, "EmailController");

    // Registering picker types and Contact Picker helper object,
    // so that it can be used in QML.
    qmlRegisterType<ContactPicker>("bb.cascades.pickers", 1, 0, "ContactPicker");
    qmlRegisterUncreatableType<ContactSelectionMode>("bb.cascades.pickers", 1, 0,
            "ContactSelectionMode", "Non creatable enum type");

    // 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);

    // Create the GlobalSettings object that holds application wide settings.
    GlobalSettings *globalSettings = new GlobalSettings(this);
    qml->setContextProperty("_appSettings", globalSettings);

    // Make the application object accessible from QML.
    qml->setContextProperty("_app", this);

    // Set the stored visual style of the application.
    app->themeSupport()->setVisualStyle(globalSettings->visualStyle());

    // Create root object for the UI.
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Set created root object as the application scene.
    app->setScene(root);

    // Add an application cover, shown when the app is running in minimized mode.
    addApplicationCover();
}
Ejemplo n.º 8
0
KakelApp::KakelApp()
{

  // Create and Load the QMLDocument, using build patterns.
  QmlDocument *qml = QmlDocument::create("asset:///main.qml");

  if (!qml->hasErrors()) {

    setNumMoves(0);
    mNumTiles = 4;

    // Set the context property we want to use from inside the QML file. Functions exposed
    // via Q_INVOKABLE will be found with the property and the name of the function.
    qml->setContextProperty("kakel", this);

    // The application Page is created from the QML file.
    mAppPage = qml->createRootObject<Page>();

    findPlayAreaAndInitialize(mAppPage);

    if (mAppPage) {
      // Finally the main scene for the application is set to the Page.
      Application::instance()->setScene(mAppPage);
    }
  }
}
Ejemplo n.º 9
0
RocknRoll::RocknRoll(bb::cascades::Application *app)
: QObject(app)
{
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    AlbumsDataModel *p1DataModel = new AlbumsDataModel(this);
    SongsDataModel *p2DataModel = new SongsDataModel(this);
    qml->setContextProperty("_model1", p1DataModel);
    qml->setContextProperty("_model2", p2DataModel);

    qmlRegisterType<QTimer>("QTimer", 1, 0, "QTimer");
    qmlRegisterType<SceneCover>("bb.cascades", 1, 0, "SceneCover");
    qmlRegisterUncreatableType<AbstractCover>("bb.cascades", 1, 0, "AbstractCover", "An AbstractCover cannot be created.");

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // set created root object as a scene
    app->setScene(root);

    startNetworkManager();
    //parseJSON();
}
Ejemplo n.º 10
0
MalcomLibBb10::MalcomLibBb10(bb::cascades::Application *app)
: QObject(app)
{
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    connect(app, SIGNAL(fullscreen()), this, SLOT(onFullscreen()));
    connect(app, SIGNAL(thumbnail()), this, SLOT(onThumbnail()));

    root = qml->createRootObject<AbstractPane>();

    MalcomLib::Instance() -> initMalcom(uuidMalcom, secretKeyMalcom);

    QVariantList tags;
    tags << "tag1" << "tag2" << "tag3" << "tag4";

    MalcomLib::Instance() -> setTags(tags);

    QDeclarativePropertyMap malcom;
    malcom.insert("uuid", uuidMalcom);
    malcom.insert("secretKey", secretKeyMalcom);

    qml->setContextProperty("malcom", &malcom);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    app->setScene(root);
}
HelloForeignWindowApp::HelloForeignWindowApp()
{
    mTvOn = false;
    mTvInitialized = false;

    // Create a QML document and load the main UI QML file, using build patterns.
    QmlDocument *qml = QmlDocument::create("asset:///helloforeignwindow.qml");

    if (!qml->hasErrors()) {

        // Set the context property we want to use from inside the QML document. Functions exposed
        // via Q_INVOKABLE will be found with this property and the name of the function.
        qml->setContextProperty("foreignWindowApp", this);

        // The application Page is created from QML.
        mAppPage = qml->createRootObject<Page>();

        if (mAppPage) {

            Application::instance()->setScene(mAppPage);

            // Initialize the foreign window.
            initForeignWindow();

            // Start the thread in which we render to the custom window.
            start();
        }
    }
}
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
		QObject(app) {
	// create scene document from main.qml asset
	// set parent to created document to ensure it exists for the whole application lifetime
	QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

	// Expose this class to QML such that our Q_INVOKABLE methods defined in applicationui.hpp
	// can be called from our QML classes.
	qml->setContextProperty("cpp", this);

	// create root object for the UI
	AbstractPane *root = qml->createRootObject<AbstractPane>();
	// set created root object as a scene
	app->setScene(root);

	// The code from here down to "void ApplicationUI::logEvent" is used to determine the device
	// location and log the result to the Flurry server. Any errors in the process will also be
	// logged
	QGeoPositionInfoSource *source =
			QGeoPositionInfoSource::createDefaultSource(this);

	if (source) {
		bool positionUpdatedConnected = connect(source,
				SIGNAL(positionUpdated (const QGeoPositionInfo &)), this,
				SLOT(positionUpdated (const QGeoPositionInfo &)));

		if (positionUpdatedConnected) {
			source->requestUpdate();
		} else {
			qDebug() << "positionUpdated connection failed";
			Flurry::Analytics::LogError("positionUpdated connection failed");
		}
	} else {
Ejemplo n.º 13
0
ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
, m_model(new FileDataListModel(false, this))
{
	QThreadPool::globalInstance ()->setMaxThreadCount(BBFM_THREAD_POOL_SIZE);

    // Load file icons
    FileDataIcon::loadIcons();

    // 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
    onSystemLanguageChanged();

    // 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
    app->setScene(root);
}
Ejemplo n.º 14
0
RegistrationHandler::RegistrationHandler(const QUuid &uuid, QObject *parent)
    : QObject(parent)
    , m_context(uuid)
    , m_isAllowed(false)
    , m_progress(BbmRegistrationProgress::NotStarted)
    , m_temporaryError(false)
    , m_statusMessage(tr("Please wait while the application connects to BBM."))
{
    QmlDocument* qml = QmlDocument::create("asset:///registration.qml")
                       .parent(this);
    qml->setContextProperty("_registrationHandler", this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    if (uuid.isNull()) {
    	SystemDialog *uuidDialog = new SystemDialog("OK");
    	uuidDialog->setTitle("UUID Error");
        uuidDialog->setBody("Invalid/Empty UUID, please set correctly in main.cpp");
        connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type)));
        uuidDialog->show();
        return;
    }
    connect(&m_context,
            SIGNAL(registrationStateUpdated(
                   bb::platform::bbm::RegistrationState::Type)),
            this,
            SLOT(processRegistrationStatus(
                 bb::platform::bbm::RegistrationState::Type)));

    if (m_context.isAccessAllowed()){ // jika sudah teregister langsung ke main app
    	qDebug() << "access allowed";
    	finishRegistration();
    }else{ // jika belum, tampilkan halaman registrasi ini.
        Application::instance()->setScene(root);
    }
}
HelloForeignWindowApp::HelloForeignWindowApp()
{
    mTvOn = false;
    mTvInitialized = false;

    // Here we create a QMLDocument and load the main UI QML file.
    QmlDocument *qml = QmlDocument::create().load("helloforeignwindow.qml");

    if (!qml->hasErrors()) {

        // Set a context property for the QML to the application object, so that we
        // can call invokable functions in the app from QML.
        qml->setContextProperty("foreignWindowApp", this);

        // The application Page is created from QML.
        mAppPage = qml->createRootNode<Page>();

        if (mAppPage) {

            Application::setScene(mAppPage);

            // Start the thread in which we render to the custom window.
            start();
        }
    }
}
Ejemplo n.º 16
0
//! [0]
App::App(QObject *parent)
    : QObject(parent)
    , m_invokeManager(new InvokeManager(this))
    , m_backButtonVisible(false)
{
    // Listen to incoming invocation requests
    connect(m_invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), this, SLOT(handleInvoke(const bb::system::InvokeRequest&)));
    connect(m_invokeManager, SIGNAL(cardResizeRequested(const bb::system::CardResizeMessage&)), this, SLOT(resized(const bb::system::CardResizeMessage&)));
    connect(m_invokeManager, SIGNAL(cardPooled(const bb::system::CardDoneMessage&)), this, SLOT(pooled(const bb::system::CardDoneMessage&)));

    // Initialize properties with default values
    switch (m_invokeManager->startupMode()) {
        case ApplicationStartupMode::LaunchApplication:
            m_startupMode = tr("Launch");
            break;
        case ApplicationStartupMode::InvokeApplication:
            m_startupMode = tr("Invoke");
            break;
        case ApplicationStartupMode::InvokeCard:
            m_startupMode = tr("Card");
            break;
    }

    m_source = m_target = m_action = m_mimeType = m_uri = m_data = m_status = tr("--");
    m_title = tr("InvokeClient");

    // Create the UI
    QmlDocument *qml = QmlDocument::create("asset:///main.qml");
    qml->setContextProperty("_app", this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(root);
}
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        QObject(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
    onSystemLanguageChanged();

    // 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);

    // Create root object for the UI
    _root = qml->createRootObject<AbstractPane>();

    // expose this object to QML
    qml->setContextProperty("ame", this);

    // Set created root object as the application scene
    app->setScene(_root);
}
Ejemplo n.º 18
0
ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{
    qmlRegisterType<ODataListModel>("odata", 1, 0, "ODataListModel");
    qmlRegisterType<ODataObjectModel>("odata", 1, 0, "ODataObjectModel");
    qmlRegisterType<ODataService>("odata", 1, 0, "ODataService");
    qmlRegisterType<ApplicationInfo>("odata", 1, 0, "ApplicationInfo");
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument* qml = QmlDocument::create("asset:///main.qml").parent(this);

    /*******************************************************************
     * Place your read/write url here in place of the read only one
     *
     * Access the following url to get a read/write sandbox and copy it in below
     *
     * http://services.odata.org/(S(readwrite))/OData/OData.svc/
     *
     *                                    VVVVVVVVVVVVVVVVVVVVVVVVVVVVV
     *******************************************************************/

    _dataService = new ODataService("http://services.odata.org/V4/(S(ugj4qzwzxt5zukh2k2b32tx3))/OData/OData.svc/", ODataService::JSON);
    qml->setContextProperty("dataService", _dataService);

    // create root object for the UI
    AbstractPane* root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    app->setScene(root);
}
Ejemplo n.º 19
0
Q_DECL_EXPORT int main(int argc, char **argv)
{
//! [0]
    // Register our custom types with QML, so that they can be used as property types
    qmlRegisterUncreatableType<EventEditor>("com.example.bb10samples.pim.calendar", 1, 0, "EventEditor", "Usage as property type and access to enums");
    qmlRegisterType<EventViewer>();
//! [0]

    Application app(argc, argv);

    // localization support
    QTranslator translator;
    const QString locale_string = QLocale().name();
    const QString filename = QString::fromLatin1("calendar_%1").arg(locale_string);
    if (translator.load(filename, "app/native/qm")) {
        app.installTranslator(&translator);
    }

//! [1]
    // Load the UI description from main.qml
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);

    // Make the Calendar object available to the UI as context property
    qml->setContextProperty("_calendar", new Calendar(&app));
//! [1]

    // Create the application scene
    AbstractPane *appPage = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(appPage);

    return Application::exec();
}
Ejemplo n.º 20
0
EcoBodhi::EcoBodhi(bb::cascades::Application *app)
: QObject(app)
{
    // We want to use DataSource in QML
    bb::data::DataSource::registerQmlTypes();

    // register type SimpleDataController to enable its instantiation in QML
    qmlRegisterType<SimpleDataController>("eco.bodhi", 1, 0, "SimpleDataController");

    // register type QuotesController to enable it's instantiation in QML
    qmlRegisterType<QuotesController>("eco.bodhi", 1, 0, "QuotesController");

    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("ecoBodhi", this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    app->setScene(root);

    // Update our data
    refreshData();
}
Ejemplo n.º 21
0
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        				QObject(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
	onSystemLanguageChanged();

	// 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
	app->setScene(root);

	// set status message of the button
	//this->setStatus(QString("Next bus information here"));

	//set a value of a component in QML from CPP
	//root->setProperty("tempText", "Hello World...");

}
Ejemplo n.º 22
0
RegistrationHandler::RegistrationHandler(const QUuid &uuid, QObject *parent)
    : QObject(parent)
    , m_context(uuid)
    , m_isAllowed(false)
    , m_progress(BbmRegistrationProgress::NotStarted)
    , m_temporaryError(false)
	, m_statusMessage(tr(""))

	// In the class provided by BlackBerry a message is displayed, but I think it is cleaner not to display anything here.
	// While connecting, an overlay toast will give feedback to the user.
	// If there is a problem, then the error message will also be displayed.
	//, m_statusMessage(tr("Please wait while the application connects to BBM."))

{
    QmlDocument* qml = QmlDocument::create("asset:///registration.qml")
                       .parent(this);
    qml->setContextProperty("_registrationHandler", this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(root);
    if (uuid.isNull()) {
        SystemDialog *uuidDialog = new SystemDialog("OK");
        uuidDialog->setTitle("UUID Error");
        uuidDialog->setBody("Invalid/Empty UUID, please set correctly in main.cpp");
        connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type)));
        uuidDialog->show();
        return;
    }
    connect(&m_context,
            SIGNAL(registrationStateUpdated(
                   bb::platform::bbm::RegistrationState::Type)),
            this,
            SLOT(processRegistrationStatus(
                 bb::platform::bbm::RegistrationState::Type)));
}
Ejemplo n.º 23
0
Q_DECL_EXPORT int main(int argc, char **argv)
{
    Application app(argc, argv);

    // localization support
    QTranslator translator;
    QString locale_string = QLocale().name();
    QString filename = QString( "dictaphone_%1" ).arg( locale_string );
    if (translator.load(filename, "app/native/qm")) {
        app.installTranslator( &translator );
    }

//! [0]
    // Load the UI description from main.qml
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);

    // Make the TrackManager object available to the UI as context property
    qml->setContextProperty("_trackManager", new TrackManager(&app));
//! [0]

    // Create the application scene
    AbstractPane *appPage = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(appPage);

    return Application::exec();
}
Ejemplo n.º 24
0
int main(int argc, char **argv)
{
    // We need to register the QML types in the multimedia-library,
    // otherwise we will get an error from the QML.
    qmlRegisterType<bb::community::barcode::BarcodeDecoderControl>(
            "bb.community.barcode", 1, 0, "BarcodeDecoder");

    //-- this is where the server is started etc
    Application app(argc, argv);

    //-- localization support
    QTranslator translator;
    const QString filename = QString("barcodescanner_%1").arg(QLocale().name());
    if (translator.load(filename, "app/native/qm")) {
        app.installTranslator(&translator);
    }

    BarcodeScannerApp* barcodeScanner = new BarcodeScannerApp(&app);

    QmlDocument *qml = QmlDocument::create("asset:///main.qml");

    // expose BarcodeScannerApp object in QML as an variable
    qml->setContextProperty("_barcodeScanner", barcodeScanner);
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    Application::instance()->setScene(root);

    return Application::exec();
}
ApplicationUI::ApplicationUI() :
        QObject(),
        m_translator(new QTranslator(this)),
        m_localeHandler(new LocaleHandler(this)),
        m_invokeManager(new InvokeManager(this))
{
    // prepare the localization
    if (!QObject::connect(m_localeHandler, 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
    onSystemLanguageChanged();

    // 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);

    // Make app available to the qml.
    qml->setContextProperty("app", this);

    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Set created root object as the application scene
    Application::instance()->setScene(root);
}
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
		QObject(app) {
	QSettings settings;

	char montreal[] = "Montr\xc3\xa9" "al";

	_plainText = settings.value("plainText",
			QString::fromUtf8(montreal, strlen(montreal))).toString();
	_key = settings.value("key", generate()).toString();
	_iv = settings.value("iv", generate()).toString();
	_cipherText = settings.value("cipherText", "").toString();
	_recoveredPlainText = settings.value("recoveredPlainText", "").toString();

	// 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
	app->setScene(root);

	if (!isCryptoAvailable()) {
		toast("Need to double check our code - crypto isn't available...");
	}
}
Ejemplo n.º 27
0
//! [0]
App::App(QObject *parent)
    : QObject(parent)
    , m_targetType(0)
    , m_action(QLatin1String("bb.action.OPEN"))
    , m_mimeType(QLatin1String("image/png"))
    , m_model(new GroupDataModel(this))
    , m_invokeManager(new InvokeManager(this))
    , m_dialog(new SystemDialog(this))
{
    // Disable item grouping in the targets result list
    m_model->setGrouping(ItemGrouping::None);

    // Create signal/slot connections to handle card status changes
    bool ok = connect(m_invokeManager,
                      SIGNAL(childCardDone(const bb::system::CardDoneMessage&)), this,
                      SLOT(childCardDone(const bb::system::CardDoneMessage&)));
    Q_ASSERT(ok);
    ok = connect(m_invokeManager, SIGNAL(peekStarted(bb::system::CardPeek::Type)),
                 this, SLOT(peekStarted(bb::system::CardPeek::Type)));
    Q_ASSERT(ok);
    ok = connect(m_invokeManager, SIGNAL(peekEnded()), this, SLOT(peekEnded()));
    Q_ASSERT(ok);

    // Load the UI from the QML file
    QmlDocument *qml = QmlDocument::create("asset:///main.qml");
    qml->setContextProperty("_app", this);

    AbstractPane *root = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(root);
}
ApplicationHeadless::ApplicationHeadless(bb::cascades::Application *app)
    : QObject(app)
    , m_remainingFlashCount(-1)
{
    // prepare the localization
    m_pTranslator = new QTranslator(this);
    m_pLocaleHandler = new LocaleHandler(this);

    QSettings settings(m_author, m_appName);
    // Force the creation of the settings file so that we can watch it for changes.
    settings.sync();
    // Watcher for changes in the settings file.
    settingsWatcher = new QFileSystemWatcher(this);
    settingsWatcher->addPath(settings.fileName());
    connect(settingsWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(settingsChanged(const QString&)));

    // 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);
    // expose this class to the qml context so that we can query it for the necessary values
    // via properties, slots or invokable methods
    qml->setContextProperty("_app", this);
    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Set created root object as the application scene
    app->setScene(root);
}
Ejemplo n.º 29
0
ApplicationUI::ApplicationUI(bb::cascades::Application *app)
	: QObject(app)
{
	ThemeSupport* themeSupport = app->themeSupport();
	Theme* currentTheme = themeSupport->theme();
	ColorTheme* colorTheme = currentTheme->colorTheme();
	VisualStyle::Type style = colorTheme->style();
	switch (style)
	{
	case VisualStyle::Bright:
		m_theme = Bright;
		break;
	case VisualStyle::Dark:
		m_theme = Dark;
		break;
	}
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
	qml->setContextProperty("_native", this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    app->setScene(root);
}
Ejemplo n.º 30
0
WeatherGuesserApp::WeatherGuesserApp()
{
    // Register QML types, so they can be used in QML.
    qmlRegisterType<SqlHeaderDataQueryEx>("bb.cascades.datamanager", 1, 2, "SqlHeaderDataQueryEx");
    qmlRegisterType<PullToRefresh>("com.weather", 1, 0, "PullToRefresh");
    qmlRegisterType<CityDataSource>("com.weather", 1, 0, "CityDataSource");
    qmlRegisterType<LoadModelDecorator>("com.weather", 1, 0, "LoadModelDecorator");
    qmlRegisterType<WeatherDataSource>("com.weather", 1, 0, "WeatherDataSource");
    qmlRegisterUncreatableType<WeatherError>("com.weather", 1, 0, "WeatherError", "Uncreatable type");

    // Prepare localization. Connect to the LocaleHandlers systemLanguaged change signal, this will
    // tell the application when it is time to load a new set of language strings.
    mTranslator = new QTranslator(this);
    mLocaleHandler = new LocaleHandler(this);
    onSystemLanguageChanged();
    bool connectResult = connect(mLocaleHandler, SIGNAL(systemLanguageChanged()), SLOT(onSystemLanguageChanged()));
    Q_ASSERT(connectResult);
    Q_UNUSED(connectResult);

    // Create a QMLDocument and load it, using build patterns.
    QmlDocument *qmlDocument = QmlDocument::create("asset:///main.qml").parent(this);

    if (!qmlDocument->hasErrors()) {
        // Make the settings object available to QML
        qmlDocument->setContextProperty("_appSettings", new AppSettings(this));

        // The application navigationPane is created from QML.
        AbstractPane *appPane = qmlDocument->createRootObject<AbstractPane>();

        if (appPane) {
            // Set the main application scene to NavigationPane.
            Application::instance()->setScene(appPane);
        }
    }
}