1 #include <QApplication>
3 #include <qtranslator.h>
6 #include <qtextcodec.h>
10 #include <Q3PopupMenu>
11 #include <QActionGroup>
15 #include "mainwindow.h"
17 #include "flagrowobj.h"
20 TextEditor *textEditor; // used in Constr. of LinkableMapObj
21 // initialized in mainwindow
23 Main *mainWindow; // used in BranchObj::select()
24 QString tmpVymDir; // All temp files go there, created in mainwindow
25 QString clipboardDir; // Clipboard used in all mapEditors
26 QDir vymBaseDir; // Containing all styles, scripts, images, ...
28 QString iconPath; // Pointing to icons used for toolbars
29 QString flagsPath; // Pointing to flags
31 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
32 FlagRowObj *standardFlagsDefault;
35 // (QActionGroup could not be "enabled")
36 Q3PtrList <QAction> actionListBranches;
38 // Actions which change sometimes
39 QAction *actionFileSave;
40 QAction *actionFilePrint;
41 QAction *actionEditUndo;
42 QAction *actionEditRedo;
43 QAction *actionEditCopy;
44 QAction *actionEditCut;
45 QAction *actionEditPaste;
46 QAction *actionEditMoveUp;
47 QAction *actionEditMoveDown;
48 QAction *actionEditToggleScroll;
49 QAction *actionEditOpenURL;
50 QAction *actionEditOpenURLTab;
51 QAction *actionEditURL;
52 QAction *actionEditHeading2URL;
53 QAction *actionEditBugzilla2URL;
54 QAction *actionEditFATE2URL;
55 QAction *actionEditOpenVymLink;
56 QAction *actionEditVymLink;
57 QAction *actionEditToggleHideExport;
58 QAction *actionEditDeleteVymLink;
59 QAction *actionEditMapInfo;
60 QAction *actionEditHeading;
61 QAction *actionEditDelete;
62 QAction *actionEditAddBranch;
63 QAction *actionEditAddBranchHere;
64 QAction *actionEditAddBranchAbove;
65 QAction *actionEditAddBranchBelow;
66 QAction *actionEditRemoveBranchKeepChilds;
67 QAction *actionEditRemoveChilds;
68 QAction *actionEditImportAdd;
69 QAction *actionEditImportReplace;
70 QAction *actionEditSaveBranch;
71 QAction *actionEditSelectFirst;
72 QAction *actionEditSelectLast;
73 QAction *actionEditLoadImage;
75 QAction *actionFormatColor;
76 QAction *actionFormatPickColor;
77 QAction *actionFormatColorBranch;
78 QAction *actionFormatColorSubtree;
79 QAction *actionFormatBackColor;
80 QAction *actionFormatLinkColorHint;
81 QAction *actionFormatLinkColor;
83 QActionGroup *actionGroupModModes;
84 QAction *actionModModeColor;
85 QAction *actionModModeLink;
86 QAction *actionModModeCopy;
88 QActionGroup *actionGroupFormatFrameTypes;
89 QAction *actionFormatFrameNone;
90 QAction *actionFormatFrameRectangle;
92 QActionGroup *actionGroupFormatLinkStyles;
93 QAction *actionFormatIncludeImagesVer;
94 QAction *actionFormatIncludeImagesHor;
95 QAction *actionFormatHideLinkUnselected;
96 QAction *actionFormatLinkStyleLine;
97 QAction *actionFormatLinkStyleParabel;
98 QAction *actionFormatLinkStylePolyLine;
99 QAction *actionFormatLinkStylePolyParabel;
101 QAction *actionViewToggleNoteEditor;
102 QAction *actionViewToggleHistoryWindow;
104 QAction *actionSettingsAutoselectHeading;
105 QAction *actionSettingsAutoselectText;
106 QAction *actionSettingsPasteNewHeading;
107 QAction *actionSettingsAutoedit;
108 QAction *actionSettingsUseDelKey;
109 QAction *actionSettingsUseFlagGroups;
110 QAction *actionSettingsUseHideExport;
113 QMenu* branchContextMenu;
114 QMenu* branchAddContextMenu;
115 QMenu* branchRemoveContextMenu;
116 QMenu* branchLinksContextMenu;
117 QMenu* branchLinksContextMenuDup;
118 QMenu* floatimageContextMenu;
119 QMenu* saveImageFormatMenu;
120 QMenu* canvasContextMenu;
121 QMenu* fileLastMapsMenu;
122 QMenu* fileImportMenu;
123 QMenu* fileExportMenu;
126 Settings settings ("vym","vym"); // Organization, Application name
130 int statusbarTime=3500;
132 int main(int argc, char** argv)
134 QApplication app(argc,argv);
137 // Reading and initializing options commandline options
138 options.add ("version", SwitchOption, "v","version");
139 options.add ("local", SwitchOption, "l", "local");
140 options.add ("help", SwitchOption, "h", "help");
141 options.add ("quit", SwitchOption, "q", "quit");
142 options.add ("test", StringOption, "t", "test");
143 options.setHelpText (
144 "VYM - View Your Mind\n"
145 "--------------------\n\n"
146 "Information about vym can be found in vym.pdf,\n"
147 "which should be part of the vym package.\n"
148 "It is also available at the project homepage:\n\n"
149 "http://www.InSilmaril.de/vym\n");
152 //FIXME QT3 cout << endl << options.getHelpText()<<endl;
156 if (options.isOn ("version"))
158 cout << "vym version "<<__VYM_VERSION
159 <<" (c) 2004 Uwe Drechsel - "
160 <<__BUILD_DATE<<endl;
165 // Use /usr/share/vym or /usr/local/share/vym or . ?
167 if (options.isOn ("local"))
169 vymBaseDir.setPath (vymBaseDir.currentDirPath());
171 // then look for environment variable
172 if (getenv("VYMHOME")!=0)
174 vymBaseDir.setPath (getenv("VYMHOME"));
176 // ok, let's find my way on my own
178 vymBaseDir.setPath ("/usr/share/vym");
179 if (!vymBaseDir.exists())
181 vymBaseDir.setPath ("/usr/local/share/vym");
182 if (!vymBaseDir.exists())
183 vymBaseDir.setPath(vymBaseDir.currentDirPath() );
187 iconPath=vymBaseDir.path()+"/icons/";
188 flagsPath=vymBaseDir.path()+"/flags/";
191 lastImageDir=QDir().home();
193 if (options.isOn ("help"))
195 cout << options.getHelpText().ascii()<<endl;
199 if (options.isOn ("test"))
201 // FIXME testing string option only
202 cout << "Testing: "<<options.getArg("test").ascii()<< endl;
206 Q3MimeSourceFactory *factory = Q3MimeSourceFactory::defaultFactory();
207 factory->setPixmap("vym-128x128", QPixmap(iconPath+"vym-128x128.png"));
208 q3InitNetworkProtocols();
211 // Initialize translations
212 QTranslator translator (0);
213 translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
214 app.installTranslator( &translator );
216 // Initializing the row of system flags
217 // is done in first call to MapEditor(),
218 // because we need at least one canvas first
219 systemFlagsDefault=NULL;
220 standardFlagsDefault=NULL;
222 // Initialize window of TextEditor
223 textEditor = new TextEditor();
224 textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
225 if (textEditor->showWithMain()) textEditor->show();
227 // Initialize mainwindow
229 //m.resize(m.sizeHint());
230 m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
235 // For benchmarking we may want to quit immediatly after drawing
236 if (options.isOn ("quit"))
241 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );