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