source: src-qt4/pc-dmconf/main.cpp @ 87b0318

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

Fix compilation of pc-dmconf on 10.x

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