-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
40 lines (33 loc) · 1.08 KB
/
main.cpp
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
#include <qtranslator.h>
#include <qlocale.h>
#include <qtsingleapplication.h>
#include <QDebug>
#include <QFile>
#include "LPTray.h"
//#include "../config.h"
#ifndef PREFIX
#define PREFIX QString("/usr/local/")
#endif
int main( int argc, char ** argv )
{
QtSingleApplication a(argc, argv);
if (a.isRunning())
return !(a.sendMessage("show"));
//Check whether running as root
if( getuid() != 0){
qDebug() << "Life-Preserver must be started as root!";
return 1;
}
QTranslator translator;
QLocale mylocale;
QString langCode = mylocale.name();
if ( ! QFile::exists( PREFIX + "/share/lifePreserver/i18n/LifePreserver_" + langCode + ".qm" ) )
langCode.truncate(langCode.indexOf("_"));
translator.load( QString("LifePreserver_") + langCode, PREFIX + "/share/lifePreserver/i18n/" );
a.installTranslator( &translator );
qDebug() << "Locale:" << langCode;
LPTray *w = new LPTray();
w->show();
QObject::connect( &a, SIGNAL( messageReceived(const QString &) ), w, SLOT( slotSingleInstance() ) );
return a.exec();
}