ttrss/main.cpp
Michael Käufl bfe25c9c6f License updates
- Added a LICENSE.txt
  (See "How to apply this license" at
   http://choosealicense.com/licenses/gpl-2.0/)

- Added license headers to files where missing.

- Used /* */ comments for license headers. (Allows folding in
  QtCreator.)

- Replaced BSD template from `harbour-ttrss.qml` with GPL.
2014-09-25 21:54:19 +02:00

109 lines
3.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* This file is part of TTRss, a Tiny Tiny RSS Reader App
* for MeeGo Harmattan and Sailfish OS.
* Copyright (C) 20122014 Hauke Schade
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#if defined(Q_OS_SAILFISH)
#include <QGuiApplication>
#include <sailfishapp.h>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
#ifdef QT_QML_DEBUG
#include <QtQuick>
#endif
#else
#include <QtGui/QApplication>
#include <QtDeclarative/QDeclarativeContext>
#include "qmlapplicationviewer.h"
#include <QDeclarativeEngine>
#endif
#include <QTranslator>
#include <QLocale>
#include "settings.hh"
#include "qmlutils.hh"
#include "mynetworkmanager.hh"
#if defined(Q_OS_SAILFISH)
#else
#include "theme.hh"
#endif
Q_DECL_EXPORT int main(int argc, char *argv[])
{
#if defined(Q_OS_SAILFISH)
QGuiApplication *app = SailfishApp::application(argc, argv);
#else
QScopedPointer<QApplication> app(createApplication(argc, argv));
#endif
app->setApplicationVersion(APP_VERSION);
app->setApplicationName("ttrss");
app->setOrganizationName("Hauke Schade");
QString locale = QLocale::system().name();
qDebug() << "detected locale is " << locale;
QTranslator translator;
/* the ":/" is a special directory Qt uses to
* distinguish resources;
* NB this will look for a filename matching locale + ".qm";
* if that's not found, it will truncate the locale to
* the first two characters (e.g. "en_GB" to "en") and look
* for that + ".qm"; if not found, it will look for a
* qml-translations.qm file; if not found, no translation is done
*/
if (translator.load("qml-translation." + locale, ":/i18n"))
app->installTranslator(&translator);
#if defined(Q_OS_SAILFISH)
QQuickView* viewer = SailfishApp::createView();
#else
QmlApplicationViewer *viewer = new QmlApplicationViewer();
viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
//QObject::connect(viewer.engine(), SIGNAL(quit()), viewer.data, SLOT(close()));
#endif
viewer->engine()->setNetworkAccessManagerFactory(MyNetworkManager::instance());
viewer->rootContext()->setContextProperty("network", MyNetworkManager::instance());
viewer->rootContext()->setContextProperty("APP_VERSION", APP_VERSION);
viewer->rootContext()->setContextProperty("QMLUtils", QMLUtils::instance());
viewer->rootContext()->setContextProperty("settings", Settings::instance());
#if defined(Q_OS_SAILFISH)
#else
viewer->rootContext()->setContextProperty("MyTheme", Theme::instance());
#endif
#if defined(Q_OS_SAILFISH)
viewer->setSource(SailfishApp::pathTo("qml/sailfish/harbour-ttrss.qml"));
#else
viewer->setMainQmlFile(QLatin1String("qml/harmattan/main.qml"));
#endif
#if defined(Q_OS_SAILFISH)
viewer->show();
#else
viewer->showExpanded();
#endif
return app->exec();
}