summaryrefslogtreecommitdiffabout
path: root/kaddressbook/mainembedded.cpp
authorzautrix <zautrix>2004-07-03 16:12:29 (UTC)
committer zautrix <zautrix>2004-07-03 16:12:29 (UTC)
commita95f7085c5dd7234c254750e32e44941599f3390 (patch) (unidiff)
tree1631703e01dbf2033394e4b71bc753b562528a67 /kaddressbook/mainembedded.cpp
parent9172a6c3325e2de04c72c53cdd760bd1efa46611 (diff)
downloadkdepimpi-a95f7085c5dd7234c254750e32e44941599f3390.zip
kdepimpi-a95f7085c5dd7234c254750e32e44941599f3390.tar.gz
kdepimpi-a95f7085c5dd7234c254750e32e44941599f3390.tar.bz2
Mainembedded cleaned up
Diffstat (limited to 'kaddressbook/mainembedded.cpp') (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,138 +1,120 @@
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" );