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