source: src-qt4/pc-gdmconf/main.cpp @ 7cc177e

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

Fix up all the last bits of clang / HEAD fussiness

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#include <QMessageBox>
2#include <qtranslator.h>
3#include <qlocale.h>
4#include <qtsingleapplication.h>
5#include <QFile>
6#include "mainwindow.h"
7#include "../config.h"
8#include <unistd.h>
9#include <sys/types.h>
10
11int main(int argc, char *argv[])
12{   
13    QtSingleApplication a(argc, argv);
14
15    if ( a.isRunning() )
16          return !(a.sendMessage("show"));
17
18    QTranslator translator;
19    QLocale mylocale;
20    QString langCode = mylocale.name();
21    if ( ! QFile::exists(PREFIX + "/share/pcbsd/i18n/pc-gdmconf_" + langCode + ".qm" ) )
22        langCode.truncate(langCode.indexOf("_"));
23    translator.load( QString("pc-gdmconf_") + langCode, PREFIX + "/share/pcbsd/i18n/" );
24    a.installTranslator( &translator );   
25
26    MainWindow w;
27    w.show();
28
29    //Check for root
30    if (0 != geteuid())
31    {
32        QMessageBox msg;
33        msg.setText(w.tr("You should run this application as root"));
34        msg.exec();
35        exit(2);
36    }
37
38    QObject::connect(&a, SIGNAL(messageReceived(const QString &)), &w, SLOT(slotSingleInstance()));
39
40    return a.exec();
41}
Note: See TracBrowser for help on using the repository browser.