main.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*****************************************************************************
  2. * main.cpp - DictionaryStar, stardict dictionary for MeeGo Harmattan *
  3. * Copyright (C) 2012 Jari P.T. Alhonen *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 3 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License along *
  16. * with this program; if not, see <http://www.gnu.org/licenses/>. *
  17. *****************************************************************************/
  18. #include <QtGui/QApplication>
  19. #include <QDeclarativeContext>
  20. #include <QtDeclarative>
  21. #include <QDeclarativeEngine>
  22. #include <QDeclarativeComponent>
  23. #include <QDeclarativeView>
  24. #include <MDeclarativeCache>
  25. #include <dictcore.h>
  26. #include "dictwebview.h"
  27. Q_DECL_EXPORT int main(int argc, char *argv[])
  28. {
  29. QApplication *app = MDeclarativeCache::qApplication(argc, argv);
  30. QDeclarativeView *view = MDeclarativeCache::qDeclarativeView();
  31. DictionariesModel model;
  32. DictCore *core = new DictCore(model);
  33. QString locale = QLocale::system().name();
  34. QTranslator translator;
  35. if (translator.load("DictionaryStar-" + locale, ":/translations/"))
  36. app->installTranslator(&translator);
  37. qmlRegisterType<DictWebView>("DictWebLib", 1, 0, "DictWebView");
  38. #if QT_VERSION < 0x040702
  39. view->setAttribute(static_cast<Qt::WidgetAttribute>(130), true);
  40. #else
  41. view->setAttribute(Qt::WA_AutoOrientation, true);
  42. #endif
  43. view->setAttribute(Qt::WA_NoSystemBackground);
  44. view->rootContext()->setContextProperty("dictCore", core);
  45. view->rootContext()->setContextProperty("dictsModel", &model);
  46. view->setSource(QUrl(QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), "qml/main.qml")));
  47. view->showFullScreen();
  48. app->exec();
  49. delete core;
  50. delete view;
  51. delete app;
  52. }