ApplicationUI::ApplicationUI() :
        QObject(),
        m_settings(new QSettings(this))
{
    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();

    QmlDocument *qml = QmlDocument::create("asset:///Main.qml").parent(this);
    qml->setContextProperty("_app", this);
    qml->setContextProperty("_notes", new Notes(this));

    DisplayInfo display;
    int width = display.pixelSize().width();
    int height = display.pixelSize().height();

    QDeclarativePropertyMap* displayProperties = new QDeclarativePropertyMap;
    displayProperties->insert("width", QVariant(width));
    displayProperties->insert("height", QVariant(height));

    qml->setContextProperty("DisplayInfo", displayProperties);

    AbstractPane *root = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(root);
}
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);
}
示例#3
0
void tst_QDeclarativePropertyMap::insert()
{
    QDeclarativePropertyMap map;
    map.insert(QLatin1String("key1"),100);
    map.insert(QLatin1String("key2"),200);
    QVERIFY(map.keys().count() == 2);
    QVERIFY(map.contains(QLatin1String("key1")));

    QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
    QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));

    map.insert(QLatin1String("key1"),"Hello World");
    QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
}
void tst_QDeclarativePropertyMap::changed()
{
    QDeclarativePropertyMap map;
    QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&, const QVariant&)));
    map.insert(QLatin1String("key1"),100);
    map.insert(QLatin1String("key2"),200);
    QCOMPARE(spy.count(), 0);

    map.clear(QLatin1String("key1"));
    QCOMPARE(spy.count(), 0);

    //make changes in QML
    QDeclarativeEngine engine;
    QDeclarativeContext *ctxt = engine.rootContext();
    ctxt->setContextProperty(QLatin1String("testdata"), &map);
    QDeclarativeComponent component(&engine);
    component.setData("import QtQuick 1.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
            QUrl::fromLocalFile(""));
    QVERIFY(component.isReady());
    QDeclarativeText *txt = qobject_cast<QDeclarativeText*>(component.create());
    QVERIFY(txt);
    QCOMPARE(txt->text(), QString('X'));
    QCOMPARE(spy.count(), 1);
    QList<QVariant> arguments = spy.takeFirst();
    QCOMPARE(arguments.count(), 2);
    QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
    QCOMPARE(arguments.at(1).value<QVariant>(),QVariant("Hello World"));
    QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
}
MainMenu::MainMenu(Application *app) :  _appVersion(QString(Settings::AppVersion)) {

	qDebug() << "XXXX NFC Tool Lite V" << Settings::AppVersion;
	qDebug() << "XXXX loading main menu qml document";

	_app = app;

	createModules();

	qDebug() << "Invoke Startup Mode: " << _invokeManager->startupMode();

	_qml = QmlDocument::create("asset:///main.qml");
	_qml->setContextProperty("_mainMenu",      this);
	_qml->setContextProperty("_ndefFactory",  _ndefFactory);

	QDeclarativePropertyMap* propertyMap = new QDeclarativePropertyMap;

	propertyMap->insert("AppVersion",       QVariant(QString(Settings::AppVersion)));

	_qml->setContextProperty("_propertyMap", propertyMap);

	_root = _qml->createRootObject<AbstractPane>();
	connectSignals();
	_app->setScene(_root);
}
void tst_QDeclarativePropertyMap::count()
{
    QDeclarativePropertyMap map;
    QCOMPARE(map.isEmpty(), true);
    map.insert(QLatin1String("key1"),100);
    map.insert(QLatin1String("key2"),200);
    QCOMPARE(map.count(), 2);
    QCOMPARE(map.isEmpty(), false);

    map.insert(QLatin1String("key3"),"Hello World");
    QCOMPARE(map.count(), 3);

    //clearing doesn't remove the key
    map.clear(QLatin1String("key3"));
    QCOMPARE(map.count(), 3);
    QCOMPARE(map.size(), map.count());
}
ApplicationUI::ApplicationUI(bb::cascades::Application *app,
		bb::platform::bbm::Context& context) :
		QObject(app), m_context(&context)

{

	qmlRegisterType<ScoreLoopThread>("com.bblive.game", 1, 0, "ScoreLoop"); //SCORELOOP
	qmlRegisterType<QTimer>("bb.cascades", 1, 0, "QTimer");

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

	mScoreLoop = ScoreLoopThread::instance(); //SCORELOOP
	QObject::connect(mScoreLoop, SIGNAL(ScoreLoopUserReady(AppData_t*)), this,
			SLOT(scoreLoopLoaded(AppData_t*))); //SCORELOOP
	QObject::connect(mScoreLoop, SIGNAL(SubmitScoreCompleted(ScoreData_t*)),
			this, SLOT(onSubmitScoreCompleted(ScoreData_t*))); //SCORELOOP
	QObject::connect(mScoreLoop, SIGNAL(ScoreLoopUserError()), this,
			SLOT(scoreLoopError())); //SCORELOOP
	qml->setContextProperty("appContext", this);

//	qml->setContextProperty("_scoreloop", scoreloopData);
	XmlReader *xml = new XmlReader();
	qml->setContextProperty("XML", xml); // create root object for the U
	bb::device::DisplayInfo display;
	int width = display.pixelSize().width();
	int height = display.pixelSize().height();

	QDeclarativePropertyMap* displayProperties = new QDeclarativePropertyMap;
	displayProperties->insert("width", QVariant(width));
	displayProperties->insert("height", QVariant(height));

	qml->setContextProperty("DisplayInfo", displayProperties);

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

	mAppData = 0; //SCORELOOP
	setConnectionStatus("0");
	mScoreLoop->start(); //SCORELOOP
}
void tst_QDeclarativePropertyMap::clear()
{
    QDeclarativePropertyMap map;
    map.insert(QLatin1String("key1"),100);
    QVERIFY(map.keys().count() == 1);

    QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));

    map.clear(QLatin1String("key1"));
    QVERIFY(map.keys().count() == 1);
    QVERIFY(map.contains(QLatin1String("key1")));
    QCOMPARE(map.value(QLatin1String("key1")), QVariant());
}
void tst_QDeclarativePropertyMap::operatorValue()
{
    QDeclarativePropertyMap map;
    map.insert(QLatin1String("key1"),100);
    map.insert(QLatin1String("key2"),200);
    QVERIFY(map.count() == 2);
    QVERIFY(map.contains(QLatin1String("key1")));

    const QDeclarativePropertyMap &constMap = map;

    QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100));
    QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200));
    QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1")));
    QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2")));
}
void tst_QDeclarativePropertyMap::insert()
{
    QDeclarativePropertyMap map;
    map.insert(QLatin1String("key1"),100);
    map.insert(QLatin1String("key2"),200);
    QVERIFY(map.keys().count() == 2);
    QVERIFY(map.contains(QLatin1String("key1")));

    QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
    QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));

    map.insert(QLatin1String("key1"),"Hello World");
    QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));

    //inserting property names same with existing method(signal, slot, method) names is not allowed
    //QDeclarativePropertyMap has an invokable keys() method
    QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols.");
    map.insert(QLatin1String("keys"), 1);
    QVERIFY(map.keys().count() == 2);
    QVERIFY(!map.contains(QLatin1String("keys")));
    QVERIFY(map.value(QLatin1String("keys")).isNull());

    //QDeclarativePropertyMap has a deleteLater() slot
    QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols.");
    map.insert(QLatin1String("deleteLater"), 1);
    QVERIFY(map.keys().count() == 2);
    QVERIFY(!map.contains(QLatin1String("deleteLater")));
    QVERIFY(map.value(QLatin1String("deleteLater")).isNull());

    //QDeclarativePropertyMap has an valueChanged() signal
    QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols.");
    map.insert(QLatin1String("valueChanged"), 1);
    QVERIFY(map.keys().count() == 2);
    QVERIFY(!map.contains(QLatin1String("valueChanged")));
    QVERIFY(map.value(QLatin1String("valueChanged")).isNull());

    //but 'valueChange' should be ok
    map.insert(QLatin1String("valueChange"), 1);
    QVERIFY(map.keys().count() == 3);
    QVERIFY(map.contains(QLatin1String("valueChange")));
    QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1));

    //'valueCHANGED' should be ok, too
    map.insert(QLatin1String("valueCHANGED"), 1);
    QVERIFY(map.keys().count() == 4);
    QVERIFY(map.contains(QLatin1String("valueCHANGED")));
    QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1));
}
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        QObject(app)
{
	qmlRegisterType<Timer>("CustomTimer", 1, 0, "Timer");
    // 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();

    //NFC and invocation bit
    _invokeManager = new bb::system::InvokeManager();
    if (_invokeManager->startupMode() == bb::system::ApplicationStartupMode::InvokeApplication) {
    	_launchedByInvoke = true;
    }
    QDeclarativePropertyMap* propertyMap = new QDeclarativePropertyMap;
    propertyMap->insert("LaunchedByInvoke", QVariant(_launchedByInvoke ? "true" : "false"));

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

    //register the property
    qml->setContextProperty("_propertyMap", propertyMap);

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

    //NFC listeners
    initialiseListeners();

    // Set created root object as the application scene
    app->setScene(_root);
}
示例#12
0
void QMLContact::setContact(const QContact& c)
{
    m_contact = c;

    if (m_contactMap) {
        delete m_contactMap;
        m_detailMaps.clear();
    }

    foreach (QObject* detail, m_details) {
        delete detail;
    }
    m_details.clear();

    m_contactMap = new QDeclarativePropertyMap(this);


    QList<QContactDetail> details = m_contact.details();
    foreach (const QContactDetail& detail, details) {
      QMLContactDetail* qd = new QMLContactDetail(this);

      QDeclarativePropertyMap* dm = new QDeclarativePropertyMap(m_contactMap);

      connect(dm, SIGNAL(valueChanged(QString,QVariant)), qd, SLOT(detailChanged(QString,QVariant)));


      QVariantMap values = detail.variantValues();
      foreach (const QString& key, values.keys()) {
          dm->insert(normalizePropertyName(key), values.value(key));
      }
      qd->setName(normalizePropertyName(detail.definitionName()));
      m_details.append(qd);
      qd->setDetailPropertyMap(dm);
      m_detailMaps.append(dm);;
      m_contactMap->insert(normalizePropertyName(detail.definitionName()), QVariant::fromValue(static_cast<QObject*>(dm)));
    }
FoodCompanion::FoodCompanion(bb::cascades::Application *app) :
		QObject(app) {

	// register camera utilities
	qmlRegisterType<CameraUtilities>("CameraUtilities", 1, 0,
			"CameraUtilities");

	// register timer functionalities
	qmlRegisterType<QTimer>("QtTimer", 1, 0, "Timer");

	// register SceneCover functionalities
	qmlRegisterType<SceneCover>("bb.cascades", 1, 0, "SceneCover");

	// Since it is not possible to create an instance of the AbstractCover
	// it is registered as an uncreatable type (necessary for accessing
	// Application.cover).
	qmlRegisterUncreatableType<AbstractCover>("bb.cascades", 1, 0,
			"AbstractCover", "An AbstractCover cannot be created.");

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

	// Retrieve the path to the app's working directory
	QString workingDir = QDir::currentPath();

	// Build the path, add it as a context property, and expose
	// it to QML
	QDeclarativePropertyMap* dirPaths = new QDeclarativePropertyMap;
	dirPaths->insert("currentPath", QVariant(QString("file://" + workingDir)));
	dirPaths->insert("assetPath", QVariant(QString("file://" + workingDir + "/app/native/assets/")));
	qml->setContextProperty("dirPaths", dirPaths);

	DisplayInfo display;
	int width = display.pixelSize().width();
	int height = display.pixelSize().height();

	QDeclarativePropertyMap* displayProperties = new QDeclarativePropertyMap;
	displayProperties->insert("width", QVariant(width));
	displayProperties->insert("height", QVariant(height));
	qml->setContextProperty("DisplayInfo", displayProperties);

	QDeclarativePropertyMap* debugMode = new QDeclarativePropertyMap;
	debugMode->insert("debugMode", QVariant(QBool(true)));
	qml->setContextProperty("DebugMode", debugMode);

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

	// Set created root object as the application scene
	app->setScene(root);
}
示例#14
0
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        QObject(app),
        m_pLocaleHandler(NULL),
        m_app(app),
        m_root(NULL),
        m_qml(NULL),
        m_Settings("Amonchakai", "HFR10Service"),
        m_InvokeManager(new bb::system::InvokeManager(this)),
        m_HeadlessStart(false),
        m_isCard(false)

{





    bool connectResult;

    // Since the variable is not used in the app, this is added to avoid a
    // compiler warning.
    Q_UNUSED(connectResult);
    connectResult = connect(m_InvokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), this, SLOT(onInvoked(const bb::system::InvokeRequest&)));
    qDebug() << "HubIntegration: started and connected to invokeManager";


    // This is only available in Debug builds.
    Q_ASSERT(connectResult);

    switch(m_InvokeManager->startupMode()) {
        case bb::system::ApplicationStartupMode::LaunchApplication:
            qDebug() << "HeadlessHubIntegration: Regular application launch";
            break;
        case bb::system::ApplicationStartupMode::InvokeApplication:
            m_HeadlessStart = true;
            qDebug() << "--------------------- HeadlessHubIntegration: Launching app from invoke";
            break;
        case bb::system::ApplicationStartupMode::InvokeCard:
            m_HeadlessStart = true;
            m_isCard = true;
            qDebug() << "--------------------- HeadlessHubIntegration: Launching card from invoke";
            break;
        // enable when 10.3 beta is released
        //case ApplicationStartupMode::InvokeHeadless:
        case 4:
            qDebug() << "--------------------- HeadlessHubIntegration: Launching headless from invoke";
            m_HeadlessStart = true;
            break;
        default:
            qDebug() << "--------------------- HeadlessHubIntegration: other launch: " << m_InvokeManager->startupMode();
            break;
       }

    // ---------------------------------------------------------------------
    // Regular integration

    // prepare the localization
    m_pTranslator = new QTranslator(this);
    m_pLocaleHandler = new LocaleHandler(this);

    CookieJar *cookies = CookieJar::get();
    cookies->loadFromDisk();

    Settings::themeValue() = app->themeSupport()->theme()->colorTheme()->style() == VisualStyle::Bright ? 1 : 2;

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


    WebResourceManager::get()->cleanup();


    // -------------------------------------------------------------------------------------------------------
    // Register controllers to QML
    qmlRegisterType<LoginController>("Network.LoginController", 1, 0, "LoginController");
    qmlRegisterType<ListFavoriteController>("Network.ListFavoriteController", 1, 0, "ListFavoriteController");
    qmlRegisterType<ExploreCategoryController>("Network.ExploreCategoryController", 1, 0, "ExploreCategoryController");
    qmlRegisterType<ShowThreadController>("Network.ShowThreadController", 1, 0, "ShowThreadController");
    qmlRegisterType<PrivateMessageController>("Network.PrivateMessageController", 1, 0, "PrivateMessageController");
    qmlRegisterType<PostMessageController>("Network.PostMessageController", 1, 0, "PostMessageController");
    qmlRegisterType<SmileyPickerController>("Network.SmileyPickerController", 1, 0, "SmileyPickerController");
    qmlRegisterType<SearchController>("Network.SearchController", 1, 0, "SearchController");
    qmlRegisterType<SearchKeyRetriever>("Network.SearchKeyRetriever", 1, 0, "SearchKeyRetriever");
    qmlRegisterType<BookmarksController>("Network.BookmarksController", 1, 0, "BookmarksController");
    qmlRegisterType<ImageUploaderController>("Network.ImageUploaderController", 1, 0, "ImageUploaderController");
    qmlRegisterType<ProfileController>("Network.ProfileController", 1, 0, "ProfileController");
    qmlRegisterType<NetImageTracker>("com.netimage", 1, 0, "NetImageTracker");
    qmlRegisterType<Settings>("conf.settings", 1, 0, "AppSettings");
    qmlRegisterType<QTimer>("Lib.QTimer", 1, 0, "QTimer");
    qmlRegisterType<BugReportController>("Lib.BugReport", 1, 0, "BugReport");
    qmlRegisterType<ApplicationLogController>("Lib.ApplicationLogController", 1, 0, "ApplicationLogController");

    // -------------------------------------------------------------------------------------------------------
    // Create scene document from main.qml asset, the parent is set
    // to ensure the document gets destroyed properly at shut down.

    if(!m_HeadlessStart) {
        QmlDocument *qml = QmlDocument::create("asset:///main.qml")
                                .parent(this);


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


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


        bb::device::DisplayInfo display;
        QDeclarativePropertyMap* displayDimensions = new QDeclarativePropertyMap;
        displayDimensions->insert( "width", QVariant( display.pixelSize().width() ) );
        displayDimensions->insert( "height", QVariant( display.pixelSize().height() ) );
        qml->setContextProperty( "DisplayInfo", displayDimensions );

    }
}
示例#15
0
void ApplicationUI::onInvoked(const bb::system::InvokeRequest& request) {
    qDebug() << "invoke!" << request.action();

    if(request.action().compare("bb.action.VIEW") == 0 || request.action().compare("bb.action.OPEN") == 0) {
//         qDebug() << "HubIntegration: onInvoked: view item: " << request.data();

         JsonDataAccess jda;

         QVariantMap objectMap = (jda.loadFromBuffer(request.data())).toMap();
         QVariantMap itemMap = objectMap["attributes"].toMap();


         QVariantList items = m_Settings.value("hub/items").toList();

         QString urlToOpen;
         for(int index = 0; index < items.size(); index++) {
             QVariantMap item = items.at(index).toMap();
             QString sourceId = item["messageid"].toString();

              if (item["sourceId"].toString() == itemMap["messageid"].toString() ||
                  item["sourceId"].toString() == itemMap["sourceId"].toString()) {

                  qDebug() << "FOUD!";
                  urlToOpen = item["url"].toString();

                  break;
              }
         }

         qDebug() << "URL TO OPEN: " << urlToOpen;

         QmlDocument *qml = QmlDocument::create("asset:///StartupCardThread.qml")
                                                          .parent(this);

         m_root = qml->createRootObject<NavigationPane>();
         qml->setContextProperty("_app", this);
         m_app->setScene(m_root);

         QObject *thread = m_root->findChild<QObject*>("pageThread");
         if(thread != NULL) {
             thread->setProperty("urlPage", urlToOpen);

             bb::device::DisplayInfo display;
             QDeclarativePropertyMap* displayDimensions = new QDeclarativePropertyMap;
             displayDimensions->insert( "width", QVariant( display.pixelSize().width() ) );
             displayDimensions->insert( "height", QVariant( display.pixelSize().height() ) );
             qml->setContextProperty( "DisplayInfo", displayDimensions );
         } else
             qDebug() << "pageThread variable is not found in the qml document :(";


         InvokeRequest request;
         request.setTarget("com.amonchakai.HFR10Service");
         request.setAction("bb.action.MARKREAD");
         request.setMimeType("hub/item");
         request.setUri(QUrl("pim:"));

         QByteArray bytes;
         jda.saveToBuffer(objectMap, &bytes);
         request.setData(bytes);

         m_InvokeManager->invoke(request);

    }

    if(request.action().compare("bb.action.COMPOSE") == 0) {
        QmlDocument *qml = QmlDocument::create("asset:///StartupCardCompose.qml")
                                                                  .parent(this);

        m_root = qml->createRootObject<NavigationPane>();
        qml->setContextProperty("_app", this);

        m_app->setScene(m_root);

        QString directory = QDir::homePath() + QLatin1String("/HFRBlackData");
        if (!QFile::exists(directory)) {
            return;
        }

        QFile file(directory + "/UserID.txt");

        QString userName;
        if (file.open(QIODevice::ReadOnly)) {
            QDataStream stream(&file);
            stream >> userName;

            file.close();
        }
示例#16
0
    QDeclarativePropertyMap *uiConstants(MLocaleWrapper *locale = 0) {

        QString defaultFontFamily      = QLatin1String("Nokia Pure Text");
        QString defaultFontFamilyLight = QLatin1String("Nokia Pure Text Light");

#ifdef HAVE_MEEGOTOUCH
        // use arial when language is set to farsi
        if (locale && locale->language() == QLatin1String("fa")) {
            defaultFontFamily = QLatin1String("Arial");
            defaultFontFamilyLight = QLatin1String("Arial");
        }
#else
        Q_UNUSED(locale);
#endif // HAVE_MEEGOTOUCH

        QDeclarativePropertyMap *uiConstantsData = new QDeclarativePropertyMap();
        uiConstantsData->insert("DefaultMargin", QVariant(16));
        uiConstantsData->insert("ButtonSpacing", QVariant(6));
        uiConstantsData->insert("HeaderDefaultHeightPortrait", QVariant(72));
        uiConstantsData->insert("HeaderDefaultHeightLandscape", QVariant(46));
        uiConstantsData->insert("HeaderDefaultTopSpacingPortrait", QVariant(20));
        uiConstantsData->insert("HeaderDefaultBottomSpacingPortrait", QVariant(20));
        uiConstantsData->insert("HeaderDefaultTopSpacingLandscape", QVariant(16));
        uiConstantsData->insert("HeaderDefaultBottomSpacingLandscape", QVariant(14));
        uiConstantsData->insert("ListItemHeightSmall", QVariant(64));
        uiConstantsData->insert("ListItemHeightDefault", QVariant(80));

        uiConstantsData->insert("IndentDefault", QVariant(16)); // For left and right
        uiConstantsData->insert("GroupHeaderHeight", QVariant(40));

        QFont bodyTextFont;
        bodyTextFont.setFamily(defaultFontFamilyLight);
        bodyTextFont.setPixelSize(24);
        uiConstantsData->insert("BodyTextFont", QVariant(bodyTextFont));

        QFont headerFont;
        headerFont.setFamily(defaultFontFamilyLight);
        headerFont.setPixelSize(32);
        uiConstantsData->insert("HeaderFont", QVariant(headerFont));

        QFont groupHeaderFont;
        groupHeaderFont.setFamily(defaultFontFamily);
        groupHeaderFont.setPixelSize(18);
        groupHeaderFont.setBold(true);
        uiConstantsData->insert("GroupHeaderFont", QVariant(groupHeaderFont));

        QFont titleFont;
        titleFont.setFamily(defaultFontFamily);
        titleFont.setPixelSize(26);
        titleFont.setBold(true);
        uiConstantsData->insert("TitleFont", QVariant(titleFont));

        QFont smallTitleFont;
        smallTitleFont.setFamily(defaultFontFamily);
        smallTitleFont.setPixelSize(24);
        smallTitleFont.setBold(true);
        uiConstantsData->insert("SmallTitleFont", QVariant(smallTitleFont));

        QFont fieldLabelFont;
        fieldLabelFont.setFamily(defaultFontFamilyLight);
        fieldLabelFont.setPixelSize(22);
        uiConstantsData->insert("FieldLabelFont", QVariant(fieldLabelFont));
        uiConstantsData->insert("FieldLabelColor", QVariant(QColor("#505050")));

        QFont subTitleFont;
        subTitleFont.setFamily(defaultFontFamilyLight);
        subTitleFont.setPixelSize(22);
        uiConstantsData->insert("SubtitleFont", QVariant(subTitleFont));

        QFont itemInfoFont;
        itemInfoFont.setFamily(defaultFontFamilyLight);
        itemInfoFont.setPixelSize(18);
        uiConstantsData->insert("InfoFont", QVariant(itemInfoFont));

        return uiConstantsData;
    }