summaryrefslogtreecommitdiffstats
path: root/karm/main.cpp
blob: a40b7e396e30388f1848d850aead386f118d9fbc (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
#include <signal.h>
#include <kapplication.h>
#include <klocale.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kdebug.h>
#include "version.h"
#include "mainwindow.h"


namespace
{
  const char* description = I18N_NOOP("TDE Time tracker tool");

  void cleanup( int )
  {
    kdDebug(5970) << i18n("Just caught a software interrupt.") << endl;
    kapp->exit();
  }
}

static const KCmdLineOptions options[] =
{
  { "+file", I18N_NOOP( "The iCalendar file to open" ), 0 },
  KCmdLineLastOption
};

int main( int argc, char *argv[] )
{
  TDEAboutData aboutData( "karm", I18N_NOOP("KArm"),
      KARM_VERSION, description, TDEAboutData::License_GPL,
      "(c) 1997-2004, KDE PIM Developers" );

  aboutData.addAuthor( "Mark Bucciarelli", I18N_NOOP( "Current Maintainer" ),
                       "[email protected]" );
  aboutData.addAuthor( "Sirtaj Singh Kang", I18N_NOOP( "Original Author" ),
                       "[email protected]" );
  aboutData.addAuthor( "Allen Winter",      0, "[email protected]" );
  aboutData.addAuthor( "David Faure",       0, "[email protected]" );
  aboutData.addAuthor( "Espen Sand",        0, "[email protected]" );
  aboutData.addAuthor( "Gioele Barabucci",  0, "[email protected]" );
  aboutData.addAuthor( "Jan Schaumann",     0, "[email protected]" );
  aboutData.addAuthor( "Jesper Pedersen",   0, "[email protected]" );
  aboutData.addAuthor( "Kalle Dalheimer",   0, "[email protected]" );
  aboutData.addAuthor( "Scott Monachello",  0, "[email protected]" );
  aboutData.addAuthor( "Thorsten Staerk",   0, "[email protected]" );
  aboutData.addAuthor( "Tomas Pospisek",    0, "[email protected]" );
  aboutData.addAuthor( "Willi Richert",     0, "[email protected]" );

  TDECmdLineArgs::init( argc, argv, &aboutData );
  TDECmdLineArgs::addCmdLineOptions( options );
  TDEApplication myApp;

  TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();

  MainWindow *mainWindow;
  if ( args->count() > 0 ) 
  {
    TQString icsfile = TQString::fromLocal8Bit( args->arg( 0 ) );
    // FIXME: there is probably a TQt or KDE fcn for this test
    if ( icsfile.startsWith( "/" ) 
        || icsfile.lower().startsWith( "http://" ) 
        || icsfile.lower().startsWith( "ftp://" ) 
        )
    {
      // leave as is
      ;
    }
    else
    {
      icsfile = TDECmdLineArgs::cwd() + "/" + icsfile;
    }
    mainWindow = new MainWindow( icsfile );
  }
  else
  {
    mainWindow = new MainWindow();
  }

  myApp.setMainWidget( mainWindow );

  if (kapp->isRestored() && KMainWindow::canBeRestored( 1 ))
    mainWindow->restore( 1, false );
  else
    mainWindow->show();

  signal( SIGQUIT, cleanup );
  signal( SIGINT, cleanup );
  int ret = myApp.exec();

  delete mainWindow;
  return ret;
}