kaddressbook Library API Documentation

main.cpp

00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (C) 1999 Don Sanders <sanders@kde.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 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 // There can only be one main window 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 // otherwise, leave the window like it is (hidden or shown) 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 // Handle startup notification and window activation 00087 // We do it ourselves instead of calling KUniqueApplication::newInstance 00088 // to avoid the show() call there. 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 }
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:08 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003