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