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