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