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