source: src-qt4/life-preserver/main.cpp @ 302f10d

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 302f10d was 302f10d, checked in by Kris Moore <kris@…>, 10 months ago

Remove ldpbiconfig and fix building life-preserver on HEAD

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#include <qtranslator.h>
2#include <qlocale.h>
3#include <qtsingleapplication.h>
4#include <QDebug>
5#include <QFile>
6#include <unistd.h>
7#include <sys/types.h>
8
9#include "LPTray.h"
10//#include "../config.h"
11
12#ifndef PREFIX
13#define PREFIX QString("/usr/local/")
14#endif
15
16int main( int argc, char ** argv )
17{
18    QtSingleApplication a(argc, argv);
19    if (a.isRunning())
20      return !(a.sendMessage("show"));
21
22    //Check whether running as root
23    if( getuid() != 0){
24      qDebug() << "Life-Preserver must be started as root!";
25      return 1;
26    }
27   
28    QTranslator translator;
29    QLocale mylocale;
30    QString langCode = mylocale.name();
31    if ( ! QFile::exists( PREFIX + "/share/lifePreserver/i18n/LifePreserver_" + langCode + ".qm" ) )
32      langCode.truncate(langCode.indexOf("_"));
33    translator.load( QString("LifePreserver_") + langCode, PREFIX + "/share/lifePreserver/i18n/" );
34    a.installTranslator( &translator );
35    qDebug() << "Locale:" << langCode;
36
37    LPTray *w = new LPTray(); 
38    w->show();
39
40    QObject::connect( &a, SIGNAL( messageReceived(const QString &) ), w, SLOT( slotSingleInstance() ) );
41    return a.exec();
42}
Note: See TracBrowser for help on using the repository browser.