main.cpp
author insilmaril
Wed Mar 15 13:53:53 2006 +0000 (2006-03-15)
changeset 249 e7acede0377c
parent 215 e211e2fc9d54
child 250 0e994bf2346b
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 QAction *actionEditToggleFloatExport;
    72 
    73 QAction *actionFormatColor;		
    74 QAction *actionFormatPickColor;		
    75 QAction *actionFormatColorBranch;
    76 QAction *actionFormatColorSubtree;
    77 QAction *actionFormatBackColor;
    78 QAction *actionFormatLinkColorHint;
    79 QAction *actionFormatLinkColor;		
    80 
    81 QActionGroup *actionGroupModModes;
    82 QAction *actionModModeColor;
    83 QAction *actionModModeLink;
    84 QAction *actionModModeCopy;
    85 
    86 QActionGroup *actionGroupFormatFrameTypes;
    87 QAction *actionFormatFrameNone;
    88 QAction *actionFormatFrameRectangle;
    89 
    90 QActionGroup *actionGroupFormatLinkStyles;
    91 QAction *actionFormatIncludeImagesVer;
    92 QAction *actionFormatIncludeImagesHor;
    93 QAction *actionFormatHideLinkUnselected;
    94 QAction *actionFormatLinkStyleLine;
    95 QAction *actionFormatLinkStyleParabel;
    96 QAction *actionFormatLinkStylePolyLine;
    97 QAction *actionFormatLinkStylePolyParabel;
    98 
    99 QAction *actionViewToggleNoteEditor;
   100 
   101 QAction *actionSettingsAutoselectHeading;
   102 QAction *actionSettingsAutoselectText;
   103 QAction *actionSettingsPasteNewHeading;
   104 QAction *actionSettingsAutoedit;
   105 QAction *actionSettingsUseDelKey;
   106 QAction *actionSettingsUseFlagGroups;
   107 
   108 QPopupMenu *branchContextMenu;
   109 QPopupMenu *branchAddContextMenu;
   110 QPopupMenu *branchRemoveContextMenu;
   111 QPopupMenu *branchLinksContextMenu;
   112 QPopupMenu *branchLinksContextMenuDup;
   113 QPopupMenu *floatimageContextMenu;
   114 QPopupMenu *saveImageFormatMenu;
   115 QPopupMenu *canvasContextMenu;
   116 QPopupMenu *lastMapsMenu;
   117 QPopupMenu *importMenu;
   118 QPopupMenu *exportMenu;
   119 QPopupMenu *exportImageFormatMenu;
   120 
   121 
   122 Settings settings;
   123 Options options;
   124 
   125 int statusbarTime=3500;
   126 
   127 int main(int argc, char** argv)
   128 {
   129     QApplication app(argc,argv);
   130 
   131 
   132 	// Reading and initializing options commandline options
   133 	options.add ("version", SwitchOption, "v","version");
   134 	options.add ("local", SwitchOption, "l", "local");
   135 	options.add ("help", SwitchOption, "h", "help");
   136 	options.add ("quit", SwitchOption, "q", "quit");
   137 	options.add ("test", StringOption, "t", "test");
   138 	options.setHelpText (
   139 		"VYM - View Your Mind\n"
   140 		"--------------------\n\n"
   141 		"Information about vym can be found in vym.pdf,\n"
   142 		"which should be part of the vym package.\n"
   143 		"It is also available at the project homepage:\n\n"
   144 		"http://www.InSilmaril.de/vym\n");
   145 	if (options.parse())
   146 	{
   147 		cout << endl << options.getHelpText()<<endl;
   148 		return 1;
   149 	}
   150 
   151 	if (options.isOn ("version"))
   152 	{
   153 		cout << "vym version "<<__VYM_VERSION
   154 			<<"  (c) 2004 Uwe Drechsel - "
   155 			<<__BUILD_DATE<<endl;
   156 			
   157 		return 0;	
   158 	}		
   159 	
   160 	// Use /usr/share/vym or /usr/local/share/vym or . ?
   161 	QDir vymBaseDir;
   162 	if (options.isOn ("local"))
   163 	{
   164 		vymBaseDir.setPath (vymBaseDir.currentDirPath());
   165 	}else
   166 	{
   167 		vymBaseDir.setPath ("/usr/share/vym");
   168 		if (!vymBaseDir.exists())
   169 			vymBaseDir.setPath ("/usr/local/share/vym");
   170 		if (!vymBaseDir.exists())
   171 			vymBaseDir.setPath(vymBaseDir.currentDirPath() );
   172 	}
   173 
   174 	if (options.isOn ("help"))
   175 	{
   176 		cout << options.getHelpText()<<endl;
   177 		return 0;	
   178 	}	
   179 
   180 	if (options.isOn ("test"))
   181 	{
   182 		// FIXME testing string option only
   183 		cout << "Testing: "<<options.getArg("test")<< endl;
   184 	}	
   185 
   186 
   187     QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
   188     factory->setPixmap("vym_128x128", QPixmap(vym_128x128_xpm));
   189     qInitNetworkProtocols();
   190 
   191 
   192 	// Initialize translations
   193 	QTranslator translator (0);
   194 	translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
   195     app.installTranslator( &translator );
   196 
   197 	// Initializing the row of system flags
   198 	// is done in first call to MapEditor(),
   199 	// because we need at least one canvas first
   200 	systemFlagsDefault=NULL;
   201 	standardFlagsDefault=NULL;
   202 
   203 	// Initialize window of TextEditor
   204 	textEditor = new TextEditor();
   205 	textEditor->setIcon (QPixmap (vym_editor_xpm));
   206 	if (textEditor->showWithMain()) textEditor->show();
   207 
   208 	// Initialize mainwindow 
   209     Main m;
   210 	//m.resize(m.sizeHint());
   211 	m.setIcon (QPixmap (vym_48x48_xpm));
   212 	m.show();
   213 	m.fileNew();
   214 	m.loadCmdLine();
   215 
   216 	// For benchmarking we may want to quit immediatly after drawing
   217 	if (options.isOn ("quit"))
   218 	{
   219 		return 0;
   220 	}	
   221 
   222     QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
   223 
   224     return app.exec();
   225 }
   226