int main(int argc, char *argv[])
{
    QProcess appinfo;
    QString appversion;
    QString appname = "TaskList";
    QString pkgname = "harbour-tasklist";

    QCoreApplication::setOrganizationName(pkgname);
    QCoreApplication::setApplicationName(pkgname);

    // read app version from rpm database on startup
    appinfo.start("/bin/rpm", QStringList() << "-qa" << "--queryformat" << "%{version}" << pkgname);
    appinfo.waitForFinished(-1);
    if (appinfo.bytesAvailable() > 0) {
        appversion = appinfo.readAll();
    }

    /*  Internationalization Support
        thanks to Antoine Reversat who mentioned this here:
        https://www.mail-archive.com/[email protected]/msg02602.html */
    QGuiApplication* app = SailfishApp::application(argc, argv);

    // load default translator and system locale's translator afterwards
    QTranslator defaultTranslator;
    defaultTranslator.load("en_US", SailfishApp::pathTo(QString("localization")).toLocalFile());
    app->installTranslator(&defaultTranslator);

    QSettings settings;
    QString locale = settings.value("language", "").toString();
    if (locale.isEmpty() || locale == QString("system_default")) {
        /* use system locale by default */
        if (locale.isEmpty())
            settings.setValue("language", "system_default");
        locale = QLocale::system().name();
    }

    QTranslator translator;
    translator.load(locale, SailfishApp::pathTo(QString("localization")).toLocalFile());
    app->installTranslator(&translator);

    qmlRegisterType<TasksExport>("harbour.tasklist.tasks_export", 1, 0, "TasksExport");

    QQuickView* view = SailfishApp::createView();
    QObject::connect(view->engine(), SIGNAL(quit()), app, SLOT(quit()));
    view->rootContext()->setContextProperty("version", appversion);
    view->rootContext()->setContextProperty("appname", appname);
    view->setSource(SailfishApp::pathTo("qml/harbour-tasklist.qml"));
    view->show();

    return app->exec();
}
Exemplo n.º 2
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();
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
     QGuiApplication *app = SailfishApp::application(argc, argv);
     QString locale = QLocale::system().name();
     QTranslator translator;
     translator.load(locale,SailfishApp::pathTo(QString("localization")).toLocalFile());
     app->installTranslator(&translator);
     QQuickView *view = SailfishApp::createView();
     view->setSource(SailfishApp::pathTo("qml/main.qml"));
     view->showFullScreen();
     return app->exec();
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    QGuiApplication *app = SailfishApp::application(argc, argv);

    app->setApplicationName("harbour-tinytodo");
    app->setApplicationVersion(QString(APP_VERSION)+QString(APP_VERSION_SUFFIX));
    qDebug()<<app->applicationName()<<" version "<<app->applicationVersion();

    QTranslator translator;
    //QString translationLocation = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
    QString translationLocation = "/usr/share/harbour-tinytodo/locale";
    QString translation = "harbour-tinytodo_" + QLocale::system().name();
    qDebug()<<"Translation location: "<<translationLocation;
    qDebug()<<"Translation: "<<translation;
    translator.load(translation, translationLocation);
    app->installTranslator(&translator);

    QQuickView *view = SailfishApp::createView();
    view->rootContext()->setContextProperty("appVersion", app->applicationVersion());
    view->setSource(SailfishApp::pathTo("qml/harbour-tinytodo.qml"));
    view->showFullScreen();

    return app->exec();
}
Exemplo n.º 6
0
Q_DECL_EXPORT
#endif
int main(int argc, char *argv[])
{
    qsrand(QDateTime::currentDateTimeUtc().toTime_t());

    #if defined(BUILD_FOR_SAILFISHOS)
        //To support calendar access
        #if defined(BUILD_FOR_OPENREPOS)
            qDebug()<<"openrepos.net build";
            setuid(getpwnam("nemo")->pw_uid);
            setgid(getgrnam("privileged")->gr_gid);
        #endif

        QGuiApplication* app = SailfishApp::application(argc, argv);
    #elif defined(HAVE_DECLARATIVE_CACHE)
        QApplication* app = MDeclarativeCache::qApplication(argc, argv);
    #elif defined(BUILD_FOR_UBUNTU)
        QGuiApplication* app = new QGuiApplication(argc, argv);
        app->setWindowIcon(QIcon(":/fahrplan2.svg"));
    #else
        QApplication* app = new QApplication(argc, argv);
        #if defined(BUILD_FOR_DESKTOP)
            app->setWindowIcon(QIcon(":/fahrplan2_64.png"));
        #endif
    #endif

    QString localeName = QLocale().name();

    qDebug() <<"Using "<<localeName<<" locale";

    // Install translations
    QTranslator translator;
    translator.load(QString("fahrplan_%1").arg(localeName), ":/translations");
    app->installTranslator(&translator);

    qDebug()<<"Startup";

    qRegisterMetaType<Station>();
    qRegisterMetaType<StationsList>();
    qRegisterMetaType<TimetableEntry>();
    qRegisterMetaType<TimetableEntriesList>();
    qRegisterMetaType<Fahrplan::StationType>();
    qRegisterMetaType<Fahrplan::Mode>();

    #if defined(BUILD_FOR_HARMATTAN) || defined(BUILD_FOR_MAEMO_5) || defined(BUILD_FOR_SYMBIAN) || defined(BUILD_FOR_BLACKBERRY) || defined(BUILD_FOR_UBUNTU) || defined(BUILD_FOR_SAILFISHOS)
        qDebug()<<"QML";
        qmlRegisterType<Fahrplan>("Fahrplan", 1, 0, "FahrplanBackend");
        qmlRegisterType<ParserAbstract>("Fahrplan", 1, 0, "ParserAbstract");
        qmlRegisterType<FahrplanParserThread>("Fahrplan", 1, 0, "FahrplanParserThread");
        qmlRegisterType<FahrplanCalendarManager>("Fahrplan", 1, 0, "CalendarManager");
        qmlRegisterUncreatableType<StationSearchResults>("Fahrplan", 1, 0, "StationSearchResults"
            , "StationSearchResults cannot be created from QML. "
              "Access it through FahrplanBackend.stationSearchResults.");
        qmlRegisterUncreatableType<Favorites>("Fahrplan", 1, 0, "Favorites"
            , "Favorites cannot be created from QML. "
              "Access it through FahrplanBackend.favorites.");
        qmlRegisterUncreatableType<Timetable>("Fahrplan", 1, 0, "Timetable"
            , "Timetable cannot be created from QML. "
              "Access it through FahrplanBackend.timetable.");
        qmlRegisterUncreatableType<Trainrestrictions>("Fahrplan", 1, 0, "Trainrestrictions"
            , "Trainrestrictions cannot be created from QML. "
              "Access it through FahrplanBackend.trainrestrictions.");
        qmlRegisterUncreatableType<Backends>("Fahrplan", 1, 0, "Backends"
            , "Backends cannot be created from QML. "
              "Access it through FahrplanBackend.backends.");
        qmlRegisterType<JourneyResultList>("Fahrplan", 1, 0, "JourneyResultList");
        qmlRegisterType<JourneyResultItem>("Fahrplan", 1, 0, "JourneyResultItem");
        qmlRegisterType<JourneyDetailResultList>("Fahrplan", 1, 0, "JourneyDetailResultList");
        qmlRegisterType<JourneyDetailResultItem>("Fahrplan", 1, 0, "JourneyDetailResultItem");

        #if defined(BUILD_FOR_SAILFISHOS)
            QQuickView *view = SailfishApp::createView();
        #elif defined(HAVE_DECLARATIVE_CACHE)
            QDeclarativeView* view = MDeclarativeCache::qDeclarativeView();
        #elif defined(BUILD_FOR_QT5)
            QQuickView *view = new QQuickView();
        #else
            QDeclarativeView* view = new QDeclarativeView();
        #endif

        #if defined(BUILD_FOR_HARMATTAN)
            qDebug()<<"Harmattan";
            view->setSource(QUrl("qrc:/src/gui/harmattan/main.qml"));
            view->showFullScreen();
        #elif defined(BUILD_FOR_MAEMO_5)
            qDebug()<<"Maemo5";
            qmlRegisterType<HildonHelper>("HildonHelper", 1, 0, "HildonHelper");
            view->setSource(QUrl("qrc:/src/gui/fremantle/main.qml"));
            view->show();
        #elif defined(BUILD_FOR_SYMBIAN)
            qDebug()<<"Symbian";
            view->setSource(QUrl("qrc:/src/gui/symbian/main.qml"));
            view->showFullScreen();
        #elif defined(BUILD_FOR_UBUNTU)
            qDebug()<<"Ubuntu";
            view->setSource(QUrl("qrc:/src/gui/ubuntu/main.qml"));
            view->setResizeMode(QQuickView::SizeRootObjectToView);
            view->show();
            QSettings settings(FAHRPLAN_SETTINGS_NAMESPACE, "fahrplan2");
            view->setGeometry(settings.value("geometry", QRect(100, 100, 400, 600)).toRect());
        #elif defined(BUILD_FOR_SAILFISHOS)
            qDebug()<<"SailfishOs";
            view->setSource(QUrl("qrc:/src/gui/sailfishos/main.qml"));

            view->showFullScreen();
        #elif defined(BUILD_FOR_BLACKBERRY)
            qDebug() << "Blackberry";

            // QML wrapper around Qt Mobility Subset
            qmlRegisterType<QtMobilitySubset::BlackBerryPositionSource>("QtMobility.location", 1, 1, "PositionSource");
            qmlRegisterUncreatableType<QtMobilitySubset::BlackBerryPosition>("QtMobility.location", 1, 1, "Position", "Cant't create Position type");
            qmlRegisterUncreatableType<QtMobilitySubset::BlackBerryCoordinate>("QtMobility.location", 1, 1, "Coordinate", "Cant't create Coordinate type");

            QSettings *settings = new QSettings(FAHRPLAN_SETTINGS_NAMESPACE, "fahrplan2");

            // Check if GPS Location permission is set
            // and geolocation services are enabled.
            int res = geolocation_request_events(0);
            if (res == BPS_SUCCESS)
                geolocation_stop_events(0);
            settings->setValue("enableGps", res == BPS_SUCCESS);

            delete settings;

            // Improves touch handling
            QApplication::setStartDragDistance(42);

            QGLWidget *gl = new QGLWidget();
            view->setViewport(gl);
            view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
            view->setSource(QUrl("qrc:/src/gui/symbian/main.qml"));

            // Hide Symbian-style status bar on BlackBerry
            view->rootObject()->setProperty("showStatusBar", false);

            view->showFullScreen();
        #endif
    #else
        qDebug()<<"Desktop";
        MainWindow w;
        w.show();
    #endif

    qDebug()<<"Exec";

    int error = app->exec();
    #if defined(BUILD_FOR_UBUNTU)
        settings.setValue("geometry", view->geometry());
    #endif

#ifndef Q_OS_BLACKBERRY
    // For some reason, this causes a weird freeze of
    // Fahrplan on BlackBerry 10 so that it can only
    // be closed by restarting the phone.
    delete app;
#endif

    return error;
}