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 4230c07..4f48850 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,222 +1,223 @@
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 <qregexp.h>
12#include <kglobal.h> 13#include <kglobal.h>
13#include <stdio.h> 14#include <stdio.h>
14#include <qdir.h> 15#include <qdir.h>
15#include "kaddressbookmain.h" 16#include "kaddressbookmain.h"
16#include "externalapphandler.h" 17#include "externalapphandler.h"
17 18
18int main( int argc, char **argv ) 19int main( int argc, char **argv )
19{ 20{
20#ifndef DESKTOP_VERSION 21#ifndef DESKTOP_VERSION
21 QPEApplication a( argc, argv ); 22 QPEApplication a( argc, argv );
22 a.setKeepRunning (); 23 a.setKeepRunning ();
23#else 24#else
24 QApplication a( argc, argv ); 25 QApplication a( argc, argv );
25 QApplication::setStyle( new QPlatinumStyle ()); 26 QApplication::setStyle( new QPlatinumStyle ());
26 QString hdir = QDir::homeDirPath(); 27 QString hdir = QDir::homeDirPath();
27 // there is a bug when creating dirs for WIN 98 28 // there is a bug when creating dirs for WIN 98
28 // it is difficult to fix, because we have no WIN 98 runnung 29 // it is difficult to fix, because we have no WIN 98 runnung
29 // such that we try it to create the dirs at startup here 30 // such that we try it to create the dirs at startup here
30 if ( hdir == "C:\\" ) { // win 98 or ME 31 if ( hdir == "C:\\" ) { // win 98 or ME
31 QDir app_dir; 32 QDir app_dir;
32 if ( !app_dir.exists("C:\\kdepim") ) 33 if ( !app_dir.exists("C:\\kdepim") )
33 app_dir.mkdir ("C:\\kdepim"); 34 app_dir.mkdir ("C:\\kdepim");
34 if ( !app_dir.exists("C:\\kdepim\\apps") ) 35 if ( !app_dir.exists("C:\\kdepim\\apps") )
35 app_dir.mkdir ("C:\\kdepim\\apps"); 36 app_dir.mkdir ("C:\\kdepim\\apps");
36 if ( !app_dir.exists("C:\\kdepim\\config") ) 37 if ( !app_dir.exists("C:\\kdepim\\config") )
37 app_dir.mkdir ("C:\\kdepim\\config"); 38 app_dir.mkdir ("C:\\kdepim\\config");
38 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) 39 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") )
39 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); 40 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook");
40 } 41 }
41#endif 42#endif
42 43
43 bool exitHelp = false; 44 bool exitHelp = false;
44 if ( argc > 1 ) { 45 if ( argc > 1 ) {
45 QString command = argv[1]; 46 QString command = argv[1];
46 if ( command == "-help" ){ 47 if ( command == "-help" ){
47 printf("KA/E command line commands:\n"); 48 printf("KA/E command line commands:\n");
48 printf(" no command: Start KA/E in usual way\n"); 49 printf(" no command: Start KA/E in usual way\n");
49 printf(" -help: This output\n"); 50 printf(" -help: This output\n");
50 printf(" KA/E is exiting now. Bye!\n"); 51 printf(" KA/E is exiting now. Bye!\n");
51 exitHelp = true; 52 exitHelp = true;
52 } 53 }
53 } 54 }
54 if ( ! exitHelp ) { 55 if ( ! exitHelp ) {
55 56
56 KGlobal::setAppName( "kaddressbook" ); 57 KGlobal::setAppName( "kaddressbook" );
57#ifndef DESKTOP_VERSION 58#ifndef DESKTOP_VERSION
58 if ( QApplication::desktop()->width() > 320 ) 59 if ( QApplication::desktop()->width() > 320 )
59 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 60 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
60 else 61 else
61 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 62 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
62#else 63#else
63 QString fileName ; 64 QString fileName ;
64 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 65 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
65 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 66 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
66 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 67 QApplication::addLibraryPath ( qApp->applicationDirPath () );
67 68
68#endif 69#endif
69 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 70 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
70 KAddressBookMain m ; 71 KAddressBookMain m ;
71//US MainWindow m; 72//US MainWindow m;
72 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 73 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
73 74
74 { 75 {
75 KConfig kon ( locateLocal( "config", "korganizerrc" ) ); 76 KConfig kon ( locateLocal( "config", "korganizerrc" ) );
76 kon.setGroup("Locale"); 77 kon.setGroup("Locale");
77 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); 78 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) );
78 QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); 79 QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( "");
79 KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); 80 KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) );
80 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 81 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
81 dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); 82 dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" );
82 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 83 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
83 kon.setGroup("Time & Date"); 84 kon.setGroup("Time & Date");
84 KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), 85 KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ),
85 kon.readNumEntry( "DaylightsavingStart", 90), 86 kon.readNumEntry( "DaylightsavingStart", 90),
86 kon.readNumEntry( "DaylightsavingEnd",304) ); 87 kon.readNumEntry( "DaylightsavingEnd",304) );
87 KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); 88 KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") );
88 } 89 }
89#ifndef DESKTOP_VERSION 90#ifndef DESKTOP_VERSION
90 a.showMainWidget( &m ); 91 a.showMainWidget( &m );
91#else 92#else
92 a.setMainWidget( &m ); 93 a.setMainWidget( &m );
93 m.resize (640, 480 ); 94 m.resize (640, 480 );
94 m.show(); 95 m.show();
95#endif 96#endif
96 a.exec(); 97 a.exec();
97 98
98 } 99 }
99 qDebug("KA: Bye! "); 100 qDebug("KA: Bye! ");
100} 101}
101 102
102/* 103/*
103#include <stdlib.h> 104#include <stdlib.h>
104 105
105#include <qstring.h> 106#include <qstring.h>
106 107
107#include <kabc/stdaddressbook.h> 108#include <kabc/stdaddressbook.h>
108#include <kaboutdata.h> 109#include <kaboutdata.h>
109#include <kcmdlineargs.h> 110#include <kcmdlineargs.h>
110#include <kcrash.h> 111#include <kcrash.h>
111#include <kdebug.h> 112#include <kdebug.h>
112#include <klocale.h> 113#include <klocale.h>
113#include <kstartupinfo.h> 114#include <kstartupinfo.h>
114#include <kuniqueapplication.h> 115#include <kuniqueapplication.h>
115#include <kwin.h> 116#include <kwin.h>
116 117
117#include "kaddressbookmain.h" 118#include "kaddressbookmain.h"
118#include "kabcore.h" 119#include "kabcore.h"
119 120
120extern "C" { 121extern "C" {
121 122
122void crashHandler( int ) 123void crashHandler( int )
123{ 124{
124 KABC::StdAddressBook::handleCrash(); 125 KABC::StdAddressBook::handleCrash();
125 ::exit( 0 ); 126 ::exit( 0 );
126} 127}
127 128
128} 129}
129 130
130class KAddressBookApp : public KUniqueApplication { 131class KAddressBookApp : public KUniqueApplication {
131 public: 132 public:
132 KAddressBookApp() : mMainWin( 0 ) {} 133 KAddressBookApp() : mMainWin( 0 ) {}
133 ~KAddressBookApp() {} 134 ~KAddressBookApp() {}
134 135
135 int newInstance(); 136 int newInstance();
136 137
137 private: 138 private:
138 KAddressBookMain *mMainWin; 139 KAddressBookMain *mMainWin;
139}; 140};
140 141
141int KAddressBookApp::newInstance() 142int KAddressBookApp::newInstance()
142{ 143{
143 if ( isRestored() ) { 144 if ( isRestored() ) {
144 // There can only be one main window 145 // There can only be one main window
145 if ( KMainWindow::canBeRestored( 1 ) ) { 146 if ( KMainWindow::canBeRestored( 1 ) ) {
146 mMainWin = new KAddressBookMain; 147 mMainWin = new KAddressBookMain;
147 mMainWin->show(); 148 mMainWin->show();
148 mMainWin->restore( 1 ); 149 mMainWin->restore( 1 );
149 } 150 }
150 } else { 151 } else {
151 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 152 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
152 153
153 QCString addrStr = args->getOption( "addr" ); 154 QCString addrStr = args->getOption( "addr" );
154 QCString uidStr = args->getOption( "uid" ); 155 QCString uidStr = args->getOption( "uid" );
155 QString addr; 156 QString addr;
156 QString uid; 157 QString uid;
157 if ( !addrStr.isEmpty() ) 158 if ( !addrStr.isEmpty() )
158 addr = QString::fromLocal8Bit( addrStr ); 159 addr = QString::fromLocal8Bit( addrStr );
159 if ( !uidStr.isEmpty() ) 160 if ( !uidStr.isEmpty() )
160 uid = QString::fromLocal8Bit( uidStr ); 161 uid = QString::fromLocal8Bit( uidStr );
161 162
162 163
163 if ( args->isSet( "editor-only" ) ) { 164 if ( args->isSet( "editor-only" ) ) {
164 if ( !mMainWin ) 165 if ( !mMainWin )
165 mMainWin = new KAddressBookMain; 166 mMainWin = new KAddressBookMain;
166 KStartupInfo::appStarted(); 167 KStartupInfo::appStarted();
167 mMainWin->hide(); 168 mMainWin->hide();
168 } else { 169 } else {
169 if ( mMainWin ) { 170 if ( mMainWin ) {
170 mMainWin->show(); 171 mMainWin->show();
171 KWin::setActiveWindow( mMainWin->winId() ); 172 KWin::setActiveWindow( mMainWin->winId() );
172 } else { 173 } else {
173 mMainWin = new KAddressBookMain; 174 mMainWin = new KAddressBookMain;
174 mMainWin->show(); 175 mMainWin->show();
175 } 176 }
176 } 177 }
177 // 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 178 // 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
178 if ( !addr.isEmpty() ) 179 if ( !addr.isEmpty() )
179 mMainWin->addEmail( addr ); 180 mMainWin->addEmail( addr );
180 181
181 if ( !uid.isEmpty() ) 182 if ( !uid.isEmpty() )
182 mMainWin->showContactEditor( uid ); 183 mMainWin->showContactEditor( uid );
183 if ( args->isSet( "new-contact" ) ) { 184 if ( args->isSet( "new-contact" ) ) {
184 mMainWin->newContact(); 185 mMainWin->newContact();
185 } 186 }
186 } 187 }
187 188
188 KCrash::setEmergencySaveFunction( crashHandler ); 189 KCrash::setEmergencySaveFunction( crashHandler );
189 190
190 return 0; 191 return 0;
191} 192}
192 193
193// the dummy argument is required, because KMail apparently sends an empty 194// the dummy argument is required, because KMail apparently sends an empty
194// argument. 195// argument.
195static KCmdLineOptions kmoptions[] = 196static KCmdLineOptions kmoptions[] =
196{ 197{
197 { "a", 0 , 0 }, 198 { "a", 0 , 0 },
198 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 199 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
199 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 200 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
200 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 201 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
201 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 202 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
202 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 203 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
203 { 0, 0, 0} 204 { 0, 0, 0}
204}; 205};
205 206
206int main( int argc, char *argv[] ) 207int main( int argc, char *argv[] )
207{ 208{
208 KLocale::setMainCatalogue( "kaddressbook" ); 209 KLocale::setMainCatalogue( "kaddressbook" );
209 210
210 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 211 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
211 KCmdLineArgs::addCmdLineOptions( kmoptions ); 212 KCmdLineArgs::addCmdLineOptions( kmoptions );
212 KUniqueApplication::addCmdLineOptions(); 213 KUniqueApplication::addCmdLineOptions();
213 214
214 if ( !KAddressBookApp::start() ) 215 if ( !KAddressBookApp::start() )
215 exit( 0 ); 216 exit( 0 );
216 217
217 KAddressBookApp app; 218 KAddressBookApp app;
218 KGlobal::locale()->insertCatalogue( "libkdepim" ); 219 KGlobal::locale()->insertCatalogue( "libkdepim" );
219 220
220 return app.exec(); 221 return app.exec();
221} 222}
222*/ 223*/