blob: 6bd502be4a0a9d0e95e389173631de0eb619471e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include <QtCore/QDebug>
#include <QtCore/QTranslator>
#include <QtGui/QApplication>
#include <QtDBus/QDBusConnection>
#include <sowatch.h>
#include "daemon.h"
#include "daemonadaptor.h"
using namespace sowatch;
static void setupLocalization(QApplication *app)
{
const QString locale(QLocale::system().name());
QTranslator *translator;
// Set up main Qt translator first
translator = new QTranslator(app);
if (translator->load("qt_" + locale,
QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
app->installTranslator(translator);
} else {
delete translator;
qWarning() << "Could not load Qt translation for" << locale;
}
// Set up libsowatch translator
translator = new QTranslator(app);
if (translator->load("libsowatch_" + locale, SOWATCH_I18N_DIR)) {
app->installTranslator(translator);
} else {
qWarning() << "Could not load translation for" << locale;
}
}
int main(int argc, char *argv[])
{
// Some plugins use QtGui functionality, so QApplication must be used
// instead of QCoreApplication.
QApplication app(argc, argv);
QApplication::setOrganizationDomain("com.javispedro.sowatch");
QApplication::setOrganizationName("sowatch");
QApplication::setApplicationName("sowatchd");
QApplication::setQuitOnLastWindowClosed(false);
// Load translators
setupLocalization(&app);
// Create the daemon object and D-Bus adaptor
Daemon daemon;
DaemonAdaptor adaptor(&daemon);
Q_UNUSED(adaptor);
QDBusConnection connection = QDBusConnection::sessionBus();
if (!connection.registerService("com.javispedro.sowatchd")) {
qCritical("Could not register D-Bus service");
}
if (!connection.registerObject("/com/javispedro/sowatch/daemon", &daemon)) {
qCritical("Could not register daemon object");
}
return app.exec();
}
|