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