karm

main.cpp

00001 #include <signal.h>
00002 #include <kapplication.h>
00003 #include <klocale.h>
00004 #include <kcmdlineargs.h>
00005 #include <kaboutdata.h>
00006 #include <kdebug.h>
00007 #include "version.h"
00008 #include "mainwindow.h"
00009 
00010 
00011 namespace
00012 {
00013   const char* description = I18N_NOOP("KDE Time tracker tool");
00014 
00015   void cleanup( int )
00016   {
00017     kdDebug(5970) << i18n("Just caught a software interrupt.") << endl;
00018     kapp->exit();
00019   }
00020 }
00021 
00022 static const KCmdLineOptions options[] =
00023 {
00024   { "+file", I18N_NOOP( "The iCalendar file to open" ), 0 },
00025   KCmdLineLastOption
00026 };
00027 
00028 int main( int argc, char *argv[] )
00029 {
00030   KAboutData aboutData( "karm", I18N_NOOP("KArm"),
00031       KARM_VERSION, description, KAboutData::License_GPL,
00032       "(c) 1997-2004, KDE PIM Developers" );
00033 
00034   aboutData.addAuthor( "Mark Bucciarelli", I18N_NOOP( "Current Maintainer" ),
00035                        "mark@hubcapconsulting.com" );
00036   aboutData.addAuthor( "Sirtaj Singh Kang", I18N_NOOP( "Original Author" ),
00037                        "taj@kde.org" );
00038   aboutData.addAuthor( "Allen Winter",      0, "winterz@verizon.net" );
00039   aboutData.addAuthor( "David Faure",       0, "faure@kde.org" );
00040   aboutData.addAuthor( "Espen Sand",        0, "espen@kde.org" );
00041   aboutData.addAuthor( "Gioele Barabucci",  0, "gioele@gioelebarabucci.com" );
00042   aboutData.addAuthor( "Jan Schaumann",     0, "jschauma@netmeister.org" );
00043   aboutData.addAuthor( "Jesper Pedersen",   0, "blackie@kde.org" );
00044   aboutData.addAuthor( "Kalle Dalheimer",   0, "kalle@kde.org" );
00045   aboutData.addAuthor( "Scott Monachello",  0, "smonach@cox.net" );
00046   aboutData.addAuthor( "Thorsten Staerk",   0, "kde@staerk.de" );
00047   aboutData.addAuthor( "Tomas Pospisek",    0, "tpo_deb@sourcepole.ch" );
00048   aboutData.addAuthor( "Willi Richert",     0, "w.richert@gmx.net" );
00049 
00050   KCmdLineArgs::init( argc, argv, &aboutData );
00051   KCmdLineArgs::addCmdLineOptions( options );
00052   KApplication myApp;
00053 
00054   KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00055 
00056   MainWindow *mainWindow;
00057   if ( args->count() > 0 ) 
00058   {
00059     QString icsfile = QString::fromLocal8Bit( args->arg( 0 ) );
00060     // FIXME: there is probably a Qt or KDE fcn for this test
00061     if ( icsfile.startsWith( "/" ) 
00062         || icsfile.lower().startsWith( "http://" ) 
00063         || icsfile.lower().startsWith( "ftp://" ) 
00064         )
00065     {
00066       // leave as is
00067       ;
00068     }
00069     else
00070     {
00071       icsfile = KCmdLineArgs::cwd() + "/" + icsfile;
00072     }
00073     mainWindow = new MainWindow( icsfile );
00074   }
00075   else
00076   {
00077     mainWindow = new MainWindow();
00078   }
00079 
00080   myApp.setMainWidget( mainWindow );
00081 
00082   if (kapp->isRestored() && KMainWindow::canBeRestored( 1 ))
00083     mainWindow->restore( 1, false );
00084   else
00085     mainWindow->show();
00086 
00087   signal( SIGQUIT, cleanup );
00088   signal( SIGINT, cleanup );
00089   int ret = myApp.exec();
00090 
00091   delete mainWindow;
00092   return ret;
00093 }
KDE Home | KDE Accessibility Home | Description of Access Keys