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-editor.xpm"
17 #include "flagrowobj.h"
20 TextEditor *textEditor; // used in Constr. of LinkableMapObj
21 // initialized in mainwindow
23 Main *mainWindow; // used in BranchObj::select()
24 MapEditor *clipboardME;
25 FlagRowObj *systemFlagsDefault; // used to copy from in LinkableMapObj
26 FlagRowObj *standardFlagsDefault;
29 // (QActionGroup could not be "enabled")
30 QPtrList <QAction> actionListBranches;
32 // Actions which change sometimes
33 QAction *actionFileSave;
34 QAction *actionFilePrint;
35 QAction *actionEditUndo;
36 QAction *actionEditCopy;
37 QAction *actionEditCut;
38 QAction *actionEditPaste;
39 QAction *actionEditMoveUp;
40 QAction *actionEditMoveDown;
41 QAction *actionEditToggleScroll;
42 QAction *actionEditOpenURL;
43 QAction *actionEditURL;
44 QAction *actionEditHeading2URL;
45 QAction *actionEditBugzilla2URL;
46 QAction *actionEditOpenVymLink;
47 QAction *actionEditVymLink;
48 QAction *actionEditDeleteVymLink;
49 QAction *actionEditMapInfo;
50 QAction *actionEditHeading;
51 QAction *actionEditDelete;
52 QAction *actionEditAddBranch;
53 QAction *actionEditAddBranchHere;
54 QAction *actionEditAddBranchAbove;
55 QAction *actionEditAddBranchBelow;
56 QAction *actionEditRemoveBranchHere;
57 QAction *actionEditRemoveChilds;
58 QAction *actionEditImportAdd;
59 QAction *actionEditImportReplace;
60 QAction *actionEditSaveBranch;
61 QAction *actionEditSelectFirst;
62 QAction *actionEditSelectLast;
63 QAction *actionEditLoadImage;
64 QAction *actionEditToggleFloatExport;
66 QAction *actionFormatColor;
67 QAction *actionFormatPickColor;
68 QAction *actionFormatColorBranch;
69 QAction *actionFormatColorSubtree;
70 QAction *actionFormatBackColor;
71 QAction *actionFormatLinkColorHint;
72 QAction *actionFormatLinkColor;
74 QActionGroup *actionGroupModModes;
75 QAction *actionModModeColor;
76 QAction *actionModModeLink;
77 QAction *actionModModeCopy;
79 QActionGroup *actionGroupFormatFrameTypes;
80 QAction *actionFormatFrameNone;
81 QAction *actionFormatFrameRectangle;
83 QActionGroup *actionGroupFormatLinkStyles;
84 QAction *actionFormatHideLinkUnselected;
85 QAction *actionFormatLinkStyleLine;
86 QAction *actionFormatLinkStyleParabel;
87 QAction *actionFormatLinkStylePolyLine;
88 QAction *actionFormatLinkStylePolyParabel;
90 QAction *actionViewToggleNoteEditor;
92 QAction *actionSettingsAutoselectHeading;
93 QAction *actionSettingsAutoselectText;
94 QAction *actionSettingsPasteNewHeading;
95 QAction *actionSettingsAutoedit;
96 QAction *actionSettingsUseDelKey;
97 QAction *actionSettingsUseFlagGroups;
99 QPopupMenu *branchContextMenu;
100 QPopupMenu *branchAddContextMenu;
101 QPopupMenu *branchRemoveContextMenu;
102 QPopupMenu *branchLinksContextMenu;
103 QPopupMenu *branchLinksContextMenuDup;
104 QPopupMenu *floatimageContextMenu;
105 QPopupMenu *saveImageFormatMenu;
106 QPopupMenu *canvasContextMenu;
107 QPopupMenu *lastMapsMenu;
108 QPopupMenu *exportMenu;
109 QPopupMenu *exportImageFormatMenu;
115 int statusbarTime=3500;
117 int main(int argc, char** argv)
119 QApplication app(argc,argv);
121 QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
122 factory->setPixmap("vym_logo", QPixmap(vym_logo_xpm));
123 qInitNetworkProtocols();
125 // Use /usr/share/vym or /usr/local/share/vym or .
127 shareDir.setPath ("/usr/share/vym");
128 if (!shareDir.exists())
129 shareDir.setPath ("/usr/local/share/vym");
130 if (!shareDir.exists())
131 shareDir.setPath(".");
133 // Initialize translations
134 QTranslator translator (0);
135 translator.load( QString("vym_")+QTextCodec::locale(), shareDir.path() + "/lang");
136 app.installTranslator( &translator );
138 // Initializing the row of system flags
139 // is done in first call to MapEditor(),
140 // because we need at least one canvas first
141 systemFlagsDefault=NULL;
142 standardFlagsDefault=NULL;
144 // Reading and initializing options commandline options
145 options.add ("version", SwitchOption, "v","version");
146 options.add ("help", SwitchOption, "h", "help");
147 options.add ("quit", SwitchOption, "q", "quit");
148 options.add ("test", StringOption, "t", "test");
149 options.setHelpText (
150 "VYM - View Your Mind\n"
151 "--------------------\n\n"
152 "Information about vym can be found in vym.pdf,\n"
153 "which should be part of the vym package.\n"
154 "It is also available at the project homepage:\n\n"
155 "http://www.InSilmaril.de/vym\n");
158 cout << endl << options.getHelpText()<<endl;
162 if (options.isOn ("version"))
164 cout << "vym version "<<__VYM_VERSION__
165 <<" (c) 2004 Uwe Drechsel - "
166 <<__BUILD_DATE__<<endl;
171 if (options.isOn ("help"))
173 cout << options.getHelpText()<<endl;
177 if (options.isOn ("test"))
179 // FIXME testing string option only
180 cout << "Testing: "<<options.getArg("test")<< endl;
183 // Initialize window of TextEditor
184 textEditor = new TextEditor();
185 textEditor->setIcon (QPixmap (vym_editor_xpm));
186 if (textEditor->showWithMain()) textEditor->show();
188 clipboardME = new MapEditor();
189 clipboardME->resize (800,600);
190 clipboardME->setCaption("VYM - clipboard");
193 // Initialize mainwindow after Mapeditors (because of Flags)
195 //m.resize(m.sizeHint());
196 m.setIcon (QPixmap (vym_logo_xpm));
201 // For benchmarking we may want to quit immediatly after drawing
202 if (options.isOn ("quit"))
207 QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );