main.cpp
author insilmaril
Mon, 28 Feb 2005 16:22:29 +0000
changeset 91 855c486b9360
parent 90 10f3d35dcbad
child 93 31c6ce8efbc7
permissions -rw-r--r--
created vym_de.ts
     1 #include <qapplication.h>
     2 #include <qpixmap.h>
     3 #include <qtranslator.h>
     4 #include <qdir.h>
     5 #include <qtextcodec.h>
     6 
     7 #include "settings.h"
     8 #include "options.h"
     9 #include "mainwindow.h"
    10 
    11 #include "icons/vym-48x48.xpm"
    12 #include "icons/vym-editor.xpm"
    13 
    14 #include "flagrowobj.h"
    15 
    16 // Global variables
    17 TextEditor *textEditor;			// used in Constr. of LinkableMapObj
    18 								// initialized in mainwindow
    19 
    20 Main *mainWindow;				// used in BranchObj::select()								
    21 MapEditor *clipboardME;			
    22 FlagRowObj *systemFlagsDefault;	// used to copy from in LinkableMapObj
    23 FlagRowObj *standardFlagsDefault;
    24 
    25 // Actions which change sometimes
    26 QAction *actionFileSave;
    27 QAction *actionFilePrint;
    28 QAction *actionEditUndo;
    29 QAction *actionEditCopy;
    30 QAction *actionEditCut;
    31 QAction *actionEditPaste;
    32 QAction *actionEditMoveUp;
    33 QAction *actionEditMoveDown;
    34 QAction *actionEditToggleScroll;
    35 QAction *actionEditOpenURL;
    36 QAction *actionEditURL;
    37 QAction *actionEditHeading2URL;
    38 QAction *actionEditBugzilla2URL;
    39 QAction *actionEditOpenVymLink;
    40 QAction *actionEditVymLink;
    41 QAction *actionEditDeleteVymLink;
    42 QAction *actionEditMapInfo;
    43 QAction *actionEditHeading;
    44 QAction *actionEditDelete;
    45 QAction *actionEditAddBranch;
    46 QAction *actionEditAddBranchAbove;
    47 QAction *actionEditAddBranchBelow;
    48 QAction *actionEditImportAdd;
    49 QAction *actionEditImportReplace;
    50 QAction *actionEditSaveBranch;
    51 QAction *actionEditSelectFirst;
    52 QAction *actionEditSelectLast;
    53 QAction *actionEditLoadImage;
    54 QAction *actionEditToggleFloatExport;
    55 QAction *actionEditNoLink;
    56 
    57 QAction *actionFormatColor;		
    58 QAction *actionFormatPickColor;		
    59 QAction *actionFormatColorBranch;
    60 QAction *actionFormatColorSubtree;
    61 QAction *actionFormatBackColor;
    62 QAction *actionFormatLinkColorHint;
    63 QAction *actionFormatLinkColor;		
    64 
    65 QActionGroup *actionGroupModModes;
    66 QAction *actionModModeColor;
    67 QAction *actionModModeLink;
    68 
    69 QActionGroup *actionGroupFormatFrameTypes;
    70 QAction *actionFormatFrameNone;
    71 QAction *actionFormatFrameRectangle;
    72 
    73 QActionGroup *actionGroupFormatLinkStyles;
    74 QAction *actionFormatLinkStyleLine;
    75 QAction *actionFormatLinkStyleParabel;
    76 QAction *actionFormatLinkStylePolyLine;
    77 QAction *actionFormatLinkStylePolyParabel;
    78 
    79 QAction *actionViewToggleNoteEditor;
    80 
    81 QAction *actionSettingsAutoselectHeading;
    82 QAction *actionSettingsAutoselectText;
    83 QAction *actionSettingsPasteNewHeading;
    84 QAction *actionSettingsAutoedit;
    85 QAction *actionSettingsUseDelKey;
    86 
    87 QPopupMenu *branchContextMenu;
    88 QPopupMenu *branchLinksContextMenu;
    89 QPopupMenu *floatimageContextMenu;
    90 QPopupMenu *saveImageFormatMenu;
    91 QPopupMenu *canvasContextMenu;
    92 QPopupMenu *lastMapsMenu;
    93 QPopupMenu *exportMenu;
    94 QPopupMenu *exportImageFormatMenu;
    95 
    96 
    97 Settings settings;
    98 Options options;
    99 
   100 int statusbarTime=3500;
   101 
   102 int main(int argc, char** argv)
   103 {
   104     QApplication app(argc,argv);
   105 
   106 
   107 	// Use /usr/share/vym or /usr/local/share/vym or .
   108 	QDir shareDir;
   109 	shareDir.setPath ("/usr/share/vym");
   110 	if (!shareDir.exists())
   111         shareDir.setPath ("/usr/local/share/vym");
   112 	if (!shareDir.exists())
   113         shareDir.setPath(".");
   114 
   115 	// Initialize translations
   116 	QTranslator translator (0);
   117 	translator.load( QString("vym_")+QTextCodec::locale(), shareDir.path() + "/lang");
   118     app.installTranslator( &translator );
   119 
   120 	// Initializing the row of system flags
   121 	// is done in first call to MapEditor(),
   122 	// because we need at least one canvas first
   123 	systemFlagsDefault=NULL;
   124 	standardFlagsDefault=NULL;
   125 
   126 	// Reading and initializing options commandline options
   127 	options.add ("version", SwitchOption, "v","version");
   128 	options.add ("help", SwitchOption, "h", "help");
   129 	options.add ("quit", SwitchOption, "q", "quit");
   130 	options.add ("test", StringOption, "t", "test");
   131 	options.setHelpText (
   132 		"VYM - View Your Mind\n"
   133 		"--------------------\n\n"
   134 		"Information about vym can be found in vym.pdf,\n"
   135 		"which should be part of the vym package.\n"
   136 		"It is also available at the project homepage:\n\n"
   137 		"http://www.InSilmaril.de/vym\n");
   138 	if (options.parse())
   139 	{
   140 		cout << endl << options.getHelpText()<<endl;
   141 		return 1;
   142 	}
   143 
   144 	if (options.isOn ("version"))
   145 	{
   146 		cout << "vym version "<<__VYM_VERSION__
   147 			<<"  (c) 2004 Uwe Drechsel - "
   148 			<<__BUILD_DATE__<<endl;
   149 			
   150 		return 0;	
   151 	}		
   152 	
   153 	if (options.isOn ("help"))
   154 	{
   155 		cout << options.getHelpText()<<endl;
   156 		return 0;	
   157 	}	
   158 
   159 	if (options.isOn ("test"))
   160 	{
   161 		// FIXME testing string option only
   162 		cout << "Testing: "<<options.getArg("test")<< endl;
   163 	}	
   164 
   165 	// Initialize window of TextEditor
   166 	textEditor = new TextEditor();
   167 	textEditor->setIcon (QPixmap (vym_editor_xpm));
   168 	if (textEditor->showWithMain()) textEditor->show();
   169 
   170 	clipboardME = new MapEditor();
   171 	clipboardME->resize (800,600);
   172 	clipboardME->setCaption("VYM - clipboard");
   173 	clipboardME->hide();
   174 
   175 	// Initialize mainwindow after Mapeditors (because of Flags)
   176     Main m;
   177 	//m.resize(m.sizeHint());
   178 	m.setIcon (QPixmap (vym_logo_xpm));
   179 	m.show();
   180 	m.fileNew();
   181 	m.loadCmdLine();
   182 
   183 	// For benchmarking we may want to quit immediatly after drawing
   184 	if (options.isOn ("quit"))
   185 	{
   186 		return 0;
   187 	}	
   188 
   189     QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
   190 
   191     return app.exec();
   192 }
   193