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 *actionEditOpenURLTab;
49 QAction *actionEditURL;
50 QAction *actionEditHeading2URL;
51 QAction *actionEditBugzilla2URL;
52 QAction *actionEditFATE2URL;
53 QAction *actionEditOpenVymLink;
54 QAction *actionEditVymLink;
55 QAction *actionEditToggleHideExport;
56 QAction *actionEditDeleteVymLink;
57 QAction *actionEditMapInfo;
58 QAction *actionEditHeading;
59 QAction *actionEditDelete;
60 QAction *actionEditAddBranch;
61 QAction *actionEditAddBranchHere;
62 QAction *actionEditAddBranchAbove;
63 QAction *actionEditAddBranchBelow;
64 QAction *actionEditRemoveBranchHere;
65 QAction *actionEditRemoveChilds;
66 QAction *actionEditImportAdd;
67 QAction *actionEditImportReplace;
68 QAction *actionEditSaveBranch;
69 QAction *actionEditSelectFirst;
70 QAction *actionEditSelectLast;
71 QAction *actionEditLoadImage;
73 QAction *actionFormatColor;
74 QAction *actionFormatPickColor;
75 QAction *actionFormatColorBranch;
76 QAction *actionFormatColorSubtree;
77 QAction *actionFormatBackColor;
78 QAction *actionFormatLinkColorHint;
79 QAction *actionFormatLinkColor;
81 QActionGroup *actionGroupModModes;
82 QAction *actionModModeColor;
83 QAction *actionModModeLink;
84 QAction *actionModModeCopy;
86 QActionGroup *actionGroupFormatFrameTypes;
87 QAction *actionFormatFrameNone;
88 QAction *actionFormatFrameRectangle;
90 QActionGroup *actionGroupFormatLinkStyles;
91 QAction *actionFormatIncludeImagesVer;
92 QAction *actionFormatIncludeImagesHor;
93 QAction *actionFormatHideLinkUnselected;
94 QAction *actionFormatLinkStyleLine;
95 QAction *actionFormatLinkStyleParabel;
96 QAction *actionFormatLinkStylePolyLine;
97 QAction *actionFormatLinkStylePolyParabel;
99 QAction *actionViewToggleNoteEditor;
101 QAction *actionSettingsAutoselectHeading;
102 QAction *actionSettingsAutoselectText;
103 QAction *actionSettingsPasteNewHeading;
104 QAction *actionSettingsAutoedit;
105 QAction *actionSettingsUseDelKey;
106 QAction *actionSettingsUseFlagGroups;
107 QAction *actionSettingsUseHideExport;
109 QPopupMenu *branchContextMenu;
110 QPopupMenu *branchAddContextMenu;
111 QPopupMenu *branchRemoveContextMenu;
112 QPopupMenu *branchLinksContextMenu;
113 QPopupMenu *branchLinksContextMenuDup;
114 QPopupMenu *floatimageContextMenu;
115 QPopupMenu *saveImageFormatMenu;
116 QPopupMenu *canvasContextMenu;
117 QPopupMenu *lastMapsMenu;
118 QPopupMenu *importMenu;
119 QPopupMenu *exportMenu;
120 QPopupMenu *exportImageFormatMenu;
126 int statusbarTime=3500;
128 int main(int argc, char** argv)
130 QApplication app(argc,argv);
133 // Reading and initializing options commandline options
134 options.add ("version", SwitchOption, "v","version");
135 options.add ("local", SwitchOption, "l", "local");
136 options.add ("help", SwitchOption, "h", "help");
137 options.add ("quit", SwitchOption, "q", "quit");
138 options.add ("test", StringOption, "t", "test");
139 options.setHelpText (
140 "VYM - View Your Mind\n"
141 "--------------------\n\n"
142 "Information about vym can be found in vym.pdf,\n"
143 "which should be part of the vym package.\n"
144 "It is also available at the project homepage:\n\n"
145 "http://www.InSilmaril.de/vym\n");
148 cout << endl << options.getHelpText()<<endl;
152 if (options.isOn ("version"))
154 cout << "vym version "<<__VYM_VERSION
155 <<" (c) 2004 Uwe Drechsel - "
156 <<__BUILD_DATE<<endl;
161 // Use /usr/share/vym or /usr/local/share/vym or . ?
163 if (options.isOn ("local"))
165 vymBaseDir.setPath (vymBaseDir.currentDirPath());
168 vymBaseDir.setPath ("/usr/share/vym");
169 if (!vymBaseDir.exists())
170 vymBaseDir.setPath ("/usr/local/share/vym");
171 if (!vymBaseDir.exists())
172 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
175 if (options.isOn ("help"))
177 cout << options.getHelpText()<<endl;
181 if (options.isOn ("test"))
183 // FIXME testing string option only
184 cout << "Testing: "<<options.getArg("test")<< endl;
188 QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
189 factory->setPixmap("vym_128x128", QPixmap(vym_128x128_xpm));
190 qInitNetworkProtocols();
193 // Initialize translations
194 QTranslator translator (0);
195 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
196 app.installTranslator( &translator );
198 // Initializing the row of system flags
199 // is done in first call to MapEditor(),
200 // because we need at least one canvas first
201 systemFlagsDefault=NULL;
202 standardFlagsDefault=NULL;
204 // Initialize window of TextEditor
205 textEditor = new TextEditor();
206 textEditor->setIcon (QPixmap (vym_editor_xpm));
207 if (textEditor->showWithMain()) textEditor->show();
209 // Initialize mainwindow
211 //m.resize(m.sizeHint());
212 m.setIcon (QPixmap (vym_48x48_xpm));
217 // For benchmarking we may want to quit immediatly after drawing
218 if (options.isOn ("quit"))
223 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );