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