main.cpp
author insilmaril
Fri Jul 08 07:24:42 2005 +0000 (2005-07-08)
changeset 111 e42f9fdb281a
parent 98 58adc2d2ed08
child 117 835f2eb4d744
permissions -rw-r--r--
changes for 1.6.9
     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 QAction *actionSettingsUseFlagGroups;
    95 
    96 QPopupMenu *branchContextMenu;
    97 QPopupMenu *branchAddContextMenu;
    98 QPopupMenu *branchRemoveContextMenu;
    99 QPopupMenu *branchLinksContextMenu;
   100 QPopupMenu *branchLinksContextMenuDup;
   101 QPopupMenu *floatimageContextMenu;
   102 QPopupMenu *saveImageFormatMenu;
   103 QPopupMenu *canvasContextMenu;
   104 QPopupMenu *lastMapsMenu;
   105 QPopupMenu *exportMenu;
   106 QPopupMenu *exportImageFormatMenu;
   107 
   108 
   109 Settings settings;
   110 Options options;
   111 
   112 int statusbarTime=3500;
   113 
   114 int main(int argc, char** argv)
   115 {
   116     QApplication app(argc,argv);
   117 
   118 
   119 	// Use /usr/share/vym or /usr/local/share/vym or .
   120 	QDir shareDir;
   121 	shareDir.setPath ("/usr/share/vym");
   122 	if (!shareDir.exists())
   123         shareDir.setPath ("/usr/local/share/vym");
   124 	if (!shareDir.exists())
   125         shareDir.setPath(".");
   126 
   127 	// Initialize translations
   128 	QTranslator translator (0);
   129 	translator.load( QString("vym_")+QTextCodec::locale(), shareDir.path() + "/lang");
   130     app.installTranslator( &translator );
   131 
   132 	// Initializing the row of system flags
   133 	// is done in first call to MapEditor(),
   134 	// because we need at least one canvas first
   135 	systemFlagsDefault=NULL;
   136 	standardFlagsDefault=NULL;
   137 
   138 	// Reading and initializing options commandline options
   139 	options.add ("version", SwitchOption, "v","version");
   140 	options.add ("help", SwitchOption, "h", "help");
   141 	options.add ("quit", SwitchOption, "q", "quit");
   142 	options.add ("test", StringOption, "t", "test");
   143 	options.setHelpText (
   144 		"VYM - View Your Mind\n"
   145 		"--------------------\n\n"
   146 		"Information about vym can be found in vym.pdf,\n"
   147 		"which should be part of the vym package.\n"
   148 		"It is also available at the project homepage:\n\n"
   149 		"http://www.InSilmaril.de/vym\n");
   150 	if (options.parse())
   151 	{
   152 		cout << endl << options.getHelpText()<<endl;
   153 		return 1;
   154 	}
   155 
   156 	if (options.isOn ("version"))
   157 	{
   158 		cout << "vym version "<<__VYM_VERSION__
   159 			<<"  (c) 2004 Uwe Drechsel - "
   160 			<<__BUILD_DATE__<<endl;
   161 			
   162 		return 0;	
   163 	}		
   164 	
   165 	if (options.isOn ("help"))
   166 	{
   167 		cout << options.getHelpText()<<endl;
   168 		return 0;	
   169 	}	
   170 
   171 	if (options.isOn ("test"))
   172 	{
   173 		// FIXME testing string option only
   174 		cout << "Testing: "<<options.getArg("test")<< endl;
   175 	}	
   176 
   177 	// Initialize window of TextEditor
   178 	textEditor = new TextEditor();
   179 	textEditor->setIcon (QPixmap (vym_editor_xpm));
   180 	if (textEditor->showWithMain()) textEditor->show();
   181 
   182 	clipboardME = new MapEditor();
   183 	clipboardME->resize (800,600);
   184 	clipboardME->setCaption("VYM - clipboard");
   185 	clipboardME->hide();
   186 
   187 	// Initialize mainwindow after Mapeditors (because of Flags)
   188     Main m;
   189 	//m.resize(m.sizeHint());
   190 	m.setIcon (QPixmap (vym_logo_xpm));
   191 	m.show();
   192 	m.fileNew();
   193 	m.loadCmdLine();
   194 
   195 	// For benchmarking we may want to quit immediatly after drawing
   196 	if (options.isOn ("quit"))
   197 	{
   198 		return 0;
   199 	}	
   200 
   201     QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
   202 
   203     return app.exec();
   204 }
   205