main.cpp
author insilmaril
Tue, 24 Oct 2006 15:36:38 +0000
changeset 394 67cfa6e6b863
parent 390 0e1aeb21cb78
child 398 d42881c25fb6
permissions -rw-r--r--
1.8.58 - More undoCommands, spanish translation of doc
     1 #include <QApplication>
     2 //#include <QPixmap>
     3 //#include <QTranslator>
     4 //#include <QDir>
     5 //#include <QTextCodec>
     6 #include <q3network.h>
     7 //#include <QActionGroup>
     8 
     9 #include "settings.h"
    10 #include "options.h"
    11 #include "mainwindow.h"
    12 #include "flagrowobj.h"
    13 
    14 // Global variables
    15 TextEditor *textEditor;			// used in Constr. of LinkableMapObj
    16 								// initialized in mainwindow
    17 
    18 Main *mainWindow;				// used in BranchObj::select()								
    19 QString tmpVymDir;				// All temp files go there, created in mainwindow
    20 QString clipboardDir;			// Clipboard used in all mapEditors
    21 QDir vymBaseDir;				// Containing all styles, scripts, images, ...
    22 QDir lastImageDir;
    23 QDir lastFileDir;
    24 QString iconPath;				// Pointing to icons used for toolbars
    25 QString flagsPath;				// Pointing to flags
    26 bool clipboardEmpty;			
    27 FlagRowObj *systemFlagsDefault;	// used to copy from in LinkableMapObj
    28 FlagRowObj *standardFlagsDefault;
    29 
    30 
    31 Settings settings ("InSilmaril","vym"); // Organization, Application name
    32 
    33 Options options;
    34 ImageIO imageIO;
    35 
    36 int statusbarTime=3500;
    37 
    38 int main(int argc, char* argv[])
    39 {
    40 	//Q_INIT_RESOURCE (application);
    41 
    42     QApplication app(argc,argv);
    43 
    44 
    45 	// Reading and initializing options commandline options
    46 	options.add ("version", SwitchOption, "v","version");
    47 	options.add ("local", SwitchOption, "l", "local");
    48 	options.add ("help", SwitchOption, "h", "help");
    49 	options.add ("quit", SwitchOption, "q", "quit");
    50 	options.add ("test", StringOption, "t", "test");
    51 	options.setHelpText (
    52 		"VYM - View Your Mind\n"
    53 		"--------------------\n\n"
    54 		"Information about vym can be found in vym.pdf,\n"
    55 		"which should be part of the vym package.\n"
    56 		"It is also available at the project homepage:\n\n"
    57 		"http://www.InSilmaril.de/vym\n");
    58 	if (options.parse())
    59 	{
    60 		cout << endl << options.getHelpText().ascii()<<endl;
    61 		return 1;
    62 	}
    63 
    64 	if (options.isOn ("version"))
    65 	{
    66 		cout << "vym version "<<__VYM_VERSION
    67 			<<"  (c) 2004-2006 Uwe Drechsel - "
    68 			<<__BUILD_DATE<<endl;
    69 			
    70 		return 0;	
    71 	}		
    72 	
    73 	// Use /usr/share/vym or /usr/local/share/vym or . ?
    74 	// First try options
    75 	if (options.isOn ("local"))
    76 	{
    77 		vymBaseDir.setPath (vymBaseDir.currentDirPath());
    78 	} else
    79 	// then look for environment variable
    80 	if (getenv("VYMHOME")!=0)
    81 	{
    82 		vymBaseDir.setPath (getenv("VYMHOME"));
    83 	} else
    84 	// ok, let's find my way on my own
    85 	{
    86 		#if defined (Q_OS_MACX)
    87 			vymBaseDir.setPath(vymBaseDir.currentDirPath() +"/vym.app/Contents/Resources");
    88 
    89 		#else
    90 			vymBaseDir.setPath ("/usr/share/vym");
    91 			if (!vymBaseDir.exists())
    92 			{
    93 				vymBaseDir.setPath ("/usr/local/share/vym");
    94 				if (!vymBaseDir.exists())
    95 					vymBaseDir.setPath(vymBaseDir.currentDirPath() );
    96 			}		
    97 		#endif
    98 	}
    99 
   100 	iconPath=vymBaseDir.path()+"/icons/";
   101 	flagsPath=vymBaseDir.path()+"/flags/";
   102 
   103 	// Some directories
   104 	lastImageDir=QDir().current();
   105 	lastFileDir=QDir().current();
   106 
   107 	if (options.isOn ("help"))
   108 	{
   109 		cout << options.getHelpText().ascii()<<endl;
   110 		return 0;	
   111 	}	
   112 
   113     q3InitNetworkProtocols();
   114 
   115 
   116 	// Initialize translations
   117 	QTranslator translator (0);
   118 	translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
   119     app.installTranslator( &translator );
   120 
   121 	// Initializing the row of system flags
   122 	// is done in first call to MapEditor(),
   123 	// because we need at least one canvas first
   124 	systemFlagsDefault=NULL;
   125 	standardFlagsDefault=NULL;
   126 
   127 	// Initialize window of TextEditor
   128 	textEditor = new TextEditor();
   129 	textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
   130 	if (textEditor->showWithMain()) textEditor->show();
   131 
   132 	// Initialize mainwindow 
   133     Main m;
   134 	//m.resize(m.sizeHint());
   135 	m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
   136 	m.show();
   137 	m.fileNew();
   138 	m.loadCmdLine();
   139 
   140 	// For benchmarking we may want to quit immediatly after drawing
   141 	if (options.isOn ("quit"))
   142 	{
   143 		return 0;
   144 	}	
   145 
   146     QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
   147 
   148     return app.exec();
   149 }
   150