summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
blob: 35542f4e4567cab03734f441c7b27a505d46ef2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/***************************************************************************
 *   Copyright (C) 2004-2007 by Georgy Yunaev, gyunaev@ulduzsoft.com       *
 *   Please do not use email address above for bug reports; see            *
 *   the README file                                                       *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/

#include "tde-tqt.h"

#include "kchmmainwindow.h"
#include "kchmconfig.h"
#include "kchmkeyeventfilter.h"

#if defined (USE_KDE)
	#include <tdeaboutdata.h>
	#include <dcopclient.h>
	
	#include "tde/kchmdcopiface.h"
#endif

KCHMMainWindow * mainWindow;


int main( int argc, char ** argv )
{
#if defined (USE_KDE)
 	static TDECmdLineOptions options[] =
 	{
    	{ "autotestmode", "Perform auto testing", 0 },
		{ "shortautotestmode", "Perform short auto testing", 0 },
		{ "+[chmfile]", "A CHM file to show", 0 },
		{ "search <query>", I18N_NOOP("'--search <query>' specifies the search query to search, and activate the first entry if found"), 0 },
		{ "sindex <word>", I18N_NOOP("'--sindex <word>' specifies the word to find in index, and activate if found"), 0 },
		TDECmdLineLastOption
 	};

	TDEAboutData aboutdata ( "kchmviewer",
				APP_NAME,
				APP_VERSION,
				I18N_NOOP("CHM file viewer"),
				TDEAboutData::License_GPL,
				"(c) 2004-2007 George Yunaev, gyunaev@ulduzsoft.com",
				0,
				"http://www.kchmviewer.net",
				"gyunaev@ulduzsoft.com");

	TDELocale::setMainCatalogue( "kchmviewer" );
	TDECmdLineArgs::init (argc, argv, &aboutdata);
	TDECmdLineArgs::addCmdLineOptions( options );

	TDEApplication app;
#else
	TQApplication app( argc, argv );
#endif
	
	appConfig.load();
	app.installEventFilter( &gKeyEventFilter );
	
#if defined(USE_KDE)	
	// DCOP stuff
	KCHMDCOPIface iface;
	
	DCOPClient *client = kapp->dcopClient();
	
	if ( !client->attach() )
		tqWarning("DCOP attach failed");
	
	//TQCString realAppId = client->registerAs( kapp->name() );
	TQCString realAppId = client->registerAs( "kchmviewer" );
#endif
						
	mainWindow = new KCHMMainWindow();
	mainWindow->show();
	
#if !defined(USE_KDE)
	app.connect( &app, TQT_SIGNAL(lastWindowClosed()), &app, TQT_SLOT(quit()) );
#else
	app.setMainWidget( mainWindow );
#endif
	
	return app.exec();
}