More documentation, fixed small bug where links of unselected objects where visible again
1 #include <qapplication.h>
3 #include <qtranslator.h>
6 #include <qtextcodec.h>
12 #include "mainwindow.h"
14 #include "icons/vym-48x48.xpm"
15 #include "icons/vym-128x128.xpm"
16 #include "icons/vym-editor.xpm"
18 #include "flagrowobj.h"
21 TextEditor *textEditor; // used in Constr. of LinkableMapObj
22 // initialized in mainwindow
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, ...
29 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
30 FlagRowObj *standardFlagsDefault;
33 // (QActionGroup could not be "enabled")
34 QPtrList <QAction> actionListBranches;
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;
72 QAction *actionFormatColor;
73 QAction *actionFormatPickColor;
74 QAction *actionFormatColorBranch;
75 QAction *actionFormatColorSubtree;
76 QAction *actionFormatBackColor;
77 QAction *actionFormatLinkColorHint;
78 QAction *actionFormatLinkColor;
80 QActionGroup *actionGroupModModes;
81 QAction *actionModModeColor;
82 QAction *actionModModeLink;
83 QAction *actionModModeCopy;
85 QActionGroup *actionGroupFormatFrameTypes;
86 QAction *actionFormatFrameNone;
87 QAction *actionFormatFrameRectangle;
89 QActionGroup *actionGroupFormatLinkStyles;
90 QAction *actionFormatIncludeImagesVer;
91 QAction *actionFormatIncludeImagesHor;
92 QAction *actionFormatHideLinkUnselected;
93 QAction *actionFormatLinkStyleLine;
94 QAction *actionFormatLinkStyleParabel;
95 QAction *actionFormatLinkStylePolyLine;
96 QAction *actionFormatLinkStylePolyParabel;
98 QAction *actionViewToggleNoteEditor;
100 QAction *actionSettingsAutoselectHeading;
101 QAction *actionSettingsAutoselectText;
102 QAction *actionSettingsPasteNewHeading;
103 QAction *actionSettingsAutoedit;
104 QAction *actionSettingsUseDelKey;
105 QAction *actionSettingsUseFlagGroups;
106 QAction *actionSettingsUseHideExport;
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;
125 int statusbarTime=3500;
127 int main(int argc, char** argv)
129 QApplication app(argc,argv);
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");
147 cout << endl << options.getHelpText()<<endl;
151 if (options.isOn ("version"))
153 cout << "vym version "<<__VYM_VERSION
154 <<" (c) 2004 Uwe Drechsel - "
155 <<__BUILD_DATE<<endl;
160 // Use /usr/share/vym or /usr/local/share/vym or . ?
162 if (options.isOn ("local"))
164 vymBaseDir.setPath (vymBaseDir.currentDirPath());
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() );
174 if (options.isOn ("help"))
176 cout << options.getHelpText()<<endl;
180 if (options.isOn ("test"))
182 // FIXME testing string option only
183 cout << "Testing: "<<options.getArg("test")<< endl;
187 QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
188 factory->setPixmap("vym_128x128", QPixmap(vym_128x128_xpm));
189 qInitNetworkProtocols();
192 // Initialize translations
193 QTranslator translator (0);
194 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
195 app.installTranslator( &translator );
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;
203 // Initialize window of TextEditor
204 textEditor = new TextEditor();
205 textEditor->setIcon (QPixmap (vym_editor_xpm));
206 if (textEditor->showWithMain()) textEditor->show();
208 // Initialize mainwindow
210 //m.resize(m.sizeHint());
211 m.setIcon (QPixmap (vym_48x48_xpm));
216 // For benchmarking we may want to quit immediatly after drawing
217 if (options.isOn ("quit"))
222 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );