示例#1
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QQuickView viewer;

    PackageManager *pm = new PackageManager(&viewer);

    QDeclarativeContext *context = viewer.rootContext();
    context->setContextProperty("initialstate", "mainview");
    context->setContextProperty("mainWindow", &viewer);
    viewer.engine()->addImageProvider(QLatin1String("icons"), new IconProvider);
    viewer.engine()->addImportPath("/usr/lib/qt5/imports");

    qmlRegisterType<Package>("Package", 1,0, "Package");
    qmlRegisterType<PackageGroup>("Package", 1,0, "PackageGroup");
    qmlRegisterType<PackageMarkings>("Package", 1, 0, "PackageMarkings");
    qmlRegisterType<Repository>("Repository", 1,0, "Repository");

    viewer.setMainQmlFile(QLatin1String("qml/package-manager/main.qml"));

    viewer.setOrientation(QQuickView::ScreenOrientationAuto);

    viewer.showExpanded();

    return app.exec();
}
SFAbstractApplicationUI::SFAbstractApplicationUI(bb::cascades::Application *app) : QObject(app) {

	//register meta types for SF classes and enums
	sfRegisterMetaTypes();

	//Setup SFDC connection info
	SFAccountManager::setClientId(SFRemoteAccessConsumerKey);
	SFAccountManager::setRedirectUri(SFOAuthRedirectURI);
	//In addition, you can set up scope for your token like below.
	/*
	QList<QString> scopes;
	scopes.append("api");
	SFAccountManager::setScopes(scopes);
	*/

	//setup API objects
	SFRestAPI::instance()->setApiVersion(SFDefaultRestApiVersion);

	//Expose API objects to QML
	QDeclarativeEngine *engine = QmlDocument::defaultDeclarativeEngine();
	QDeclarativeContext *context = engine ? engine->rootContext() : NULL;
	if (context) {
		context->setContextProperty("SFAccountManager", SFAccountManager::instance());
		context->setContextProperty("SFAuthenticationManager", SFAuthenticationManager::instance());
		context->setContextProperty("SFRestAPI", SFRestAPI::instance());
	} else {
		sfWarning() << "[SFAbstractApplicationUI] Failed to grab shared QML declarative engine. SF APIs may not be accessible in QML.";
	}

	//connect some slots
	connect(app, SIGNAL(aboutToQuit()), SFAuthenticationManager::instance(), SLOT(onAboutToQuit()));
	connect(app, SIGNAL(fullscreen()), SFAuthenticationManager::instance(), SLOT(onAppStart()));
}
示例#3
0
void PropertyEditor::NodeType::setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditor *propertyEditor)
{
    if (!fxObjectNode.isValid())
        return;

    QDeclarativeContext *ctxt = m_view->rootContext();

    if (fxObjectNode.isValid()) {
        foreach (const PropertyName &propertyName, fxObjectNode.modelNode().metaInfo().propertyNames())
            createPropertyEditorValue(fxObjectNode, propertyName, fxObjectNode.instanceValue(propertyName), &m_backendValuesPropertyMap, propertyEditor);

        // className
        PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value("className")));
        if (!valueObject)
            valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap);
        valueObject->setName("className");
        valueObject->setModelNode(fxObjectNode.modelNode());
        valueObject->setValue(fxObjectNode.modelNode().simplifiedTypeName());
        QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant)));
        m_backendValuesPropertyMap.insert("className", QVariant::fromValue(valueObject));

        // id
        valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value("id")));
        if (!valueObject)
            valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap);
        valueObject->setName("id");
        valueObject->setValue(fxObjectNode.id());
        QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant)));
        m_backendValuesPropertyMap.insert("id", QVariant::fromValue(valueObject));

        // anchors
        m_backendAnchorBinding.setup(QmlItemNode(fxObjectNode.modelNode()));

        ctxt->setContextProperty("anchorBackend", &m_backendAnchorBinding);

        ctxt->setContextProperty("transaction", m_propertyEditorTransaction.data());

        m_contextObject->setSpecificsUrl(qmlSpecificsFile);

        m_contextObject->setStateName(stateName);
        if (!fxObjectNode.isValid())
            return;
        ctxt->setContextProperty("propertyCount", QVariant(fxObjectNode.modelNode().properties().count()));

        m_contextObject->setIsBaseState(fxObjectNode.isInBaseState());
        m_contextObject->setSelectionChanged(false);

        m_contextObject->setSelectionChanged(false);

        NodeMetaInfo metaInfo = fxObjectNode.modelNode().metaInfo();

        if (metaInfo.isValid()) {
            m_contextObject->setMajorVersion(metaInfo.majorVersion());
            m_contextObject->setMinorVersion(metaInfo.minorVersion());
        } else {
            m_contextObject->setMajorVersion(-1);
            m_contextObject->setMinorVersion(-1);
        }

    } else {
示例#4
0
void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine)
{
    ProjectExplorerPlugin *pePlugin = ProjectExplorer::ProjectExplorerPlugin::instance();
    m_sessionModel = new SessionModel(pePlugin->session(), this);
    m_projectModel = new ProjectModel(pePlugin, this);

    QDeclarativeContext *ctx = engine->rootContext();
    ctx->setContextProperty("sessionList", m_sessionModel);
    ctx->setContextProperty("projectList", m_projectModel);
    ctx->setContextProperty("projectWelcomePage", this);
}
示例#5
0
void
ProcessMethodView::OnCreate( const adportable::Configuration& config )
{
    *pConfig_ = config;

    std::wstring xml = config.xml();

    pugi::xml_document dom;
    pugi::xml_parse_result result;

    if ( ! ( result = dom.load( pugi::as_utf8( xml ).c_str() ) ) )
        return;

    qmlRegisterType< CentroidMethodModel >( "com.scienceliaison.qml", 1, 0, "CentroidModel" );
	// qmlRegisterType< IsotopeMethodModel > ( "com.scienceliaison.qml", 1, 0, "IsotopeModel" );
    qmlRegisterType< ElementalCompModel > ( "com.scienceliaison.qml", 1, 0, "ElementalCompModel" );
	// qmlRegisterType< MSCalibrateModel > ( "com.scienceliaison.qml", 1, 0, "MSCalibrateModel" );

    QDeclarativeContext * ctx = rootContext();
    ctx->setContextProperty( "configXML", qtwrapper::qstring::copy( xml ) );
    ctx->setContextProperty( "centroidModel", pCentroidModel_.get() );
	// ctx->setContextProperty( "isotopeModel", pIsotopeModel_.get() );
    ctx->setContextProperty( "elementalCompModel", pElementalCompModel_.get() );
	// ctx->setContextProperty( "msCalibrateModel", pMSCalibrateModel_.get() );
    setResizeMode( QDeclarativeView::SizeRootObjectToView );

#if defined DEBUG && 0
    do {
      std::ofstream of( "/Users/thondo/src/qtplatz/config.xml" );
      dom.save( of );
    } while(0);
#endif

    QString qmlpath;
#ifdef Q_OS_MAC
    qmlpath = QCoreApplication::applicationDirPath() + "/../Resources";
#else
    qmlpath = QCoreApplication::applicationDirPath() + "/../share";
#endif

    // engine()->addImportPath( QCoreApplication::applicationDirPath() + "/../imports" );
    // QML_IMPORT_PATH

    pugi::xpath_node node = dom.select_single_node( "//Component[@type='qml']" );
    if ( node ) {
        QString source = qmlpath + node.node().attribute( "QUrl" ).value();
        setSource( QUrl::fromLocalFile( source ) );

        QList< QDeclarativeError > errors = this->errors();
        for ( QList< QDeclarativeError >::const_iterator it = errors.begin(); it != errors.end(); ++it )
            QMessageBox::warning( this, "QDeclarativeError", it->toString() + " file: " + source );
    }
}
示例#6
0
文件: meetv.cpp 项目: RobertMe/MeeTV
void MeeTv::_initViewer()
{
    QDeclarativeContext *context = m_viewer.rootContext();
    context->setContextProperty("dvrEntriesModel", m_dvrEntriesModel);
    context->setContextProperty("htsp", m_htsp);
    context->setContextProperty("meetv", this);
    context->setContextProperty("settings", m_settings);
    context->setContextProperty("tagModel", m_tagModel);

    m_viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    m_viewer.setMainQmlFile(QLatin1String("qml/MeeTV/main.qml"));
}
示例#7
0
文件: main.cpp 项目: chegestar/arca
QTM_USE_NAMESPACE

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QCoreApplication::setOrganizationName("Synchroma");
    QCoreApplication::setOrganizationDomain("synchroma.com.au");
    QCoreApplication::setApplicationName("Arca");

    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QmlApplicationViewer viewer;

    QDeclarativeEngine *engine = viewer.engine();
    QDeclarativeContext *context = engine->rootContext();

    DBSession session;
    session.setConsumerKey(DROPBOX_APP_KEY);
    session.setConsumerSecret(DROPBOX_APP_SECRET);

    // Have the REST client visible in the QML
    DBRestClient restClient(session);
    context->setContextProperty("restClient", &restClient);

    // TESTING
    context->setContextProperty("param", QString(argv[1]));

    // TESTING
    qDebug() << "temp dir: " << QDir::tempPath();
    qDebug() << "home dir: " << QDir::homePath();
    qDebug() << "current dir: " << QDir::currentPath();

    QServiceManager serviceManager(QService::SystemScope);
    QStringList stringList = serviceManager.findServices();
    foreach (QString interfaceName, stringList)
        qDebug() << "service interface: " << interfaceName;

    QList<QServiceInterfaceDescriptor> descriptors = serviceManager.findInterfaces();
    for (int i=0; i<descriptors.count(); i++)
    {
        QString service = descriptors[i].serviceName();

        if (descriptors[i].scope() == QService::SystemScope)
            service += " (system)";

        qDebug() << "service: " << service;
    }

    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/arca/main.qml"));
    viewer.showExpanded();

    return app->exec();
}
示例#8
0
IconView::IconView(QAbstractItemModel *model, QWidget *parent) :
    QFrame(parent), m_model(model)
{
    QDeclarativeView *view = new QDeclarativeView(this);
    QDeclarativeContext *ctxt = view->rootContext();
    ctxt->setContextProperty("orderModel", m_model);
    ctxt->setContextProperty("sizeData", this);
    view->setSource(QUrl("qrc:IconView.qml"));
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->addWidget(view);
    setLayout(mainLayout);
}
示例#9
0
文件: main.cpp 项目: Hnz/qtmc
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    // Load settings
    QSettings settings;
    settings.setValue("dbtype", "QSQLITE");
    settings.setValue("dbname", "/tmp/testdb.sqlite3");

    // Translator
    QString translationfile = QString("qtmc_nl");
    QTranslator translator;
    if (!translator.load(translationfile) &&
            !translator.load(translationfile,
                             app.applicationDirPath() +  "../lib/qtmc/translations/")) {
        qWarning() << "Failed to load translation file";
    }
    app.installTranslator(&translator);

    // Open database
    QSqlDatabase db = QSqlDatabase::addDatabase(settings.value("dbtype").toString());
    db.setDatabaseName(settings.value("dbname").toString());
    //db.setDatabaseName(":memory:");

    // Check if database is open
    if (!db.open()) {
        qWarning() << app.tr("Cannot open database") << settings.value("dbname");
        return 1;
    }

    // Create mediadb
    MediaDB *mediadb = new MediaDB();
    qDebug() << app.tr("QtMC version") << QString(QTMC_VERSION);
    qDebug() << app.tr("MediaDB version") << mediadb->version();

    // Create qml-view and connect quit-signal
    QDeclarativeView *view = new QDeclarativeView;
    QObject::connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));

    // Expose c++ object to qml
    QDeclarativeContext *ctxt = view->rootContext();
    ctxt->setContextProperty("MediaDB", mediadb);
    ctxt->setContextProperty("Settings", &settings);

    // Run view
    view->setSource(QUrl(app.applicationDirPath() + "/../lib/qtmc/qml/QtMC.qml"));
    view->show();
    //view->showFullScreen();

    return app.exec();
}
示例#10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_mapModel(&m_fieldModel, this)
{
    ui->setupUi(this);
    MapLoader mapLoader(&m_mapModel, &m_fieldModel);
    mapLoader.loadMap("/home/guillaume/Workspace/Test_QGraphicsMap/1.map");
    this->ui->graphicsView->setSource(QUrl("qrc:/qml/qml/main.qml"));
    QDeclarativeContext *ctxt = this->ui->graphicsView->rootContext();
    ctxt->setContextProperty("MapModel", &m_mapModel);
    ctxt->setContextProperty("FieldModel", &m_fieldModel);
    //MapModel::getInstance()->debug();

}
示例#11
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    // Register QML bindings fo DrumEngine and TouchEvents
#ifdef Q_OS_SYMBIAN
    qmlRegisterType<DrumEngine>("DrumEngine", 1,0, "DrumEngine");
#endif
    qmlRegisterType<TouchEvents>("TouchEvents", 1,0, "TouchEvents");

    QmlViewer viewer;
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);

    // Check for VGA resolution and inform QML. Needed for some
    // gfx layouting on on Symbian devices with VGA resolution (E6).
    QDesktopWidget *desktop = QApplication::desktop();
    const QRect screenRect = desktop->screenGeometry();
    QDeclarativeContext* context = viewer.rootContext();
    if (screenRect.width() == 640 && screenRect.height() == 480) {
        context->setContextProperty("screenVGA", true);
    } else {
        context->setContextProperty("screenVGA", false);
    }

    // Provide information whether running in simulator. Used in Pad.qml.
#ifdef QT_SIMULATOR
    context->setContextProperty("simulator", true);
#else
    context->setContextProperty("simulator", false);
#endif

    // Select the main.qml according to platform.
#ifdef Q_OS_SYMBIAN
    viewer.setMainQmlFile(QLatin1String("qml/symbian/main.qml"));
#else
    viewer.setMainQmlFile(QLatin1String("qml/harmattan/main.qml"));
#endif

    // Enable OpenGL rendering
    QGLFormat fmt = QGLFormat::defaultFormat();
    fmt.setDirectRendering(true);
    fmt.setDoubleBuffer(true);
    QGLWidget *glWidget = new QGLWidget(fmt);
    viewer.setViewport(glWidget);
    viewer.showFullScreen();

    return app.exec();
}
示例#12
0
int main(int argc, char **argv)
{
    QApplication a(argc, argv);

    QDeclarativeView v;

    v.setAttribute(Qt::WA_OpaquePaintEvent);
    v.setAttribute(Qt::WA_NoSystemBackground);
    v.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);        v.viewport()->setAttribute(Qt::WA_NoSystemBackground);

    QDeclarativeContext *c = v.rootContext();
    c->setContextProperty("fileBrowserUtils", new Utils);

    if (QFile::exists("main.qml"))
        v.setSource(QUrl::fromLocalFile("main.qml"));
    else
        v.setSource(QUrl("qrc:/qml/main.qml"));

    if (QCoreApplication::arguments().contains("-fullscreen")) {
        qDebug() << Q_FUNC_INFO << "Starting in fullscreen mode";
        v.showFullScreen();
    } else {
        qDebug() << Q_FUNC_INFO << "Starting in windowed mode";
        v.show();
    }

    return a.exec();
}
示例#13
0
InitQML::InitQML(QWidget *MainW,QWidget *parent) :
  QDeclarativeView(parent),mainW(MainW)
{
  resetDone = false;
  QPalette pal = palette();

  pal.setColor(QPalette::Window,QColor("black"));
  // setAutoFillBackground(true);
  pal.setColor( QPalette::Background, Qt::transparent);
  setPalette(pal);
  rip = new ResourceImageProvider(QDeclarativeImageProvider::Pixmap);
  rip->mainW = mainW;
  engine()->addImageProvider("background",rip); 
  setSource(QUrl("qrc:/qml/init.qml"));
  QDeclarativeContext *context = rootContext();
  context->setContextProperty("backgroundColor", 
			      QPalette().color(QPalette::Window));


  QGraphicsObject *object = this->rootObject();
  
  QObject *rect = object->findChild<QObject*>("imageRect");
  /*
  if (!rect) 
    qDebug() <<"Image Rect not found !!!!!!" << __FILE__ << __LINE__;
  else {
    rect->setProperty("src",);
  */
}
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"));
}
示例#15
0
int main(int argc, char* argv[])
      {
      QApplication app(argc, argv);

      QWidget wi(0);
      PDPI = wi.logicalDpiX();    // physical resolution
      DPI  = PDPI;                // logical drawing resolution
      DPMM = DPI / INCH;          // dots/mm

      runtime = new Runtime;

      MScore::init();
      seq = new Seq;
      if (!seq->init()) {
            printf("cannot initialize sequencer\n");
            exit(-1);
            }

      qmlRegisterType<ScoreView>("MuseScore", 1, 0, "ScoreView");

      QDeclarativeView view;
      view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
      QDeclarativeContext* ctxt = view.rootContext();
      ctxt->setContextProperty(QLatin1String("runtime"), runtime);

      // registering only for exposing the Runtime::Orientation enum
      qmlRegisterUncreatableType<Runtime>("Qt", 4, 7, "Orientation", QString());
      qmlRegisterUncreatableType<Runtime>("QtQuick", 1, 0, "Orientation", QString());

      view.setSource(QUrl("qrc:/mplayer.qml"));
      view.show();
      return app.exec();
      }
示例#16
0
int main(int argc, char **argv)
{
    qRegisterMetaType<QVector<QFileInfo> >();
    qmlRegisterType<DirModel>("FBrowser", 1, 0, "DirModel");
    QApplication a(argc, argv);

    QDeclarativeView v;

    QDeclarativeEngine *e = v.engine();
    e->addImageProvider(QLatin1String("nemoThumbnail"), new FileThumbnailImageProvider);

    QDeclarativeContext *c = v.rootContext();
    c->setContextProperty("fileBrowserUtils", new Utils);

    if (QFile::exists("main.qml"))
        v.setSource(QUrl::fromLocalFile("main.qml"));
    else
        v.setSource(QUrl("qrc:/qml/main.qml"));

    if (QCoreApplication::arguments().contains("-fullscreen")) {
        qDebug() << Q_FUNC_INFO << "Starting in fullscreen mode";
        v.showFullScreen();
    } else {
        qDebug() << Q_FUNC_INFO << "Starting in windowed mode";
        v.show();
    }

    return a.exec();
}
示例#17
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());

    qmlRegisterType<FeedHelper>("FeedHelper", 1, 0, "FeedHelper");

    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer->setMainQmlFile(QLatin1String("qml/newsg/main.qml"));

    QDeclarativeContext *ctxt = viewer->rootContext();

    ShareHelper sh;
    ctxt->setContextProperty("Share", &sh);

    viewer->setAttribute(Qt::WA_OpaquePaintEvent);
    viewer->setAttribute(Qt::WA_NoSystemBackground);
    viewer->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
    viewer->viewport()->setAttribute(Qt::WA_NoSystemBackground);
    viewer->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

    viewer->showExpanded();

    return app->exec();
}
示例#18
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QDeclarativeView view;
    QDeclarativeContext *context = view.rootContext();
    context->setContextProperty("backgroundColor",
                                QColor(Qt::yellow));

    KDeclarative kdeclarative;
    kdeclarative.setDeclarativeEngine(view.engine());
    kdeclarative.initialize();
    //binds things like kconfig and icons
    kdeclarative.setupBindings();

    //If all gone well, the QScriptEngine has been extracted
    QScriptEngine *scriptEngine = kdeclarative.scriptEngine();
    Q_ASSERT(scriptEngine);

    //Bind a test QObject in the "QtScript way"
    QScriptValue global = scriptEngine->globalObject();
    TestObject *testObject = new TestObject();
    QScriptValue testValue = scriptEngine->newQObject(testObject);
    testValue.setScope(global);
    global.setProperty("testObject", testValue);

    view.setSource(QUrl::fromLocalFile("test.qml"));
    view.show();

    return app.exec();
}
示例#19
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    qDebug() << "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
    QApplication *app = MDeclarativeCache::qApplication(argc, argv);
    app->setOrganizationName("frals");
    app->setOrganizationDomain("frals.se");
    app->setApplicationName("lpmcustomizer");

    QFont font = QFont("Nokia Pure Text Light");
    app->setFont(font);

    QDeclarativeView *view = MDeclarativeCache::qDeclarativeView();
    QDeclarativeContext *ctx = view->rootContext();

    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    view->setInputMethodHints(Qt::ImhNoPredictiveText);

    qmlRegisterType<GalleryItem>("LPM", 1, 0, "GalleryItem");

    PlatformIntegration *p = new PlatformIntegration(ctx);
    ImageGenerator *ig = new ImageGenerator();
    ImageSaver *is = new ImageSaver(ig);

    QObject::connect(is, SIGNAL(imageSaved(QString)), p, SLOT(onImageSaved(QString)));

    view->engine()->addImageProvider(QString("logocreator"), ig);

    ctx->setContextProperty("platform", p);
    ctx->setContextProperty("imageSaver", is);

    p->updateGallery();

    QObject::connect(view->engine(), SIGNAL(quit()), app, SLOT(quit()));

//    QString pathInInstallDir = QCoreApplication::applicationDirPath()
//            + QLatin1String("/../") + "qml/lpmcustomizer";

    view->setSource(QUrl("qrc:/qml/main.qml"));
    view->showFullScreen();

//    QmlApplicationViewer viewer;
//    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
//    viewer.setMainQmlFile(QLatin1String("qml/LPMCustomizer/main.qml"));
//    viewer.showExpanded();

    return app->exec();
}
void tst_qsganimatedimage::progressAndStatusChanges()
{
    TestHTTPServer server(14449);
    QVERIFY(server.isValid());
    server.serveDirectory(SRCDIR "/data");

    QDeclarativeEngine engine;
    QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }";
    QDeclarativeContext *ctxt = engine.rootContext();
    ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/stickman.gif"));
    QDeclarativeComponent component(&engine);
    component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
    QSGImage *obj = qobject_cast<QSGImage*>(component.create());
    QVERIFY(obj != 0);
    QVERIFY(obj->status() == QSGImage::Ready);
    QTRY_VERIFY(obj->progress() == 1.0);

    QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
    QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
    QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QSGImageBase::Status)));

    // Loading local file
    ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.gif"));
    QTRY_VERIFY(obj->status() == QSGImage::Ready);
    QTRY_VERIFY(obj->progress() == 1.0);
    QTRY_COMPARE(sourceSpy.count(), 1);
    QTRY_COMPARE(progressSpy.count(), 0);
    QTRY_COMPARE(statusSpy.count(), 0);

    // Loading remote file
    ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif");
    QTRY_VERIFY(obj->status() == QSGImage::Loading);
    QTRY_VERIFY(obj->progress() == 0.0);
    QTRY_VERIFY(obj->status() == QSGImage::Ready);
    QTRY_VERIFY(obj->progress() == 1.0);
    QTRY_COMPARE(sourceSpy.count(), 2);
    QTRY_VERIFY(progressSpy.count() > 1);
    QTRY_COMPARE(statusSpy.count(), 2);

    ctxt->setContextProperty("srcImage", "");
    QTRY_VERIFY(obj->status() == QSGImage::Null);
    QTRY_VERIFY(obj->progress() == 0.0);
    QTRY_COMPARE(sourceSpy.count(), 3);
    QTRY_VERIFY(progressSpy.count() > 2);
    QTRY_COMPARE(statusSpy.count(), 3);
}
void AlternatingListItem::setup(const QString& qmlFile) {
	QmlDocument* document = QmlDocument::create(qmlFile);
	QDeclarativeContext *derivedContext = new QDeclarativeContext(
			document->documentContext(), this);
	derivedContext->setContextProperty("_item", this);

	setRoot(document->createRootObject<Control>(derivedContext));
}
示例#22
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QApplication::setGraphicsSystem("opengl");

    QDeclarativeView* view = new QDeclarativeView();
    QDeclarativeTouchArea::registerQML();

    QGLFormat format = QGLFormat::defaultFormat();
    format.setSampleBuffers(false);

    QGLWidget* glWidget = new QGLWidget(format, view);
    glWidget->setAutoFillBackground(false);

    QDeclarativeContext* context = view->rootContext();

    AudioControl audioControl(context);
    audioControl.start();

    QMutex& waitAudio = audioControl.getStartLock();
    qDebug("main::waiting for Audio thread to initialize");
    waitAudio.lock();
    qDebug("main::Audio thread initialized, setting up qml window");
    waitAudio.unlock();

    QRect screenSize = app.desktop()->screenGeometry();
    context->setContextProperty("ScreenWidth", screenSize.width());
    context->setContextProperty("ScreenHeight", screenSize.height());
    context->setContextProperty("PlayControl", &audioControl);

    view->setViewport(glWidget);
    view->setSource(QUrl("qrc:/qml/funkeysynth/main.qml"));
    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    //qDebug("main::showing qml window");
    //view->showFullScreen();    
    view->showNormal();

    app.exec();

    delete view;

    return 0;
}
示例#23
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(new QApplication(argc, argv));
    QScopedPointer<QDeclarativeView> view(new QDeclarativeView);

    app.data()->setOrganizationName("cuteRadio");
    app.data()->setApplicationName("cuteRadio");
    
    qmlRegisterType<ActiveColorModel>("CuteRadioApp", 1, 0, "ActiveColorModel");
    qmlRegisterType<HomescreenModel>("CuteRadioApp", 1, 0, "HomescreenModel");
    qmlRegisterType<ScreenOrientationModel>("CuteRadioApp", 1, 0, "ScreenOrientationModel");
    qmlRegisterType<StreamExtractor>("CuteRadioApp", 1, 0, "StreamExtractor");
    
    qmlRegisterType<CuteRadio::CountriesModel>("CuteRadio", 1, 0, "CountriesModel");
    qmlRegisterType<CuteRadio::GenresModel>("CuteRadio", 1, 0, "GenresModel");
    qmlRegisterType<CuteRadio::LanguagesModel>("CuteRadio", 1, 0, "LanguagesModel");
    qmlRegisterType<CuteRadio::ResourcesRequest>("CuteRadio", 1, 0, "ResourcesRequest");
    qmlRegisterType<CuteRadio::SearchesModel>("CuteRadio", 1, 0, "SearchesModel");
    qmlRegisterType<CuteRadio::StationsModel>("CuteRadio", 1, 0, "StationsModel");
    
    QScopedPointer<Settings> settings(Settings::instance());
    Utils utils;
    
    if (!Settings::instance()->language().isEmpty()) {
        QTranslator translator;
        translator.load(QString("/opt/cuteradio/translations/%1").arg(Settings::instance()->language()));
        app.data()->installTranslator(&translator);
    }
    
    QDeclarativeContext *context = view.data()->rootContext();
    context->setContextProperty("Settings", Settings::instance());
    context->setContextProperty("Utils", &utils);
    context->setContextProperty("VERSION_NUMBER", VERSION_NUMBER);
    
    view.data()->setViewport(new QGLWidget);
    view.data()->setSource(QUrl::fromLocalFile("/opt/cuteradio/qml/main.qml"));
    view.data()->showFullScreen();

    QObject::connect(view.data()->engine(), SIGNAL(quit()), app.data(), SLOT(quit()));

    return app.data()->exec();
}
示例#24
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());

    //Launch Torrent manager instance
    MainTorrentManager manager;

    //Sharing data to js
    QDeclarativeContext *ctxt = viewer.data()->rootContext();
    ctxt->setContextProperty("qtorrentApp", &manager);
    ctxt->setContextProperty("miniInfo", &manager.miniInfo);
    ctxt->setContextProperty("qtorrentModel", &manager.jobs);

    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer->setMainQmlFile(QLatin1String("qml/QtHarmattanTorrent/main.qml"));
    viewer->showExpanded();

    return app->exec();
}
示例#25
0
文件: main.cpp 项目: chegestar/butaca
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QApplication *app;
#ifdef QT_SIMULATOR
    app = new QApplication(argc, argv);
#else
    app = MDeclarativeCache::qApplication(argc, argv);
#endif
    app->setApplicationName("Butaca");
    app->setOrganizationDomain("com.simonpena");
    app->setOrganizationName("simonpena");

    // Assume that strings in source files are UTF-8
    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));

    QString locale(QLocale::system().name());
    QTranslator translator;

    if (translator.load("l10n/butaca." + locale, ":/")) {
        app->installTranslator(&translator);
    } else {
        translator.load("l10n/butaca.en.qm", ":/");
        app->installTranslator(&translator);
    }

    QDeclarativeView *view;
#ifdef QT_SIMULATOR
    view = new QDeclarativeView();
#else
    view = MDeclarativeCache::qDeclarativeView();
#endif

    view->engine()->setOfflineStoragePath(
                QDesktopServices::storageLocation(QDesktopServices::DataLocation));

    QDeclarativeContext *context = view->rootContext();

    // The Movie Database uses "-" as the divider between language and country code
    context->setContextProperty("appLocale", locale.left(locale.indexOf("_")));
    Controller *controller = new Controller(context);

    view->engine()->setNetworkAccessManagerFactory(new CustomNetworkAccessManagerFactory);
    view->setSource(QUrl("qrc:/qml/main.qml"));
    view->showFullScreen();

    int result = app->exec();

    delete controller;
    delete view;
    delete app;

    return result;
}
static void alternative()
{
    // Alternatively, if we don't actually want to display main.qml:
//![1]
    QDeclarativeEngine engine;
    QDeclarativeContext *windowContext = new QDeclarativeContext(engine.rootContext());
    windowContext->setContextProperty("backgroundColor", QColor(Qt::yellow));

    QDeclarativeComponent component(&engine, "main.qml");
    QObject *window = component.create(windowContext);
//![1]
}
示例#27
0
QGraphicsItem *FolderPlugin::item()
{
   if (mFrameParentitem == NULL) {
       mFrameParentitem = new PlexyDesk::QmlDesktopWidget(QRectF(0.0, 0.0, 400.0, 400.0));
       QDeclarativeContext *context = mFrameParentitem->engine()->rootContext();
       const QString qmlData = mThemePack->hiddenQmlWidgets(QLatin1String("folderview"));

       qDebug() << Q_FUNC_INFO << qmlData;
       context->setContextProperty("DirSource", this);
       mFrameParentitem->setSourceUrl (QUrl(qmlData));
   }

   return mFrameParentitem;
}
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QDeclarativeView view;
    QDeclarativeContext *context = view.rootContext();
    context->setContextProperty("backgroundColor",
                                QColor(Qt::yellow));

    view.setSource(QUrl::fromLocalFile("main.qml"));
    view.show();

    return app.exec();
}
示例#29
0
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));

    QmlApplicationViewer viewer;
    QDeclarativeContext *ctxt = viewer.rootContext();
    ctxt->setContextProperty("KipptConnector", new KipptConnector());

    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/klippr/main.qml"));
    viewer.showExpanded();

    return app->exec();
}
示例#30
0
Cometd::Cometd(QObject *parent)
    : QObject(parent)
    , m_binding(new Binding(this))
{
    QDeclarativeEngine *engine = CometdPlugin::engine();
    QDeclarativeContext *rootContext = engine->rootContext();
    QDeclarativeContext *cometdContext = new QDeclarativeContext(rootContext);

    // Cometd-JavaScript depends on window.setTimeout and friends
    cometdContext->setContextProperty("timerWindow", new TimerWindow(this));

    // Allow the implementation to pass back the forward-function
    cometdContext->setContextProperty("binding", m_binding);

    cometdContext->setContextProperty("application", qApp);

    QDeclarativeComponent component(engine, QUrl("qrc:/cometd.qml"));
    QObject *implementation = component.create(cometdContext);
    cometdContext->setParent(implementation);
    implementation->setParent(this);

    QMetaObject::invokeMethod(implementation, "initialize");
}