karm

main.cpp
1 #include <signal.h>
2 #include <tdeapplication.h>
3 #include <tdelocale.h>
4 #include <tdecmdlineargs.h>
5 #include <tdeaboutdata.h>
6 #include <kdebug.h>
7 #include "version.h"
8 #include "mainwindow.h"
9 
10 
11 namespace
12 {
13  const char* description = I18N_NOOP("TDE Time tracker tool");
14 
15  void cleanup( int )
16  {
17  kdDebug(5970) << i18n("Just caught a software interrupt.") << endl;
18  kapp->exit();
19  }
20 }
21 
22 static const TDECmdLineOptions options[] =
23 {
24  { "+file", I18N_NOOP( "The iCalendar file to open" ), 0 },
25  TDECmdLineLastOption
26 };
27 
28 int main( int argc, char *argv[] )
29 {
30  TDEAboutData aboutData( "karm", I18N_NOOP("KArm"),
31  KARM_VERSION, description, TDEAboutData::License_GPL,
32  "(c) 1997-2004, KDE PIM Developers" );
33 
34  aboutData.addAuthor( "Mark Bucciarelli", I18N_NOOP( "Current Maintainer" ),
35  "mark@hubcapconsulting.com" );
36  aboutData.addAuthor( "Sirtaj Singh Kang", I18N_NOOP( "Original Author" ),
37  "taj@kde.org" );
38  aboutData.addAuthor( "Allen Winter", 0, "winterz@verizon.net" );
39  aboutData.addAuthor( "David Faure", 0, "faure@kde.org" );
40  aboutData.addAuthor( "Espen Sand", 0, "espen@kde.org" );
41  aboutData.addAuthor( "Gioele Barabucci", 0, "gioele@gioelebarabucci.com" );
42  aboutData.addAuthor( "Jan Schaumann", 0, "jschauma@netmeister.org" );
43  aboutData.addAuthor( "Jesper Pedersen", 0, "blackie@kde.org" );
44  aboutData.addAuthor( "Kalle Dalheimer", 0, "kalle@kde.org" );
45  aboutData.addAuthor( "Scott Monachello", 0, "smonach@cox.net" );
46  aboutData.addAuthor( "Thorsten Staerk", 0, "kde@staerk.de" );
47  aboutData.addAuthor( "Tomas Pospisek", 0, "tpo_deb@sourcepole.ch" );
48  aboutData.addAuthor( "Willi Richert", 0, "w.richert@gmx.net" );
49 
50  TDECmdLineArgs::init( argc, argv, &aboutData );
51  TDECmdLineArgs::addCmdLineOptions( options );
52  TDEApplication myApp;
53 
54  TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
55 
56  MainWindow *mainWindow;
57  if ( args->count() > 0 )
58  {
59  TQString icsfile = TQString::fromLocal8Bit( args->arg( 0 ) );
60  // FIXME: there is probably a TQt or KDE fcn for this test
61  if ( icsfile.startsWith( "/" )
62  || icsfile.lower().startsWith( "http://" )
63  || icsfile.lower().startsWith( "ftp://" )
64  )
65  {
66  // leave as is
67  ;
68  }
69  else
70  {
71  icsfile = TDECmdLineArgs::cwd() + "/" + icsfile;
72  }
73  mainWindow = new MainWindow( icsfile );
74  }
75  else
76  {
77  mainWindow = new MainWindow();
78  }
79 
80  myApp.setMainWidget( mainWindow );
81 
82  if (kapp->isRestored() && TDEMainWindow::canBeRestored( 1 ))
83  mainWindow->restore( 1, false );
84  else
85  mainWindow->show();
86 
87  signal( SIGQUIT, cleanup );
88  signal( SIGINT, cleanup );
89  int ret = myApp.exec();
90 
91  delete mainWindow;
92  return ret;
93 }
Main window to tie the application together.
Definition: mainwindow.h:27