README
[n9profile] / main.cpp
1 /** \file main.cpp
2   \brief main + loading translations
3   \author Jakub Šplíchal <jakub.bzouk@gmail.com>
4  */
5 #include <QtGui/QApplication>
6 #include <QtCore/QTextCodec>
7 #include <QtCore/QLocale>
8 #include <QtCore/QTranslator>
9 #include <QtCore/QDebug> //Debug pro informace
10 #include <QtDBus/QDBusConnection>
11 #include <QtDBus/QDBusError>
12 #include "mainwindow.h"
13
14 int main(int argc, char *argv[])
15 {
16
17
18     QApplication a(argc, argv);
19     Q_INIT_RESOURCE(rcc);
20     //names for app and setting class
21     a.setOrganizationName("N9Profil");
22     a.setApplicationName("N9Profil");
23     a.setApplicationVersion("0.1");
24
25     //Text in  UTF-8
26     QTextCodec* utf = QTextCodec::codecForName("UTF-8");
27     QTextCodec::setCodecForCStrings(utf);
28     QTextCodec::setCodecForTr(utf);
29
30     QTranslator t;
31
32     /*! http://www.abclinuxu.cz/clanky/programovani/graficke-programy-v-qt-4-7-lokalizace-a-data-programu
33       Sets the application name and the text codec to UTF-8 and
34       reads the translation according to the currently set language:
35       program name + _ + language of the country
36       where language is a two-language code (ISO 639) in lowercase
37       and the country is a two-country code (ISO 3166) in capitals,
38       eg cs_CZ lupdate N9Profil.pro for updating translation
39      */
40     t.load(":/translations/" + a.applicationName() + "_" + QLocale::system().name() ); //QLocale::system() vrati info o jaz. systemu
41     //qDebug() << "In file:" <<  __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "bude se nahravat" << (":/translations/" + a.applicationName() + "_" + QLocale::system().name()) ;
42     // install language
43     a.installTranslator(&t);
44
45
46     MainWindow w;
47
48
49     if (!QDBusConnection::sessionBus().isConnected()) {
50         qWarning("Cannot connect to the D-Bus session bus.");
51         exit(1);
52     }
53
54     if (!QDBusConnection::sessionBus().registerService("org.indt.N9Profil")) {
55         qWarning("%s", qPrintable(QDBusConnection::sessionBus().lastError().
56                                   message()));
57         exit(2);
58     }
59
60     if (!QDBusConnection::sessionBus().registerObject("/org/indt/N9Profil", &w,
61                                                       QDBusConnection::ExportAllContents)) {
62         qWarning("%s", qPrintable(QDBusConnection::sessionBus().lastError().
63                                   message()));
64         exit(3);
65     }
66
67
68     w.Init();//init
69
70     w.show();
71
72     return a.exec();
73 }
74
75 /** \mainpage N9Profile for N900
76   N9Profile can create profiles for N900 and set them via libprofile
77
78   \section instal_section Instalation
79 You can use scratchbox and compile source or use .deb packege <br>
80 You will need: <br>
81 \> scratchbox
82 \> libprofile
83 \> calendar-backend
84 \> QT4.6.2 for maemo( in /opt/qt..)
85
86 */
87