source: src-qt4/pc-pkgmanager/main.cpp @ 3f4caf6

9.1-release9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 3f4caf6 was 3f4caf6, checked in by Kris Moore <kris@…>, 12 months ago

Add the beginnings of our new pc-pkgmanager GUI utility

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[3f4caf6]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/PackageManager_" + langCode + ".qm" ) )
21     langCode.truncate(langCode.indexOf("_"));
22   translator.load( QString("PackageManager_") + 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;
39   if ( argc >= 2)
40   {
41       QString chkarg = argv[1];
42       // Running in a chroot
43       if ( chkarg == "-chroot" )
44         if ( argc == 3 ) {
45           chroot = argv[2];
46         } else {
47           qDebug() << "Usage: -chroot <directory>";
48           exit(1);
49         }
50   }
51
52   w.ProgramInit(chroot);
53   w.show();
54
55   QObject::connect( &a, SIGNAL( messageReceived(const QString &) ), &w, SLOT( slotSingleInstance() ) );
56   a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
57   return a.exec();
58}
Note: See TracBrowser for help on using the repository browser.