int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
    QScopedPointer<QQuickView> view(SailfishApp::createView());

    QQmlContext* context = view->rootContext();

    qmlRegisterUncreatableType<XmlItem>("SomaFM", 1, 0, "XmlItem", "");
    qmlRegisterUncreatableType<Channel>("SomaFM", 1, 0, "Channel", "");
    qmlRegisterUncreatableType<Song>("SomaFM", 1, 0, "Song", "");

    QCoreApplication::setApplicationVersion(APP_VERSION);
    context->setContextProperty("_appVersion", APP_VERSION);

    QScopedPointer<ChannelsModel> channelsModel(new ChannelsModel());
    QScopedPointer<ChannelsProxyModel> channelsProxyModel(new ChannelsProxyModel());
    channelsProxyModel->setSourceModel(channelsModel.data());
    context->setContextProperty("_channelsModel", channelsProxyModel.data());

    QScopedPointer<ChannelsFavoritesManager> favoritesManager(ChannelsFavoritesManager::instance());
    context->setContextProperty("_favoritesManager", favoritesManager.data());

    QScopedPointer<SongsModel> channelSongsModel(new SongsModel());
    QScopedPointer<SongsProxyModel> channelSongsProxyModel(new SongsProxyModel());
    channelSongsProxyModel->setSourceModel(channelSongsModel.data());
    context->setContextProperty("_channelSongsModel", channelSongsProxyModel.data());

    QScopedPointer<SongsBookmarksManager> bookmarksManager(SongsBookmarksManager::instance());
    QScopedPointer<SongsBookmarksProxyModel> songsBookmarkProxyModel(new SongsBookmarksProxyModel());
    songsBookmarkProxyModel->setSourceModel(bookmarksManager.data());
    context->setContextProperty("_bookmarksManager", songsBookmarkProxyModel.data());

    QScopedPointer<NewsModel> newsModel(new NewsModel());
    QScopedPointer<NewsProxyModel> newsProxyModel(new NewsProxyModel());
    newsProxyModel->setSourceModel(newsModel.data());
    context->setContextProperty("_newsModel", newsProxyModel.data());

    QScopedPointer<RefreshModel> refreshModel(RefreshModel::instance());
    context->setContextProperty("_refreshModel", refreshModel.data());

    QScopedPointer<Player> player(new Player());
    context->setContextProperty("_player", player.data());

    QScopedPointer<Settings> settings(new Settings());
    context->setContextProperty("_settings", settings.data());

    view->setSource(SailfishApp::pathTo("qml/harbour-somafm.qml"));
    view->show();

    return app->exec();
}
Beispiel #2
0
void BrowserApplication::retranslate()
{
    bookmarksManager()->retranslate();
    networkAccessManager()->loadSettings();
}