source: src-qt4/pc-updategui/main.cpp @ cd8bb9d

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

Fix compilation warning for pc-update-gui on 10.x

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#include <qapplication.h>
2#include <qtranslator.h>
3#include <qtextcodec.h>
4#include <qstylefactory.h>
5#include <qdesktopwidget.h>
6#include <qtsingleapplication.h>
7#include <QDebug>
8#include "mainWin.h"
9#include "../config.h"
10
11int main( int argc, char ** argv )
12{
13   QtSingleApplication a(argc, argv);
14   if (a.isRunning())
15     return !(a.sendMessage("show"));
16
17   QTranslator translator;
18   QLocale mylocale;
19   QString langCode = mylocale.name();
20   if ( ! QFile::exists( PREFIX + "/share/pcbsd/i18n/UpdateGUI_" + langCode + ".qm" ) )
21     langCode.truncate(langCode.indexOf("_"));
22   translator.load( QString("UpdateGui_") + langCode, PREFIX + "/share/pcbsd/i18n/" );
23   a.installTranslator( &translator );
24   qDebug() << "Locale:" << langCode;
25
26   // Check the language we are running in, and set the correct font
27   if (  langCode == "zh_CN" ||  langCode == "zh_TW" )
28   {
29     QFont f( "mingunittf", 10);
30     a.setFont( f);
31   } else if ( langCode == "ja" ) {
32     QFont f( "vlgothic", 10);
33     a.setFont( f);
34   }
35 
36   mainWin w;
37
38   QString chroot, ip;
39   if ( argc >= 2)
40   {
41       QString chkarg = argv[1];
42       // Running in a warden jail?
43       if ( chkarg == "-warden" )
44         if ( argc == 4 ){
45           chroot = argv[2];
46           ip = argv[3];
47         }else{
48           qDebug() << "Usage: -warden <directory> <ip>";
49           exit(1);
50         }
51   }
52
53   w.ProgramInit(chroot, ip);
54   w.show();
55
56   QObject::connect( &a, SIGNAL( messageReceived(const QString &) ), &w, SLOT( slotSingleInstance() ) );
57   a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
58   return a.exec();
59}
Note: See TracBrowser for help on using the repository browser.