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