1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary 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.
10 mDictionary 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.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
25 #include <QtGui/QApplication>
26 #include "MainWindow.h"
27 #include "../backbone/backbone.h"
28 #include "../../include/translation.h"
29 #include "../../include/Notify.h"
30 #include "DBusAdapter.h"
32 #include <QDBusConnection>
36 QStringList parseParameters(int argc, char *argv[]) {
37 bool wordListStarted = false;
39 for(int i=1; i<argc; i++) {
40 QString argument(argv[i]);
41 if(!wordListStarted) {
42 if(argument == "-s" || argument == "--search") {
43 wordListStarted = true;
47 if(!argument.startsWith("-") &&
48 !argument.startsWith("--")) {
57 int main(int argc, char *argv[]) {
58 QApplication a(argc, argv);
59 QApplication::setOrganizationName("Comarch S.A.");
60 QApplication::setOrganizationDomain("comarch.com");
61 QApplication::setApplicationName("mDictionary");
63 QStringList search = parseParameters(argc, argv);
65 qRegisterMetaType<Translation*>("Translation*");
66 qRegisterMetaType<QList<Translation*> >("QList<Translation*>");
67 qRegisterMetaType<Notify>("Notify");
68 qRegisterMetaType<Notify::NotifyType>("Notify::NotifyType");
70 QString locale = QLocale::system().name();
72 QTranslator qtTranslator;
73 qtTranslator.load("qt_" + QLocale::system().name(),
74 QLibraryInfo::location(QLibraryInfo::TranslationsPath));
76 a.installTranslator(&qtTranslator);
78 QTranslator myTranslator;
80 myTranslator.load(":/translations/dict_pl");
82 myTranslator.load(":/translations/dict_en");
83 a.installTranslator(&myTranslator);
86 MainWindow w(&backbone);
88 DBusAdapter* adapter = new DBusAdapter(&w);
90 QDBusConnection::sessionBus().registerObject("/mainWindow",
92 QDBusConnection::sessionBus().registerService("com.comarch.mdictionary");
98 if(search.count() > 0) {
99 w.setExactSearch(true);
100 w.searchExact(search[0]);