コード例 #1
0
int main(int argc, char *argv[])
{

	KAboutData aboutData( "kmouth", I18N_NOOP("KMouth"),
		KMOUTH_VERSION, description, KAboutData::License_GPL,
		"(c) 2002/2003, Gunnar Schmi Dt", 0, "http://www.schmi-dt.de/kmouth/index.en.html", "*****@*****.**");
	aboutData.addAuthor("Gunnar Schmi Dt",0, "*****@*****.**");
	KCmdLineArgs::init( argc, argv, &aboutData );
	KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

	aboutData.addCredit("Olaf Schmidt", I18N_NOOP("Tips, extended phrase books"), 0, 0);
  KApplication app;

  if (app.isRestored())
  {
    RESTORE(KMouthApp);
  }
  else
  {
    KMouthApp *kmouth = new KMouthApp();
    if (!kmouth->configured())
       return 0;

    kmouth->show();

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

		if (args->count())
		{
        kmouth->openDocumentFile(args->url(0));
		}
		args->clear();
  }
  return app.exec();
}
コード例 #2
0
int main(int argc, char *argv[])
{

	KAboutData aboutData( "klatin", I18N_NOOP("KLatin"),
	"0.9", description, KAboutData::License_GPL,
	"(C) 2001-2004, George Wright", 0, "http://edu.kde.org/klatin", "*****@*****.**");

	aboutData.addAuthor("George Wright",I18N_NOOP("Author and Maintainer"), "*****@*****.**");
	aboutData.addCredit("Anne-Marie Mahfouf",I18N_NOOP("Bug fixes, documentation"), "*****@*****.**");
	aboutData.addCredit("Neil Stevens",I18N_NOOP("Vocabulary shuffling code"), "*****@*****.**");
	
	aboutData.addCredit("Danny Allen",I18N_NOOP("SVG icon"), "*****@*****.**");
	aboutData.addCredit("Pino Toscano",I18N_NOOP("Bug fixes and code improvement, Italian Vocabulary Data Translation"), "*****@*****.**");
	aboutData.addCredit("Mikolaj Machowski",I18N_NOOP("Polish Vocabulary Data Translation"), "*****@*****.**");

	KCmdLineArgs::init( argc, argv, &aboutData );
	KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

	KApplication a;
	
	KLatin *klatin = new KLatin();
	
	if (a.isRestored()) {
		RESTORE(KLatin);
	} else {
		a.setMainWidget(klatin);
		klatin->show();
	}
	
	return a.exec();
}
コード例 #3
0
int main(int argc, char **argv)
{
    KAboutData about("proptest", "KoProperty Test", version, description,
                     KAboutData::License_GPL, "(C) 2005 Cedric Pasteur", 0, 0, "*****@*****.**");
    about.addAuthor( "Cedric Pasteur", 0, "*****@*****.**" );
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions( options );
    KApplication app;
    Test *mainWin = 0;

    if (app.isRestored())
    {
        RESTORE(Test);
    }
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

        /// @todo do something with the command line args here

        mainWin = new Test();
        app.setMainWidget( mainWin );
        mainWin->show();

        args->clear();
    }

    // mainWin has WDestructiveClose flag by default, so it will delete itself.
    return app.exec();
}
コード例 #4
0
ファイル: main.cpp プロジェクト: serghei/kde3-kdewebdev
int main(int argc, char *argv[])
{

    KAboutData aboutData( "kimagemapeditor", I18N_NOOP("KImageMapEditor"),
                          VERSION, description, KAboutData::License_GPL,
                          "(C) 2001-2008 Jan Schaefer", 0, "http://www.nongnu.org/kimagemap/", "*****@*****.**");
    aboutData.addAuthor("Jan Schaefer",0, "*****@*****.**");
    aboutData.addCredit("Joerg Jaspert",I18N_NOOP("For helping me with the Makefiles, and creating the Debian package"));
    aboutData.addCredit("Aaron Seigo and Michael",I18N_NOOP("For helping me fixing --enable-final mode"));
    aboutData.addCredit("Antonio Crevillen",I18N_NOOP("For the Spanish translation"));
    aboutData.addCredit("Fabrice Mous",I18N_NOOP("For the Dutch translation"));
    aboutData.addCredit("Germain Chazot",I18N_NOOP("For the French translation"));
    KCmdLineArgs::init( argc, argv, &aboutData );
    KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

    KApplication a;
    a.dcopClient()->registerAs(a.name());



    if (a.isRestored())
    {
        RESTORE(KimeShell);
    }
    else
    {
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
        if ( args->count() == 0 )
        {
            KimeShell *kimeShell = new KimeShell();
            kimeShell->setStdout(args->isSet("stdout"));
            kimeShell->readConfig();
            kimeShell->show();
            kimeShell->openLastFile();
        }
        else
        {
            int i = 0;
            for (; i < args->count(); i++ )
            {
                KimeShell *kimeShell = new KimeShell();
                kimeShell->setStdout(args->isSet("stdout"));
                kimeShell->readConfig();
                kimeShell->show();
                kimeShell->openFile(args->url(i));
            }
        }
        args->clear();
    }

    return a.exec();
}
コード例 #5
0
ファイル: main.cpp プロジェクト: iegor/kdesktop
int main( int argc, char** argv )
{
  KAboutData aboutData( "kdat", I18N_NOOP("KDat"), 
    KDAT_VERSION, description, KAboutData::License_GPL, 
    "(c) 1999-2000, Sean Vyain; 2001-2002 Lawrence Widman");

  /* 2002-01-28 LEW: so we can dump core if we want to */
  // KCrash::setCrashHandler(0);  // this is supposed to work, but it doesn't
#ifdef DEBUG
  {
    char *newarg;
    if( ( newarg = (char *)malloc( strlen("--nocrashhandler") + 1 ) ) == NULL )
      {
	KMessageBox::sorry(NULL, i18n("Can't allocate memory in kdat"));
        exit(1);
      }
    strcpy( newarg, "--nocrashhandler" );
    argv[ argc ] = newarg;
    argc++;
  }
  {
    int i;
    for(i=0; i<argc; i++){
      printf("Arg %d: %s\n", i, argv[i]);
    }
  }
#endif /* DEBUG */
  /* 2002-01-28 LEW */

  KCmdLineArgs::init( argc, argv, &aboutData );
  aboutData.addAuthor( "Lawrence Widman", 0, "*****@*****.**");
//  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
  KApplication app;
  
  app.setMainWidget( KDatMainWindow::getInstance() );

  /* set up error handler so we don't crash without notice */
  signal(SIGHUP,  error_handler);
  signal(SIGINT,  error_handler);
  signal(SIGFPE,  error_handler);
  signal(SIGSEGV, error_handler);
  signal(SIGTERM, error_handler);   

  if ( app.isRestored() && KDatMainWindow::canBeRestored( 1 ) ) {
    KDatMainWindow::getInstance()->restore( 1 );
  } else {
    KDatMainWindow::getInstance()->show();
  }

  return app.exec();
}
コード例 #6
0
ファイル: main.cpp プロジェクト: BackupTheBerlios/kasablanca
int main(int argc, char **argv)
{
	 KLocale::setMainCatalogue("kasablanca");	

    KAboutData about("kasablanca", I18N_NOOP("kasablanca"), version, description,
                     KAboutData::License_GPL, "(C) 2004 Magnus Kulke", 0, 0,
							"*****@*****.**");
    about.addAuthor( "Magnus Kulke", 0, "*****@*****.**" );
    about.addAuthor( "Big Biff", 0, "*****@*****.**" );
	 about.addCredit( "Stefan Bogner", 0, "*****@*****.**" );
	 about.addCredit( "Christoph Thielecke", 0, "*****@*****.**" );
	about.addCredit( "Richard Stellingwerf", 0, "*****@*****.**" );
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions(options);
    KApplication app;

    // register ourselves as a dcop client
    app.dcopClient()->registerAs(app.name(), false);

    // see if we are starting with session management
    if (app.isRestored())
    {
        RESTORE(Kasablanca);
    }
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
        if (args->count() == 0)
        {
            Kasablanca *widget = new Kasablanca;
            widget->show();
        }
        else
        {
            int i = 0;
            for (; i < args->count(); i++)
            {
                Kasablanca *widget = new Kasablanca;
                widget->show();
// TODO: Load the ftp url passed on the command line.
//                widget->load(args->url(i));
            }
        }
        args->clear();
    }

    return app.exec();
}
コード例 #7
0
int main(int argc, char **argv)
{
    KAboutData about("ktouch",
                     I18N_NOOP("KTouch"),
                     version,
                     description,
                     KAboutData::License_GPL,
                     "Copyright (C) 2000-2006 by Håvard Frøiland and Andreas Nicolai",
                     0,
                     "http://edu.kde.org/ktouch",
                     "*****@*****.**");
    about.addAuthor( "Andreas Nicolai", I18N_NOOP("Current maintainer and programmer"), "*****@*****.**" );
    about.addAuthor( "Håvard Frøiland", I18N_NOOP("Original author, project admin"), "*****@*****.**" );
    about.addCredit( "David Vignoni", I18N_NOOP("Creator of the SVG icon"), "*****@*****.**");
    about.addCredit( "Anne-Marie Mahfouf", I18N_NOOP("Lots of patches, fixes, updates"), "*****@*****.**");
    about.addCredit( "All the creators of training and keyboard files", 0, 0);
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions( options );
    KApplication app;
    KTouch *mainWin = 0;

    if (app.isRestored()) {
        RESTORE(KTouch);
    }
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
        // TODO: check the command line for a training file and set this as the new to open training file

        /* TODO: turn splash screen on in release
        KTouchSplash splash;            // create the splash screen
        splash.setHideEnabled( true );  // allow user to click the splash screen away
        splash.show();                  // show it
        QTimer splashTimer;
        splashTimer.connect(&splashTimer, SIGNAL(timeout()), &splash, SLOT(hide()));
        splashTimer.start(2000, true);  // start singleshot timer to hide the splashscreen
        */

        mainWin = new KTouch();
        app.setMainWidget( mainWin );

        mainWin->show();
        args->clear();
    }

    return app.exec();
}
コード例 #8
0
ファイル: main.cpp プロジェクト: serghei/kde3-apps-dolphin
int main(int argc, char **argv)
{
    KAboutData about("d3lphin",
                     I18N_NOOP("Dolphin"),
                     "0.9.2",
                     I18N_NOOP("File Manager"),
                     KAboutData::License_GPL,
                     "(C) 2007 Marcel Juhnke");
    about.setHomepage("https://marrat.homelinux.org/D3lphin");
    about.setBugAddress("*****@*****.**");
    about.addAuthor("Marcel Juhnke", I18N_NOOP("Maintainer and developer"), "*****@*****.**");
    about.addAuthor("Michael Austin", I18N_NOOP("Documentation"), "*****@*****.**");
    about.addAuthor("Orville Bennett", I18N_NOOP("Documentation"), "*****@*****.**");
    about.addCredit("Peter Penz", I18N_NOOP("... for the great original Dolphin"));
    about.addCredit("Cvetoslav Ludmiloff, Stefan Monov", I18N_NOOP("... for their development on the original Dolphin"));
    about.addCredit("Aaron J. Seigo", I18N_NOOP("... for the great support and the amazing patches for the orignal Dolphin"));
    about.addCredit("Patrice Tremblay, Gregor Kalisnik, Filip Brcic, Igor Stepin and Jan Mette", I18N_NOOP("... for their patches"));
    about.addCredit("Ain, Itai, Ivan, Jannick, Stephane, Patrice, Piotr, Stefano and Power On",
                    I18N_NOOP("... for their translations"));

    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;
    Dolphin& mainWin = Dolphin::mainWin();
    mainWin.show();

    if (app.isRestored()) {
        int n = 1;
        while (KMainWindow::canBeRestored(n)){
            Dolphin::mainWin().restore(n);
            ++n;
        }
    } else {
        KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
        if (args->count() > 0) {
            mainWin.activeView()->setURL(args->url(0));

            for (int i = 1; i < args->count(); ++i) {
                KRun::run("d3lphin", args->url(i));
            }
        }
        args->clear();
    }

    return app.exec();
}
コード例 #9
0
ファイル: main.cpp プロジェクト: serghei/kde3-kdewebdev
int main(int argc, char *argv[])
{
    KAboutData about("kfilereplace", I18N_NOOP("KFileReplace"), version, description,
                     KAboutData::License_GPL_V2, "(C) 2004-2005 Andras Mantia\n(C) 2004-2005 Emiliano Gulmini\n(C) 1999-2002 Francois Dupoux", I18N_NOOP("Part of the KDEWebDev module."),
                     "http://www.kdewebdev.org");

    about.addAuthor("Andras Mantia", I18N_NOOP("Shell author, KPart creator, co-maintainer"), "*****@*****.**");
    about.addAuthor("Emiliano Gulmini", I18N_NOOP("Current maintainer, code cleaner and rewriter"),"*****@*****.**");
    about.addAuthor("Francois Dupou",
                          I18N_NOOP("Original author of the KFileReplace tool"),
                          "*****@*****.**");

    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions( options );

    KApplication app;

    // see if we are starting with session management
    if (app.isRestored())
    {
        RESTORE(KFileReplace);
    }
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

        KFileReplace *kfr = new KFileReplace;
        kfr->show();

        if (args->count() == 0)
        {
            kfr->openURL(KURL());
        }
        else
        {
            kfr->openURL(args->url(0));
        }
        args->clear();
    }

    return app.exec();
}
コード例 #10
0
ファイル: main.cpp プロジェクト: Flameeyes/atmosphere
int main(int argc, char **argv)
{
	// Initialize net-snmp library
	KSNMP::init("atmosphere");
		
	KAboutData about("atmosphere", I18N_NOOP("ATMOSphere"), version, description,
			KAboutData::License_GPL, "(C) 2004 Flameeyes", 0, 0, "*****@*****.**");
	about.addAuthor( "Flameeyes", 0, "*****@*****.**" );
	KCmdLineArgs::init(argc, argv, &about);
	KCmdLineArgs::addCmdLineOptions( options );
	KApplication app;
	ATMOSphere *mainWin = 0;
	
	try {
		if (app.isRestored())
		{
			RESTORE(ATMOSphere);
		}
		else
		{
			// no session.. just start up normally
			KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
		
			/// @todo do something with the command line args here
		
			mainWin = new ATMOSphere();
			app.setMainWidget( mainWin );
			mainWin->show();
		
			args->clear();
		}
	} catch( ATMOS::Exception &e ) {
		KMessageBox::error(0, e.message(), "Unhandled exception!", KMessageBox::Dangerous);
	}
	
	// mainWin has WDestructiveClose flag by default, so it will delete itself.
	int ret = app.exec();
	
	// Deinitialize net-snmp library
	KSNMP::shutdown();
	
	return ret;
}
コード例 #11
0
ファイル: main.cpp プロジェクト: nijel/kalcatel
int main(int argc, char *argv[]) {
    KAboutData aboutData( "kalcatel", I18N_NOOP("KAlcatel"),
        VERSION, description, KAboutData::License_GPL,
        "(c) 2002, Michal Cihar",
        I18N_NOOP("This application allows you to manage messages, calls, contacts, todos\n"
        "and calendar in your Alcatel One Touch 50x and 70x mobile.\n\n"
        "Protocol used by this phone is binary and not documented, so this\n"
        "program could not guarantee any functionality in your case, but it works well for me."),
        "http://cihar.liten.cz", "*****@*****.**");
    aboutData.addAuthor("Michal Cihar",0, "*****@*****.**");
    aboutData.addCredit("Alcatel", I18N_NOOP("for NOT publishing specification of protocol\n"
        "Their only answer was:\n"
        "\"Your piece of advice will be helpful enough for us to deliberate\n"
        "and  get the best service for all our customers.\"\n\n"
        "However they probably like this program because they write about it\n"
        "in their news (HTTP Referer can contain many information) and they\n"
        "downloaded few copies of it (from alcatel.de and alcatel.be) ;-)."),
        "*****@*****.**", "http://www.alcatel.com");
    aboutData.addCredit("George Voina", I18N_NOOP("for initial KDE/Qt 3 porting"),
        "*****@*****.**", "http://www.esat.kuleuven.ac.be/~gvoina");
    KCmdLineArgs::init( argc, argv, &aboutData );
    KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

    KApplication app;
 
    if (app.isRestored()) {
        RESTORE(KAlcatelApp);
    } else {
        KAlcatelApp *kalcatel = new KAlcatelApp();
        kalcatel->show();

        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

        if (args->count()) {
            kalcatel->openDocumentFile(args->arg(0));
        } else {
//            kalcatel->openDocumentFile();
        }
        args->clear();
    }

    return app.exec();
}  
コード例 #12
0
ファイル: main.cpp プロジェクト: BackupTheBerlios/keda-svn
int main(int argc, char **argv)
{
    KAboutData about("composer", I18N_NOOP("Composer"), version, description,
                     KAboutData::License_GPL, "(C) 2007 sebastian", 0, 0, "*****@*****.**");
    about.addAuthor( "sebastian", 0, "*****@*****.**" );
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions(options);
    KApplication app;

    // register ourselves as a dcop client
    app.dcopClient()->registerAs(app.name(), false);

    // see if we are starting with session management
    if (app.isRestored())
    {
        RESTORE(Composer);
    }
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
        if (args->count() == 0)
        {
            Composer *widget = new Composer;
            widget->show();
        }
        else
        {
            int i = 0;
            for (; i < args->count(); i++)
            {
                Composer *widget = new Composer;
                widget->show();
                widget->load(args->url(i));
            }
        }
        args->clear();
    }

    return app.exec();
}
コード例 #13
0
ファイル: main.cpp プロジェクト: fullstory-morgue/sidux-edu
int main(int argc, char **argv)
{
	// specify data for About dialog
	KAboutData* about = new KAboutData("aptgetkonsole", "aptgetkonsole", "");

	about->setProgramLogo( QImage("/usr/share/icons/hicolor/32x32/apps/kappinstaller.png") );
	about->setShortDescription( "aptgetkonsole" );
	about->setLicense(KAboutData::License_GPL_V2);
	about->setHomepage("http://linux.wuertz.org");
	about->setBugAddress("*****@*****.**");
	about->setCopyrightStatement("(c) 2008 Fabian Wuertz");
	about->addAuthor("Fabian Würtz (xadras)", "Developer", "*****@*****.**", "http://linux.wuertz.org/");


	KCmdLineArgs::init(argc, argv, about);
	KCmdLineArgs::addCmdLineOptions( options );


	KApplication app;
	ac *mainWin = 0;

	// start program
	if (!app.isRestored())
	{
		KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
		
		QString changes;
		for(int i = 0; i < args->count(); i++) // Counting start at 0!
			changes = QString::fromLocal8Bit(args->arg(i));



		mainWin = new ac( changes );
		app.setMainWidget( mainWin );
		mainWin->show();

		args->clear();
	}

	return app.exec();
}
コード例 #14
0
int main(int argc, char *argv[])
{
  // about the application
  KAboutData *aboutData = new KAboutData("kmag", I18N_NOOP("KMagnifier"), KMAG_VERSION,
                                         I18N_NOOP("Screen magnifier for the K Desktop Environment (KDE)"),
                                         KAboutData::License_GPL,
                                         "(C) 2001-2003, Sarang Lakare","",
                                         "http://kmag.sourceforge.net");

  // about the authors
  aboutData->addAuthor("Sarang Lakare",
                       I18N_NOOP("Rewrite and current maintainer"),"*****@*****.**",
                       "http://www.cs.sunysb.edu/~lsarang/linux");
  aboutData->addAuthor("Michael Forster",
                       I18N_NOOP("Original idea and author (KDE1)"), "*****@*****.**");

  aboutData->addCredit("Olaf Schmidt", I18N_NOOP("Rework of the user interface, improved selection window, speed optimisation, rotation, bug fixes"), "*****@*****.**");
  aboutData->addCredit("Claudiu Costin", I18N_NOOP("Some tips"), "*****@*****.**",
                       "http://www.ro.kde.org");

  KCmdLineArgs::init( argc, argv, aboutData );
  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  KApplication app;

  if (app.isRestored())
  {
    RESTORE(KmagApp);
  }
  else
  {
    kmagapp = new KmagApp();

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    args->clear();
  }

  return app.exec();
}
コード例 #15
0
int main(int argc, char *argv[])
{

  global_debug=0;
  KAboutData aboutData( "lskat", I18N_NOOP("Lieutenant Skat"),
                        "1.0",
                        I18N_NOOP("Card Game"),
                        KAboutData::License_GPL,
                        "(c) 2000, Martin Heni");
  aboutData.addAuthor("Martin Heni",0, "*****@*****.**");
  aboutData.addCredit("Laura", I18N_NOOP("Beta testing"), 0);
  KCmdLineArgs::init( argc, argv, &aboutData );
  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  /* command line handling */
  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

  if (args->isSet("debug"))
  {
    QString s = args->getOption("debug");
    global_debug = s.toInt();
    qDebug("Debug level set to %d\n", global_debug);
  }
  args->clear();

  KApplication app;

  if (app.isRestored())
  {
    RESTORE(LSkatApp);
  }
  else
  {
    LSkatApp *lskat = new LSkatApp();
    lskat->show();
  }

  return app.exec();
}
コード例 #16
0
int main(int argc, char **argv)
{
  KAboutData about("protoeditor", I18N_NOOP("Protoeditor"), version, description,
                   KAboutData::License_GPL, "(C) 2004 Thiago Silva", 0, 0, "*****@*****.**");
  about.addAuthor( "Thiago Silva", 0, "*****@*****.**" );
  KCmdLineArgs::init(argc, argv, &about);
  KCmdLineArgs::addCmdLineOptions( options );


  KApplication app;
  //ProtoEditor *protoeditor = 0;
  //ProtoEditor protoeditor;
  MainWindow window;


  if (app.isRestored())
  {
    RESTORE(MainWindow);
  }
  else
  {
    // no session.. just start up normally

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    //protoeditor = new ProtoEditor();
    //QWidget* mainWin = protoeditor.mainWindow();
    app.setMainWidget(&window);
    window.show();

    args->clear();
  }

  // mainWin has WDestructiveClose flag by default, so it will delete itself.
  return app.exec();

  //delete protoeditor;
}
コード例 #17
0
ファイル: main.cpp プロジェクト: corentin38/konjue
int main(int argc, char **argv)
{
  KAboutData about("konjue", I18N_NOOP("Konjue"), version, description,
                   KAboutData::License_GPL, "(C) 2005 Pieter Pareit", 0, 0, "*****@*****.**");
  about.addAuthor( "Pieter Pareit", 0, "*****@*****.**" );
  about.addCredit( "Pierre Sarrazin", I18N_NOOP("Programmer of Verbiste, backend used by Konjue."),
                   "sarrazip AT sarrazip DOT com", "http://sarrazip.com" );
  about.addCredit( "Sebastian Sariego Benitez", I18N_NOOP("Artist that created the icon for Konjue."),
                   "segfault AT kde DOT cl", "http://segfault.kde.cl" );
  KCmdLineArgs::init(argc, argv, &about);
  KCmdLineArgs::addCmdLineOptions(options);
  KApplication app;

  // register ourselves as a dcop client
  app.dcopClient()->registerAs(app.name(), false);

  // see if we are starting with session management
  if (app.isRestored())
  {
    RESTORE(Konjue);
  }
  else
  {
    // no session.. just start up normally, create window
    Konjue *widget = new Konjue;
    widget->show();
    // load all verbs that were give as arguments
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    for (int i = 0; i < args->count(); i++)
    {
      widget->displayVerb( args->arg( i ) );
    }
    args->clear();
  }

  return app.exec();
}
コード例 #18
0
int main(int argc, char *argv[])
{
    KAboutData aboutData( "kbugbuster", I18N_NOOP( "KBugBuster" ),
                          VERSION, description, KAboutData::License_GPL,
                          I18N_NOOP("(c) 2001,2002,2003 the KBugBuster authors") );
    aboutData.addAuthor( "Martijn Klingens", 0, "*****@*****.**" );
    aboutData.addAuthor( "Cornelius Schumacher", 0, "*****@*****.**" );
    aboutData.addAuthor( "Simon Hausmann", 0, "*****@*****.**" );
    aboutData.addAuthor( "David Faure", 0, "*****@*****.**" );
    KCmdLineArgs::init( argc, argv, &aboutData );
    KCmdLineArgs::addCmdLineOptions( options );

    KApplication app;

    app.dcopClient()->attach();

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if (args->isSet("disconnected")) {
        BugSystem::self()->setDisconnected( true );
    }

    if ( app.isRestored() )
    {
        RESTORE( KBBMainWindow );
    }
    else
    {
        KBBMainWindow *mainWin = new KBBMainWindow(args->getOption("package"), args->getOption("bug"));

        // Since all background jobs remaing running after closing the
        // main window we force a quit here
        QObject::connect( &app, SIGNAL( lastWindowClosed() ),
                          &app, SLOT( quit() ) );
        mainWin->show();
        return app.exec();
    }
}
コード例 #19
0
int main(int argc, char *argv[])
{
#ifdef _WIN32
   /* KDiff3 can be used as replacement for the text-diff and merge tool provided by
      Clearcase. This is experimental and so far has only been tested under Windows.

      There are two ways to use KDiff3 with clearcase
      -  The file lib/mgrs/map contains the list of compare/merge tasks on one side and 
         the tool on the other. Originally this contains only clearcase tools, but you can
         edit this file and put kdiff3 there instead. (Recommended method)
      -  Exchange the original program with KDiff3: (Hackish, no fine control)
         1. In the Clearcase "bin"-directory rename "cleardiffmrg.exe" to "cleardiffmrg_orig.exe".
         2. Copy kdiff3.exe into that "bin"-directory and rename it to "cleardiffmrg.exe".
            (Also copy the other files that are needed by KDiff3 there.)
         Now when a file comparison or merge is done by Clearcase then of course KDiff3 will be
         run instead.
         If the commandline contains the option "-directory" then KDiff3 can't do it but will
         run "cleardiffmrg_orig.exe" instead.
   */

   // Write all args into a temporary file. Uncomment this for debugging purposes.
   /*
   FILE* f = fopen("c:\\t.txt","w");
   for(int i=0; i< argc; ++i)
      fprintf(f,"Arg %d: %s\n", i, argv[i]);

   // Call orig cleardiffmrg.exe to see what result it returns.
   int result=0;
   result = ::_spawnvp(_P_WAIT , "C:\\Programme\\Rational\\ClearCase\\bin\\cleardiffmrg.exe", argv );
   fprintf(f,"Result: %d\n", result );
   fclose(f);
   return result;
   */

   // KDiff3 can replace cleardiffmrg from clearcase. But not all functions.
   if ( isOptionUsed( "directory", argc,argv ) )
   {
      return ::_spawnvp(_P_WAIT , "cleardiffmrg_orig", argv );      
   }

#endif
   //QApplication::setColorSpec( QApplication::ManyColor ); // Grab all 216 colors

   KAboutData aboutData( "kdiff3", I18N_NOOP("KDiff3"),
      VERSION, description, KAboutData::License_GPL,
      "(c) 2002-2007 Joachim Eibl", 0, "http://kdiff3.sourceforge.net/", "joachim.eibl" "@" "gmx.de");
   aboutData.addAuthor("Joachim Eibl",0, "joachim.eibl" "@" "gmx.de");
   aboutData.addCredit("Eike Sauer", "Bugfixes, Debian package maintainer" );
   aboutData.addCredit("Sebastien Fricker", "Windows installer" );
   aboutData.addCredit("Stephan Binner", "i18n-help", "binner" "@" "kde.org" );
   aboutData.addCredit("Stefan Partheymueller", "Clipboard-patch" );
   aboutData.addCredit("David Faure", "KIO-Help", "faure" "@" "kde.org" );
   aboutData.addCredit("Bernd Gehrmann", "Class CvsIgnoreList from Cervisia" );
   aboutData.addCredit("Andre Woebbeking", "Class StringMatcher" );
   aboutData.addCredit("Michael Denio", "Directory Equality-Coloring patch");
   aboutData.addCredit("Manfred Koehler", "Fix for slow startup on Windows");
   aboutData.addCredit("Sergey Zorin", "Diff Ext for Windows");
   aboutData.addCredit("Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, Len Tower", "GNU-Diffutils");
   aboutData.addCredit("Tino Boellsterling, Timothy Mee", "Intensive test, use and feedback");
   aboutData.addCredit("Michael Schmidt", "Mac support");

   aboutData.addCredit(I18N_NOOP("+ Many thanks to those who reported bugs and contributed ideas!"));

   KCmdLineArgs::init( argc, argv, &aboutData );
   std::vector<KCmdLineOptions> vOptions;
   QStringList ignorableOptions;
   initialiseCmdLineArgs(vOptions, ignorableOptions);

   KApplication app;

#ifdef KREPLACEMENTS_H
   QString locale;

   locale = app.config()->readEntry("Language", "Auto");
   int spacePos = locale.indexOf(' ');
   if (spacePos>0) locale = locale.left(spacePos);
   QTranslator kdiff3Translator( 0 );
   QTranslator qtTranslator( 0 );
   if (locale != "en_orig")
   {
      if ( locale == "Auto" || locale.isEmpty() )
         locale = locale = QLocale::system().name().left(2);
         
      QString translationDir = getTranslationDir();
      kdiff3Translator.load( QString("kdiff3_")+locale, translationDir );
      app.installTranslator( &kdiff3Translator );
      
      qtTranslator.load( QString("qt_")+locale, translationDir );
      app.installTranslator( &qtTranslator );
   }
#endif

  if (app.isRestored())
  {
     RESTORE(KDiff3Shell);
  }
  else
  {
     new KDiff3Shell();
  }

  int retVal = app.exec();
  return retVal;
}
コード例 #20
0
int main(int argc, char *argv[]) {
    int i_file, i_v, i_curve;
    int i_plot;
    QString fullPath;

    KAboutData aboutData("kst", I18N_NOOP("Kst"),
                         KSTVERSION, description, KAboutData::License_GPL,
                         I18N_NOOP("(c) 2000-2007 Barth Netterfield"),
                         0,
                         "http://kst.kde.org/");
    aboutData.addAuthor("Barth Netterfield",
                        I18N_NOOP("Original author and maintainer."),
                        "*****@*****.**",
                        "http://omega.astro.utoronto.ca/");
    aboutData.addAuthor("Staikos Computing Services Inc.",
                        I18N_NOOP("Developed for the University of Toronto."),
                        "*****@*****.**",
                        "http://www.staikos.net/");
    aboutData.addAuthor("Sumus Technology Limited",
                        I18N_NOOP("Developed for the University of British Columbia"),
                        "*****@*****.**",
                        "http://www.sumusltd.com/");
    aboutData.addAuthor("Rick Chern",
                        I18N_NOOP("University of British Columbia"),
                        "",
                        "");
    aboutData.addAuthor("Duncan Hanson",
                        I18N_NOOP("University of British Columbia"),
                        "",
                        "");
    aboutData.addAuthor("Nicolas Brisset",
                        "",
                        "",
                        "");
    aboutData.addAuthor("Matthew Truch",
                        "",
                        "http://matt.truch.net/",
                        "*****@*****.**");
    aboutData.addAuthor("Theodore Kisner",
                        "",
                        "*****@*****.**",
                        "");
    aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"),
                            I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));

    KCmdLineArgs::init( argc, argv, &aboutData );
    KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

    KApplication app;
    KImageIO::registerFormats();

    KstDialogs::replaceSelf(new KstGuiDialogs);
    KstData::replaceSelf(new KstGuiData);
    KstApp::initialize();

    atexit(exitHelper);

    if (app.isRestored()) {
        RESTORE(KstApp)
    } else {
        KstApp *kst = new KstApp;
        InType in;
        QColor color;
        QCStringList ycolList;
        QCStringList matrixList;
        QCStringList yEqList;
        QCStringList psdList;
        QCStringList hsList;
        QCStringList errorList;
        unsigned int i_ycol;
        QCStringList::Iterator hs_string;
        QCStringList::Iterator eq_i;
        QCStringList::Iterator mat_i;
        bool showQuickStart = false;
        bool showDataWizard = false;
        bool nOK;
        int n_y = 0;
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

        CheckForCMDErrors(args);

        QString wizardfile = args->getOption("w");
        QString printfile = args->getOption("print");
        QString pngfile = args->getOption("png");
        bool print_and_exit = false;

        if (printfile != "<none>") {
            print_and_exit = true;
        }
        if (pngfile != "<none>") {
            print_and_exit = true;
        }

        if (!print_and_exit) {
            app.setMainWidget(kst);
            QRect rect = KGlobalSettings::desktopGeometry(kst);
            kst->resize(5 * rect.width() / 6, 5 * rect.height() / 6);
            kst->show();
        }

        // get Y axis columns
        ycolList = args->getOptionList("y");
        matrixList = args->getOptionList("z");
        yEqList = args->getOptionList("ye");
        psdList = args->getOptionList("p");
        hsList = args->getOptionList("h");
        errorList = args->getOptionList("e");

        // y axis or PSD specified, so the files are data files, not kst files.
        n_y = ycolList.count() + psdList.count() + hsList.count() + yEqList.count() + matrixList.count();
        if (n_y > 0) {
            QString creatingEquations = i18n("Creating equations");
            QString creatingCurves = i18n("Creating curves");
            QString creatingPlots = i18n("Creating plots");
            int count;
            int handled;

            kst->slotUpdateProgress( 0, 0, QString::null );

            SetCMDOptions(args, in, n_y);

            KstTopLevelViewPtr tlv = kst->activeView();

            if (!tlv) {
                // if there was no active view then we create one...
                kst->newWindow(false);
                tlv = kst->activeView();
            }

            if (!tlv) {
                kstdError() << i18n("Can't create a view.") << endl;
                return 0;
            }

            CreatePlots(in, tlv);
            Kst2DPlotList plist = kstObjectSubList<KstViewObject, Kst2DPlot>(tlv->children());

            i_plot = 0;
            Kst2DPlotPtr plot = *plist.at(i_plot);

            KstVCurveList vcurves = kstObjectSubList<KstBaseCurve,KstVCurve>(plot->Curves);

            // make stand alone equations if there are no files
            if (args->count() < 1) {
                if (!yEqList.isEmpty()) {
                    QString eqS;
                    double max, min;
                    int n;
                    bool xeq;

                    SetEqXRanges(args->getOption("xe"), &min, &max, &n, &xeq);
                    if (xeq) {
                        count = yEqList.size();
                        handled = 0;
                        kst->slotUpdateProgress( count, handled, creatingEquations );

                        for (eq_i = yEqList.begin(); eq_i != yEqList.end(); ++eq_i) {
                            eqS = *eq_i;
                            if (NoVectorEq(eqS)) {
                                KstEquationPtr eq = new KstEquation(KST::suggestEQName(eqS), eqS, min, max, n);
                                KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(eq->tag(), true),
                                                                eq->vX(), eq->vY(), 0L, 0L, 0L, 0L,
                                                                KstColorSequence::next(vcurves,plot->backgroundColor()));
                                KST::dataObjectList.lock().writeLock();
                                KST::dataObjectList.append(eq.data());
                                KST::dataObjectList.append(vc.data());
                                KST::dataObjectList.lock().unlock();
                                plot->addCurve(vc.data());

                                if (in.sep_plots) {
                                    i_plot++;
                                    if (i_plot < in.n_plots) {
                                        plot = *plist.at(i_plot);
                                    }
                                }
                            }

                            handled++;
                            kst->slotUpdateProgress( count, handled, creatingEquations );
                        }
                    }
                }
            }

            // make the requested curves for each data file
            count = args->count();
            handled = 0;
            kst->slotUpdateProgress( count, handled, creatingCurves );

            for (i_curve = i_v = 0, i_file = 0; i_file < args->count(); i_file++) {
                // make the file
                if (QFile::exists(args->arg(i_file))) {
                    fullPath = QFileInfo(args->arg(i_file)).absFilePath();
                } else {
                    fullPath = args->arg(i_file);
                }

                KstDataSourcePtr file = KstDataSource::loadSource(fullPath);

                if (file) {
                    if (!file->isValid() || file->isEmpty()) {
                        kstdError() << i18n("No data in file %1.  Trying to continue...").arg(args->arg(i_file)) << endl;
                        // The file might get data later!
                    }

                    KST::dataObjectList.lock().writeLock();
                    KST::dataSourceList.append(file);
                    KST::dataObjectList.lock().unlock();

                    KstRVectorPtr yvector;
                    KstRVectorPtr evector;
                    KstVCurvePtr curve;
                    KstPSDPtr psd;
                    KstHistogramPtr hs;
                    KstRVectorPtr xvector;

                    if (!ycolList.isEmpty()) { // if there are some xy plots
                        // make the x axis vector
                        xvector = GetOrCreateVector(args->getOption("x"), file, in);
                        if (xvector) {
                            // make the y axis vectors
                            for (i_ycol = 0; i_ycol < ycolList.count(); ++i_ycol ) {
                                yvector = GetOrCreateVector(*(ycolList.at(i_ycol)), file, in);
                                if (yvector) {
                                    // make the curves
                                    color = KstColorSequence::next(vcurves,plot->backgroundColor());
                                    curve = new KstVCurve(KST::suggestCurveName(yvector->tag(), false),
                                                          KstVectorPtr(xvector), KstVectorPtr(yvector),
                                                          0L, 0L, 0L, 0L, color);
                                    if (in.has_points) {
                                        curve->setHasPoints(true);
                                        curve->setHasLines(false);
                                    }

                                    if (i_ycol<errorList.count()) {
                                        evector = GetOrCreateVector(*(errorList.at(i_ycol)), file, in);
                                        if (evector) {
                                            curve->setYError(KstVectorPtr(evector));
                                            curve->setYMinusError(KstVectorPtr(evector));
                                        }
                                    }

                                    KST::dataObjectList.lock().writeLock();
                                    KST::dataObjectList.append(curve.data());
                                    KST::dataObjectList.lock().unlock();
                                    plot->addCurve(curve.data());

                                    if (in.sep_plots) {
                                        plot->setTagName(curve->tag());
                                        i_plot++;
                                        if (i_plot < in.n_plots) {
                                            plot = *plist.at(i_plot);
                                        }
                                    } // end (if they are separate plots)
                                }
                            } // next y col
                        }
                    } // end (if there are some xy plots)

                    if (!yEqList.isEmpty()) {
                        QString eqS;
                        double max, min;
                        int n;
                        bool xeq, eq_ok;

                        SetEqXRanges(args->getOption("xe"), &min, &max, &n, &xeq);
                        for (eq_i = yEqList.begin(); eq_i != yEqList.end(); ++eq_i) {
                            KstEquationPtr eq;

                            eqS = *eq_i;
                            ProcessEq(eqS, file, in, &eq_ok);

                            if (xeq) {
                                eq = new KstEquation(KST::suggestEQName(eqS), eqS, min,max,n);
                            } else {
                                if (!xvector) {
                                    xvector = GetOrCreateVector(args->getOption("x"), file, in);
                                }
                                if (xvector) {
                                    eq = new KstEquation(KST::suggestEQName(eqS), eqS, KstVectorPtr(xvector), true);
                                }
                            }

                            if (eq) {
                                KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(eq->tag(), true),
                                                                eq->vX(), eq->vY(), 0L, 0L, 0L, 0L,
                                                                KstColorSequence::next(vcurves,plot->backgroundColor()));
                                KST::dataObjectList.lock().writeLock();
                                KST::dataObjectList.append(eq.data());
                                KST::dataObjectList.append(vc.data());
                                KST::dataObjectList.lock().unlock();
                                plot->addCurve(vc.data());

                                if (in.sep_plots) {
                                    plot->setTagName(eq->tag());
                                    i_plot++;
                                    if (i_plot <in.n_plots) {
                                        plot = *plist.at(i_plot);
                                    }
                                }
                            }
                        }
                    }

                    if (psdList.count() > 0) { // if there are some psd plots
                        KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
                        for (QCStringList::ConstIterator it = psdList.begin(); it != psdList.end(); ++it) {

                            yvector = GetOrCreateVector(*it, file, in);
                            if (yvector) {
                                color = KstColorSequence::next(vcurves,plot->backgroundColor());

                                psd = new KstPSD( KST::suggestPSDName(yvector->tag()), // FIXME: this was yvector->field(), is this right?
                                                  KstVectorPtr(yvector), in.rate, true, in.len,
                                                  true, true, in.VUnits, in.RUnits, WindowOriginal);
                                KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(psd->tag(), true),
                                                                psd->vX(), psd->vY(), 0L, 0L, 0L, 0L, color);
                                if (in.has_points) {
                                    vc->setHasPoints(true);
                                    vc->setHasLines(false);
                                }
                                KST::dataObjectList.lock().writeLock();
                                KST::dataObjectList.append(psd.data());
                                KST::dataObjectList.append(vc.data());
                                KST::dataObjectList.lock().unlock();
                                plot->addCurve(vc.data());

                                if (in.sep_plots) {
                                    plot->setTagName(psd->tag());
                                    i_plot++;
                                    if (i_plot <in.n_plots) {
                                        plot = *plist.at(i_plot);
                                    }
                                }
                            }
                        } // next psd
                    } // end (if there are some psds)

                    if (hsList.count() > 0) { // if there are some histograms
                        double max, min;
                        int N;

                        KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
                        for (hs_string = hsList.begin(); hs_string != hsList.end(); ++hs_string) {
                            yvector = GetOrCreateVector(*hs_string, file, in);
                            if (yvector) {
                                color = KstColorSequence::next(vcurves,plot->backgroundColor());

                                KstHistogram::AutoBin(KstVectorPtr(yvector), &N, &max, &min);

                                hs = new KstHistogram(KST::suggestHistogramName(yvector->tag()),
                                                      KstVectorPtr(yvector), min, max, N, KST_HS_NUMBER);
                                KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(hs->tag(), true),
                                                                hs->vX(), hs->vY(),
                                                                0L, 0L, 0L, 0L, color);

                                vc->setHasPoints(false);
                                vc->setHasLines(false);
                                vc->setHasBars(true);
                                vc->setBarStyle(1);

                                KST::dataObjectList.lock().writeLock();
                                KST::dataObjectList.append(hs.data());
                                KST::dataObjectList.append(vc.data());
                                KST::dataObjectList.lock().unlock();
                                plot->addCurve(vc.data());

                                if (in.sep_plots) {
                                    plot->setTagName(hs->tag());
                                    i_plot++;
                                    if (i_plot < in.n_plots) {
                                        plot = *plist.at(i_plot);
                                    }
                                }
                            }
                        } // next histogram
                    } // end (if there are some histograms)

                    if (matrixList.count() > 0) { // if there are some matrixes
                        for (mat_i = matrixList.begin(); mat_i != matrixList.end(); ++mat_i) {
                            QString tag_name = KST::suggestMatrixName(*mat_i);
                            if (!file->isValidMatrix(*mat_i)) {
                                startupErrors.append(i18n("Failed to create matrix '%1' from file '%2'.").arg(*mat_i).arg(file->fileName()));
                            }
                            KstRMatrixPtr matrix = new KstRMatrix(file, *mat_i,
                                                                  KstObjectTag(tag_name, file->tag()),
                                                                  0,0,-1,-1,false,false,0);
                            // xStart, yStart, xNumSteps, yNumSteps,
                            //doAve, doSkip, skip);

                            // Time to create the image from the matrix
                            tag_name = KST::suggestImageName(matrix->tag());
                            QStringList palList = KPalette::getPaletteList();
                            QString pal;
                            if (palList.contains("IDL 13 RAINBOW")) {
                                pal = QString("IDL 13 RAINBOW");
                            } else {
                                pal = QString(*palList.at(0));
                            }

                            KPalette* newPal = new KPalette(pal);
                            KstImagePtr image = new KstImage(tag_name, KstMatrixPtr(matrix), 0.0, 1.0,
                                                             true, newPal);
                            plot->addCurve(KstBaseCurvePtr(image));
                            KST::dataObjectList.lock().writeLock();
                            KST::dataObjectList.append(image.data());
                            KST::dataObjectList.lock().unlock();
                            image = 0L; // drop the reference

                            if (in.sep_plots) {
                                plot->setTagName(matrix->tag());
                                i_plot++;
                                if (i_plot < in.n_plots) {
                                    plot = *plist.at(i_plot);
                                }
                            }
                        }
                    }
                } else {
                    startupErrors.append(i18n("Failed to load file '%1'.").arg(args->arg(i_file)));
                }
                handled++;
                kst->slotUpdateProgress( count, handled, creatingCurves );
            } // next data file

            count = in.n_plots;
            handled = 0;
            kst->slotUpdateProgress( count, handled, creatingPlots );
            for (i_plot = 0; i_plot < in.n_plots; i_plot++) {
                plot = *plist.at(i_plot);
                plot->generateDefaultLabels();

                // if we have only images in a plot then set the scale mode to AUTO (instead of AUTOBORDER)
                KstImageList images = kstObjectSubList<KstBaseCurve,KstImage>(plot->Curves);
                if (images.count() == plot->Curves.count()) {
                    plot->setXScaleMode(AUTO);
                    plot->setYScaleMode(AUTO);
                }

                if (plot->Curves.count() > 3 || in.dolegend) {
                    KstViewLegendPtr vl = plot->getOrCreateLegend();
                    vl->resizeFromAspect(0.1, 0.1, 0.2, 0.1);
                    vl->setBorderWidth(2);
                }
                handled++;
                kst->slotUpdateProgress( count, handled, creatingPlots );
            }

            kst->slotUpdateProgress( 0, 0, QString::null );
        } else if (args->count() > 0) { // open a kst file
            // some of the options can be overridden
            kst->openDocumentFile(args->arg(0),
                                  args->getOption("F"),             // override FileName
                                  args->getOption("n").toInt(&nOK), // override number of frames
                                  args->getOption("f").toInt(&nOK), // override starting frame
                                  args->getOption("s").toInt(&nOK), // override skip
                                  args->isSet("a"),                 // add averaging
                                  !print_and_exit);                 // delayed
        } else {
            //kst->openDocumentFile();
            showQuickStart = true;
        }

        if (args->isSet("nq")) {
            showQuickStart = false;
        }
        if (args->isSet("w")) {
            showDataWizard = true;
            showQuickStart = false;
        }

        if (printfile != "<none>") {
            kst->forceUpdate();
            kst->immediatePrintToFile(printfile, false);
        }

        if (pngfile != "<none>") {
            kst->forceUpdate();
            kst->immediatePrintToPng(pngfile);
        }

        kst->document()->setModified(false);

        if (print_and_exit) {
            delete kst;
            return 0;
        } else {
            kst->updateDialogs();

            if (showQuickStart) {
                kst->showQuickStartDialog();
            }
            if (showDataWizard) {
                kst->showDataWizardWithFile(wizardfile);
            }
            for (size_t i = 0; i < startupErrors.size(); ++i) {
                KstDebug::self()->log(startupErrors[i], KstDebug::Error);
            }
            startupErrors.clear();
        }

        // LEAVE THIS HERE - causes crashes otherwise!
        int rc = app.exec();
        delete kst;
        return rc;
    }

    return app.exec();
}
コード例 #21
0
int main(int argc, char** argv)
{
  KAboutData about ("kdvi", I18N_NOOP("KDVI"), "1.4",
                    description, KAboutData::License_GPL,
                    "Markku Hinhala, Stephan Kebekus",
                    I18N_NOOP("This program displays Device Independent (DVI) files which are produced by the TeX typesetting system.\n"
                    "This KDVI version is based on original code from KDVI version 0.43 and xdvik."));

  about.addAuthor ("Stefan Kebekus",
                   I18N_NOOP("Current Maintainer."),
                   "*****@*****.**",
                   "http://www.mi.uni-koeln.de/~kebekus");

  about.addAuthor ("Markku Hinhala", I18N_NOOP("Author of kdvi 0.4.3"));
  about.addAuthor ("Nicolai Langfeldt", I18N_NOOP("Maintainer of xdvik"));
  about.addAuthor ("Paul Vojta", I18N_NOOP("Author of xdvi"));
  about.addCredit ("Philipp Lehmann", I18N_NOOP("Testing and bug reporting."));
  about.addCredit ("Wilfried Huss", I18N_NOOP("Re-organisation of source code."));

  KCmdLineArgs::init(argc, argv, &about);
  KCmdLineArgs::addCmdLineOptions(options);
  KApplication app;

  // see if we are starting with session management
  if (app.isRestored())
  {
    RESTORE(KViewShell);
  }
  else
  {
    KCmdLineArgs* args = KCmdLineArgs::parsedArgs();

    if (args->isSet("unique"))
    {
      // With --unique, we need 2 arguments.
      if (args->count() < 1) 
      {
        args->usage();
        exit(-1);
      }

      // Find the fully qualified file name of the file we are
      // loading. Complain, if we are given a URL which does not point
      // to a local file.
      KURL url(args->url(0));

      if (!url.isValid()) 
      {
        kdError(4300) << QString(I18N_NOOP("The URL %1 is not well-formed.")).arg(args->arg(0)) << endl;
        return -1;
      }

      if (!url.isLocalFile()) 
      {
        kdError(4300) << QString(I18N_NOOP("The URL %1 does not point to a local file. You can only specify local "
             "files if you are using the '--unique' option.")).arg(args->arg(0)) << endl;
        return -1;
      }

      QString qualPath = QFileInfo(url.path()).absFilePath();

      app.dcopClient()->attach();
      // We need to register as "kviewshell" to stay compatible with existing DCOP-skripts.
      QCString id = app.dcopClient()->registerAs("unique-kviewshell");
      if (id.isNull())
        kdError(4300) << "There was an error using dcopClient()->registerAs()." << endl;
      QCStringList apps = app.dcopClient()->registeredApplications();
      for ( QCStringList::Iterator it = apps.begin(); it != apps.end(); ++it ) 
      {
        if ((*it).find("kviewshell") == 0) 
        {
          QByteArray data, replyData;
          QCString replyType;
          QDataStream arg(data, IO_WriteOnly);
          bool result;
          arg << qualPath.stripWhiteSpace();
          if (!app.dcopClient()->call( *it, "kmultipage", "is_file_loaded(QString)", data, replyType, replyData))
            kdError(4300) << "There was an error using DCOP." << endl;
          else 
          {
            QDataStream reply(replyData, IO_ReadOnly);
            if (replyType == "bool") 
            {
              reply >> result;
              if (result == true) 
              {
                if (app.dcopClient()->send( *it, "kmultipage", "jumpToReference(QString)", url.ref()) == true)
                {
                  app.dcopClient()->detach();
                  return 0;
                }
              }
            }
            else
              kdError(4300) << "The DCOP function 'doIt' returned an unexpected type of reply!";
          }
        }
      }
コード例 #22
0
ファイル: kdirstatmain.cpp プロジェクト: gregp-forks/kdirstat
int main(int argc, char *argv[])
{
    KAboutData aboutData( "kdirstat", "KDirStat",
			  VERSION, description, KAboutData::License_GPL,
			  "(c) 1999-2008 Stefan Hundhammer", 0, 0,
			  "*****@*****.**" );
    
    aboutData.addAuthor( "Stefan Hundhammer",
			 I18N_NOOP("\n"
				   "If you have any comments or if you would simply like to tell\n"
				   "your opinion about this program, please use \n"
				   "\"Send Feedback Mail\" from the \"Help\" menu.\n"
				   "\n"
				   "Any feedback (even negative!) is appreciated." ),
			 "*****@*****.**",
			 "http://kdirstat.sourceforge.net/" );

    aboutData.addCredit( "SequoiaView Team",
			 I18N_NOOP( "for showing just how useful treemaps really can be." ),
			 0,	// e-mail
			 "http://www.win.tue.nl/sequoiaview" );

    aboutData.addCredit( "Jarke J. van Wijk, Huub van de Wetering, Mark Bruls",
			 I18N_NOOP( "for their papers about treemaps." ),
			 "*****@*****.**",
			 "http://www.win.tue.nl/~vanwijk/" );

    aboutData.addCredit( "Ben Shneiderman",
			 I18N_NOOP( "for his ingenious idea of treemaps -\n"
				    "a truly intuitive way of visualizing tree contents." ),
			 "",	// E-Mail
			 "http://www.cs.umd.edu/hcil/treemaps/" );

    aboutData.setTranslator( "", "" ); // Default KDE templates don't apply - better leave it empty

    KCmdLineArgs::init( argc, argv, &aboutData );
    KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

    KApplication app;

    
    if ( app.isRestored() )
    {
	RESTORE( KDirStatApp );
    }
    else
    {
	KDirStatApp *kdirstat = new KDirStatApp();
	kdirstat->show();

	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

	if ( args->count() )
	{
	    // Process command line arguments as URLs or paths to scan

	    KURL url = fixedUrl( args->arg( 0 ) );
	    // kdDebug() << "Opening " << url.url() << endl;
	    kdirstat->openURL( url );
	}
	else
	{
	    kdirstat->fileAskOpenDir();
	}

	args->clear();
    }

    // kdDebug() << "Entering main loop" << endl;

    return app.exec();
}
コード例 #23
0
ファイル: main.cpp プロジェクト: serghei/kde-kdesdk
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
{
    static KCmdLineOptions options[] = {
        { "+[directory]", I18N_NOOP("The sandbox to be loaded"), 0 },
        { "resolve <file>", I18N_NOOP("Show resolve dialog for the given file"), 0 },
        { "log <file>", I18N_NOOP("Show log dialog for the given file"), 0 },
        { "annotate <file>", I18N_NOOP("Show annotation dialog for the given file"), 0 },
        KCmdLineLastOption
    };
    KAboutData about("cervisia", I18N_NOOP("Cervisia"), CERVISIA_VERSION,
                     I18N_NOOP("A CVS frontend"), KAboutData::License_GPL,
                     I18N_NOOP("Copyright (c) 1999-2002 Bernd Gehrmann\n"
                               "Copyright (c) 2002-2007 the Cervisia authors"), 0,
                     "http://www.kde.org/apps/cervisia");

    about.addAuthor("Bernd Gehrmann", I18N_NOOP("Original author and former "
                    "maintainer"), "*****@*****.**", 0);
    about.addAuthor("Christian Loose", I18N_NOOP("Maintainer"),
                    "*****@*****.**", 0);
    about.addAuthor("Andr\303\251 W\303\266bbeking", I18N_NOOP("Developer"),
                    "*****@*****.**", 0);
    about.addAuthor("Carlos Woelz", I18N_NOOP("Documentation"),
                    "*****@*****.**", 0);

    about.addCredit("Richard Moore", I18N_NOOP("Conversion to KPart"),
                    "*****@*****.**", 0);

    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;

    QString resolvefile = KCmdLineArgs::parsedArgs()->getOption("resolve");
    if (!resolvefile.isEmpty())
        return ShowResolveDialog(resolvefile);

    // is command line option 'show log dialog' specified?
    QString logFile = KCmdLineArgs::parsedArgs()->getOption("log");
    if( !logFile.isEmpty() )
        return ShowLogDialog(logFile);

    // is command line option 'show annotation dialog' specified?
    QString annotateFile = KCmdLineArgs::parsedArgs()->getOption("annotate");
    if( !annotateFile.isEmpty() )
        return ShowAnnotateDialog(annotateFile);

    if ( app.isRestored() ) {
        RESTORE(CervisiaShell);
    } else {
        CervisiaShell* shell = new CervisiaShell();

        const KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
        if( args->count() )
        {
            KURL directory = args->url(0);
            shell->openURL(directory);
        }
        else
            shell->openURL();

        shell->setIcon(app.icon());
        app.setMainWidget(shell);
        shell->show();
    }

    int res = app.exec();
    cleanupTempFiles();
    return res;
}
コード例 #24
0
ファイル: main.cpp プロジェクト: serghei/kde3-kdebase
/* --| main |------------------------------------------------------ */
extern "C" int KDE_EXPORT kdemain(int argc, char *argv[])
{
    setgid(getgid());
    setuid(getuid()); // drop privileges

    // deal with shell/command ////////////////////////////
    bool histon = true;
    bool menubaron = true;
    bool tabbaron = true;
    bool frameon = true;
    bool scrollbaron = true;
    bool showtip = true;

    KAboutData aboutData("konsole", I18N_NOOP("Konsole"), KONSOLE_VERSION, description, KAboutData::License_GPL_V2,
                         "Copyright (c) 1997-2006, Lars Doelle");
    aboutData.addAuthor("Robert Knight", I18N_NOOP("Maintainer"), "*****@*****.**");
    aboutData.addAuthor("Lars Doelle", I18N_NOOP("Author"), "*****@*****.**");
    aboutData.addCredit("Kurt V. Hindenburg", I18N_NOOP("bug fixing and improvements"), "*****@*****.**");
    aboutData.addCredit("Waldo Bastian", I18N_NOOP("bug fixing and improvements"), "*****@*****.**");
    aboutData.addCredit("Stephan Binner", I18N_NOOP("bug fixing and improvements"), "*****@*****.**");
    aboutData.addCredit("Chris Machemer", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("Stephan Kulow", I18N_NOOP("Solaris support and work on history"), "*****@*****.**");
    aboutData.addCredit("Alexander Neundorf", I18N_NOOP("faster startup, bug fixing"), "*****@*****.**");
    aboutData.addCredit("Peter Silva", I18N_NOOP("decent marking"), "*****@*****.**");
    aboutData.addCredit("Lotzi Boloni", I18N_NOOP("partification\n"
                                                  "Toolbar and session names"),
                        "*****@*****.**");
    aboutData.addCredit("David Faure", I18N_NOOP("partification\n"
                                                 "overall improvements"),
                        "*****@*****.**");
    aboutData.addCredit("Antonio Larrosa", I18N_NOOP("transparency"), "*****@*****.**");
    aboutData.addCredit("Matthias Ettrich", I18N_NOOP("most of main.C donated via kvt\n"
                                                      "overall improvements"),
                        "*****@*****.**");
    aboutData.addCredit("Warwick Allison", I18N_NOOP("schema and selection improvements"), "*****@*****.**");
    aboutData.addCredit("Dan Pilone", I18N_NOOP("SGI Port"), "*****@*****.**");
    aboutData.addCredit("Kevin Street", I18N_NOOP("FreeBSD port"), "*****@*****.**");
    aboutData.addCredit("Sven Fischer", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("Dale M. Flaven", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("Martin Jones", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("Lars Knoll", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("", I18N_NOOP("Thanks to many others.\n"
                                      "The above list only reflects the contributors\n"
                                      "I managed to keep track of."));

    KCmdLineArgs::init(argc, argv, &aboutData);
    KCmdLineArgs::addCmdLineOptions(options); // Add our own options.
    // 1.53 sec
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    KCmdLineArgs *qtargs = KCmdLineArgs::parsedArgs("qt");
    has_noxft = !args->isSet("xft");
    TEWidget::setAntialias(!has_noxft);
    TEWidget::setStandalone(true);

    // The following Qt options have no effect; warn users.
    if(qtargs->isSet("background"))
        kdWarning() << "The Qt option -bg, --background has no effect." << endl;
    if(qtargs->isSet("foreground"))
        kdWarning() << "The Qt option -fg, --foreground has no effect." << endl;
    if(qtargs->isSet("button"))
        kdWarning() << "The Qt option -btn, --button has no effect." << endl;
    if(qtargs->isSet("font"))
        kdWarning() << "The Qt option -fn, --font has no effect." << endl;

    KApplication *a = NULL;
#ifdef COMPOSITE
    if(args->isSet("real-transparency"))
    {
        char *display = 0;
        if(qtargs->isSet("display"))
            display = qtargs->getOption("display").data();

        Display *dpy = XOpenDisplay(display);
        if(!dpy)
        {
            kdError() << "cannot connect to X server " << display << endl;
            exit(1);
        }

        int screen = DefaultScreen(dpy);
        Colormap colormap = 0;
        Visual *visual = 0;
        int event_base, error_base;

        if(XRenderQueryExtension(dpy, &event_base, &error_base))
        {
            int nvi;
            XVisualInfo templ;
            templ.screen = screen;
            templ.depth = 32;
            templ.c_class = TrueColor;
            XVisualInfo *xvi = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi);

            for(int i = 0; i < nvi; i++)
            {
                XRenderPictFormat *format = XRenderFindVisualFormat(dpy, xvi[i].visual);
                if(format->type == PictTypeDirect && format->direct.alphaMask)
                {
                    visual = xvi[i].visual;
                    colormap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone);
                    kdDebug() << "found visual with alpha support" << endl;
                    argb_visual = true;
                    break;
                }
            }
        }
        // The QApplication ctor used is normally intended for applications not using Qt
        // as the primary toolkit (e.g. Motif apps also using Qt), with some slightly
        // unpleasant side effects (e.g. #83974). This code checks if qt-copy patch #0078
        // is applied, which allows turning this off.
        bool *qt_no_foreign_hack = static_cast< bool * >(dlsym(RTLD_DEFAULT, "qt_no_foreign_hack"));
        if(qt_no_foreign_hack)
            *qt_no_foreign_hack = true;
        // else argb_visual = false ... ? *shrug*

        if(argb_visual)
            a = new KApplication(dpy, Qt::HANDLE(visual), Qt::HANDLE(colormap));
        else
            XCloseDisplay(dpy);
    }
    if(a == NULL)
        a = new KApplication;
#else
    KApplication *a = new KApplication;
#endif

    QString dataPathBase = KStandardDirs::kde_default("data").append("konsole/");
    KGlobal::dirs()->addResourceType("wallpaper", dataPathBase + "wallpapers");

    KImageIO::registerFormats(); // add io for additional image formats
    // 2.1 secs

    QString title;
    if(args->isSet("T"))
    {
        title = QFile::decodeName(args->getOption("T"));
    }
    if(qtargs->isSet("title"))
    {
        title = QFile::decodeName(qtargs->getOption("title"));
    }

    QString term = "";
    if(args->isSet("tn"))
    {
        term = QString::fromLatin1(args->getOption("tn"));
    }
    login_shell = args->isSet("ls");

    QStrList eargs;

    const char *shell = 0;
    if(!args->getOption("e").isEmpty())
    {
        if(args->isSet("ls"))
            KCmdLineArgs::usage(i18n("You can't use BOTH -ls and -e.\n"));
        shell = strdup(args->getOption("e"));
        eargs.append(shell);
        for(int i = 0; i < args->count(); i++)
            eargs.append(args->arg(i));

        if(title.isEmpty() && (kapp->caption() == kapp->aboutData()->programName()))
        {
            title = QFile::decodeName(shell); // program executed in the title bar
        }
        showtip = false;
    }

    QCString sz = "";
    sz = args->getOption("vt_sz");
    histon = args->isSet("hist");
    menubaron = args->isSet("menubar");
    tabbaron = args->isSet("tabbar") && args->isSet("toolbar");
    frameon = args->isSet("frame");
    scrollbaron = args->isSet("scrollbar");
    QCString wname = qtargs->getOption("name");
    full_script = args->isSet("script");
    auto_close = args->isSet("close");
    fixed_size = !args->isSet("resize");

    if(!full_script)
        a->dcopClient()->setQtBridgeEnabled(false);

    QCString type = "";

    if(args->isSet("type"))
    {
        type = args->getOption("type");
    }
    if(args->isSet("types"))
    {
        QStringList types = KGlobal::dirs()->findAllResources("appdata", "*.desktop", false, true);
        types.sort();
        for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it)
        {
            QString file = *it;
            file = file.mid(file.findRev('/') + 1);
            if(file.endsWith(".desktop"))
                file = file.left(file.length() - 8);
            printf("%s\n", QFile::encodeName(file).data());
        }
        return 0;
    }
    if(args->isSet("schemas") || args->isSet("schemata"))
    {
        ColorSchemaList colors;
        colors.checkSchemas();
        for(int i = 0; i < (int)colors.count(); i++)
        {
            ColorSchema *schema = colors.find(i);
            QString relPath = schema->relPath();
            if(!relPath.isEmpty())
                printf("%s\n", QFile::encodeName(relPath).data());
        }
        return 0;
    }

    if(args->isSet("keytabs"))
    {
        QStringList lst = KGlobal::dirs()->findAllResources("data", "konsole/*.keytab");

        printf("default\n"); // 'buildin' keytab
        lst.sort();
        for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it)
        {
            QFileInfo fi(*it);
            QString file = fi.baseName();
            printf("%s\n", QFile::encodeName(file).data());
        }
        return 0;
    }

    QString workDir = QFile::decodeName(args->getOption("workdir"));

    QString keytab = "";
    if(args->isSet("keytab"))
        keytab = QFile::decodeName(args->getOption("keytab"));

    QString schema = "";
    if(args->isSet("schema"))
        schema = args->getOption("schema");

    KConfig *sessionconfig = 0;
    QString profile = "";
    if(args->isSet("profile"))
    {
        profile = args->getOption("profile");
        QString path = locate("data", "konsole/profiles/" + profile);
        if(QFile::exists(path))
            sessionconfig = new KConfig(path, true);
        else
            profile = "";
    }
    if(args->isSet("profiles"))
    {
        QStringList profiles = KGlobal::dirs()->findAllResources("data", "konsole/profiles/*", false, true);
        profiles.sort();
        for(QStringList::ConstIterator it = profiles.begin(); it != profiles.end(); ++it)
        {
            QString file = *it;
            file = file.mid(file.findRev('/') + 1);
            printf("%s\n", QFile::encodeName(file).data());
        }
        return 0;
    }


    // FIXME: more: font

    args->clear();

    int c = 0, l = 0;
    if(!sz.isEmpty())
    {
        char *ls = (char *)strchr(sz.data(), 'x');
        if(ls != NULL)
        {
            *ls = '\0';
            ls++;
            c = atoi(sz.data());
            l = atoi(ls);
        }
        else
        {
            KCmdLineArgs::usage(i18n("expected --vt_sz <#columns>x<#lines> e.g. 80x40\n"));
        }
    }

    if(!kapp->authorizeKAction("size"))
        fixed_size = true;

    // ///////////////////////////////////////////////

    // Ignore SIGHUP so that we don't get killed when
    // our parent-shell gets closed.
    signal(SIGHUP, SIG_IGN);

    putenv((char *)"COLORTERM="); // to trigger mc's color detection
    KonsoleSessionManaged ksm;

    if(a->isRestored() || !profile.isEmpty())
    {
        if(!shell)
            shell = konsole_shell(eargs);

        if(profile.isEmpty())
            sessionconfig = a->sessionConfig();
        sessionconfig->setDesktopGroup();
        int n = 1;

        QString key;
        QString sTitle;
        QString sPgm;
        QString sTerm;
        QString sIcon;
        QString sCwd;
        int n_tabbar;

        // TODO: Session management stores everything in same group,
        // should use one group / mainwindow
        while(KMainWindow::canBeRestored(n) || !profile.isEmpty())
        {
            sessionconfig->setGroup(QString("%1").arg(n));
            if(!sessionconfig->hasKey("Pgm0"))
                sessionconfig->setDesktopGroup(); // Backwards compatible

            int session_count = sessionconfig->readNumEntry("numSes");
            int counter = 0;

            wname = sessionconfig->readEntry("class", wname).latin1();

            sPgm = sessionconfig->readEntry("Pgm0", shell);
            sessionconfig->readListEntry("Args0", eargs);
            sTitle = sessionconfig->readEntry("Title0", title);
            sTerm = sessionconfig->readEntry("Term0");
            sIcon = sessionconfig->readEntry("Icon0", "konsole");
            sCwd = sessionconfig->readPathEntry("Cwd0");
            workDir = sessionconfig->readPathEntry("workdir");
            n_tabbar = QMIN(sessionconfig->readUnsignedNumEntry("tabbar", Konsole::TabBottom), 2);
            Konsole *m = new Konsole(wname, histon, menubaron, tabbaron, frameon, scrollbaron, 0 /*type*/, true, n_tabbar, workDir);

            m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd);

            m->enableFullScripting(full_script);
            m->enableFixedSize(fixed_size);
            m->restore(n);
            sessionconfig->setGroup(QString("%1").arg(n));
            if(!sessionconfig->hasKey("Pgm0"))
                sessionconfig->setDesktopGroup(); // Backwards compatible
            m->makeGUI();
            m->setEncoding(sessionconfig->readNumEntry("Encoding0"));
            m->setSchema(sessionconfig->readEntry("Schema0"));
            // Use konsolerc default as tmpFont instead?
            QFont tmpFont = KGlobalSettings::fixedFont();
            m->initSessionFont(sessionconfig->readFontEntry("SessionFont0", &tmpFont));
            m->initSessionKeyTab(sessionconfig->readEntry("KeyTab0"));
            m->initMonitorActivity(sessionconfig->readBoolEntry("MonitorActivity0", false));
            m->initMonitorSilence(sessionconfig->readBoolEntry("MonitorSilence0", false));
            m->initMasterMode(sessionconfig->readBoolEntry("MasterMode0", false));
            m->initTabColor(sessionconfig->readColorEntry("TabColor0"));
            // -1 will be changed to the default history in konsolerc
            m->initHistory(sessionconfig->readNumEntry("History0", -1), sessionconfig->readBoolEntry("HistoryEnabled0", true));
            counter++;

            // show() before 2nd+ sessions are created allows --profile to
            //  initialize the TE size correctly.
            m->show();

            while(counter < session_count)
            {
                key = QString("Title%1").arg(counter);
                sTitle = sessionconfig->readEntry(key, title);
                key = QString("Args%1").arg(counter);
                sessionconfig->readListEntry(key, eargs);

                key = QString("Pgm%1").arg(counter);

                // if the -e option is passed on the command line, this overrides the program specified
                // in the profile file
                if(args->isSet("e"))
                    sPgm = (shell ? QFile::decodeName(shell) : QString::null);
                else
                    sPgm = sessionconfig->readEntry(key, shell);

                key = QString("Term%1").arg(counter);
                sTerm = sessionconfig->readEntry(key);
                key = QString("Icon%1").arg(counter);
                sIcon = sessionconfig->readEntry(key, "konsole");
                key = QString("Cwd%1").arg(counter);
                sCwd = sessionconfig->readPathEntry(key);
                m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd);
                m->setSessionTitle(sTitle); // Use title as is
                key = QString("Schema%1").arg(counter);
                m->setSchema(sessionconfig->readEntry(key));
                key = QString("Encoding%1").arg(counter);
                m->setEncoding(sessionconfig->readNumEntry(key));
                key = QString("SessionFont%1").arg(counter);
                QFont tmpFont = KGlobalSettings::fixedFont();
                m->initSessionFont(sessionconfig->readFontEntry(key, &tmpFont));
                key = QString("KeyTab%1").arg(counter);
                m->initSessionKeyTab(sessionconfig->readEntry(key));
                key = QString("MonitorActivity%1").arg(counter);
                m->initMonitorActivity(sessionconfig->readBoolEntry(key, false));
                key = QString("MonitorSilence%1").arg(counter);
                m->initMonitorSilence(sessionconfig->readBoolEntry(key, false));
                key = QString("MasterMode%1").arg(counter);
                m->initMasterMode(sessionconfig->readBoolEntry(key, false));
                key = QString("TabColor%1").arg(counter);
                m->initTabColor(sessionconfig->readColorEntry(key));
                // -1 will be changed to the default history in konsolerc
                key = QString("History%1").arg(counter);
                QString key2 = QString("HistoryEnabled%1").arg(counter);
                m->initHistory(sessionconfig->readNumEntry(key, -1), sessionconfig->readBoolEntry(key2, true));
                counter++;
            }
            m->setDefaultSession(sessionconfig->readEntry("DefaultSession", "shell.desktop"));

            m->initFullScreen();
            if(!profile.isEmpty())
            {
                m->callReadPropertiesInternal(sessionconfig, 1);
                profile = "";
                // Hack to work-around sessions initialized with minimum size
                for(int i = 0; i < counter; i++)
                    m->activateSession(i);
                m->setColLin(c, l); // will use default height and width if called with (0,0)
            }
            // works only for the first one, but there won't be more.
            n++;
            m->activateSession(sessionconfig->readNumEntry("ActiveSession", 0));
            m->setAutoClose(auto_close);
        }
    }
    else
    {
        Konsole *m = new Konsole(wname, histon, menubaron, tabbaron, frameon, scrollbaron, type, false, 0, workDir);
        m->newSession((shell ? QFile::decodeName(shell) : QString::null), eargs, term, QString::null, title, workDir);
        m->enableFullScripting(full_script);
        m->enableFixedSize(fixed_size);
        // 3.8 :-(
        // exit(0);

        if(!keytab.isEmpty())
            m->initSessionKeyTab(keytab);

        if(!schema.isEmpty())
        {
            if(schema.right(7) != ".schema")
                schema += ".schema";
            m->setSchema(schema);
            m->activateSession(0); // Fixes BR83162, transp. schema + notabbar
        }

        m->setColLin(c, l); // will use default height and width if called with (0,0)

        m->initFullScreen();
        m->show();
        if(showtip)
            m->showTipOnStart();
        m->setAutoClose(auto_close);
    }

    int ret = a->exec();

    //// Temporary code, waiting for Qt to do this properly

    // Delete all toplevel widgets that have WDestructiveClose
    QWidgetList *list = QApplication::topLevelWidgets();
    // remove all toplevel widgets that have a parent (i.e. they
    // got WTopLevel explicitly), they'll be deleted by the parent
    list->first();
    while(list->current())
    {
        if(list->current()->parentWidget() != NULL || !list->current()->testWFlags(Qt::WDestructiveClose))
        {
            list->remove();
            continue;
        }
        list->next();
    }
    QWidgetListIt it(*list);
    QWidget *w;
    while((w = it.current()) != 0)
    {
        ++it;
        delete w;
    }
    delete list;

    delete a;

    return ret;
}
コード例 #25
0
ファイル: main.cpp プロジェクト: scim-im/skim
int main( int argc, char ** argv )
{
    //disable qt module support for skim itself; xim will be disabled latter
    setenv("QT_IM_SWITCHER", "imsw-none", 1);
    setenv("QT_IM_MODULE", "xim", 1);
    setenv("XMODIFIER", "@im=none", 1);

    KAboutData about(PACKAGE, "SKIM",
        VERSION " (compiled with libscim " SCIM_VERSION ")",
        description, KAboutData::License_GPL_V2, "(C) 2004 - 2006 LiuCougar",
        I18N_NOOP("IRC:\nserver: irc.freenode.net / channel: #scim\n\nFeedback:\[email protected]"),
        "http://www.scim-im.org");
    about.addAuthor( "LiuCougar (liuspider)", I18N_NOOP("Core Developer"),
      "*****@*****.**" );
    about.addCredit ( "JamesSu", I18N_NOOP("SCIM Core Author"), "*****@*****.**" );
    about.addAuthor ( "JanHefti", I18N_NOOP("Doc writer and German translator"),
      "*****@*****.**" );
    about.addAuthor ( "KitaeKim", I18N_NOOP("Art designer and Korean translator"),
      "*****@*****.**" );
    about.addAuthor ( "YukikoBando", I18N_NOOP("Japanese translator"),
      "*****@*****.**" );
    about.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names")
        ,I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));

    QString curarg;

    QStringList otherArgs;

    for(int i = 1; i < argc ; i++)
    {
        curarg = argv[i];
        if( curarg == "--no-stay")
            otherArgs.push_back("no-stay");
        else if (curarg == "-c" ) {
            otherArgs.push_back("c");
            //FIXME
            otherArgs.push_back(argv[++i]);
        } else if( curarg == "-f")
            otherArgs.push_back("force");
    }

    //FIXME: noxim is necessary to disable xim support in qt for this app
    const char* fake_arg1 =  "--noxim";
    char* fake_argv[10] = {argv[0], const_cast<char *>(fake_arg1), 0, 0, 0, 0, 0};
    for(int i = 1; i < argc; i++)
    {
      fake_argv[i+1] = argv[i];
    }
    KCmdLineArgs::init(argc+1, fake_argv, &about);

    KCmdLineArgs::addCmdLineOptions( options );

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    scim::uint32 verbose_level = 0;
    QString verbose_raw = args->getOption("verbose");
    if( verbose_raw.length() && verbose_raw.toInt())
        verbose_level = verbose_raw.toInt();

    scim::DebugOutput::set_verbose_level( verbose_level );
    scim::DebugOutput::enable_debug (SCIM_DEBUG_AllMask);
//     scim::DebugOutput::enable_debug (SCIM_DEBUG_MainMask | SCIM_DEBUG_SocketMask);

    if( args->isSet("l") ) {
      new KInstance(PACKAGE);
      QValueList<SkimPluginInfo *> info = SkimPluginManager::allAvailablePlugins();
      std::cout << I18N_NOOP("Installed skim Plugins:") << "\n" << I18N_NOOP("Name") << "\t\t\t\t" << I18N_NOOP("Comment") << "\n";
      for(uint i = 0; i < info.size(); i++) {
          printf("%-26s\t%s", (const char *)info[i]->pluginName().local8Bit(), (const char *)info[i]->comment().local8Bit());
          if(info[i]->isNoDisplay())
              std::cout << I18N_NOOP(" (Hidden)");
          std::cout << "\n";
      }
      std::cout << "\n" << I18N_NOOP("Note: Hidden plugins can not be disabled.") << "\n";
      return 0;
    }

    QCString p = args->getOption("p"), np = args->getOption("np");
    QStringList enabledPlugins, disabledPlugins;
    if( p.length() )
      enabledPlugins = QStringList::split(",", p);

    if( np.length() )
      disabledPlugins = QStringList::split(",", np);

    if( args->isSet("d") )
        scim::scim_daemon ();

    KApplication * kAppMainThread = new KApplication();
    if( kAppMainThread->isRestored() && !ScimKdeSettings::autoStart() )
      return 127; //when skim should not auto start, restore from session is not permitted

    if (signal(SIGTERM, sighandler) == SIG_IGN)
        signal(SIGTERM, SIG_IGN);
    if (signal(SIGINT, sighandler) == SIG_IGN)
        signal(SIGINT, SIG_IGN);
    if (signal(SIGHUP, sighandler) == SIG_IGN)
        signal(SIGHUP, SIG_IGN);

    new SkimPluginManager(enabledPlugins, disabledPlugins, otherArgs);
    return kAppMainThread->exec();
}
コード例 #26
0
ファイル: main.cpp プロジェクト: maelvalais/cameroa
// Fonction principale de l'application
//
int main(int argc, char **argv)
{
	int lancement=true;			// Drapeau pour savoir si on doit lancer l'application
	int ArretSystemeEnQuittant=false;	// Drapeau pour le lancement de l'arret du systeme en quittant l'application
	int retour=0;				// Valeur de retour de la fin de l'application
	
	// Renseignements KDE
	//
	KAboutData about("cameroa", I18N_NOOP("CamerOA"), version, description,KAboutData::License_GPL, "(C) 2006 David Romeuf", 0, 0, "*****@*****.**");
	about.addAuthor( "David Romeuf", 0, "*****@*****.**" );
	
	
	// Initialisation des options de la ligne de commande (avec les Qt et KDE specifiques)
	//
	KCmdLineArgs::init(argc, argv, &about);
	
	// Ajout des options possibles sur la ligne de commande supportees par l'application
	//
	KCmdLineArgs::addCmdLineOptions(options);
	
	// Acces aux arguments reconnus par l'application
	//
	KCmdLineArgs *arguments=KCmdLineArgs::parsedArgs();
	
	// On test la validite des arguments
	//
	if( !QDir(arguments->getOption(OptionsLC[CheminRepCamerOA])).exists() )
	{
		std::cerr << "CamerOA: ERREUR: Le repertoire " << arguments->getOption(OptionsLC[CheminRepCamerOA]) << " n'existe pas." << std::endl;
		lancement=false;
	}
	
	struct in_addr AdresseClient;
	
	if( !inet_aton(arguments->getOption(OptionsLC[AdresseClientAutorise]),&AdresseClient) )
	{
		std::cerr << "CamerOA: ERREUR: L'adresse du client autorise " << arguments->getOption(OptionsLC[AdresseClientAutorise]) << "est invalide." << std::endl;
		lancement=false;
	}
	AdresseClient.s_addr=ntohl(AdresseClient.s_addr);
	
	if( QString(arguments->getOption(OptionsLC[ArretSysteme])) == QString("o") ) ArretSystemeEnQuittant=true;
	
	
	if( lancement )
	{
		// Instanciation de l'objet camera :
		//
		// ApnCamera.cpp contient le code de la classe CApnCamera definit dans ApnCamera.h commun
		//  a toutes les versions d'interfaces peripheriques (USB, Ethernet). Aucun code n'est
		//  specialise USB/Linux.
		//
		// ApnCamera_USB.cpp contient le code de la classe CApnCamera definit dans ApnCamera.h
		//  specialise pour la version USB (par exemple la methode InitDriver() qui n'est pas
		//  codee dans ApnCamera.cpp).
		//
		// ApogeeUsbLinux.cpp contient toutes les fonctions de communication via USB pour Linux
		//  utilisees par l'objet CApnCamera (par exemple : ApnUsbOpen() qui recherche les
		//  peripheriques par Id vendeur, ApnUsbClose()).
		//
#ifndef _SIMULATEUR_APOGEE
		CameraCCD=new CApnCamera();
#else
		CameraCCD=new SimulateurApogeeUSB(false);
#endif

		// Initialisation du systeme de la camera et test de communication USB
		//
		// Le numero de camera est celui trouve par ordre d'Id vendeur Apogee en scannant tous
		//  les bus USB.
		//
		if( !CameraCCD->InitDriver(NumeroCamera,0,0) )
		{
			std::cout << "CamerOA: ERREUR: Impossible d'initialiser le systeme de la camera." << std::endl;
			exit(EXIT_FAILURE);
		}

		// Reinitialisation complete du systeme de la camera et permission du flushing (vidage)
		//  FPGA_BIT_CMD_FLUSH
		//
		if( !CameraCCD->ResetSystem() )
		{
			std::cout << "CamerOA: ERREUR: Impossible de reinitialiser le systeme de la camera." << std::endl;
			exit(EXIT_FAILURE);
		}

		// Recuperation des informations de la camera (version Linux speciale dans
		//  ApnCamera_Linux.cpp)
		//
		CameraCCD->sensorInfo();

		// Mode de fonctionnement de la camera
		//
		CameraCCD->write_CameraMode(Apn_CameraMode_Normal);

		// Parametrage du mode des diodes LED sur la camera
		//
		//  Apn_LedMode_DisableAll, Apn_LedMode_DisableWhileExpose, Apn_LedMode_EnableAll
		//
		CameraCCD->write_LedMode(Apn_LedMode_EnableAll);

		// Puissance lumineuse des diodes LED
		//
		CameraCCD->write_TestLedBrightness(100.0);

		// Fonction de la LED A
		//
		CameraCCD->write_LedState(0,Apn_LedState_Flushing);

		// Fonction de la LED B
		//
		CameraCCD->write_LedState(1,Apn_LedState_ImageActive);

		// Allocation memoire des buffers pixels physiques pour cette camera
		//
		// Il s'agit du nombre de pixels physiques et pas surface image du capteur pour avoir de la marge
		//
		if( (BufferPixelsPhysiquesImage=new (std::nothrow) unsigned short[CameraCCD->m_TotalRows*CameraCCD->m_TotalColumns]) == NULL )
		{
			std::cout << "CamerOA: ERREUR: Impossible d'allouer le buffer pixels physiques image pour cette camera." << std::endl;
			exit(EXIT_FAILURE);
		}

		if( (BufferPixelsPhysiquesVidage=new (std::nothrow) unsigned short[CameraCCD->m_TotalRows*CameraCCD->m_TotalColumns]) == NULL )
		{
			std::cout << "CamerOA: ERREUR: Impossible d'allouer le buffer pixels physiques vidage pour cette camera." << std::endl;
			exit(EXIT_FAILURE);
		}

		if( (BufferPixelsPhysiquesCentrage=new (std::nothrow) unsigned short[CameraCCD->m_TotalRows*CameraCCD->m_TotalColumns]) == NULL )
		{
			std::cout << "CamerOA: ERREUR: Impossible d'allouer le buffer pixels physiques centrage pour cette camera." << std::endl;
			exit(EXIT_FAILURE);
		}

		// Allocation memoire du buffer pixels d'une pose de centrage horizontal
		//
		if( (BufferPixelsPCH=new (std::nothrow) unsigned short[NB_LIGNES_POSE_CENTRAGE*CameraCCD->m_ImagingColumns/BINNING_POSE_CENTRAGE]) == NULL )
		{
			std::cout << "CamerOA: ERREUR: Impossible d'allouer le buffer pixels d'une pose de centrage horizontal pour cette camera." << std::endl;
			exit(EXIT_FAILURE);
		}

		// Allocation memoire du buffer pixels d'une pose de centrage vertical
		//
		if( (BufferPixelsPCV=new (std::nothrow) unsigned short[NB_COLONNES_POSE_CENTRAGE*CameraCCD->m_ImagingRows/BINNING_POSE_CENTRAGE]) == NULL )
		{
			std::cout << "CamerOA: ERREUR: Impossible d'allouer le buffer pixels d'une pose de centrage vertical pour cette camera." << std::endl;
			exit(EXIT_FAILURE);
		}


		// Creation d'un objet application KDE
		//
		KApplication appli;
		
		// Pointeur sur un objet de fenetre principale KDE
		//
		CamerOA *FenetrePrincipale=0;		// Pointeur sur objet fenetre principale de notre application

		// Instanciation du processus leger de controle de la camera
		//
		// ATTENTION: On le fait avant la fenetre principale car celle-ci a besoin d'un pointeur
		//  vers le thread de controle de la camera
		//
		ProcessusLegerControleCamera PLCamera;

		// Si l'application est restauree par le gestionnaire de session
		//
		if( appli.isRestored() )
		{
			// On restaure l'application a l'aide de l'objet de configuration de la session sauve lors de la fermeture de session
			//
			RESTORE(CamerOA(arguments->getOption(OptionsLC[CheminRepCamerOA]),&appli,&PLCamera));
		}
		else
		{
			// Pas de restauration de session donc on demarre l'application normalement
			//
			
			// Creation de l'objet fenetre principale de l'application
			//
			if( (FenetrePrincipale=new (std::nothrow) CamerOA(arguments->getOption(OptionsLC[CheminRepCamerOA]),&appli,&PLCamera)) == NULL )
			{
    				std::cerr << "CamerOA: ERREUR: Impossible de creer la fenetre principale KMainWindow de l'application." << std::endl;
					appli.exit(-1);
			}

			// Le processus leger de controle de la camera contient un pointeur vers la fenetre
			//   principale de l'application
			//
			// ATTENTION: Il faut le placer immediatement apres la creation de la fenetre 
			//  principale de l'application car le thread utilise ses methodes
			//
			PLCamera.FPCamerOA=FenetrePrincipale;

			// On fixe la fenetre principale pour l'objet application KDE
			//
			appli.setMainWidget(FenetrePrincipale);
		
			// On fixe quelques proprietes de la fenetre principale heritees de QWidget
			//
			FenetrePrincipale->setMinimumSize(QSize(TAILLE_X_BASE_CAMEROA,TAILLE_Y_BASE_CAMEROA));
		
			// Chargement des consignes sauvegardees
			//
			if( !FenetrePrincipale->ChargeConsignes() ) exit(EXIT_FAILURE);
		}
		
		// Lancement du processus leger serveur reseau des commandes sur le CamerOA
		//
		ProcessusLegerServeurCommandes PLServeurCommandes(FenetrePrincipale,INADDR_ANY,QString(arguments->getOption(OptionsLC[PortCanalCommandes])).toInt(),AdresseClient.s_addr,2,TIMEOUT_EMISSION,TIMEOUT_RECEPTION,5,FnHandlerSIGPIPECamerOA,arguments->getOption(OptionsLC[MdpClePriveeServeur]),MotDePasseClePriveeServeurCAMEROA,FnMotDePasseClePriveeChiffreeCAMEROA,arguments->getOption(OptionsLC[CheminFichCertCA_OA]),arguments->getOption(OptionsLC[CheminFichCertServCamerOA]),arguments->getOption(OptionsLC[CheminFichClePriveeServCamerOA]),arguments->getOption(OptionsLC[CheminFichParamDH]),"HIGH");

		FenetrePrincipale->PLServeurCommandes=&PLServeurCommandes;
		
		PLServeurCommandes.start();
		
		// Lancement du processus leger serveur reseau des donnees sur le CamerOA
		//
		ProcessusLegerServeurDonnees PLServeurDonnees(FenetrePrincipale,INADDR_ANY,QString(arguments->getOption(OptionsLC[PortCanalDonnees])).toInt(),AdresseClient.s_addr,2,TIMEOUT_EMISSION,TIMEOUT_RECEPTION);

		FenetrePrincipale->PLServeurDonnees=&PLServeurDonnees;
		
		PLServeurDonnees.start();
		
		// Les pointeurs entre les processus
		//
		PLServeurCommandes.threadCanalDonnees=&PLServeurDonnees;
		PLServeurCommandes.threadCamera=&PLCamera;
		
		// Lancement du processus leger de controle de la camera
		//
		PLCamera.start();
		
		// Tant que les threads ne sont pas tous lances et operationnels
		//
		while( SemaphoreSyncLancementThreadCamerOA.available() > 0 );
		
		// On affiche la fenetre principale
		//
		FenetrePrincipale->show();
		
		// Demarrage du timer une fois que tout est lance et affiche
		//
		FenetrePrincipale->Pulsar1s->start(1000,FALSE);
		
		
		// FenetrePrincipale a un drapeau WDestructiveClose par defaut, elle se detruira elle meme.
		//
		retour=appli.exec();


		//	On demande l'arret des processus legers
		//
		if( PLServeurCommandes.running() )
		{
			PLServeurCommandes.DemandeTerminaison();
		}

		if( PLServeurDonnees.running() )
		{
			PLServeurDonnees.DemandeTerminaison();
		}

		if( PLCamera.running() )
		{
			PLCamera.DemandeTerminaison();
		}

		// Si le processus leger de controle de la camera tourne encore
		//  on attend la terminaison propre par lui meme
		//
		while( PLCamera.running() );
		PLCamera.wait(TEMPS_ATTENTE_TERMINAISON_PROCESSUS_LEGER);

		// Fermeture de la communication USB avec la camera
		//
		CameraCCD->write_ForceShutterOpen(false);
		CameraCCD->ResetSystem();
		usleep(1000000);
		CameraCCD->CloseDriver();
		
		// On attend la terminaison du processus leger avant de retourner la valeur
		//
		PLServeurCommandes.wait(TEMPS_ATTENTE_TERMINAISON_PROCESSUS_SERVEUR);

		// On attend la terminaison du processus leger avant de retourner la valeur
		//
		PLServeurDonnees.wait(TEMPS_ATTENTE_TERMINAISON_PROCESSUS_SERVEUR);

		
		// On lave la liste des options et arguments de la ligne de commande de l'application
		//
		arguments->clear();
		
		
		// Destruction de l'objet camera
		//
		delete CameraCCD;
		
		
		// Liberation de la memoire utilisee pour la gestion de la camera
		//
		delete [] BufferPixelsPhysiquesImage;
		delete [] BufferPixelsPhysiquesVidage;
		delete [] BufferPixelsPhysiquesCentrage;
		delete [] BufferPixelsPCH;
		delete [] BufferPixelsPCV;


		// Si on a demande l'arret du systeme en quittant l'application CamerOA
		//
		if( ArretSystemeEnQuittant )
		{
			std::cout << "Lancement de la demande de l'arret du systeme dans 60 secondes." << std::endl;
			
			// On utilise la commande propre du systeme via la commande sudo
			//
			// Il faut installer l'utilitaire sudo et configurer /etc/sudoers avec la ligne :
			//
			//  dromeuf cameroa-1=NOPASSWD: /sbin/halt
			//	observateur cameroa-1=NOPASSWD: /sbin/halt
			//
			//  qui permet par exemple a l'utilisateur dromeuf depuis la machine jedi, sans mot de passe,
			//   de lancer la commande /sbin/halt
			//
			system("/bin/sync ; /bin/sleep 60s ; /usr/bin/sudo /sbin/halt");
		}

		// Resultat de l'execution de la QApplication heritee par KApplication
		//
		return retour;
	}
}
コード例 #27
0
int main(int argc, char *argv[]) {
  int i_file, i_v, i_curve;
  int i_plot;

  KAboutData aboutData( "kst", I18N_NOOP("Kst"),
                        "0.95-devel", description, KAboutData::License_GPL,
                        I18N_NOOP("(c) 2000-2003 Barth Netterfield"),
                        0,
                        "http://extragear.kde.org/apps/kst.php");
  aboutData.addAuthor("Barth Netterfield",
                      I18N_NOOP("Original author and maintainer."),
                      "*****@*****.**",
                      "http://omega.astro.utoronto.ca/");
  aboutData.addAuthor("Staikos Computing Services Inc.",
                      I18N_NOOP("Developed for the University of Toronto."),
                      "*****@*****.**",
                      "http://www.staikos.net/");

  KCmdLineArgs::init( argc, argv, &aboutData );
  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  KApplication app;
  KImageIO::registerFormats();

  if (app.isRestored()) {
    RESTORE(KstApp)
  } else {
    KstApp *kst = new KstApp;

    struct InType in;
    QColor color;
    QCStringList ycolList;
    QCStringList yEqList;
    QCStringList psdList;
    QCStringList hsList;
    QCStringList errorList;
    unsigned int i_ycol;
    QCStringList::Iterator psd;
    QCStringList::Iterator hs;
    QCStringList::Iterator eq_i;
    bool nOK;

    /* temp variables: these all get stuck into list objects */
    KstDataSourcePtr file;
    KstRVector *xvector=NULL;
    KstRVector *yvector;
    KstRVector *evector;
    KstVCurve *curve;
    KstPSDCurve *psdcurve;
    KstEquationCurve *eqcurve;
    KstHistogram *hscurve;
    KstPlot *plot;
    int n_y, n_eq=0;

    /* Parse command line args */
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    CheckForCMDErrors(args);

    // Initialise the plugin loader and collection.
    PluginCollection::self();

    /* get Y axis collums */
    ycolList = args->getOptionList("y");
    yEqList = args->getOptionList("ye");
    psdList = args->getOptionList("p");
    hsList = args->getOptionList("h");
    errorList = args->getOptionList("e");

    // y axis or PSD specified, so the files are data files, not kst files.
    n_y = ycolList.count() + psdList.count() + hsList.count()
      + yEqList.count();
    if (n_y > 0) {

      SetCMDOptions(args, in, n_y);

      CreatePlots(in);

      i_plot = 0;
      plot = KST::plotList.at(i_plot);

      /* make stand alone equations if there are no files */
      if (args->count()<1) {
        if (!yEqList.isEmpty()) {
	  QString eqS;
          double max, min;
          int n;
          bool xeq;
          SetEqXRanges(args->getOption("xe"), &min, &max, &n, &xeq);
          if (xeq) {
            for (eq_i = yEqList.begin(); eq_i != yEqList.end(); ++eq_i) {
              eqS = *eq_i;
              if (NoVectorEq(eqS)) {
                eqcurve =
                  new KstEquationCurve(QString("E")+QString::number(n_eq+1)+
                                       "-" + eqS,
                                       eqS,
                                       min,max,n, KstColorSequence::next());

                KST::dataObjectList.lock().writeLock();
                KST::dataObjectList.append(eqcurve);
                KST::dataObjectList.lock().writeUnlock();
                plot->addCurve(eqcurve);

                if (in.sep_plots) {
                  i_plot++;
                  if (i_plot <in.n_plots) plot = KST::plotList.at(i_plot);
                }
              }
            }
          }
        }
      }

      /* Make the requested curves for each data file */
      for (i_curve = i_v = 0, i_file = 0; i_file < args->count(); i_file++) {
        /* Make the file */
        file = KstDataSource::loadSource(args->arg(i_file));

        if (!file) {
          kdWarning() << I18N_NOOP("Error: No data in file: ")
	              << args->arg(i_file) << endl;
          delete kst;
          exit(0);
        }

	if (!file->isValid() || file->frameCount() < 1) {
          kdWarning() << I18N_NOOP("Error: No data in file: ")
	              << args->arg(i_file) << endl;
          // The file might get data later!
	}

        KST::dataObjectList.lock().writeLock();
        KST::dataSourceList.append(file);
        KST::dataObjectList.lock().writeUnlock();

        if (!ycolList.isEmpty()) { // if there are some xy plots
          /* make the x axis vector */
          xvector = GetOrCreateVector(args->getOption("x"), file, in);

          /* make the y axis vectors */
          for (i_ycol = 0; i_ycol < ycolList.count(); ++i_ycol ) {
            yvector = GetOrCreateVector(*(ycolList.at(i_ycol)), file, in);

            /* make the curves */
            color = KstColorSequence::next();
            curve = new KstVCurve(QString("C") + QString::number(1+i_curve++)
                                  + "-" + yvector->getField(),
                                  KstVectorPtr(xvector), KstVectorPtr(yvector),
                                  0L, 0L, color);
            if (in.has_points) {
              curve->setHasPoints(true);
              curve->setHasLines(false);
            }

            if (i_ycol<errorList.count()) {
              evector = GetOrCreateVector(*(errorList.at(i_ycol)), file, in);
              curve->setYError(KstVectorPtr(evector));
            }

            KST::dataObjectList.lock().writeLock();
            KST::dataObjectList.append(curve);
            KST::dataObjectList.lock().writeUnlock();
            plot->addCurve(curve);

            if (in.sep_plots) {
              i_plot++;
              if (i_plot < in.n_plots)
                plot = KST::plotList.at(i_plot);
            } // end (if they are separate plots)
          } // next y col
        } // end (if there are some xy plots)
	if (!yEqList.isEmpty()) {
	  QString eqS;
          double max, min;
          int n;
          bool xeq, eq_ok;

          SetEqXRanges(args->getOption("xe"), &min, &max, &n, &xeq);
	  for (eq_i = yEqList.begin(); eq_i != yEqList.end(); ++eq_i) {
	    eqS = *eq_i;
	    ProcessEq(eqS, file, in, &eq_ok);
            if (xeq) {
              eqcurve =
                new KstEquationCurve(QString("E")+QString::number(n_eq+1)+
                                     "-" + eqS,
                                     eqS,
                                     min,max,n, KstColorSequence::next());
            } else {
              if (xvector==NULL)
                xvector = GetOrCreateVector(args->getOption("x"), file, in);

              eqcurve =
                new KstEquationCurve(QString("E")+QString::number(n_eq+1)+eqS,
                                     eqS,
                                     KstVectorPtr(xvector),
                                     true, KstColorSequence::next());
            }
            KST::dataObjectList.lock().writeLock();
            KST::dataObjectList.append(eqcurve);
            KST::dataObjectList.lock().writeUnlock();
            plot->addCurve(eqcurve);

            if (in.sep_plots) {
              i_plot++;
              if (i_plot <in.n_plots) plot = KST::plotList.at(i_plot);
            }
	  }
	}
        if (psdList.count() > 0) { // if there are some psd plots
          KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
          for(psd = psdList.begin(); psd != psdList.end(); ++psd ) {

	    yvector = GetOrCreateVector(*psd, file, in);

            color = KstColorSequence::next();

            psdcurve = new KstPSDCurve(QString("P") +
                                       QString::number(1+i_curve++)
                                       + "-" + yvector->getField(),
                                       KstVectorPtr(yvector), in.rate, in.len,
                                       in.VUnits,in.RUnits,
                                       color);
            if (in.has_points) {
              psdcurve->setHasPoints(true);
              psdcurve->setHasLines(false);
            }
            KST::dataObjectList.lock().writeLock();
            KST::dataObjectList.append(psdcurve);
            KST::dataObjectList.lock().writeUnlock();
            plot->addCurve(psdcurve);

            if (in.sep_plots) {
              i_plot++;
              if (i_plot <in.n_plots) plot = KST::plotList.at(i_plot);
            }
          } // next psd
        } // end (if there are some psds)
        if (hsList.count()>0) { // if there are some histograms
          double max, min;
          int N;

          KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
          for (hs = hsList.begin(); hs != hsList.end(); ++hs ) {
	    yvector = GetOrCreateVector(*hs, file, in);

            color = KstColorSequence::next();

            KstHistogram::AutoBin(KstVectorPtr(yvector), &N, &max, &min);

            hscurve = new KstHistogram(QString("H") +
                                       QString::number(1+i_curve++)
                                       + "-" + yvector->getField(),
                                       KstVectorPtr(yvector), min, max, N,
                                       KST_HS_NUMBER,
                                       color);
            KST::dataObjectList.lock().writeLock();
            KST::dataObjectList.append(KstDataObjectPtr(hscurve));
            KST::dataObjectList.lock().writeUnlock();
            plot->addCurve(hscurve);

            if (in.sep_plots) {
              i_plot++;
              if (i_plot < in.n_plots)
                plot = KST::plotList.at(i_plot);
            }
          } // next histogram
        } // end (if there are some histograms)
      } // next data file
      for (i_plot = 0; i_plot < in.n_plots; i_plot++) {
        KST::plotList.at(i_plot)->GenerateDefaultLabels();
      }
      KST::plotList.setPlotCols(in.n_cols);

    } else if (args->count() > 0) {
      /* open a kst file */
      /* some of the options can be overridden */
      kst->openDocumentFile(args->arg(0),
			    args->getOption("F"), // override FileName
			    // override number of frames
			    args->getOption("n").toInt(&nOK),
			    // override starting frame
			    args->getOption("f").toInt(&nOK),
			    // override skip
			    args->getOption("s").toInt(&nOK),
			    // add averaging
			    args->isSet("a"));
    } else {
      //kst->openDocumentFile();
    }

    QString printfile;
    printfile = args->getOption("print");
    QString pngfile;
    pngfile = args->getOption("png");
    bool print_and_exit = false;

    if (printfile!="<none>") {
      args->clear();
      kst->forceUpdate();
      kst->immediatePrintToFile(printfile);
      print_and_exit = true;
    }

    if (pngfile!="<none>") {
      args->clear();
      kst->forceUpdate();
      kst->immediatePrintToPng(pngfile);
      print_and_exit = true;
    }

    if (print_and_exit) {
      delete kst;
      exit(0);
    } else {
      args->clear();
      app.setMainWidget(kst);
      kst->show();
    }

    // LEAVE THIS HERE - causes crashes otherwise!
    int rc = app.exec();
    delete kst;
    return rc;
  }
  return app.exec();
}
コード例 #28
0
ファイル: main.cpp プロジェクト: BackupTheBerlios/kslovar-svn
int main(int argc, char **argv)
{
    KAboutData about("kslovar", I18N_NOOP("KSlovar"), version, description,
         KAboutData::License_GPL, "(C) 2005-2006 Gregor Kališnik", 0, 0, "*****@*****.**");
    about.addAuthor("Gregor Kališnik", I18N_NOOP("Lead developer"), "*****@*****.**");
    about.addCredit("Kopete development team", I18N_NOOP("Mouse navigation in lists"), "*****@*****.**", "http://kopete.kde.org");
    about.addCredit("Grega Štajer", I18N_NOOP("Creator of icons, logo and splash screen"), "*****@*****.**", "http://blender.kicks-ass.net");
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions(options);
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    KApplication app;
    QPixmap splash(locate("appdata", "splash.png"));
    KSplashScreen *splashScreen=new KSplashScreen(splash);
    splashScreen->show();

    // Decided not to go to version 0.3.0 !
    /*splashScreen->message(I18N_NOOP("Creating dcitionary list..."));

    QDir dictionaries(locate("appdata", "dictionaries/"));
    QDir dictionariesLocal(locateLocal("appdata", "dictionaries/", true));

    if (dictionaries.exists()) {
      QStringList files(dictionaries.entryList("*.scmd", QDir::Files));
      QStringList::const_iterator end = files.constEnd();

      for (QStringList::const_iterator count = files.constBegin(); count != end; count++) {
        KSDBHandler *dictionary = new KSDBHandler(dictionariesLocal.absFilePath(*count));
        KSResult result = dictionary->processString("SELECT greeting, type FROM head;");

        QString text = result["greeting"];
        QString name = result["greeting"];
        text.remove(QRegExp("<h1>.+</h1>"));
        name.remove(text).remove("<h1>").remove("</h1>");

        KSData::instance()->addDictionaryData(name, text, true, result["type"]);
        //kdDebug() << dictionaries.absFilePath(*count) << endl;
        delete dictionary;
      }
    }*/

    splashScreen->message("Launching application...");

    KSlovar *mainWin = 0;

    if (app.isRestored()) {
        RESTORE(KSlovar);
    } else {
        // no session.. just start up normally

        mainWin = new KSlovar();

        //Opening file from command line
        if(args->count())
          mainWin->openFile(QString::fromUtf8(args->arg(0)));

        app.setMainWidget( mainWin );
        mainWin->resize(1000, 800);
        mainWin->show();
        splashScreen->finish(mainWin);

        args->clear();
    }

    // mainWin has WDestructiveClose flag by default, so it will delete itself.
    return app.exec();
}