main.cpp
changeset 434 c585be63ec69
parent 406 1c8ff1928b97
child 473 8b9cfc26638c
     1.1 --- a/main.cpp	Thu Nov 23 13:53:08 2006 +0000
     1.2 +++ b/main.cpp	Tue Mar 06 19:37:39 2007 +0000
     1.3 @@ -1,5 +1,4 @@
     1.4  #include <QApplication>
     1.5 -#include <q3network.h>
     1.6  
     1.7  #include "flagrowobj.h"
     1.8  #include "mainwindow.h"
     1.9 @@ -50,6 +49,7 @@
    1.10  	options.add ("local", SwitchOption, "l", "local");
    1.11  	options.add ("help", SwitchOption, "h", "help");
    1.12  	options.add ("quit", SwitchOption, "q", "quit");
    1.13 +	options.add ("run", StringOption, "r", "run");
    1.14  	options.add ("test", StringOption, "t", "test");
    1.15  	options.setHelpText (
    1.16  		"VYM - View Your Mind\n"
    1.17 @@ -113,9 +113,6 @@
    1.18  		return 0;	
    1.19  	}	
    1.20  
    1.21 -    q3InitNetworkProtocols();
    1.22 -
    1.23 -
    1.24  	// Initialize translations
    1.25  	QTranslator translator (0);
    1.26  	translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
    1.27 @@ -140,7 +137,31 @@
    1.28  	m.fileNew();
    1.29  	m.loadCmdLine();
    1.30  
    1.31 -	// For benchmarking we may want to quit immediatly after drawing
    1.32 +	// Run script
    1.33 +	if (options.isOn ("run"))
    1.34 +	{
    1.35 +		QString script;
    1.36 +		QString fn=options.getArg ("run");
    1.37 +		if ( !fn.isEmpty() )
    1.38 +		{
    1.39 +			QFile f( fn );
    1.40 +			if ( !f.open( QIODevice::ReadOnly ) )
    1.41 +			{
    1.42 +				QMessageBox::warning(0, 
    1.43 +					QObject::tr("Error"),
    1.44 +					QObject::tr("Couldn't open %1.\n").arg(fn));
    1.45 +				return 0;
    1.46 +			}	
    1.47 +
    1.48 +			QTextStream ts( &f );
    1.49 +			script= ts.read();
    1.50 +			f.close();
    1.51 +			m.setScript (script);
    1.52 +			m.runScript (script);
    1.53 +		}
    1.54 +	}		
    1.55 +	
    1.56 +	// For benchmarking we may want to quit instead of entering event loop
    1.57  	if (options.isOn ("quit"))
    1.58  	{
    1.59  		return 0;