main.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <stdlib.h>
00025 #include <unistd.h>
00026
00027 #include <qstring.h>
00028
00029 #include <kabc/stdaddressbook.h>
00030 #include <kaboutdata.h>
00031 #include <kcmdlineargs.h>
00032 #include <kcrash.h>
00033 #include <kdebug.h>
00034 #include <klocale.h>
00035 #include <kstartupinfo.h>
00036 #include <kuniqueapplication.h>
00037 #include <kwin.h>
00038
00039 #include "kaddressbookmain.h"
00040 #include "kaddressbook_options.h"
00041 #include "kabcore.h"
00042
00043 class KAddressBookApp : public KUniqueApplication {
00044 public:
00045 KAddressBookApp() : mMainWin( 0 ) {}
00046 ~KAddressBookApp() {}
00047
00048 int newInstance();
00049
00050 private:
00051 KAddressBookMain *mMainWin;
00052 };
00053
00054 int KAddressBookApp::newInstance()
00055 {
00056 if ( isRestored() ) {
00057
00058 if ( KMainWindow::canBeRestored( 1 ) ) {
00059 mMainWin = new KAddressBookMain;
00060 setMainWidget( mMainWin );
00061 mMainWin->show();
00062 mMainWin->restore( 1 );
00063 }
00064 } else {
00065 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00066
00067 if ( args->isSet( "editor-only" ) ) {
00068 if ( !mMainWin ) {
00069 mMainWin = new KAddressBookMain;
00070 setMainWidget( mMainWin );
00071 mMainWin->hide();
00072 }
00073
00074 KStartupInfo::appStarted();
00075 } else {
00076 if ( !mMainWin ) {
00077 mMainWin = new KAddressBookMain;
00078 setMainWidget( mMainWin );
00079 }
00080 mMainWin->show();
00081 }
00082
00083 mMainWin->handleCommandLine();
00084 }
00085
00086
00087
00088
00089 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00090 KStartupInfo::setNewStartupId( mMainWin, kapp->startupId() );
00091 #endif
00092
00093 return 0;
00094 }
00095
00096 int main( int argc, char *argv[] )
00097 {
00098 KLocale::setMainCatalogue( "kaddressbook" );
00099
00100 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
00101 KCmdLineArgs::addCmdLineOptions( kaddressbook_options );
00102 KUniqueApplication::addCmdLineOptions();
00103
00104 if ( !KAddressBookApp::start() )
00105 exit( 0 );
00106
00107 KAddressBookApp app;
00108 KGlobal::locale()->insertCatalogue( "libkdepim" );
00109
00110 bool ret = app.exec();
00111 while (KMainWindow::memberList->first())
00112 delete KMainWindow::memberList->first();
00113 return ret;
00114 }
This file is part of the documentation for kaddressbook Library Version 3.2.2.