summaryrefslogtreecommitdiffabout
path: root/kaddressbook/mainembedded.cpp
Unidiff
Diffstat (limited to 'kaddressbook/mainembedded.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/mainembedded.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index dce6a88..cf1fd3e 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,189 +1,190 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#else 4#else
5#include <qapplication.h> 5#include <qapplication.h>
6#include <qwindowsstyle.h> 6#include <qwindowsstyle.h>
7#include <qplatinumstyle.h> 7#include <qplatinumstyle.h>
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#endif 9#endif
10 10
11#include <kstandarddirs.h> 11#include <kstandarddirs.h>
12#include <kglobal.h> 12#include <kglobal.h>
13#include <stdio.h> 13#include <stdio.h>
14#include <qdir.h> 14#include <qdir.h>
15#include "kaddressbookmain.h" 15#include "kaddressbookmain.h"
16 16
17int main( int argc, char **argv ) 17int main( int argc, char **argv )
18{ 18{
19#ifndef DESKTOP_VERSION 19#ifndef DESKTOP_VERSION
20 QPEApplication a( argc, argv ); 20 QPEApplication a( argc, argv );
21 a.setKeepRunning (); 21 a.setKeepRunning ();
22#else 22#else
23 QApplication a( argc, argv ); 23 QApplication a( argc, argv );
24 QApplication::setStyle( new QPlatinumStyle ()); 24 QApplication::setStyle( new QPlatinumStyle ());
25#endif 25#endif
26 26
27 bool exitHelp = false; 27 bool exitHelp = false;
28 if ( argc > 1 ) { 28 if ( argc > 1 ) {
29 QString command = argv[1]; 29 QString command = argv[1];
30 if ( command == "-help" ){ 30 if ( command == "-help" ){
31 printf("KA/E command line commands:\n"); 31 printf("KA/E command line commands:\n");
32 printf(" no command: Start KA/E in usual way\n"); 32 printf(" no command: Start KA/E in usual way\n");
33 printf(" -help: This output\n"); 33 printf(" -help: This output\n");
34 printf(" KA/E is exiting now. Bye!\n"); 34 printf(" KA/E is exiting now. Bye!\n");
35 exitHelp = true; 35 exitHelp = true;
36 } 36 }
37 } 37 }
38 if ( ! exitHelp ) { 38 if ( ! exitHelp ) {
39 39
40 KGlobal::setAppName( "kaddressbook" ); 40 KGlobal::setAppName( "kaddressbook" );
41#ifndef DESKTOP_VERSION 41#ifndef DESKTOP_VERSION
42 if ( QApplication::desktop()->width() > 320 ) 42 if ( QApplication::desktop()->width() > 320 )
43 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 43 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
44 else 44 else
45 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 45 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
46#else 46#else
47 QString fileName ; 47 QString fileName ;
48 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; 48 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
49 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 49 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
50 QApplication::addLibraryPath ( qApp->applicationDirPath () );
50 51
51#endif 52#endif
52 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 53 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
53 KAddressBookMain m ; 54 KAddressBookMain m ;
54//US MainWindow m; 55//US MainWindow m;
55//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 56//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
56 57
57#ifndef DESKTOP_VERSION 58#ifndef DESKTOP_VERSION
58 a.showMainWidget( &m ); 59 a.showMainWidget( &m );
59#else 60#else
60 a.setMainWidget(m ); 61 a.setMainWidget( &m );
61 m->show(); 62 m.show();
62#endif 63#endif
63 a.exec(); 64 a.exec();
64 65
65 } 66 }
66 qDebug("KA: Bye! "); 67 qDebug("KA: Bye! ");
67} 68}
68 69
69/* 70/*
70#include <stdlib.h> 71#include <stdlib.h>
71 72
72#include <qstring.h> 73#include <qstring.h>
73 74
74#include <kabc/stdaddressbook.h> 75#include <kabc/stdaddressbook.h>
75#include <kaboutdata.h> 76#include <kaboutdata.h>
76#include <kcmdlineargs.h> 77#include <kcmdlineargs.h>
77#include <kcrash.h> 78#include <kcrash.h>
78#include <kdebug.h> 79#include <kdebug.h>
79#include <klocale.h> 80#include <klocale.h>
80#include <kstartupinfo.h> 81#include <kstartupinfo.h>
81#include <kuniqueapplication.h> 82#include <kuniqueapplication.h>
82#include <kwin.h> 83#include <kwin.h>
83 84
84#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
85#include "kabcore.h" 86#include "kabcore.h"
86 87
87extern "C" { 88extern "C" {
88 89
89void crashHandler( int ) 90void crashHandler( int )
90{ 91{
91 KABC::StdAddressBook::handleCrash(); 92 KABC::StdAddressBook::handleCrash();
92 ::exit( 0 ); 93 ::exit( 0 );
93} 94}
94 95
95} 96}
96 97
97class KAddressBookApp : public KUniqueApplication { 98class KAddressBookApp : public KUniqueApplication {
98 public: 99 public:
99 KAddressBookApp() : mMainWin( 0 ) {} 100 KAddressBookApp() : mMainWin( 0 ) {}
100 ~KAddressBookApp() {} 101 ~KAddressBookApp() {}
101 102
102 int newInstance(); 103 int newInstance();
103 104
104 private: 105 private:
105 KAddressBookMain *mMainWin; 106 KAddressBookMain *mMainWin;
106}; 107};
107 108
108int KAddressBookApp::newInstance() 109int KAddressBookApp::newInstance()
109{ 110{
110 if ( isRestored() ) { 111 if ( isRestored() ) {
111 // There can only be one main window 112 // There can only be one main window
112 if ( KMainWindow::canBeRestored( 1 ) ) { 113 if ( KMainWindow::canBeRestored( 1 ) ) {
113 mMainWin = new KAddressBookMain; 114 mMainWin = new KAddressBookMain;
114 mMainWin->show(); 115 mMainWin->show();
115 mMainWin->restore( 1 ); 116 mMainWin->restore( 1 );
116 } 117 }
117 } else { 118 } else {
118 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 119 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
119 120
120 QCString addrStr = args->getOption( "addr" ); 121 QCString addrStr = args->getOption( "addr" );
121 QCString uidStr = args->getOption( "uid" ); 122 QCString uidStr = args->getOption( "uid" );
122 QString addr; 123 QString addr;
123 QString uid; 124 QString uid;
124 if ( !addrStr.isEmpty() ) 125 if ( !addrStr.isEmpty() )
125 addr = QString::fromLocal8Bit( addrStr ); 126 addr = QString::fromLocal8Bit( addrStr );
126 if ( !uidStr.isEmpty() ) 127 if ( !uidStr.isEmpty() )
127 uid = QString::fromLocal8Bit( uidStr ); 128 uid = QString::fromLocal8Bit( uidStr );
128 129
129 130
130 if ( args->isSet( "editor-only" ) ) { 131 if ( args->isSet( "editor-only" ) ) {
131 if ( !mMainWin ) 132 if ( !mMainWin )
132 mMainWin = new KAddressBookMain; 133 mMainWin = new KAddressBookMain;
133 KStartupInfo::appStarted(); 134 KStartupInfo::appStarted();
134 mMainWin->hide(); 135 mMainWin->hide();
135 } else { 136 } else {
136 if ( mMainWin ) { 137 if ( mMainWin ) {
137 mMainWin->show(); 138 mMainWin->show();
138 KWin::setActiveWindow( mMainWin->winId() ); 139 KWin::setActiveWindow( mMainWin->winId() );
139 } else { 140 } else {
140 mMainWin = new KAddressBookMain; 141 mMainWin = new KAddressBookMain;
141 mMainWin->show(); 142 mMainWin->show();
142 } 143 }
143 } 144 }
144 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do 145 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
145 if ( !addr.isEmpty() ) 146 if ( !addr.isEmpty() )
146 mMainWin->addEmail( addr ); 147 mMainWin->addEmail( addr );
147 148
148 if ( !uid.isEmpty() ) 149 if ( !uid.isEmpty() )
149 mMainWin->showContactEditor( uid ); 150 mMainWin->showContactEditor( uid );
150 if ( args->isSet( "new-contact" ) ) { 151 if ( args->isSet( "new-contact" ) ) {
151 mMainWin->newContact(); 152 mMainWin->newContact();
152 } 153 }
153 } 154 }
154 155
155 KCrash::setEmergencySaveFunction( crashHandler ); 156 KCrash::setEmergencySaveFunction( crashHandler );
156 157
157 return 0; 158 return 0;
158} 159}
159 160
160// the dummy argument is required, because KMail apparently sends an empty 161// the dummy argument is required, because KMail apparently sends an empty
161// argument. 162// argument.
162static KCmdLineOptions kmoptions[] = 163static KCmdLineOptions kmoptions[] =
163{ 164{
164 { "a", 0 , 0 }, 165 { "a", 0 , 0 },
165 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 166 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
166 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 167 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
167 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 168 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
168 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 169 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
169 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 170 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
170 { 0, 0, 0} 171 { 0, 0, 0}
171}; 172};
172 173
173int main( int argc, char *argv[] ) 174int main( int argc, char *argv[] )
174{ 175{
175 KLocale::setMainCatalogue( "kaddressbook" ); 176 KLocale::setMainCatalogue( "kaddressbook" );
176 177
177 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 178 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
178 KCmdLineArgs::addCmdLineOptions( kmoptions ); 179 KCmdLineArgs::addCmdLineOptions( kmoptions );
179 KUniqueApplication::addCmdLineOptions(); 180 KUniqueApplication::addCmdLineOptions();
180 181
181 if ( !KAddressBookApp::start() ) 182 if ( !KAddressBookApp::start() )
182 exit( 0 ); 183 exit( 0 );
183 184
184 KAddressBookApp app; 185 KAddressBookApp app;
185 KGlobal::locale()->insertCatalogue( "libkdepim" ); 186 KGlobal::locale()->insertCatalogue( "libkdepim" );
186 187
187 return app.exec(); 188 return app.exec();
188} 189}
189*/ 190*/