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