source: src-qt4/life-preserver/lp-tray/main.cpp @ 6a2483b

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 6a2483b was 6a2483b, checked in by Ken Moore <ken@…>, 6 months ago

Remove the old life-preserver from the src-qt4/life-preserver dir, and replace it with src-qt4/life-preserver/lp-tray and src-qt4/life-preserver/lp-gui.

  • Property mode set to 100644
File size: 1.3 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 Tray must not 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/LifePreserverTray_" + langCode + ".qm" ) )
32      langCode.truncate(langCode.indexOf("_"));
33    translator.load( QString("LifePreserverTray_") + 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    int ret = -1;
42    while( w->isVisible() ){
43      //Make sure the application does not exit while the tray is still open
44      ret = a.exec();
45    }
46    return ret;
47}
Note: See TracBrowser for help on using the repository browser.