Ejemplo n.º 1
0
int main( int argc, char ** argv )
{

	QApplication a( argc, argv );
//	dSelectDB dselectdb;
	dLogin dlogin;
//	application = &a;
	int rc = 1;
	bool ok;
	QPixmap pixmap;
	BrInitError error;

	QTextCodec::setCodecForCStrings( QTextCodec::codecForName("UTF8") );
	aLog::init("",aLog::MT_DEBUG);    

#ifndef _Windows
	if (br_init_lib(&error) == 0 && error != BR_INIT_ERROR_DISABLED) {
		aLog::print(aLog::MT_INFO, QObject::tr("Warning: BinReloc failed to initialize (error code %1)\n").arg(error));
		aLog::print(aLog::MT_INFO, QObject::tr("Will fallback to hardcoded default path.\n"));
	}
	aLog::print(aLog::MT_DEBUG, QObject::tr("main - BinReloc path to data dir is %1.\n").arg( br_find_data_dir("/usr/share") ));
	aLog::print(aLog::MT_DEBUG, QObject::tr("main - BinReloc path to lib dir is %1.\n").arg( br_find_data_dir("/usr/lib") ));
#endif
	if ( parseCommandLine( qApp->argc(), qApp->argv() ) ) return 1;
	qApp->installTranslator( &tr_app );
	qApp->installTranslator( &tr_lib );
	qApp->installTranslator( &tr_plugins );
	pixmap = QPixmap::fromMimeSource( "engine-splash-"+lang+".png" );
	if ( pixmap.isNull() )
#ifdef _Windows
	pixmap = QPixmap::fromMimeSource( qApp->applicationDirPath()+"/engine-splash-"+lang+".png" );
	qApp->addLibraryPath( qApp->applicationDirPath() );
#else
	pixmap = QPixmap::fromMimeSource( QString(br_find_data_dir("/usr/share") ) + "/ananas/designer/locale/engine-splash-"+lang+".png");
	qApp->addLibraryPath( QString( br_find_lib_dir("/usr/lib")) + "/ananas/qt3plugins" );

        QStringList list = a.libraryPaths();
	QString libPath = "";
	QStringList::Iterator it = list.begin();
	while( it != list.end() ) {
    	    libPath += *it+":";
    	    ++it;
	}
	aLog::print(aLog::MT_DEBUG, QString("main - qt library path is '%1'\n").arg( libPath));
#endif
	printf("extensions: \n%s\n",( const char *) AExtensionFactory::keys().join("\n") );
// Test create extension
//	AExtension *e = AExtensionFactory::create("AExtTest");
//	if (e) printf("EXT OK\n"); else printf("NO EXT OK\n");

	if ( pixmap.isNull() )
		pixmap = QPixmap::fromMimeSource( "engine-splash-en.png" );
	QSplashScreen *splash = new QSplashScreen( pixmap );
	if ( ananas_login( rcfile, username, userpassword ) ){
//	if ( rcfile.isEmpty() ) {
//    	    if (dselectdb.exec()==QDialog::Accepted) rcfile = dselectdb.rcfile;
//	}
//	if ( !rcfile.isEmpty() ) {
//    		if (dlogin.exec()==QDialog::Accepted) {
//		    username = dlogin.username;
//		    userpassword = dlogin.password;
//		}
//		if (dselectdb.rcfile.isEmpty()) return 0;

		splash->show();
		splash->message( QObject::tr("Init application"), Qt::AlignBottom, Qt::white );
		MainForm *w = new MainForm( 0, "MainForm");
		mainform = w;
		mainformws = mainform->ws;
		mainformwl = mainform->wl;
		qApp->setMainWidget( w );
		w->rcfile = rcfile;
//		printf( "rcfile = %s\n", rcfile.ascii() );
		w->show();
		ok = w->init();
		splash->clear();
       	splash->finish( w );
       	delete splash;
		if ( ok ) {
			qApp->connect( qApp, SIGNAL( lastWindowClosed() ), qApp, SLOT( quit() ) );
			rc = qApp->exec();
			if( w ) delete w;
			w=0;
		} else {
			QMessageBox::critical(0, QObject::tr("Error"), QObject::tr("Ananas runtime init error. See message window and log file for details."));
		}
		aLog::close();
		return rc;
	}
	else
	{
		aLog::close();
		return 0;
	}
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------------
// Run app
//----------------------------------------------------------------------------
void CApp::runApp()
{

    // We must always have an application
    QApplication application( argc_, argv_ );
    AmonSoft *main = new AmonSoft; // We create our dialog

    dlgAmonSoft *gui = const_cast< dlgAmonSoft* >( g_gui );
    gui = main;

    // Shareware version !
    QDate currentDate = QDate::currentDate();
    QDate expireDate;
    expireDate.setYMD( 2007, 12, 30 );

    if( currentDate > expireDate )
    {
        QMessageBox::critical( main,
            "Votre version a expiré",
            "Veuillez contacter votre revendeur pour continuer à utiliser ce programme",
            QMessageBox::Ok,
            QMessageBox::NoButton );
        exit( 0 );
    }

    // Splash screen
    QImage imgSplash( "Forms/Img/Splash.PNG" );
    QSplashScreen *splash =
	    new QSplashScreen( imgSplash );

    splash->show();  

    Datas::usLastId = 0;
    Datas::usLastIdEntses = 0;

    splash->message(QObject::tr("Initialisation de Xerces..."),
	    Qt::AlignLeft | Qt::AlignTop, Qt::blue);

    XMLPlatformUtils::Initialize();

    //<-- Insert here modules to load during splash screen
    splash->message(QObject::tr("Chargement de l'interface..."),
        Qt::AlignLeft | Qt::AlignTop, Qt::blue);
    //-->

    application.setMainWidget( main );        // It is our main widget

    CUpdater  up( *main );
    up.updateAvailable();

    // Interface init
    splash->message(QObject::tr("Chargement des données..."),
        Qt::AlignLeft | Qt::AlignTop, Qt::blue);

    makeBackup();

    // Load searchs
    Datas::g_Search = new Datas::CSearch();
    Datas::g_Search->loadFileSearch( sSearchFile );
    Datas::g_Search->loadInComboBox( main->comboBoxSearchFunction, true );

    // Add empty enterprise and person to reset form
    Datas::CPersonnes    *pEmptyPerson = new Datas::CPersonnes( true );
    Datas::CEntreprise   *pEmptyEnterprise = new Datas::CEntreprise( true );

    Datas::g_listPersonnes.push_back( pEmptyPerson );
    Datas::g_listEntreprises.push_back( pEmptyEnterprise );
        
    // Initialize & load preference system
    g_Preferences = new Preferences::CPreferences();

    // Initialize parser
    g_Parser              = new CParser( sPersonnesFile );
    g_ParserEntses        = new CParser( sEntreprisesFile );
    g_ParserFamille       = new CParser( sFamilleFile );

    // Be carrefull, order is really important !
    loadXercesData( *main );
    loadXercesDataEntses( *main );
    loadXercesDataFamille( *main ); // Always after Personnes load !!

    // TODO: Put progress bar

    // Show version information
    QString   strVersion = "Amonsoft (c) Sesam micro 2005-2006 Version ";
    qDebug( strVersion + STR_APP_VERSION );

    main->lister();
    main->show(); // Show it...
        
    delete splash;

    application.exec();              // And run!

    saveXercesData();
    delete g_Preferences;

    XMLPlatformUtils::Terminate();    
}
Ejemplo n.º 3
0
int main( int argc, char **argv )
{
	QPCApplication app(argc, argv);

	QApplication::setStyle("plastik");
	
	qapital::QPLOGGER.salvarLog(SBLogger::QP_INFO, SBLogger::CLIENTE, QObject::tr("Iniciando QPCliente"));
	
	QString splash = qapital::GUIDATADIR + QString("qapital-splash-2004-08-31.png");
	
	QPixmap pixmap( splash );
    	QSplashScreen *pantalla = new QSplashScreen( pixmap );
      	pantalla->show();
	pantalla->message(QObject::tr("Iniciando aplicacion..."));

	QFile configFile( qapital::CONFIGRC +  QString("QPCConfig.xml"));

	QXmlInputSource sourceXML(configFile);
	configFile.close();
	
	QPCConfigHandler *handler = new QPCConfigHandler;
	QXmlSimpleReader reader;
    	reader.setContentHandler( handler );
		
	if ( ! reader.parse( sourceXML ) )
	{
		std::cout << QObject::tr("Error en la configuracion del cliente") << std::endl;
	}		
	
	ClnRed cliente ( handler->obtenerQPSHost(), handler->obtenerQPSPuerto() );

	pantalla->message(QObject::tr("creando interfaz..."));

	//GCLMdiMainWindow *qpCliente;
	QMainWindow *qpCliente = 0;

	switch ( int opt = handler->obtenerTipoDeInterfaz() )
	{
		case SBGui::MenuBased:
		{
			std::cout << "Iniciando MenuBased" << std::endl;
			qpCliente = new GCLPrincipal(&cliente);
		}
		break;
		case SBGui::MDIBased:
		{
			std::cout << "Iniciando MDIBased" << std::endl;
			qpCliente = new GCLMdiMainWindow();
		}
		break;
		default:
		{
			std::cout << "Tipo de interfaz desconocido " << opt << std::endl;
			qpCliente = new GCLMdiMainWindow();
		}
		break;
	}
	
	app.setMainWidget( qpCliente );
	
	
	QObject::connect( qApp, SIGNAL( lastWindowClosed() ), &cliente, SLOT( clnCerrarConexion() ) );
	
	pantalla->finish( qpCliente );

    	delete pantalla;
	
	return app.exec();
}
Ejemplo n.º 4
0
void aq_main(int argc, char **argv) 
{
  QPalette p(QColor(229, 229, 229), QColor(229, 229, 229));
  p.setColor(QPalette::Active, QColorGroup::Dark, QColor(246, 242, 246));
  p.setColor(QPalette::Inactive, QColorGroup::Dark, QColor(246, 242, 246));
  p.setColor(QPalette::Disabled, QColorGroup::Dark, QColor(246, 242, 246));
  p.setColor(QPalette::Active, QColorGroup::Base, QColor(255, 255, 248));
  p.setColor(QPalette::Inactive, QColorGroup::Base, QColor(255, 255, 248));
  p.setColor(QPalette::Disabled, QColorGroup::Base, QColor(255, 255, 248));
  p.setColor(QPalette::Active, QColorGroup::Highlight, QColor(95, 150, 205));
  p.setColor(QPalette::Active, QColorGroup::HighlightedText, Qt::white);
  p.setColor(QPalette::Active, QColorGroup::Highlight, QColor(95, 150, 205));
  p.setColor(QPalette::Inactive, QColorGroup::HighlightedText, Qt::white);
  p.setColor(QPalette::Active, QColorGroup::Highlight, QColor(95, 150, 205));
  p.setColor(QPalette::Disabled, QColorGroup::HighlightedText, Qt::white);
  p.setColor(QPalette::Inactive, QColorGroup::Text, Qt::black);
  p.setColor(QPalette::Disabled, QColorGroup::Text, QColor(100, 100, 100));
  p.setColor(QPalette::Active, QColorGroup::Foreground, QColor(30, 30, 30));
  p.setColor(QPalette::Inactive, QColorGroup::Foreground, QColor(30, 30, 30));
  p.setColor(QPalette::Disabled, QColorGroup::Foreground, QColor(100, 100, 100));
  p.setColor(QPalette::Active, QColorGroup::ButtonText, QColor(30, 30, 30));
  p.setColor(QPalette::Inactive, QColorGroup::ButtonText, QColor(30, 30, 30));
  p.setColor(QPalette::Disabled, QColorGroup::ButtonText, QColor(100, 100, 100));

  QString formAlone, callFunction, arguments, strConn, silentConn;
  bool quitAfterCall = false, autoLogin_ = false, noMax = false;

  for (int i = 1; i < argc; i++) {
    if (qstrcmp(argv[i], "-f") == 0) {
      if (i != argc - 1) {
        i++;
        formAlone = QString::fromLatin1(argv[i]);
      }
    } else if (qstrcmp(argv[i], "-c") == 0) {
      if (i != argc - 1) {
        i++;
        callFunction = QString::fromLatin1(argv[i]);
      }
    } else if (qstrcmp(argv[i], "-a") == 0) {
      if (i != argc - 1) {
        i++;
        arguments = QString::fromLatin1(argv[i]);
      }
    } else if (qstrcmp(argv[i], "-sc") == 0) {
      if (i != argc - 1) {
        i++;
        strConn = QString::fromLatin1(argv[i]);
      }
    } else if (qstrcmp(argv[i], "-silentconn") == 0) {
      if (i != argc - 1) {
        i++;
        silentConn = QString::fromLatin1(argv[i]);
      }
    } else if (qstrcmp(argv[i], "-q") == 0) {
      quitAfterCall = true;
    } else if (qstrcmp(argv[i], "-auto") == 0) {
      autoLogin_ = true;
    } else if (qstrcmp(argv[i], "-nomax") == 0) {
      noMax = true;
    }
  }

  FLApplication *AbanQ = aqApp;
  QFont appFont;

  QStringList paths(AbanQ->libraryPaths());
  QString pathApp(AQ_PREFIX + "/plugins");
  if (!paths.contains(pathApp))
    paths << pathApp;
  if (!paths.contains(AQ_LIB))
    paths << AQ_LIB;
  AbanQ->setLibraryPaths(paths);

  int pointSize = 8;

#if defined (Q_OS_LINUX)
  appFont.setFamily(FLSettings::readEntry("font/family", "Verdana"));
#endif

#if defined(Q_OS_WIN32)
  appFont.setFamily(FLSettings::readEntry("font/family", "Tahoma"));
#endif

#if defined(Q_OS_MACX)
  appFont.setFamily(FLSettings::readEntry("font/family", "Lucida Grande"));
  pointSize = 12;
  QString envPath(getenv("PATH"));
  envPath = "/sw/sbin:/sw/bin:" + envPath + ":/usr/X11R6/bin";
  setenv("PATH", envPath.local8Bit(), 1);
#endif

  appFont.setPointSize(FLSettings::readNumEntry("font/pointSize", pointSize));
  appFont.setBold(FLSettings::readBoolEntry("font/bold", false));
  appFont.setItalic(FLSettings::readBoolEntry("font/italic", false));
  appFont.setUnderline(FLSettings::readBoolEntry("font/underline", false));
  appFont.setStrikeOut(FLSettings::readBoolEntry("font/strikeOut", false));

  AbanQ->setFont(appFont);
  AbanQ->setStyle(FLSettings::readEntry("style", "QtCurve"));

  AbanQ->installTranslator(AbanQ->createSysTranslator(QString(QTextCodec::locale()).left(2), true));
  AbanQ->installTranslator(AbanQ->createSysTranslator("multilang"));
  AbanQ->setPalette(p, true);

  FLConnectDBDialog *s = 0;
  QSplashScreen *splash = 0;

  if (silentConn.isEmpty()) {
    bool autoLogin = FLSettings::readBoolEntry("application/autoLogin", autoLogin_);
    s = new FLConnectDBDialog(autoLogin, 0, "FLConnectDBDialog", 0, strConn);

    static_cast<QWidget *>(s->child("frMore"))->hide();
    s->adjustSize();
    s->setPalette(p);
    int ret = -1;
    bool connectAttempts = 0;

    do {
      if (!s->isShown()) {
        s->show();
        s->raise();
      }
      if (autoLogin && !connectAttempts) {
        QTimer::singleShot(1000, s, SLOT(tryConnect()));
        connectAttempts++;
      } else
        s->exec();
    } while (s->error());

    ret = s->result();
    QTimer::singleShot(0, s, SLOT(deleteLater()));

    if (ret != QDialog::Accepted) {
      QTimer::singleShot(0, AbanQ, SLOT(quit()));
      return;
    }

    splash = new QSplashScreen(QPixmap::fromMimeSource("splashabanq.png"));
    splash->show();
    splash->message(QT_TR_NOOP("Inicializando..."), Qt::AlignRight, QColor(0, 0, 0));
  } else if (!silentConnect(silentConn)) {
    QTimer::singleShot(0, AbanQ, SLOT(quit()));
    return;
  }
  AbanQ->setNotExit(FLSettings::readBoolEntry("application/notExit", false));
  AbanQ->setPrintProgram(FLSettings::readEntry("printing/printProgram", QString::null));
  AbanQ->flushX();
  AbanQ->syncX();
  AbanQ->processEvents();
  AbanQ->init(
    FLSettings::readEntry("application/formAlone", formAlone),
    FLSettings::readEntry("application/callFunction", callFunction),
    FLSettings::readEntry("application/arguments", arguments),
    FLSettings::readBoolEntry("application/quitAfterCall", quitAfterCall),
    FLSettings::readBoolEntry("application/noMax", noMax)
  );

  if (AbanQ->mainWidget()) {
    AbanQ->mainWidget()->show();
    AbanQ->mainWidget()->raise();
    if (splash) {
      splash->finish(AbanQ->mainWidget());
      delete splash;
    }
  } else {
    if (splash) {
      QTimer::singleShot(0, splash, SLOT(deleteLater()));
    }
  }
    
}