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 \brief mDictionary's main file
24 \author Mateusz Półrola <mateusz.polrola@comarch.pl>
27 #include <QtGui/QApplication>
28 #include "MainWindow.h"
29 #include "../backbone/backbone.h"
30 #include "../../include/translation.h"
31 #include "../../include/Notify.h"
32 #include "DBusAdapter.h"
34 #include <QDBusConnection>
38 QStringList parseParameters(int argc, char *argv[]) {
39 bool wordListStarted = false;
41 for(int i=1; i<argc; i++) {
42 QString argument(argv[i]);
43 if(!wordListStarted) {
44 if(argument == "-s" || argument == "--search") {
45 wordListStarted = true;
49 if(!argument.startsWith("-") &&
50 !argument.startsWith("--")) {
60 QString locale = QLocale::system().name();
62 QTranslator *translator = new QTranslator;
63 QTranslator *qtTranslator = new QTranslator;
65 qtTranslator->load("qt_" + locale,
66 QLibraryInfo::location(QLibraryInfo::TranslationsPath));
67 QCoreApplication::installTranslator(qtTranslator);
69 if(!translator->load(":/translations/" + locale)) {
70 translator->load(":/translations/en_US");
74 QCoreApplication::installTranslator(translator);
77 int main(int argc, char *argv[]) {
78 QApplication a(argc, argv);
79 QApplication::setOrganizationName("Comarch S.A.");
80 QApplication::setOrganizationDomain("comarch.com");
81 QApplication::setApplicationName("mDictionary");
83 QStringList search = parseParameters(argc, argv);
85 qRegisterMetaType<Translation*>("Translation*");
86 qRegisterMetaType<QList<Translation*> >("QList<Translation*>");
87 qRegisterMetaType<Notify>("Notify");
88 qRegisterMetaType<Notify::NotifyType>("Notify::NotifyType");
92 Backbone* backbone = new Backbone();
93 MainWindow* mainWindow = new MainWindow(backbone);
95 DBusAdapter* adapter = new DBusAdapter(mainWindow);
97 QDBusConnection::sessionBus().registerObject("/mainWindow",
99 QDBusConnection::sessionBus().registerService("com.comarch.mdictionary");
103 if(search.count() > 0) {
104 mainWindow->setExactSearch(true);
105 mainWindow->searchExact(search[0]);
110 QDBusConnection::sessionBus().unregisterObject("/mainWindow");
111 QDBusConnection::sessionBus().unregisterService("com.comarch.mdictionary");