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