summaryrefslogtreecommitdiffabout
path: root/kaddressbook/mainembedded.cpp
Unidiff
Diffstat (limited to 'kaddressbook/mainembedded.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/mainembedded.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index cf1fd3e..7f368eb 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,190 +1,191 @@
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/icons22/"; 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 QApplication::addLibraryPath ( qApp->applicationDirPath () );
51 51
52#endif 52#endif
53 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 53 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
54 KAddressBookMain m ; 54 KAddressBookMain m ;
55//US MainWindow m; 55//US MainWindow m;
56//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& )));
57 57
58#ifndef DESKTOP_VERSION 58#ifndef DESKTOP_VERSION
59 a.showMainWidget( &m ); 59 a.showMainWidget( &m );
60#else 60#else
61 a.setMainWidget( &m ); 61 a.setMainWidget( &m );
62 m.resize (640, 480 );
62 m.show(); 63 m.show();
63#endif 64#endif
64 a.exec(); 65 a.exec();
65 66
66 } 67 }
67 qDebug("KA: Bye! "); 68 qDebug("KA: Bye! ");
68} 69}
69 70
70/* 71/*
71#include <stdlib.h> 72#include <stdlib.h>
72 73
73#include <qstring.h> 74#include <qstring.h>
74 75
75#include <kabc/stdaddressbook.h> 76#include <kabc/stdaddressbook.h>
76#include <kaboutdata.h> 77#include <kaboutdata.h>
77#include <kcmdlineargs.h> 78#include <kcmdlineargs.h>
78#include <kcrash.h> 79#include <kcrash.h>
79#include <kdebug.h> 80#include <kdebug.h>
80#include <klocale.h> 81#include <klocale.h>
81#include <kstartupinfo.h> 82#include <kstartupinfo.h>
82#include <kuniqueapplication.h> 83#include <kuniqueapplication.h>
83#include <kwin.h> 84#include <kwin.h>
84 85
85#include "kaddressbookmain.h" 86#include "kaddressbookmain.h"
86#include "kabcore.h" 87#include "kabcore.h"
87 88
88extern "C" { 89extern "C" {
89 90
90void crashHandler( int ) 91void crashHandler( int )
91{ 92{
92 KABC::StdAddressBook::handleCrash(); 93 KABC::StdAddressBook::handleCrash();
93 ::exit( 0 ); 94 ::exit( 0 );
94} 95}
95 96
96} 97}
97 98
98class KAddressBookApp : public KUniqueApplication { 99class KAddressBookApp : public KUniqueApplication {
99 public: 100 public:
100 KAddressBookApp() : mMainWin( 0 ) {} 101 KAddressBookApp() : mMainWin( 0 ) {}
101 ~KAddressBookApp() {} 102 ~KAddressBookApp() {}
102 103
103 int newInstance(); 104 int newInstance();
104 105
105 private: 106 private:
106 KAddressBookMain *mMainWin; 107 KAddressBookMain *mMainWin;
107}; 108};
108 109
109int KAddressBookApp::newInstance() 110int KAddressBookApp::newInstance()
110{ 111{
111 if ( isRestored() ) { 112 if ( isRestored() ) {
112 // There can only be one main window 113 // There can only be one main window
113 if ( KMainWindow::canBeRestored( 1 ) ) { 114 if ( KMainWindow::canBeRestored( 1 ) ) {
114 mMainWin = new KAddressBookMain; 115 mMainWin = new KAddressBookMain;
115 mMainWin->show(); 116 mMainWin->show();
116 mMainWin->restore( 1 ); 117 mMainWin->restore( 1 );
117 } 118 }
118 } else { 119 } else {
119 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 120 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
120 121
121 QCString addrStr = args->getOption( "addr" ); 122 QCString addrStr = args->getOption( "addr" );
122 QCString uidStr = args->getOption( "uid" ); 123 QCString uidStr = args->getOption( "uid" );
123 QString addr; 124 QString addr;
124 QString uid; 125 QString uid;
125 if ( !addrStr.isEmpty() ) 126 if ( !addrStr.isEmpty() )
126 addr = QString::fromLocal8Bit( addrStr ); 127 addr = QString::fromLocal8Bit( addrStr );
127 if ( !uidStr.isEmpty() ) 128 if ( !uidStr.isEmpty() )
128 uid = QString::fromLocal8Bit( uidStr ); 129 uid = QString::fromLocal8Bit( uidStr );
129 130
130 131
131 if ( args->isSet( "editor-only" ) ) { 132 if ( args->isSet( "editor-only" ) ) {
132 if ( !mMainWin ) 133 if ( !mMainWin )
133 mMainWin = new KAddressBookMain; 134 mMainWin = new KAddressBookMain;
134 KStartupInfo::appStarted(); 135 KStartupInfo::appStarted();
135 mMainWin->hide(); 136 mMainWin->hide();
136 } else { 137 } else {
137 if ( mMainWin ) { 138 if ( mMainWin ) {
138 mMainWin->show(); 139 mMainWin->show();
139 KWin::setActiveWindow( mMainWin->winId() ); 140 KWin::setActiveWindow( mMainWin->winId() );
140 } else { 141 } else {
141 mMainWin = new KAddressBookMain; 142 mMainWin = new KAddressBookMain;
142 mMainWin->show(); 143 mMainWin->show();
143 } 144 }
144 } 145 }
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 146 // 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
146 if ( !addr.isEmpty() ) 147 if ( !addr.isEmpty() )
147 mMainWin->addEmail( addr ); 148 mMainWin->addEmail( addr );
148 149
149 if ( !uid.isEmpty() ) 150 if ( !uid.isEmpty() )
150 mMainWin->showContactEditor( uid ); 151 mMainWin->showContactEditor( uid );
151 if ( args->isSet( "new-contact" ) ) { 152 if ( args->isSet( "new-contact" ) ) {
152 mMainWin->newContact(); 153 mMainWin->newContact();
153 } 154 }
154 } 155 }
155 156
156 KCrash::setEmergencySaveFunction( crashHandler ); 157 KCrash::setEmergencySaveFunction( crashHandler );
157 158
158 return 0; 159 return 0;
159} 160}
160 161
161// the dummy argument is required, because KMail apparently sends an empty 162// the dummy argument is required, because KMail apparently sends an empty
162// argument. 163// argument.
163static KCmdLineOptions kmoptions[] = 164static KCmdLineOptions kmoptions[] =
164{ 165{
165 { "a", 0 , 0 }, 166 { "a", 0 , 0 },
166 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 167 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
167 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 168 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
168 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 169 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
169 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 170 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
170 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 171 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
171 { 0, 0, 0} 172 { 0, 0, 0}
172}; 173};
173 174
174int main( int argc, char *argv[] ) 175int main( int argc, char *argv[] )
175{ 176{
176 KLocale::setMainCatalogue( "kaddressbook" ); 177 KLocale::setMainCatalogue( "kaddressbook" );
177 178
178 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 179 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
179 KCmdLineArgs::addCmdLineOptions( kmoptions ); 180 KCmdLineArgs::addCmdLineOptions( kmoptions );
180 KUniqueApplication::addCmdLineOptions(); 181 KUniqueApplication::addCmdLineOptions();
181 182
182 if ( !KAddressBookApp::start() ) 183 if ( !KAddressBookApp::start() )
183 exit( 0 ); 184 exit( 0 );
184 185
185 KAddressBookApp app; 186 KAddressBookApp app;
186 KGlobal::locale()->insertCatalogue( "libkdepim" ); 187 KGlobal::locale()->insertCatalogue( "libkdepim" );
187 188
188 return app.exec(); 189 return app.exec();
189} 190}
190*/ 191*/