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