main.cpp
author insilmaril
Wed, 15 Mar 2006 13:53:54 +0000
changeset 252 f9ed11f2ab60
parent 250 0e994bf2346b
child 260 69d648a0a15b
permissions -rw-r--r--
hide export for floatimages.
     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 *actionEditToggleHideExport;
    55 QAction *actionEditDeleteVymLink;
    56 QAction *actionEditMapInfo;
    57 QAction *actionEditHeading;
    58 QAction *actionEditDelete;
    59 QAction *actionEditAddBranch;
    60 QAction *actionEditAddBranchHere;
    61 QAction *actionEditAddBranchAbove;
    62 QAction *actionEditAddBranchBelow;
    63 QAction *actionEditRemoveBranchHere;
    64 QAction *actionEditRemoveChilds;
    65 QAction *actionEditImportAdd;
    66 QAction *actionEditImportReplace;
    67 QAction *actionEditSaveBranch;
    68 QAction *actionEditSelectFirst;
    69 QAction *actionEditSelectLast;
    70 QAction *actionEditLoadImage;
    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 
   131 	// Reading and initializing options commandline options
   132 	options.add ("version", SwitchOption, "v","version");
   133 	options.add ("local", SwitchOption, "l", "local");
   134 	options.add ("help", SwitchOption, "h", "help");
   135 	options.add ("quit", SwitchOption, "q", "quit");
   136 	options.add ("test", StringOption, "t", "test");
   137 	options.setHelpText (
   138 		"VYM - View Your Mind\n"
   139 		"--------------------\n\n"
   140 		"Information about vym can be found in vym.pdf,\n"
   141 		"which should be part of the vym package.\n"
   142 		"It is also available at the project homepage:\n\n"
   143 		"http://www.InSilmaril.de/vym\n");
   144 	if (options.parse())
   145 	{
   146 		cout << endl << options.getHelpText()<<endl;
   147 		return 1;
   148 	}
   149 
   150 	if (options.isOn ("version"))
   151 	{
   152 		cout << "vym version "<<__VYM_VERSION
   153 			<<"  (c) 2004 Uwe Drechsel - "
   154 			<<__BUILD_DATE<<endl;
   155 			
   156 		return 0;	
   157 	}		
   158 	
   159 	// Use /usr/share/vym or /usr/local/share/vym or . ?
   160 	QDir vymBaseDir;
   161 	if (options.isOn ("local"))
   162 	{
   163 		vymBaseDir.setPath (vymBaseDir.currentDirPath());
   164 	}else
   165 	{
   166 		vymBaseDir.setPath ("/usr/share/vym");
   167 		if (!vymBaseDir.exists())
   168 			vymBaseDir.setPath ("/usr/local/share/vym");
   169 		if (!vymBaseDir.exists())
   170 			vymBaseDir.setPath(vymBaseDir.currentDirPath() );
   171 	}
   172 
   173 	if (options.isOn ("help"))
   174 	{
   175 		cout << options.getHelpText()<<endl;
   176 		return 0;	
   177 	}	
   178 
   179 	if (options.isOn ("test"))
   180 	{
   181 		// FIXME testing string option only
   182 		cout << "Testing: "<<options.getArg("test")<< endl;
   183 	}	
   184 
   185 
   186     QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
   187     factory->setPixmap("vym_128x128", QPixmap(vym_128x128_xpm));
   188     qInitNetworkProtocols();
   189 
   190 
   191 	// Initialize translations
   192 	QTranslator translator (0);
   193 	translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
   194     app.installTranslator( &translator );
   195 
   196 	// Initializing the row of system flags
   197 	// is done in first call to MapEditor(),
   198 	// because we need at least one canvas first
   199 	systemFlagsDefault=NULL;
   200 	standardFlagsDefault=NULL;
   201 
   202 	// Initialize window of TextEditor
   203 	textEditor = new TextEditor();
   204 	textEditor->setIcon (QPixmap (vym_editor_xpm));
   205 	if (textEditor->showWithMain()) textEditor->show();
   206 
   207 	// Initialize mainwindow 
   208     Main m;
   209 	//m.resize(m.sizeHint());
   210 	m.setIcon (QPixmap (vym_48x48_xpm));
   211 	m.show();
   212 	m.fileNew();
   213 	m.loadCmdLine();
   214 
   215 	// For benchmarking we may want to quit immediatly after drawing
   216 	if (options.isOn ("quit"))
   217 	{
   218 		return 0;
   219 	}	
   220 
   221     QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
   222 
   223     return app.exec();
   224 }
   225