Esempio n. 1
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QQuickView viewer;

    // The following are needed to make examples run without having to install the module
    // in desktop environments.
#ifdef Q_OS_WIN
    QString extraImportPath(QStringLiteral("%1/../../../../%2"));
#else
    QString extraImportPath(QStringLiteral("%1/../../../%2"));
#endif
    viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
                                                       QString::fromLatin1("qml")));

    viewer.setSource(QUrl("qrc:/main.qml"));

    viewer.setTitle(QStringLiteral("Interaction"));
    viewer.setResizeMode(QQuickView::SizeRootObjectToView);
    viewer.setColor("#fafafa");
    viewer.show();

    return app.exec();
}
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

#ifdef Q_OS_WIN
    // Force usage of OpenGL ES through ANGLE on Windows
    QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif

    // Register the map view for QML
    qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView");
    qmlRegisterType<SetInitialMapArea>("Esri.Samples", 1, 0, "SetInitialMapAreaSample");

    // Intialize application view
    QQuickView view;
    view.setResizeMode(QQuickView::SizeRootObjectToView);

    // Add the import Path
    view.engine()->addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));

    // Set the source
    view.setSource(QUrl("qrc:/Samples/Maps/SetInitialMapArea/SetInitialMapArea.qml"));

    view.show();

    return app.exec();
}
Esempio n. 3
0
int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);

//    qmlRegisterType<TraceView>("SysViz", 1, 0, "TraceView");
    qmlRegisterType<ThreadSliceView>("SysViz", 1, 0, "ThreadSliceView");
    qmlRegisterType<GraphItem>      ("SysViz", 1, 0, "GraphItem");
    qmlRegisterType<TraceModel>();
    qmlRegisterType<QAbstractListModel>();
    qmlRegisterType<CpuFrequencyModel>();
    qmlRegisterType<GpuFrequencyModel>();

    TraceModel model;

    QQuickView view;
    QSurfaceFormat format = view.requestedFormat();
    format.setSamples(16);
    view.setFormat(format);

    view.rootContext()->setContextProperty("traceModel", &model);
    view.rootContext()->setContextProperty("cm", view.screen()->physicalDotsPerInch() / 2.54);

    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl::fromLocalFile("qml/main.qml"));
    view.setTitle("sysviz");
    view.show();

#ifdef QT_DQML_LIB
    DQmlLocalServer server(view.engine(), &view, "qml/main.qml");
    server.fileTracker()->track("qml", "qml");
#endif

    app.exec();
}
Esempio n. 4
0
int main(int argc, char *argv[])
{
    // SailfishApp::main() will display "qml/template.qml", if you need more
    // control over initialization, you can use:
    //
    //   - SailfishApp::application(int, char *[]) to get the QGuiApplication *
    //   - SailfishApp::createView() to get a new QQuickView * instance
    //   - SailfishApp::pathTo(QString) to get a QUrl to a resource file
    //
    // To display the view, call "show()" (will show fullscreen on device).

    qRegisterMetaType<QList<FileInfoEntry*> >();

    QGuiApplication *app = SailfishApp::application(argc, argv);
    QQuickView *view = SailfishApp::createView();

    // Add image providers and C++ classes
    view->engine()->addImageProvider(QLatin1String("thumbnail"), new ThumbnailProvider);

    FileEngine fileEngine;
    view->engine()->rootContext()->setContextProperty("engine", &fileEngine);
    view->engine()->rootContext()->setContextProperty("fileList", fileEngine.fileList);
    view->engine()->rootContext()->setContextProperty("fileInfo", fileEngine.fileInfo);
    view->engine()->rootContext()->setContextProperty("fileProcess", fileEngine.fileProcess);
    view->engine()->rootContext()->setContextProperty("clipboard", fileEngine.clipboard);
    view->engine()->rootContext()->setContextProperty("settings", fileEngine.settings);
    view->engine()->rootContext()->setContextProperty("coverModel", fileEngine.coverModel);

    // Show the application
    view->setSource(SailfishApp::pathTo("qml/Filetug.qml"));
    view->show();

    return app->exec();
}
Esempio n. 5
0
int main(int argc, char *argv[])
{
    // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
    QApplication app(argc, argv);

    QQuickView viewer;
    // The following are needed to make examples run without having to install the module
    // in desktop environments.
#ifdef Q_OS_WIN
    QString extraImportPath(QStringLiteral("%1/../../../../%2"));
#else
    QString extraImportPath(QStringLiteral("%1/../../../%2"));
#endif
    viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
                                      QString::fromLatin1("qml")));
    QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);

    QString appKey;
    if (argc > 1) {
        appKey = argv[1];
        qDebug() << "App key for worldweatheronline.com:" << appKey;
    } else {
        qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data.";
    }
    viewer.setTitle(QStringLiteral("QML Weather"));
    viewer.rootContext()->setContextProperty("weatherAppKey", appKey);
    viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml"));
    viewer.setResizeMode(QQuickView::SizeRootObjectToView);
    viewer.show();

    return app.exec();
}
Esempio n. 6
0
int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);

    FileTest *fileTest = new FileTest();
    fileTest->writeFilesToDisk();
    fileTest->readFilesFromDisk();

    NetworkTest *networkTest = new NetworkTest();
    networkTest->TestHttp();
    networkTest->TestHttps();

    QQuickView view;

    GpsClient *gpsClient = new GpsClient(&view);
    view.engine()->rootContext()->setContextProperty(QLatin1String("gpsClient"),
                                                     gpsClient);

    NotificationClient *notificationClient = new NotificationClient(&view);
    view.engine()->rootContext()->setContextProperty(QLatin1String("notificationClient"),
                                                     notificationClient);
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));

    view.show();

    return app.exec();
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
    //start appliacation
    QGuiApplication a(argc, argv);
    //settings
    CQmlSettings settings(QCoreApplication::applicationDirPath() + "/qmlConfigure.xml");
    if(settings.errorMap.count() > 0)
        exit(0);

    DVRSettings dvrSetting;
    dvrSetting.IP = settings.node("IP");
    dvrSetting.server_port = settings.node("serverPort").toInt();

    //事物层对象初始化
    CTransaction transaction;

    //初始化clientThread
    ClientThread receiveDataThread(&transaction, dvrSetting);
    receiveDataThread.start();
    QQuickView view;
    view.rootContext()->setContextProperty("transaction", &transaction);
    view.rootContext()->setContextProperty("settings", &settings);
    view.rootContext()->setContextProperty("mainWindow", &view);
    view.setSource(QUrl("qrc:/robo/qml/hitRobotGroup/MainPage.qml"));
    view.show();

    return a.exec();


}
Esempio n. 8
0
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);

  QQuickView viewer;
  viewer.setResizeMode(QQuickView::SizeRootObjectToView);

  QObjectList model_qobjectlist;
  model_qobjectlist << new TestObject(0);
  model_qobjectlist << new TestObject(1);
  model_qobjectlist << new TestObject(2);
  viewer.rootContext()->setContextProperty("model_qobjectlist", QVariant::fromValue(model_qobjectlist));

  TestObject *model_qobject = new TestObject(0);
  viewer.rootContext()->setContextProperty("model_qobject", QVariant::fromValue(model_qobject));

  QStringList model_qstringlist;
  model_qstringlist << QStringLiteral("A");
  model_qstringlist << QStringLiteral("B");
  model_qstringlist << QStringLiteral("C");
  viewer.rootContext()->setContextProperty("model_qstringlist", model_qstringlist);

  TestModel *model_qaim = new TestModel;
  viewer.rootContext()->setContextProperty("model_qaim", model_qaim);

  viewer.setSource(QStringLiteral("qrc:/qml/main.qml"));
  viewer.show();

  return app.exec();
}
Esempio n. 9
0
//=====================================================================================================================
int main(int argc, char* argv[])
//=====================================================================================================================
{
  QGuiApplication app(argc, argv);
  QQuickView viewer;

  //QString extraImportPath(QStringLiteral("%1/../../../%2"));
  //viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), QString::fromLatin1("qml")));

  // set path to find the plugin
  QString extraImportPath(QStringLiteral("%1/../pluginlib"));
  QString path = extraImportPath.arg(QGuiApplication::applicationDirPath());
  viewer.engine()->addImportPath(path);

  // create list of my custom objects
  Wrapper wrapper;

  // and set the list as model
  QQmlContext *ctxt = viewer.rootContext();
  ctxt->setContextProperty("wrapper", &wrapper);

  // set up connection
  QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
  viewer.setTitle(QStringLiteral("Custom Plugin Demo"));

  viewer.setResizeMode(QQuickView::SizeRootObjectToView);
  viewer.setSource(QUrl("qrc:/qml/view.qml"));
  viewer.show();

  return QGuiApplication::exec();
}
Esempio n. 10
0
int main(int argc, char *argv[]) {
    QGuiApplication* app = SailfishApp::application(argc, argv);
    QQuickView* view = SailfishApp::createView();

    Configurator config;
    config.load();

    //qmlRegisterType<Request>("Sailbook.Request", 1, 0, "Request");
    qmlRegisterUncreatableType<Request>("App.Sailbook", 1, 0, "Request", QStringLiteral("Error"));
    //qmlRegisterInterface<SessionManager>("SessionManager");

    SessionManager session(QStringLiteral(APPID), config.getValue(QStringLiteral("token")).toString());
    session.setExtendedPermission(SessionManager::ExtendedPermissions(
        SessionManager::Email |
        SessionManager::ManageNotifications |
        SessionManager::ManagePages |
        SessionManager::PublishActions |
        SessionManager::ReadFriendList |
        SessionManager::ReadInsights |
        SessionManager::ReadMailbox |
        SessionManager::ReadPageMailboxes |
        SessionManager::ReadStream |
        SessionManager::RsvpEvent
    ));

    session.setUserDataPermission(SessionManager::UserDataPermissions(
        SessionManager::UserAboutMe |
        SessionManager::UserActionsBooks |
        SessionManager::UserActionsMusic |
        SessionManager::UserActionsNews |
        SessionManager::UserActionsVideo |
        SessionManager::UserActivities |
        SessionManager::UserBirthday |
        SessionManager::UserEducationHistory |
        SessionManager::UserEvents |
        SessionManager::UserFriends |
        SessionManager::UserGamesActivity |
        SessionManager::UserGroups |
        SessionManager::UserHometown |
        SessionManager::UserInterests |
        SessionManager::UserLikes |
        SessionManager::UserLocation |
        SessionManager::UserPhotos |
        SessionManager::UserRelationshipDetails |
        SessionManager::UserRelationships |
        SessionManager::UserReligionPolitics |
        SessionManager::UserStatus |
        SessionManager::UserTaggedPlaces |
        SessionManager::UserVideos |
        SessionManager::UserWebsite |
        SessionManager::UserWorkHistory
    ));

    view->rootContext()->setContextProperty("SessionManager", &session);
    view->rootContext()->setContextProperty("Configurator", &config);
    view->setSource(SailfishApp::pathTo("qml/sailbook.qml"));
    view->show();

    return app->exec();
}
Esempio n. 11
0
void tst_QQuickGraphicsInfo::testProperties()
{
    QQuickView view;
    view.setSource(QUrl("data/basic.qml"));

    view.show();
    QVERIFY(QTest::qWaitForWindowExposed(&view));

    QSignalSpy spy(&view, SIGNAL(sceneGraphInitialized()));
    spy.wait();

    QObject* obj = view.rootObject();
    QVERIFY(obj);

    QSGRendererInterface *rif = view.rendererInterface();
    const int expectedAPI = rif ? rif->graphicsApi() : QSGRendererInterface::Unknown;

    QCOMPARE(obj->property("api").toInt(), expectedAPI);

#if QT_CONFIG(opengl)
    if (expectedAPI == QSGRendererInterface::OpenGL) {
        QCOMPARE(obj->property("shaderType").toInt(), int(QSGRendererInterface::GLSL));
        QVERIFY(view.openglContext());
        QSurfaceFormat format = view.openglContext()->format();
        QCOMPARE(obj->property("majorVersion").toInt(), format.majorVersion());
        QCOMPARE(obj->property("minorVersion").toInt(), format.minorVersion());
        QCOMPARE(obj->property("profile").toInt(), static_cast<int>(format.profile()));
        QCOMPARE(obj->property("renderableType").toInt(), static_cast<int>(format.renderableType()));
    }
#endif
}
Esempio n. 12
0
int main(int argc, char *argv[])
{
    //! [0]
    // Uncomment to turn on all the logging categories of Canvas3D
//    QString loggingFilter = QString("qt.canvas3d.info.debug=true\n");
//    loggingFilter += QStringLiteral("qt.canvas3d.rendering.debug=true\n")
//            + QStringLiteral("qt.canvas3d.rendering.warning=true\n")
//            + QStringLiteral("qt.canvas3d.glerrors.debug=true");
//    QLoggingCategory::setFilterRules(loggingFilter);
    //! [0]

    QGuiApplication app(argc, argv);

    QQuickView viewer;

    // The following are needed to make examples run without having to install the module
    // in desktop environments.
#ifdef Q_OS_WIN
    QString extraImportPath(QStringLiteral("%1/../../../../%2"));
#else
    QString extraImportPath(QStringLiteral("%1/../../../%2"));
#endif
    viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
                                                       QString::fromLatin1("qml")));

    viewer.setSource(QUrl("qrc:/main.qml"));

    viewer.setTitle(QStringLiteral("Textured and Lit Cube"));
    viewer.setResizeMode(QQuickView::SizeRootObjectToView);
    viewer.setColor("#fafafa");
    viewer.show();

    return app.exec();
}
Esempio n. 13
0
int main(int argc, char *argv[])
{
    // SailfishApp::main() will display "qml/template.qml", if you need more
    // control over initialization, you can use:
    //
    //   - SailfishApp::application(int, char *[]) to get the QGuiApplication *
    //   - SailfishApp::createView() to get a new QQuickView * instance
    //   - SailfishApp::pathTo(QString) to get a QUrl to a resource file
    //
    // To display the view, call "show()" (will show fullscreen on device).

    QGuiApplication *app = SailfishApp::application(argc, argv);

    QTranslator translator;
    translator.load(QLocale::system(), "ownNotes", "_", SailfishApp::pathTo("i18n").toLocalFile(), ".qm");
    app->installTranslator(&translator);
    QPython::registerQML();
    qmlRegisterType<DocumentHandler>("net.khertan.documenthandler", 1, 0, "DocumentHandler");
    QQuickView *view = SailfishApp::createView();
    view->setSource(SailfishApp::pathTo("qml/ownNotes.qml"));
    view->engine()->rootContext()->setContextProperty("VERSION", VERSION);
    view->show();

    return app->exec();
}
Esempio n. 14
0
int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);
    qmlRegisterType<FileReader>("org.qtproject.testapi", 1, 0, "FileReader");

    QQuickView view;
    app.setOrganizationName("Acomb Methodist Church");
    app.setOrganizationDomain("amc.com");
    app.setApplicationName("Church Calendar");
    #ifdef Q_OS_ANDROID
    NotificationClient *notificationClient = new NotificationClient(&view);

    view.engine()->rootContext()->setContextProperty(QLatin1String("notificationClient"),
                                                      notificationClient);

#endif
    FileReader *fileReader = new FileReader(&view);

    view.engine()->rootContext()->setContextProperty(QLatin1String("fileReader"),
	fileReader);
    view.engine()->addImportPath("/usr/share/qml/");
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl(QStringLiteral("qrc:/Views/Main.qml")));
    view.show();


    return app.exec();
}
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

#ifdef Q_OS_WIN
    // Force usage of OpenGL ES through ANGLE on Windows
    QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif

    // Register the map view for QML
    qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView");
    qmlRegisterUncreatableType<ArcGISSublayerListModel>("Esri.Samples", 1, 0, "ArcGISSublayerListModel", "ArcGISSublayerListModel is an uncreatable type");
    qmlRegisterType<ChangeSublayerVisibility>("Esri.Samples", 1, 0, "ChangeSublayerVisibilitySample");

    // Intialize application view
    QQuickView view;
    view.setResizeMode(QQuickView::SizeRootObjectToView);

    // Add the import Path
    view.engine()->addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));

    // Set the source
    view.setSource(QUrl("qrc:/Samples/Layers/ChangeSublayerVisibility/ChangeSublayerVisibility.qml"));

    view.show();

    return app.exec();
}
Esempio n. 16
0
int main(int argc, char* argv[])
{
   QGuiApplication app(argc,argv);
   qmlRegisterType<Connector>("Connector", 1, 0, "Connector");
   app.setOrganizationName("QtProject");\
   app.setOrganizationDomain("qt-project.org");\
   app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());\
   QQuickView view;\
   if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
       QSurfaceFormat f = view.format();\
       f.setProfile(QSurfaceFormat::CoreProfile);\
       f.setVersion(4, 4);\
       view.setFormat(f);\
   }\
   view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));\
   new QQmlFileSelector(view.engine(), &view);\
   view.setSource(QUrl("qrc:///demos/tweetsearch/tweetsearch.qml")); \
   view.setResizeMode(QQuickView::SizeRootObjectToView);\
   if (QGuiApplication::platformName() == QLatin1String("qnx") || \
         QGuiApplication::platformName() == QLatin1String("eglfs")) {\
       view.showFullScreen();\
   } else {\
       view.show();\
   }\
   return app.exec();\
}
Esempio n. 17
0
int main(int argc, char** argv)
{

    QCoreApplication::setOrganizationName("com.ubuntu.developer.mzanetti.kodimote");
    QCoreApplication::setApplicationName("kodimote");

    QGuiApplication application(argc, argv);

    // Load language file
    QString language = QLocale::system().bcp47Name();
    qDebug() << "got language:" << language;

    QTranslator qtTranslator;

    if(!qtTranslator.load("qt_" + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
        qDebug() << "couldn't load qt_" + language;
    }
    application.installTranslator(&qtTranslator);

    QTranslator translator;
    if (!translator.load(":/kodimote_" + language + ".qm")) {
        qDebug() << "Cannot load translation file" << "kodimote_" + language + ".pm";
    }
    application.installTranslator(&translator);


    Kodi::instance()->setDataPath(QDir::homePath() + "/.cache/com.ubuntu.developer.mzanetti.kodimote/");
    Kodi::instance()->eventClient()->setApplicationThumbnail("kodimote80.png");

    QQuickView *view = new QQuickView();

    Settings settings;
    UbuntuHelper helper(view, &settings);

    ProtocolManager protocols;

    MprisController controller(&protocols, &helper);
    Q_UNUSED(controller)


    view->setResizeMode(QQuickView::SizeRootObjectToView);

    view->engine()->setNetworkAccessManagerFactory(new NetworkAccessManagerFactory());

    view->setTitle("Kodimote");
    view->engine()->rootContext()->setContextProperty("kodi", Kodi::instance());

    view->engine()->rootContext()->setContextProperty("settings", &settings);
    view->engine()->rootContext()->setContextProperty("protocolManager", &protocols);
    view->setSource(QUrl("qrc:///qml/main.qml"));

    if(QGuiApplication::arguments().contains("--fullscreen")) {
        view->showFullScreen();
    } else {
//        view->resize(QSize(720, 1280));
        view->show();
    }

    return application.exec();
}
Esempio n. 18
0
int main(int argc, char *argv[])
{
    // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
    QApplication app(argc, argv);

    QQuickView viewer;
    // The following are needed to make examples run without having to install the module
    // in desktop environments.
#ifdef Q_OS_WIN
    QString extraImportPath(QStringLiteral("%1/../../../../%2"));
#else
    QString extraImportPath(QStringLiteral("%1/../../../%2"));
#endif
    viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
                                      QString::fromLatin1("qml")));
    QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);

    viewer.setTitle(QStringLiteral("QML Chart"));

    viewer.setSource(QUrl("qrc:/qml/qmlchart/main.qml"));
    viewer.setResizeMode(QQuickView::SizeRootObjectToView);
    viewer.show();

    return app.exec();
}
Esempio n. 19
0
int main(int argc, char **argv)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    QGuiApplication app(argc, argv);
#else
    QApplication app(argc, argv);
#endif

    app.setProperty("NoMStyle", QVariant(true));

    QDir::setCurrent(app.applicationDirPath());

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    QQuickView window;
#else
    QDeclarativeView window;
#endif
    window.setSource(QUrl("qrc:/main.qml"));
#ifdef __arm__
    window.showFullScreen();
#else
    window.show();
#endif

    return app.exec();
}
Esempio n. 20
0
int main(int argc, char **argv)
{
	QGuiApplication *app = SailfishApp::application(argc, argv);
	
    qmlRegisterType<Mainview>("harbour.monav", 1, 0, "Mainview");
    qmlRegisterType<TapMenu>("harbour.monav", 1, 0, "TapMenu");
    qmlRegisterType<MapPackages>("harbour.monav", 1, 0, "MapPackages");
    qmlRegisterType<Bookmarks>("harbour.monav", 1, 0, "Bookmarks");
    qmlRegisterType<PaintWidget>("harbour.monav", 1, 0, "PaintWidget");
    qmlRegisterType<WorldMapChooser>("harbour.monav", 1, 0, "WorldMapChooser");

	QQuickView *view = SailfishApp::createView();
	view->setSource(SailfishApp::pathTo("qml/Main.qml"));
	view->show();
	view->setResizeMode(QQuickView::SizeRootObjectToView);
	QObject *object = (QObject *) view->rootObject();
	
	Mainview *mainview = object->findChild<Mainview *>("mainview");
	mainview->init();
	
	app->connect( app, SIGNAL(aboutToQuit()), MapData::instance(), SLOT(cleanup()) );
	app->connect( app, SIGNAL(aboutToQuit()), RoutingLogic::instance(), SLOT(cleanup()) );
	app->connect( app, SIGNAL(aboutToQuit()), Logger::instance(), SLOT(cleanup()) );
	
	app->connect( app, SIGNAL(aboutToQuit()), mainview, SLOT(cleanup()) );

	return app->exec();
}
Esempio n. 21
0
void tst_qquickfocusscope::nested()
{
    QQuickView *view = new QQuickView;
    view->setSource(testFileUrl("test2.qml"));

    QQuickFocusScope *item1 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item1"));
    QQuickFocusScope *item2 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item2"));
    QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
    QQuickFocusScope *item4 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item4"));
    QQuickFocusScope *item5 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item5"));
    QVERIFY(item1 != 0);
    QVERIFY(item2 != 0);
    QVERIFY(item3 != 0);
    QVERIFY(item4 != 0);
    QVERIFY(item5 != 0);

    view->show();
    view->requestActivate();

    QTest::qWaitForWindowActive(view);
    QTRY_VERIFY(view == qGuiApp->focusWindow());

    QVERIFY(item1->hasActiveFocus() == true);
    QVERIFY(item2->hasActiveFocus() == true);
    QVERIFY(item3->hasActiveFocus() == true);
    QVERIFY(item4->hasActiveFocus() == true);
    QVERIFY(item5->hasActiveFocus() == true);
    delete view;
}
Esempio n. 22
0
int main(int argc, char *argv[])
{
    std::cout << "Have " << argc << " arguments:" << std::endl;
    for (int i = 0; i < argc; ++i) {
        std::cout << argv[i] << std::endl;
    }

    Client c;
    if (argc > 1) {
	c.doConnect();
    }

    QGuiApplication a(argc, argv);
    QQuickView view;

    QRCodeReader reader;
    view.engine()->rootContext()->setContextProperty("qrCodeReader", &reader);

    qmlRegisterType<QRCodeGenerator>("Tagger", 0, 1, "QRCodeGenerator");

    view.engine()->addImageProvider(QStringLiteral("qrcode"), new QRCodeImageProvider);
    view.engine()->addImageProvider(QStringLiteral("reader"), &reader);

    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl::fromLocalFile("qml/tagger.qml"));
    view.show();

    return a.exec();
}
Esempio n. 23
0
void ZLibrary::run(ZLApplication* aApp)
{
    if (ZLLanguageUtil::isRTLLanguage(ZLibrary::Language())) {
        qApp->setLayoutDirection(Qt::RightToLeft);
    }

    QString qml(QString::fromStdString(BaseDirectory + BOOKS_QML_FILE));
    HDEBUG("qml file" << qPrintable(qml));

    QQuickView* view = SailfishApp::createView();
    QQmlContext* root = view->rootContext();
    QSize screenSize(view->screen()->size());
    booksPPI =
#if defined(__i386__)
        (screenSize == QSize(1536,2048)) ? 330 : 300;
#elif defined(__arm__)
        (screenSize == QSize(540,960)) ? 245 : 290;
#else
#  error Unexpected architechture
#endif
    HDEBUG("screen" << screenSize << booksPPI << "dpi");
    root->setContextProperty("PointsPerInch", booksPPI);
    root->setContextProperty("MaximumHintCount", 1);

    view->setTitle(qtTrId("books-app-name"));
    view->setSource(QUrl::fromLocalFile(qml));
    view->show();
    HDEBUG("started");
    qApp->exec();
    HDEBUG("exiting...");
}
int main(int argc, char *argv[])
{
    // SailfishApp::main() will display "qml/template.qml", if you need more
    // control over initialization, you can use:
    //
    //   - SailfishApp::application(int, char *[]) to get the QGuiApplication *
    //   - SailfishApp::createView() to get a new QQuickView * instance
    //   - SailfishApp::pathTo(QString) to get a QUrl to a resource file
    //
    // To display the view, call "show()" (will show fullscreen on device).
    QCoreApplication::setOrganizationName("org");
    QCoreApplication::setOrganizationDomain("Sparkeyy");
    QCoreApplication::setApplicationName("harbour-spritradar");
    qmlRegisterType<Settings>("harbour.spritradar.Settings", 1,0, "Settings");

    QGuiApplication* app = SailfishApp::application(argc, argv);

    QQuickView* view = SailfishApp::createView();
    QObject::connect(view->engine(), SIGNAL(quit()), app, SLOT(quit()));
    view->rootContext()->setContextProperty("tankerkoenig_apikey", TANKERKOENIG_APIKEY); //Claim here: https://creativecommons.tankerkoenig.de/#register
    // has to be set as additional qmake argument to the project configuration (armv7hl, i486 and debug/release for both), like this: "TANKERKOENIG_APIKEY=<your_apikey>"
    view->setSource(SailfishApp::pathTo("qml/harbour-spritradar.qml"));
    view->show();

    return app->exec();
}
Esempio n. 25
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QQuickView view;
    view.setSource(QUrl("qrc:/qrc_example.qml"));
    view.show();
    return app.exec();
}
void tst_QQuickAccessible::hitTest()
{
    QQuickView *window = new QQuickView;
    window->setSource(testFileUrl("hittest.qml"));
    window->show();

    QAccessibleInterface *windowIface = QAccessible::queryAccessibleInterface(window);
    QVERIFY(windowIface);
    QAccessibleInterface *rootItem = windowIface->child(0);
    QRect rootRect = rootItem->rect();

    // check the root item from app
    QAccessibleInterface *appIface = QAccessible::queryAccessibleInterface(qApp);
    QVERIFY(appIface);
    QAccessibleInterface *itemHit = appIface->childAt(rootRect.x() + 200, rootRect.y() + 50);
    QVERIFY(itemHit);
    QCOMPARE(itemHit->rect(), rootRect);

    QAccessibleInterface *rootItemIface;
    for (int c = 0; c < rootItem->childCount(); ++c) {
        QAccessibleInterface *iface = rootItem->child(c);
        QString name = iface->text(QAccessible::Name);
        if (name == QLatin1String("rect1")) {
            // hit rect1
            QAccessibleInterface *rect1 = iface;
            QRect rect1Rect = rect1->rect();
            QAccessibleInterface *rootItemIface = rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10);
            QVERIFY(rootItemIface);
            QCOMPARE(rect1Rect, rootItemIface->rect());
            QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1"));

            // should also work from top level (app)
            QAccessibleInterface *app(QAccessible::queryAccessibleInterface(qApp));
            QAccessibleInterface *itemHit2(topLevelChildAt(app, rect1Rect.x() + 10, rect1Rect.y() + 10));
            QVERIFY(itemHit2);
            QCOMPARE(itemHit2->rect(), rect1Rect);
            QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
        } else if (name == QLatin1String("rect2")) {
            QAccessibleInterface *rect2 = iface;
            // FIXME: This is seems broken on OS X
            // QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100));
            QAccessibleInterface *rect20 = rect2->child(0);
            QVERIFY(rect20);
            QCOMPARE(rect20->text(QAccessible::Name), QLatin1String("rect20"));
            QPoint p = rect20->rect().bottomRight() + QPoint(20, 20);
            QAccessibleInterface *rect201 = rect20->childAt(p.x(), p.y());
            QVERIFY(rect201);
            QCOMPARE(rect201->text(QAccessible::Name), QLatin1String("rect201"));
            rootItemIface = topLevelChildAt(windowIface, p.x(), p.y());
            QVERIFY(rootItemIface);
            QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201"));

        }
    }

    delete window;
    QTestAccessibility::clearEvents();
}
Esempio n. 27
0
int main(int argc, char *argv[])
{
    QGuiApplication application(argc, argv);
    QQuickView view;
    view.setSource(QUrl("qrc:/corkboards.qml"));
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.show();
    return application.exec();
}
Esempio n. 28
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QGuiApplication* app = SailfishApp::application(argc, argv);

    qmlRegisterType<Creature>("harbour.morzyn", 1,0 , "Creature");
    qmlRegisterType<Player>("harbour.morzyn", 1,0 , "Player");
    qmlRegisterType<Game>("harbour.morzyn", 1,0 , "Game");
    qmlRegisterType<Scroll>("harbour.morzyn", 1,0 , "Scroll");
    qmlRegisterType<Statistics>("harbour.morzyn", 1,0 , "Statistics");
    qmlRegisterType<Library>("harbour.morzyn", 1,0 , "Library");

    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "harbour-morzyn", "morzyn");
    if (!settings.contains("fullscreen"))
        settings.setValue("fullscreen", QVariant((bool)true));
    if (!settings.contains("music"))
        settings.setValue("music", QVariant((bool)true));
    if (!settings.contains("sound"))
        settings.setValue("sound", QVariant((bool)true));


    qsrand ( time(NULL) );

    QString locale = QLocale::system().name();

    QTranslator translator;
    translator.load(QString("morzyn_") + locale.left(2).toLower(), SailfishApp::pathTo("translations").toString());
    app->installTranslator(&translator);

    GameService gs;
    Game g;
    Constants c;
    c.HCOUNT = 10;
    c.VCOUNT = 10;
    Library library;
    Statistics s;

    gs.setGame(&g);
    gs.setConstants(&c);
    gs.setLibrary(&library);
    gs.setStatistics(&s);
    gs.setSettings(&settings);

    QQuickView* view = SailfishApp::createView();
    view->rootContext()->setContextProperty("gameService", &gs);
    view->rootContext()->setContextProperty("game", &g);
    view->rootContext()->setContextProperty("library", &library);
    view->rootContext()->setContextProperty("statistics", &s);
    view->rootContext()->setContextProperty("os", QVariant("sailfish"));
    view->rootContext()->setContextProperty("hCount", QVariant(c.HCOUNT));
    view->rootContext()->setContextProperty("vCount", QVariant(c.VCOUNT));
    view->rootContext()->setContextProperty("version", QVariant("0.7.17"));
    view->setTitle("Morzyn v0.7.17");
    view->setSource(SailfishApp::pathTo("qml/morzyn.qml"));
    view->show();
    
    return app->exec();
}
Esempio n. 29
0
void HtmlEditor::on_actionTextShadow_triggered()
{
    QQuickView* view = new QQuickView(QUrl::fromLocalFile(qmlFilePath("text_shadow.qml")));
    view->setTitle(tr("Text Shadow"));
    view->setColor(palette().window().color());
    connect(view->rootObject(), SIGNAL(accepted(QString)), SLOT(formatTextShadow(QString)));
    connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
    view->show();
}
Esempio n. 30
0
int main(int argc, char *argv[])
{
    // QLoggingCategory::setFilterRules(QLatin1String("*.debug=false"));

    qmlRegisterUncreatableType<qml::DataRepositoryObject>("harbour.twablet", 1, 0, "DataRepository", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::IModel>("harbour.twablet", 1, 0, "Model", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::AccountObject>("harbour.twablet", 1, 0, "Account", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::LayoutObject>("harbour.twablet", 1, 0, "Layout", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::QueryTypeObject>("harbour.twablet", 1, 0, "QueryType", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::TweetObject>("harbour.twablet", 1, 0, "Tweet", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::QuotedTweetObject>("harbour.twablet", 1, 0, "QuotedTweet", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::UserObject>("harbour.twablet", 1, 0, "User", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::MediaObject>("harbour.twablet", 1, 0, "Media", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::MediaModel>("harbour.twablet", 1, 0, "MediaModel", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<qml::IQueryItem>("harbour.twablet", 1, 0, "QueryItem", QLatin1String("Uncreatable"));
    qmlRegisterUncreatableType<Info>("harbour.twablet", 1, 0, "Info", QLatin1String("Uncreatable"));
    qmlRegisterType<qml::TwitterAuthentification>("harbour.twablet", 1, 0, "TwitterAuthentification");
    qmlRegisterType<qml::AccountModel>("harbour.twablet", 1, 0, "AccountModel");
    qmlRegisterType<qml::AccountSelectionModel>("harbour.twablet", 1, 0, "AccountSelectionModel");
    qmlRegisterType<qml::LayoutModel>("harbour.twablet", 1, 0, "LayoutModel");
    qmlRegisterType<qml::TweetModel>("harbour.twablet", 1, 0, "TweetModel");
    qmlRegisterType<qml::QueryTypeModel>("harbour.twablet", 1, 0, "QueryTypeModel");
    qmlRegisterType<qml::DescriptionFormatter>("harbour.twablet", 1, 0, "DescriptionFormatter");
    qmlRegisterType<qml::TweetFormatter>("harbour.twablet", 1, 0, "TweetFormatter");
    qmlRegisterType<qml::QuotedTweetFormatter>("harbour.twablet", 1, 0, "QuotedTweetFormatter");
    qmlRegisterType<qml::UserModel>("harbour.twablet", 1, 0, "UserModel");
    qmlRegisterType<qml::TweetQueryItem>("harbour.twablet", 1, 0, "TweetQueryItem");
    qmlRegisterType<qml::UserQueryItem>("harbour.twablet", 1, 0, "UserQueryItem");
    qmlRegisterType<qml::TweetListQueryWrapperObject>("harbour.twablet", 1, 0, "TweetListQuery");
    qmlRegisterType<qml::UserListQueryWrapperObject>("harbour.twablet", 1, 0, "UserListQuery");
    qmlRegisterType<qml::StatusUpdateQueryWrapperObject>("harbour.twablet", 1, 0, "StatusUpdateQuery");
    qmlRegisterType<qml::TweetSpecificQueryWrapperObject>("harbour.twablet", 1, 0, "TweetQuery");
    qmlRegisterType<qml::UserSpecificQueryWrapperObject>("harbour.twablet", 1, 0, "UserQuery");
    qmlRegisterSingletonType<qml::DataRepositoryObject>("harbour.twablet", 1, 0, "Repository",
                                                          [](QQmlEngine *e, QJSEngine *) -> QObject * {
        return new qml::DataRepositoryObject(e);
    });
    qmlRegisterSingletonType<Info>("harbour.twablet", 1, 0, "INFO",
                                   [](QQmlEngine *e, QJSEngine *) -> QObject * {
        return new Info(e);
    });
    qmlRegisterSingletonType<NetworkMonitor>("harbour.twablet", 1, 0, "NetworkMonitor",
                                             [](QQmlEngine *e, QJSEngine *) -> QObject * {
        return new NetworkMonitor(e);
    });

#ifndef DESKTOP
    return SailfishApp::main(argc, argv);
#else
    QGuiApplication app {argc, argv};
    QQuickView view {};
    view.setSource(QUrl(QLatin1String("qrc:/qml/harbour-twablet.qml")));
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.show();
    return app.exec();
#endif
}