Exemplo n.º 1
2
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    Controller controller; //
    QtQuick2ApplicationViewer viewer;

    viewer.rootContext()->
            setContextProperty("controller", &controller); //
    viewer.installEventFilter(&controller);
    viewer.setMainQmlFile(QStringLiteral("qml/QCloseConfirm/main.qml"));

    viewer.showExpanded();

    return app.exec();
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;

    //Logic logic(":/aggettivi.txt",  viewer.rootContext());
    Logic logic(":/indeterminativo",  viewer.rootContext());
    ExerciseVocabularyAnswer vocabulary(":/parole.txt");

    TwoSetExercise set;
    set.load("/tmp/sets.xml");

    set.print();
    viewer.rootContext()->setContextProperty("logic", &logic);
    viewer.rootContext()->setContextProperty("vocabulary", &vocabulary);

    viewer.rootContext()->setContextProperty("setexercise", &set);

    //viewer.addImportPath("qml/educazionik-framework/");
    viewer.setMainQmlFile(QStringLiteral("qml/educazionik-framework/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QLocalSocket localSocket;
    localSocket.connectToServer("bloggerQml", QIODevice::ReadOnly);
    if(localSocket.waitForConnected(5000))
    {
        // there is already an application running
        qDebug() << "Application is already running.";
        QMessageBox::information(0, QObject::tr("Erro"), QObject::tr("A aplicação já está a ser executada."), QMessageBox::Ok);
        return 0;
    }
    QLocalServer localServer;
    localServer.listen("bloggerQml");

    BloggerLoader bloggerloader;
    bloggerloader.loadBlogsFromFile();

    BloggerProxyModel model;
    model.setSourceModel(bloggerloader.model());

    Helper helper;
    QtQuick2ApplicationViewer viewer;
    viewer.rootContext()->setContextProperty("blogsModel", &model);
    viewer.rootContext()->setContextProperty("helper", &helper);
    viewer.rootContext()->setContextProperty("bloggerloader", &bloggerloader);

    viewer.setMainQmlFile(QStringLiteral("qml/blogerQML/main.qml"));
    viewer.showExpanded();

    int res = app.exec();
    bloggerloader.saveDB();
    return res;
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);

	QDir::setCurrent(QCoreApplication::applicationDirPath());

	App application;

	qmlRegisterType<App>("App", 1, 0, "App");
	qmlRegisterType<CollectionModel>("CollectionModel", 1, 0, "CollectionModel");
    qmlRegisterType<QStringListModel>("QStringListModel", 1, 0, "QStringListModel");

	QtQuick2ApplicationViewer viewer;
	viewer.rootContext()->setContextProperty("app", &application);
	viewer.rootContext()->setContextProperty("checkModeCpp", &application.getCheckMode());
	viewer.rootContext()->setContextProperty("dictionaryModeCpp", &application.getDictionaryMode());
	viewer.rootContext()->setContextProperty("rememberModeCpp", &application.getRememberMode());
	viewer.setMainQmlFile(QStringLiteral("qml/Learn/main.qml"));
	viewer.showExpanded();

	viewer.setIcon(QIcon(":/new/g/dictionary-icon.png"));
    viewer.setTitle("Learn");

    application.setWindow(&viewer);

    return app.exec();
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
    qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");

    Configuration m_configuration;
    SerialLink m_serialLink;
    MavLinkManager m_mavlink_manager;

    LinkManager m_gLinkManager;

    QtQuick2ApplicationViewer viewer;
    QtQuick2ApplicationViewer splashscreen;

    QString customPath = "Sqlite/OfflineStorage";
    QDir dir;
    if(dir.mkpath(QString(customPath))){
//        qDebug() << "Default path >> "+viewer.engine()->offlineStoragePath();
        viewer.engine()->setOfflineStoragePath(QString(customPath));
//        qDebug() << "New path >> "+viewer.engine()->offlineStoragePath();
    }
    // using as normal
//    viewer.setMainQmlFile(QStringLiteral("qml/gStabiSC/main.qml"));
    // using qml files form resources file, uncomment this to compile all qml file to .exe

    splashscreen.setSource(QUrl("qrc:/qml/gStabiSC/GSplashScreen.qml"));
    splashscreen.setFlags(Qt::FramelessWindowHint);
    splashscreen.setMinimumSize(QSize(1000,500));
    splashscreen.show();


    viewer.setSource(QUrl("qrc:/qml/gStabiSC/GMain.qml"));
    viewer.setTitle(QString("%1 %2").arg(APPLICATION_NAME).arg(APPLICATION_VERSION));
    viewer.setMinimumSize(QSize(APPLICATION_WIDTH,APPLICATION_HEIGHT));
    viewer.setMaximumSize(QSize(APPLICATION_WIDTH,APPLICATION_HEIGHT));

//    viewer.addImportPath("qrc:/qml/gStabiSC");
//    viewer.addImportPath("qrc:/qml/gStabiSC/Components");
//    viewer.addImportPath("qrc:/qml/gStabiSC/GDashboard");
//    viewer.addImportPath("qrc:/javascript/storage.js");

    viewer.rootContext()->setContextProperty("_configuration",&m_configuration);
    viewer.rootContext()->setContextProperty("_serialLink", &m_serialLink);
    viewer.rootContext()->setContextProperty("_mavlink_manager", &m_mavlink_manager);

    m_gLinkManager.connectLink(&m_serialLink,&m_mavlink_manager);

    QTimer::singleShot(3000, &splashscreen, SLOT(close()));
    QTimer::singleShot(3000, &viewer, SLOT(show()));

    return app.exec();
}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QtQuick2ApplicationViewer viewer;
    Hash hash(viewer.rootContext());

    viewer.rootContext()->setContextProperty("hash", &hash);
    viewer.setMainQmlFile(QStringLiteral("qrc:/qml/pasgen/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
Exemplo n.º 7
0
int main(int argc, char * argv[])
{
    qsrand(QTime::currentTime().msec());

    qmlRegisterType<QmlMapInterface>("DumbHome", 1, 0, "QmlMapInterface");
    qmlRegisterType<MapObjectQmlWrapper>("DumbHome", 1, 0, "MapObjectQmlWrapper");

    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qmlsrc/code-if-wanna-live/main.qml"));
    viewer.showExpanded();

    Map * const map = createMap();
    World world(map, new MapPhysics(*map));

    PlayerActionsQmlReceiver playerActionsQmlReceiver(world.getMap());
    viewer.rootContext()->setContextProperty("playerActionsReceiver", &playerActionsQmlReceiver);

    QmlMapInterface * const qmlMapInterface =
            viewer.rootObject()->findChild<QmlMapInterface*>("qmlMapInterface");

    if (qmlMapInterface != nullptr)
    {
        qmlMapInterface->setMap(world.getMap());
        world.getMapPhysics().addListener(*qmlMapInterface);
    }

    return app.exec();
}
Exemplo n.º 8
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    FishManager* fishManager = new FishManager(&app);

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/FishRandomizer/main.qml"));
    viewer.showExpanded();
    viewer.rootContext()->setContextProperty("fishManager",fishManager);
    qmlRegisterType<Fish>("Fishes",1,0,"FishObj");

    return app.exec();
}
Exemplo n.º 9
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

	CommHandler comm;
	ColorModel model;

    QtQuick2ApplicationViewer viewer;
	viewer.rootContext()->setContextProperty("comm", &comm);
	viewer.rootContext()->setContextProperty("model", &model);
    viewer.setMainQmlFile(QStringLiteral("qml/QtLight/main.qml"));
    viewer.showExpanded();

#ifdef Q_OS_UNIX
	qDebug() << "You are on Unix";
#endif
#ifdef Q_OS_WIN
	qDebug() << "You are on Windows";
#endif

    return app.exec();
}
Exemplo n.º 10
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QtQuick2ApplicationViewer viewer;

    VideosDatabase *db = new VideosDatabase;
    viewer.rootContext()->setContextProperty("videosDB", db);

    viewer.setMainQmlFile(QStringLiteral("qml/app/qtquick20/main.qml")); // MAINQML
    viewer.showFullScreen();

    return app.exec();
}
Exemplo n.º 11
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QtQuick2ApplicationViewer viewer;

    NestedListModel* platforms = new NestedListModel(new UPlatform);

    UPlatform* platform1 = createPlatform(platforms, 1);
    UPlatform* platform2 = createPlatform(platforms, 2);
    UPlatform* platform3 = createPlatform(platforms, 3);

    ListModel* devices1 = platform1->nestedModel();
    ListModel* devices2 = platform2->nestedModel();
    ListModel* devices3 = platform3->nestedModel();

    UDevice* device1 = createDevice(devices1, 1);
    UDevice* device2 = createDevice(devices2, 2);
    UDevice* device3 = createDevice(devices3, 3);

    ListModel* scenarios1 = device1->nestedModel();
    ListModel* scenarios2 = device2->nestedModel();
    ListModel* scenarios3 = device3->nestedModel();

    UScenario* scenario1 = createScenario(scenarios1, 1);
    UScenario* scenario2 = createScenario(scenarios2, 2);
    UScenario* scenario3 = createScenario(scenarios3, 3);

    ListModel* tasks1 = scenario1->nestedModel();
    ListModel* tasks2 = scenario2->nestedModel();
    ListModel* tasks3 = scenario3->nestedModel();

    UTask* taks1 = createTask(tasks1, 1);
    UTask* taks2 = createTask(tasks2, 2);
    UTask* taks3 = createTask(tasks3, 3);

    ListModel* conditions1 = taks1->nestedModel();
    ListModel* conditions2 = taks2->nestedModel();
    ListModel* conditions3 = taks3->nestedModel();

    createCondition(conditions1, 1);
    createCondition(conditions2, 2);
    createCondition(conditions3, 3);

    QQmlContext* ctxt = viewer.rootContext();
    ctxt->setContextProperty("platformsModel", platforms);

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

    return app.exec();
}
Exemplo n.º 12
0
int main(int argc, char *argv[])
{
	QCoreApplication::setOrganizationDomain("ecikowaty.com");
	QCoreApplication::setOrganizationName("ecikowaty");

	QApplication app(argc, argv);

	Settings settings;
	QtQuick2ApplicationViewer viewer;
	ingonline::AccountInfoProvider accountInfoProvider;

	AccountModel accountModel;
	QObject::connect(&accountInfoProvider, &ingonline::AccountInfoProvider::balanceDataUpdated,
					 &accountModel, &AccountModel::replaceWith);
	try
	{
		HistoryModel historyModel;
		QObject::connect(&accountInfoProvider, &ingonline::AccountInfoProvider::historyDataUpdated,
						 &historyModel, &HistoryModel::replaceWith);

		viewer.rootContext()->setContextProperty("accountInfoProvider", &accountInfoProvider);
		viewer.rootContext()->setContextProperty("accountModel", &accountModel);
		viewer.rootContext()->setContextProperty("historyModel", &historyModel);
		viewer.rootContext()->setContextProperty("settings", &settings);

		viewer.setMainQmlFile(QStringLiteral("qml/main.qml"));
		viewer.showExpanded();

		return app.exec();
	}
	catch (const std::runtime_error& e)
	{
		qCritical() << e.what();
		return 1;
	}

	return 0;
}
Exemplo n.º 13
0
int main(int argc, char *argv[]) {
	QGuiApplication app(argc, argv);

	Utility::registerTypes();
	qmlRegisterType<BarcodeObject>("KoboMan", 1, 0, "Barcode");
	qmlRegisterType<BarcodeScanner>("KoboMan", 1, 0, "BarcodeScanner");

	QtQuick2ApplicationViewer viewer;
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
	viewer.addImportPath(QStringLiteral("assets:/imports"));
#else
	viewer.addImportPath(QStringLiteral("imports"));
#endif
	qDebug() << viewer.engine()->importPathList();
	Utility::initialize(&viewer);
	Theme::initialize(Theme::androidHoloLight());
	BookListModel bookList;
	viewer.rootContext()->setContextProperty("BookList", &bookList);
	viewer.rootContext()->setContextProperty("Library", &Library::get());
	viewer.setMainQmlFile(QStringLiteral("qml/koboman/main.qml"));
	viewer.showExpanded();
	return app.exec();
}
Exemplo n.º 14
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QtQuick2ApplicationViewer viewer;

    QQmlEngine engine;
    QQmlComponent component(&engine, QUrl::fromLocalFile("qml/Playing/Player.qml"));
    QObject *object = component.create();

    viewer.rootContext()->setContextProperty("player", object);

    viewer.setMainQmlFile(QStringLiteral("qml/Playing/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
Exemplo n.º 15
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;

    qmlRegisterType<MindCell>("org.ginosoft.qmlcomponents", 1, 0, "MindCell");

    CellManager cellManager;
    viewer.rootContext()->setContextProperty("cellManager", &cellManager);

    viewer.setMainQmlFile(QStringLiteral("qml/DontMind/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
Exemplo n.º 16
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    Timekeeper timekeeper;
    QtQuick2ApplicationViewer viewer;

    timekeeper.nextWeek();
    timekeeper.addEvent(QStringLiteral("Jotain"), 2, 2);
    timekeeper.addEvent(QStringLiteral("Muuta"), 2, 3);
    timekeeper.prevWeek();

    viewer.rootContext()->setContextProperty("timekeeper", &timekeeper);
    viewer.setMainQmlFile(QStringLiteral("qml/timekeeper/main.qml"));
    viewer.setTitle(QStringLiteral("Timekeeper"));
    viewer.showExpanded();


    return app.exec();
}
Exemplo n.º 17
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QString filepath = app.arguments().value(1, "./why_are_you_reading_this.png");
    filepath = QDir().absoluteFilePath(filepath);
    Comic comic;
    if (QFile(filepath).exists()) {
        comic.load(QImage(filepath));
    } else {
        qDebug() << "File does not exist:" << filepath;
    }

    QtQuick2ApplicationViewer viewer;
    viewer.engine()->addImageProvider("comicimageprovider", new ComicImageProvider(comic));
    QQmlContext* context = viewer.rootContext();
    context->setContextProperty("comic", &comic);
    viewer.setMainQmlFile(QStringLiteral("qml/quick/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
Exemplo n.º 18
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    World world;
    for (int i = 0; i < 500; i++)
    {
        int x = qrand() % ((2500 + 1) - 0) + 0;
        int y = qrand() % ((2500 + 1) - 0) + 0;
        if(!world.ContainsCellAt(x, y))
            world.AddCell(x,y);
    }

    QtQuick2ApplicationViewer viewer;
    viewer.rootContext()->setContextProperty("world", &world);
    viewer.setMainQmlFile(QStringLiteral("qml/UI/main.qml"));
    viewer.showExpanded();

    auto rootobject = viewer.rootObject();
    QObject::connect(rootobject, SIGNAL(evolve()), &world, SLOT(Evolve()));

    return app.exec();
}
Exemplo n.º 19
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QString path(".");

    if (argc == 2) {
        path = argv[1];
    }

    QtQuick2ApplicationViewer viewer;

    GitProject git;
    git.setCurrentPath(path);

    QQmlContext *context = viewer.rootContext();
    context->setContextProperty("gGit", &git);

    viewer.setMainQmlFile(QStringLiteral("qml/GitGrown/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
Exemplo n.º 20
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    if (!createConnection())
        return 1;

    QtQuick2ApplicationViewer viewer;

    EditableSqlModel *editableModel = new EditableSqlModel;
    //initializeModel(editableModel);

//    editableModel->insertMetadata("/home/mengcong", 100,100,100);
//    editableModel->insertMetadata("/home/meng", 100,100,100);
//    editableModel->insertMetadata("/home/cong", 100,100,100);
//    editableModel->removeMetadata("/home/meng");
    editableModel->updateLastTime("/home/cong", 111);

    viewer.rootContext()->setContextProperty("mymodel", editableModel);

    viewer.setMainQmlFile(QStringLiteral("qml/testSqlQueryModel/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
Exemplo n.º 21
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QByteArray applicationName;
    applicationName = QFileInfo(QCoreApplication::applicationFilePath()).fileName().toUtf8();
    qputenv("APP_ID", applicationName);

    qmlRegisterType<WhiteListItem>("Ubuntu.Checkbox", 0, 1, "WhiteListItem");
    qmlRegisterType<TestItem>("Ubuntu.Checkbox", 0, 1, "TestItem");

    QtQuick2ApplicationViewer viewer;

    // Create our GuiEngine and hang it on QGuiApplication
    GuiEngine guiengine((QObject*)&app);

    // Register the applicationName with the QML runtime
    viewer.rootContext()->setContextProperty("applicationName", applicationName);

    // Register the GuiEngine with the QML runtime
    viewer.rootContext()->setContextProperty("guiEngine", &guiengine);

    // Initialise - connect to Plainbox
    guiengine.Initialise();


    // WhiteList Item Model Factory and placeholder model registered with QML engine
    WhiteListModelFactory whitelistfactory;
    viewer.rootContext()->setContextProperty("whitelistitemFactory",&whitelistfactory);

    /* We need a placeholder object here or the QML integration is unhappy
     * that this isnt a recognisable Qt object.
     */
    ListModel* whitelistmodel = new ListModel(new WhiteListItem, qApp);
    if (!whitelistmodel) {
        // Essentially we are likely out of memory here
        qDebug("Cannot create whitelist model");
        exit(1);
    }

    viewer.rootContext()->setContextProperty("whiteListModel", whitelistmodel);



    // Test Item Model Factory and placeholder model registered with QML engine
    TestItemModel testitemFactory;
    viewer.rootContext()->setContextProperty("testitemFactory",&testitemFactory);

    /* We need a placeholder object here or the QML integration is unhappy
     * that this isnt a recognisable Qt object.
     */
    ListModel* testlistmodel = new ListModel(new TestItem, qApp); //CreateTestListModel();
    if (!testlistmodel) {
        // Essentially we are likely out of memory here
        qDebug("Cannot create testlist model");
        exit(1);
    }

    viewer.rootContext()->setContextProperty("testListModel", testlistmodel);



    // We may not need this at all
    CommandTool cmdTool;
    viewer.rootContext()->setContextProperty("cmdTool", &cmdTool);



     // In the beginning, lets see if we need to resume
    bool resumeSession = false;

    QString previous = guiengine.GuiPreviousSessionFile();
     if ( previous.isEmpty() ) {
         // Show the Welcome screen
     } else {
          // show the resume screen
         qDebug() << "Resume session file : " << previous;

         resumeSession = true;
     }

    viewer.rootContext()->setContextProperty("resumePreviousSession",resumeSession);



    // Now, load the main page
    viewer.setMainQmlFile(QStringLiteral("../share/checkbox-gui/qml/checkbox-gui.qml"));

    viewer.setTitle(app.tr("System Testing"));

    // Ensure a reasonable minimum size for this window
    viewer.setMinimumSize(QSize(800,600));

    viewer.showExpanded();

    int errcode = app.exec();

    // Shutdown the guiengine
    guiengine.Shutdown();

    return errcode;
}
Exemplo n.º 22
0
    qRegisterMetaType<ItemListModel*>("ItemListModel");
    qmlRegisterType<ItemListModel>("Models",1,0,"ItemListModel");
    qRegisterMetaType<CategoryListModel*>("CategoryListModel");
    qmlRegisterType<CategoryListModel>("Models",1,0,"CategoryListModel");
    qRegisterMetaType<PaginationListModel*>("PaginationListModel");
    qmlRegisterType<PaginationListModel>("Models",1,0,"PaginationListModel");
    qRegisterMetaType<PlaceListModel*>("PlaceListModel");
    qmlRegisterType<PlaceListModel>("Models",1,0,"PlaceListModel");

    qmlRegisterType<ItemDetail>("Models",1,0,"ItemDetail");
    qmlRegisterType<CategoryDetail>("Models",1,0,"CategoryDetail");
    qmlRegisterType<PlaceDetail>("Models",1,0,"PlaceDetail");

    QtQuick2ApplicationViewer viewer;

    QQmlContext* rootContext = viewer.rootContext();
    rootContext->setContextProperty("Settings", &settings);
    rootContext->setContextProperty("Utils", &utils);
    rootContext->setContextProperty("HalalJapanAPI", &halalJapanAPI);

    viewer.setMainQmlFile(QStringLiteral("qml/HalalJapan/main.qml"));
#ifdef Q_OS_ANDROID
    viewer.showFullScreen();
#else
    viewer.showExpanded();
#endif


    return app.exec();
}
Exemplo n.º 23
0
Arquivo: main.cpp Projeto: oosavu/IVL
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    //Создание структуры объектов

    //CanDevice* canDevice = SocketCanDevice::instance();
    CanDevice* canDevice = EmulationCanDevice::instance();
    canDevice->registerCanUnit(CanUnitCapno1::instance());
    canDevice->registerCanUnit(CanUnitCapno2::instance());
    canDevice->registerCanUnit(CanUnitPower::instance());
    canDevice->registerCanUnit(CanUnitSPO::instance());
    canDevice->registerCanUnit(CanUnitKIVL::instance());
    canDevice->registerCanUnit(CanUnitMix::instance());

    RegimeManager::instance();
    CanManager::instance();
    EventManager::instance();
    GraphicManager::instance();
    OptionsManager::instance();

    VentModeManager::instance();
    TranslationManager::instance();
    QObject::connect(canDevice,SIGNAL(canDeviceModeChanged(CanDevice::canDeviceModes)),
                     RegimeManager::instance(), SLOT(slotCanDeviceMode(CanDevice::canDeviceModes)));

    //Регистрация перечислений для QML
    qmlRegisterUncreatableType<CanUnitMix>("CppImport", 1, 0, "CanUnitMix", "NOT MAY CREATE");
    qmlRegisterUncreatableType<CanUnitKIVL>("CppImport", 1, 0, "CanUnitKIVL", "NOT MAY CREATE");
    qmlRegisterUncreatableType<MeasureParameter>("CppImport", 1, 0, "MeasureParameter", "NOT MAY CREATE");
    qmlRegisterUncreatableType<TunningParameter>("CppImport", 1, 0, "TunningParameter", "NOT MAY CREATE");
    qmlRegisterUncreatableType<AssociatedParameter>("CppImport", 1, 0, "AssociatedParameter", "NOT MAY CREATE");
    qmlRegisterUncreatableType<EventIDs>("CppImport", 1, 0, "EventIDs", "NOT MAY CREATE");
    qmlRegisterUncreatableType<EventTypes>("CppImport", 1, 0, "EventTypes", "NOT MAY CREATE");
    qmlRegisterUncreatableType<CanUnitPower>("CppImport", 1, 0, "CanUnitPower", "NOT MAY CREATE");
    qmlRegisterUncreatableType<CanUnit>("CppImport", 1, 0, "CanUnit", "NOT MAY CREATE");
    qmlRegisterUncreatableType<RegimeManager>("CppImport", 1, 0, "RegimeManager", "NOT MAY CREATE");
    qmlRegisterUncreatableType<VentModeManager>("CppImport", 1, 0, "VentModeManager", "NOT MAY CREATE");

    //Создание представления и контекста QML
    QtQuick2ApplicationViewer viewer;
    QQmlContext* ctx = viewer.rootContext();


    //регистрация объектов для QML
    ctx->setContextProperty("keySim",         new KeyboardSimulator());
    ctx->setContextProperty("tm",             TranslationManager::instance());
    ctx->setContextProperty("regimeManager",  RegimeManager::instance());
    ctx->setContextProperty("canUnitMix",     CanUnitMix::instance());
    ctx->setContextProperty("canUnitKIVL",    CanUnitKIVL::instance());
    ctx->setContextProperty("canUnitPower",   CanUnitPower::instance());    
    ctx->setContextProperty("eventManager",   EventManager::instance());
    ctx->setContextProperty("ventModeManager",VentModeManager::instance());
    ctx->setContextProperty("graphicManager", GraphicManager::instance());
    ctx->setContextProperty("canManager",     CanManager::instance());
    CanUnitKIVL::instance()->bindContext(ctx);
    CanUnitCapno1::instance()->bindContext(ctx);
    VentModeManager::instance()->bindContext(ctx);
    GraphicManager::instance()->bindContext(ctx);
    OptionsManager::instance()->bindContext(ctx);


    viewer.setMainQmlFile(QStringLiteral("qml/BaseIVL2/main.qml"));
    viewer.setWidth(1024);
    viewer.setHeight(768);
    viewer.setColor(QColor::fromRgb(0,0,0,0)/*Qt::transparent*/);
    viewer.showExpanded();

    canDevice->startInit();
    return app.exec();
}
Exemplo n.º 24
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

//    QtQuick2ApplicationViewer viewer;
//    viewer.setMainQmlFile(QStringLiteral("qml/GUI-Scenario/main.qml"));
//    viewer.showExpanded();


    //temp for testing


//    Story* story;
//    Item* hammer = new Item{"hammer"};
//    //story->add_item(hammer);
//    QMap<QString, qint16> attributes;
//    attributes["hp"] = 10;

//    Character player1{};//attributes, 5, story};

////    player1.set_name("player1");
////    player1.add_to_attribute("hp", 10);

//    Character player2;

//      player2.set_name("player2");
////    player2.add_to_attribute("hp", 13);
//    //player1.add_item(1); does not work for some reasaon LOOK IT UP!!!!!

//    QList<Character*> characterlist;

//    //characterlist.append(&player1);
//    characterlist.append(&player2);

//    QMap<quint16, Item*> items;
//    items[1] = hammer;

////    qDebug() << "before add";
////    player1.add_item(1);
////    qDebug() << "after add";
///
///

    //from other main

    QList<QString> attr_list{"health", "armor", "strength"};
    Ruleset *rs;
    rs = new Ruleset(attr_list);

    Story* main_story = new Story(rs);

    QMap<QString, qint16> attr_map{{"health", 10}, {"armor", 2}, {"strength", 5}};
    main_story->add_character(new Character(attr_map, 50, main_story));

    Character* bob = main_story->get_characters().front();
    bob->set_name("BOB!");


    try {
      Item* hammer1 = new Item("Hammer of doom");
      main_story->add_item(hammer1);
      hammer1->set_attribute("Weight", 20);

      Item* hammer2 = new Item("nicer hammah");
      main_story->add_item(hammer2);
      hammer2->set_attribute("Weight", 20);
      hammer2->set_attribute("bonk", 50);
      hammer2->set_attribute("smash", 3000);

      bob->add_item(hammer1->get_id());
      bob->add_item(hammer2->get_id());


      qDebug() << "Bob's stuff:";
      for (auto item_id : bob->inventory.get_items()) {
        qDebug() << main_story->get_items().value(item_id)->get_name();
      }
    }
    catch (const std::out_of_range& e) {
      qDebug() << "out_of_range exception: " << e.what();
    }


    Character* herman = new Character(attr_map, 10, main_story);
    main_story->add_character(herman);
    herman->set_name("Herr Man");

    rs->add_skill(new Skill("Break those cuffs"));
    rs->add_skill(new Skill("Eat horse"));
    rs->get_skills().at(0)->set_modifier("int", 10);
    rs->get_skills().at(0)->set_modifier("str", 11);
    rs->get_skills().at(1)->set_modifier("int" , 5);
    rs->get_skills().at(1)->set_modifier("str", 25);
    bob->add_skill(rs->get_skills().at(0));
    bob->add_skill(rs->get_skills().at(1));


    herman->add_skill(rs->get_skills().at(1));



    //connect signals from QML

//    QObject::connect((QObject*)viewer.rootObject(), SIGNAL(testSignal(QString)),&controller, SLOT(oklart(QString)));
//    QObject::connect((QObject*)viewer.rootObject(), SIGNAL(setDropAreaParent(int)),&controller, SLOT(set_active_block_number_(int)));
//    QObject::connect((QObject*)viewer.rootObject(), SIGNAL(setDropAreaSide(QString)),&controller, SLOT(set_active_block_side(QString)));
//    QObject::connect((QObject*)viewer.rootObject(), SIGNAL(add_block(int, QString)),&controller, SLOT(add_block(int,QString)));
//    QObject::connect((QObject*)viewer.rootObject(), SIGNAL(editValueBlock(QString, bool, int)),&controller, SLOT(edit_valueblock(QString, bool, int)));
//    QObject::connect((QObject*)viewer.rootObject(), SIGNAL(setCompareBlockValue(int)),&controller, SLOT(set_compareblock_value(int)));
//    QObject::connect((QObject*)viewer.rootObject(), SIGNAL(editDamageBlock(QString, bool, int)),&controller, SLOT(edit_damageblock(QString, bool, int)));

//    //TODO: complete signals below
//    QObject::connect((QObject*)viewer.rootObject(), SIGNAL(editCompareBlock(QString, bool, int)),&controller, SLOT(edit_compareblock(QString, bool, int)));

//    QStringList dataList;
//    dataList.append("Item 1");
//    dataList.append("Item 2");
//    dataList.append("Item 3");
//    dataList.append("Item 4");
//    dataList.append("Item 1");
//    dataList.append("Item 2");
//    dataList.append("Item 3");
//    dataList.append("Item 4");
//    dataList.append("Item 1");
//    dataList.append("Item 2");
//    dataList.append("Item 3");
//    dataList.append("Item 4");
//    dataList.append("Item 1");
//    dataList.append("Item 2");
//    dataList.append("Item 3");
//    dataList.append("Item 4");

//    // export instance to qml
//    QQmlContext *ctxt = viewer.rootContext();
//    ctxt->setContextProperty("controller", &controller);

    //ctxt->setContextProperty("dataList", QVariant::fromValue(dataList));

    //ctxt->setContextProperty("sController", &controller);

    //QML

    QtQuick2ApplicationViewer viewer;

    // create a controller
    ScenarioController controller{herman, main_story->get_characters(),main_story->get_items(),rs->get_skills(),rs->get_attributes()};

    // export instance to qml
    QQmlContext *ctxt = viewer.rootContext();
    ctxt->setContextProperty("controller", &controller);
    viewer.setMainQmlFile(QStringLiteral("qml/GUI-Scenario/main.qml"));
    viewer.showExpanded();



    return app.exec();
}