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 *actionEditRemoveBranchKeepChilds;
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;
98 QAction *actionViewToggleHistoryWindow;
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 . ?
164 if (options.isOn ("local"))
166 vymBaseDir.setPath (vymBaseDir.currentDirPath());
168 // then look for environment variable
169 if (getenv("VYMHOME")!=0)
171 vymBaseDir.setPath (getenv("VYMHOME"));
173 // ok, let's find my way on my own
175 vymBaseDir.setPath ("/usr/share/vym");
176 if (!vymBaseDir.exists())
177 vymBaseDir.setPath ("/usr/local/share/vym");
178 if (!vymBaseDir.exists())
179 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
182 iconPath=vymBaseDir.path()+"/icons/";
183 flagsPath=vymBaseDir.path()+"/flags/";
185 if (options.isOn ("help"))
187 cout << options.getHelpText()<<endl;
191 if (options.isOn ("test"))
193 // FIXME testing string option only
194 cout << "Testing: "<<options.getArg("test")<< endl;
198 QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
199 factory->setPixmap("vym-128x128", QPixmap(iconPath+"vym-128x128.png"));
200 qInitNetworkProtocols();
203 // Initialize translations
204 QTranslator translator (0);
205 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
206 app.installTranslator( &translator );
208 // Initializing the row of system flags
209 // is done in first call to MapEditor(),
210 // because we need at least one canvas first
211 systemFlagsDefault=NULL;
212 standardFlagsDefault=NULL;
214 // Initialize window of TextEditor
215 textEditor = new TextEditor();
216 textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
217 if (textEditor->showWithMain()) textEditor->show();
219 // Initialize mainwindow
221 //m.resize(m.sizeHint());
222 m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
227 // For benchmarking we may want to quit immediatly after drawing
228 if (options.isOn ("quit"))
233 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );