1 #include <qapplication.h>
3 #include <qtranslator.h>
6 #include <qtextcodec.h>
12 #include "mainwindow.h"
14 #include "flagrowobj.h"
17 TextEditor *textEditor; // used in Constr. of LinkableMapObj
18 // initialized in mainwindow
20 Main *mainWindow; // used in BranchObj::select()
21 QString tmpVymDir; // All temp files go there, created in mainwindow
22 QString clipboardDir; // Clipboard used in all mapEditors
23 QDir vymBaseDir; // Containing all styles, scripts, images, ...
24 QString iconPath; // Pointing to icons used for toolbars
25 QString flagsPath; // Pointing to flags
27 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
28 FlagRowObj *standardFlagsDefault;
31 // (QActionGroup could not be "enabled")
32 QPtrList <QAction> actionListBranches;
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 *actionEditOpenURLTab;
47 QAction *actionEditURL;
48 QAction *actionEditHeading2URL;
49 QAction *actionEditBugzilla2URL;
50 QAction *actionEditFATE2URL;
51 QAction *actionEditOpenVymLink;
52 QAction *actionEditVymLink;
53 QAction *actionEditToggleHideExport;
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;
71 QAction *actionFormatColor;
72 QAction *actionFormatPickColor;
73 QAction *actionFormatColorBranch;
74 QAction *actionFormatColorSubtree;
75 QAction *actionFormatBackColor;
76 QAction *actionFormatLinkColorHint;
77 QAction *actionFormatLinkColor;
79 QActionGroup *actionGroupModModes;
80 QAction *actionModModeColor;
81 QAction *actionModModeLink;
82 QAction *actionModModeCopy;
84 QActionGroup *actionGroupFormatFrameTypes;
85 QAction *actionFormatFrameNone;
86 QAction *actionFormatFrameRectangle;
88 QActionGroup *actionGroupFormatLinkStyles;
89 QAction *actionFormatIncludeImagesVer;
90 QAction *actionFormatIncludeImagesHor;
91 QAction *actionFormatHideLinkUnselected;
92 QAction *actionFormatLinkStyleLine;
93 QAction *actionFormatLinkStyleParabel;
94 QAction *actionFormatLinkStylePolyLine;
95 QAction *actionFormatLinkStylePolyParabel;
97 QAction *actionViewToggleNoteEditor;
99 QAction *actionSettingsAutoselectHeading;
100 QAction *actionSettingsAutoselectText;
101 QAction *actionSettingsPasteNewHeading;
102 QAction *actionSettingsAutoedit;
103 QAction *actionSettingsUseDelKey;
104 QAction *actionSettingsUseFlagGroups;
105 QAction *actionSettingsUseHideExport;
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;
124 int statusbarTime=3500;
126 int main(int argc, char** argv)
128 QApplication app(argc,argv);
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");
146 cout << endl << options.getHelpText()<<endl;
150 if (options.isOn ("version"))
152 cout << "vym version "<<__VYM_VERSION
153 <<" (c) 2004 Uwe Drechsel - "
154 <<__BUILD_DATE<<endl;
159 // Use /usr/share/vym or /usr/local/share/vym or . ?
163 if (options.isOn ("local"))
165 vymBaseDir.setPath (vymBaseDir.currentDirPath());
167 // then look for environment variable
168 if (getenv("VYMHOME")!=0)
170 vymBaseDir.setPath (getenv("VYMHOME"));
172 // ok, let's find my way on my own
174 vymBaseDir.setPath ("/usr/share/vym");
175 if (!vymBaseDir.exists())
176 vymBaseDir.setPath ("/usr/local/share/vym");
177 if (!vymBaseDir.exists())
178 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
181 iconPath=vymBaseDir.path()+"/icons/";
182 flagsPath=vymBaseDir.path()+"/flags/";
184 if (options.isOn ("help"))
186 cout << options.getHelpText()<<endl;
190 if (options.isOn ("test"))
192 // FIXME testing string option only
193 cout << "Testing: "<<options.getArg("test")<< endl;
197 QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
198 factory->setPixmap("vym-128x128", QPixmap(iconPath+"vym-128x128.png"));
199 qInitNetworkProtocols();
202 // Initialize translations
203 QTranslator translator (0);
204 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
205 app.installTranslator( &translator );
207 // Initializing the row of system flags
208 // is done in first call to MapEditor(),
209 // because we need at least one canvas first
210 systemFlagsDefault=NULL;
211 standardFlagsDefault=NULL;
213 // Initialize window of TextEditor
214 textEditor = new TextEditor();
215 textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
216 if (textEditor->showWithMain()) textEditor->show();
218 // Initialize mainwindow
220 //m.resize(m.sizeHint());
221 m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
226 // For benchmarking we may want to quit immediatly after drawing
227 if (options.isOn ("quit"))
232 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );