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