main.cpp
author insilmaril
Tue, 03 Jan 2006 09:44:41 +0000
changeset 170 e696dd4a100f
parent 166 325958acb69b
child 175 728f51b71e71
permissions -rw-r--r--
1.7.6 New features for floatimages and fixes
insilmaril@0
     1
#include <qapplication.h>
insilmaril@0
     2
#include <qpixmap.h>
insilmaril@0
     3
#include <qtranslator.h>
insilmaril@90
     4
#include <qdir.h>
insilmaril@98
     5
#include <qptrlist.h>
insilmaril@90
     6
#include <qtextcodec.h>
insilmaril@117
     7
#include <qnetwork.h>
jhilmer@152
     8
#include <qmime.h>
insilmaril@0
     9
insilmaril@0
    10
#include "settings.h"
insilmaril@0
    11
#include "options.h"
insilmaril@0
    12
#include "mainwindow.h"
insilmaril@0
    13
insilmaril@0
    14
#include "icons/vym-48x48.xpm"
insilmaril@0
    15
#include "icons/vym-editor.xpm"
insilmaril@0
    16
insilmaril@0
    17
#include "flagrowobj.h"
insilmaril@0
    18
insilmaril@0
    19
// Global variables
insilmaril@0
    20
TextEditor *textEditor;			// used in Constr. of LinkableMapObj
insilmaril@0
    21
								// initialized in mainwindow
insilmaril@0
    22
insilmaril@0
    23
Main *mainWindow;				// used in BranchObj::select()								
insilmaril@164
    24
QString tmpVymDir;				// All temp files go there, created in mainwindow
insilmaril@166
    25
QString clipboardDir;			// Clipboard used in all mapEditors
insilmaril@166
    26
bool clipboardEmpty;			
insilmaril@0
    27
FlagRowObj *systemFlagsDefault;	// used to copy from in LinkableMapObj
insilmaril@0
    28
FlagRowObj *standardFlagsDefault;
insilmaril@0
    29
insilmaril@98
    30
// Lists of actions
insilmaril@98
    31
// (QActionGroup could not be "enabled")
insilmaril@98
    32
QPtrList <QAction> actionListBranches;
insilmaril@98
    33
insilmaril@0
    34
// Actions which change sometimes
insilmaril@0
    35
QAction *actionFileSave;
insilmaril@0
    36
QAction *actionFilePrint;
insilmaril@0
    37
QAction *actionEditUndo;
insilmaril@163
    38
QAction *actionEditRedo;
insilmaril@0
    39
QAction *actionEditCopy;
insilmaril@0
    40
QAction *actionEditCut;
insilmaril@0
    41
QAction *actionEditPaste;
insilmaril@0
    42
QAction *actionEditMoveUp;
insilmaril@0
    43
QAction *actionEditMoveDown;
insilmaril@0
    44
QAction *actionEditToggleScroll;
insilmaril@0
    45
QAction *actionEditOpenURL;
insilmaril@0
    46
QAction *actionEditURL;
insilmaril@0
    47
QAction *actionEditHeading2URL;
insilmaril@0
    48
QAction *actionEditBugzilla2URL;
insilmaril@0
    49
QAction *actionEditOpenVymLink;
insilmaril@0
    50
QAction *actionEditVymLink;
insilmaril@0
    51
QAction *actionEditDeleteVymLink;
insilmaril@0
    52
QAction *actionEditMapInfo;
insilmaril@0
    53
QAction *actionEditHeading;
insilmaril@0
    54
QAction *actionEditDelete;
insilmaril@0
    55
QAction *actionEditAddBranch;
insilmaril@98
    56
QAction *actionEditAddBranchHere;
insilmaril@0
    57
QAction *actionEditAddBranchAbove;
insilmaril@0
    58
QAction *actionEditAddBranchBelow;
insilmaril@98
    59
QAction *actionEditRemoveBranchHere;
insilmaril@98
    60
QAction *actionEditRemoveChilds;
insilmaril@0
    61
QAction *actionEditImportAdd;
insilmaril@0
    62
QAction *actionEditImportReplace;
insilmaril@0
    63
QAction *actionEditSaveBranch;
insilmaril@0
    64
QAction *actionEditSelectFirst;
insilmaril@0
    65
QAction *actionEditSelectLast;
insilmaril@0
    66
QAction *actionEditLoadImage;
insilmaril@0
    67
QAction *actionEditToggleFloatExport;
insilmaril@0
    68
insilmaril@0
    69
QAction *actionFormatColor;		
insilmaril@0
    70
QAction *actionFormatPickColor;		
insilmaril@0
    71
QAction *actionFormatColorBranch;
insilmaril@0
    72
QAction *actionFormatColorSubtree;
insilmaril@0
    73
QAction *actionFormatBackColor;
insilmaril@0
    74
QAction *actionFormatLinkColorHint;
insilmaril@0
    75
QAction *actionFormatLinkColor;		
insilmaril@0
    76
insilmaril@89
    77
QActionGroup *actionGroupModModes;
insilmaril@89
    78
QAction *actionModModeColor;
insilmaril@89
    79
QAction *actionModModeLink;
insilmaril@93
    80
QAction *actionModModeCopy;
insilmaril@89
    81
insilmaril@0
    82
QActionGroup *actionGroupFormatFrameTypes;
insilmaril@0
    83
QAction *actionFormatFrameNone;
insilmaril@0
    84
QAction *actionFormatFrameRectangle;
insilmaril@0
    85
insilmaril@0
    86
QActionGroup *actionGroupFormatLinkStyles;
insilmaril@160
    87
QAction *actionFormatHideLinkUnselected;
insilmaril@0
    88
QAction *actionFormatLinkStyleLine;
insilmaril@0
    89
QAction *actionFormatLinkStyleParabel;
insilmaril@0
    90
QAction *actionFormatLinkStylePolyLine;
insilmaril@0
    91
QAction *actionFormatLinkStylePolyParabel;
insilmaril@0
    92
insilmaril@0
    93
QAction *actionViewToggleNoteEditor;
insilmaril@0
    94
insilmaril@0
    95
QAction *actionSettingsAutoselectHeading;
insilmaril@0
    96
QAction *actionSettingsAutoselectText;
insilmaril@0
    97
QAction *actionSettingsPasteNewHeading;
insilmaril@0
    98
QAction *actionSettingsAutoedit;
insilmaril@0
    99
QAction *actionSettingsUseDelKey;
insilmaril@103
   100
QAction *actionSettingsUseFlagGroups;
insilmaril@0
   101
insilmaril@0
   102
QPopupMenu *branchContextMenu;
insilmaril@98
   103
QPopupMenu *branchAddContextMenu;
insilmaril@98
   104
QPopupMenu *branchRemoveContextMenu;
insilmaril@89
   105
QPopupMenu *branchLinksContextMenu;
insilmaril@94
   106
QPopupMenu *branchLinksContextMenuDup;
insilmaril@0
   107
QPopupMenu *floatimageContextMenu;
insilmaril@0
   108
QPopupMenu *saveImageFormatMenu;
insilmaril@0
   109
QPopupMenu *canvasContextMenu;
insilmaril@0
   110
QPopupMenu *lastMapsMenu;
insilmaril@0
   111
QPopupMenu *exportMenu;
insilmaril@0
   112
QPopupMenu *exportImageFormatMenu;
insilmaril@0
   113
insilmaril@0
   114
insilmaril@0
   115
Settings settings;
insilmaril@0
   116
Options options;
insilmaril@0
   117
insilmaril@0
   118
int statusbarTime=3500;
insilmaril@0
   119
insilmaril@0
   120
int main(int argc, char** argv)
insilmaril@0
   121
{
insilmaril@0
   122
    QApplication app(argc,argv);
insilmaril@0
   123
jhilmer@152
   124
    QMimeSourceFactory *factory = QMimeSourceFactory::defaultFactory();
jhilmer@152
   125
    factory->setPixmap("vym_logo", QPixmap(vym_logo_xpm));
insilmaril@117
   126
    qInitNetworkProtocols();
insilmaril@0
   127
insilmaril@90
   128
	// Use /usr/share/vym or /usr/local/share/vym or .
insilmaril@90
   129
	QDir shareDir;
insilmaril@90
   130
	shareDir.setPath ("/usr/share/vym");
insilmaril@90
   131
	if (!shareDir.exists())
insilmaril@90
   132
        shareDir.setPath ("/usr/local/share/vym");
insilmaril@90
   133
	if (!shareDir.exists())
insilmaril@90
   134
        shareDir.setPath(".");
insilmaril@90
   135
insilmaril@0
   136
	// Initialize translations
insilmaril@0
   137
	QTranslator translator (0);
insilmaril@91
   138
	translator.load( QString("vym_")+QTextCodec::locale(), shareDir.path() + "/lang");
insilmaril@0
   139
    app.installTranslator( &translator );
insilmaril@0
   140
insilmaril@0
   141
	// Initializing the row of system flags
insilmaril@0
   142
	// is done in first call to MapEditor(),
insilmaril@0
   143
	// because we need at least one canvas first
insilmaril@0
   144
	systemFlagsDefault=NULL;
insilmaril@0
   145
	standardFlagsDefault=NULL;
insilmaril@0
   146
insilmaril@0
   147
	// Reading and initializing options commandline options
insilmaril@0
   148
	options.add ("version", SwitchOption, "v","version");
insilmaril@0
   149
	options.add ("help", SwitchOption, "h", "help");
insilmaril@0
   150
	options.add ("quit", SwitchOption, "q", "quit");
insilmaril@0
   151
	options.add ("test", StringOption, "t", "test");
insilmaril@0
   152
	options.setHelpText (
insilmaril@0
   153
		"VYM - View Your Mind\n"
insilmaril@0
   154
		"--------------------\n\n"
insilmaril@0
   155
		"Information about vym can be found in vym.pdf,\n"
insilmaril@0
   156
		"which should be part of the vym package.\n"
insilmaril@0
   157
		"It is also available at the project homepage:\n\n"
insilmaril@0
   158
		"http://www.InSilmaril.de/vym\n");
insilmaril@0
   159
	if (options.parse())
insilmaril@0
   160
	{
insilmaril@0
   161
		cout << endl << options.getHelpText()<<endl;
insilmaril@0
   162
		return 1;
insilmaril@0
   163
	}
insilmaril@0
   164
insilmaril@0
   165
	if (options.isOn ("version"))
insilmaril@0
   166
	{
insilmaril@0
   167
		cout << "vym version "<<__VYM_VERSION__
insilmaril@0
   168
			<<"  (c) 2004 Uwe Drechsel - "
insilmaril@0
   169
			<<__BUILD_DATE__<<endl;
insilmaril@0
   170
			
insilmaril@0
   171
		return 0;	
insilmaril@0
   172
	}		
insilmaril@0
   173
	
insilmaril@0
   174
	if (options.isOn ("help"))
insilmaril@0
   175
	{
insilmaril@0
   176
		cout << options.getHelpText()<<endl;
insilmaril@0
   177
		return 0;	
insilmaril@0
   178
	}	
insilmaril@0
   179
insilmaril@0
   180
	if (options.isOn ("test"))
insilmaril@0
   181
	{
insilmaril@0
   182
		// FIXME testing string option only
insilmaril@0
   183
		cout << "Testing: "<<options.getArg("test")<< endl;
insilmaril@0
   184
	}	
insilmaril@0
   185
insilmaril@0
   186
	// Initialize window of TextEditor
insilmaril@0
   187
	textEditor = new TextEditor();
insilmaril@0
   188
	textEditor->setIcon (QPixmap (vym_editor_xpm));
insilmaril@0
   189
	if (textEditor->showWithMain()) textEditor->show();
insilmaril@0
   190
insilmaril@166
   191
	// Initialize mainwindow 
insilmaril@0
   192
    Main m;
insilmaril@0
   193
	//m.resize(m.sizeHint());
insilmaril@0
   194
	m.setIcon (QPixmap (vym_logo_xpm));
insilmaril@0
   195
	m.show();
insilmaril@0
   196
	m.fileNew();
insilmaril@0
   197
	m.loadCmdLine();
insilmaril@0
   198
insilmaril@0
   199
	// For benchmarking we may want to quit immediatly after drawing
insilmaril@0
   200
	if (options.isOn ("quit"))
insilmaril@0
   201
	{
insilmaril@0
   202
		return 0;
insilmaril@0
   203
	}	
insilmaril@0
   204
insilmaril@0
   205
    QObject::connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
insilmaril@0
   206
insilmaril@0
   207
    return app.exec();
insilmaril@0
   208
}
insilmaril@0
   209