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