summaryrefslogtreecommitdiffabout
path: root/kaddressbook/mainembedded.cpp
Unidiff
Diffstat (limited to 'kaddressbook/mainembedded.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/mainembedded.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 850e5b2..d781f67 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,121 +1,136 @@
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#include "externalapphandler.h" 16#include "externalapphandler.h"
17 17
18int main( int argc, char **argv ) 18int 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 QString hdir = QDir::homeDirPath();
27 // there is a bug when creating dirs for WIN 98
28 // it is difficult to fix, because we have no WIN 98 runnung
29 // such that we try it to create the dirs at startup here
30 if ( hdir == "C:\\" ) { // win 98 or ME
31 QDir app_dir;
32 if ( !app_dir.exists("C:\\kdepim") )
33 app_dir.mkdir ("C:\\kdepim");
34 if ( !app_dir.exists("C:\\kdepim\\apps") )
35 app_dir.mkdir ("C:\\kdepim\\apps");
36 if ( !app_dir.exists("C:\\kdepim\\config") )
37 app_dir.mkdir ("C:\\kdepim\\config");
38 if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") )
39 app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook");
40 }
26#endif 41#endif
27 42
28 bool exitHelp = false; 43 bool exitHelp = false;
29 if ( argc > 1 ) { 44 if ( argc > 1 ) {
30 QString command = argv[1]; 45 QString command = argv[1];
31 if ( command == "-help" ){ 46 if ( command == "-help" ){
32 printf("KA/E command line commands:\n"); 47 printf("KA/E command line commands:\n");
33 printf(" no command: Start KA/E in usual way\n"); 48 printf(" no command: Start KA/E in usual way\n");
34 printf(" -help: This output\n"); 49 printf(" -help: This output\n");
35 printf(" KA/E is exiting now. Bye!\n"); 50 printf(" KA/E is exiting now. Bye!\n");
36 exitHelp = true; 51 exitHelp = true;
37 } 52 }
38 } 53 }
39 if ( ! exitHelp ) { 54 if ( ! exitHelp ) {
40 55
41 KGlobal::setAppName( "kaddressbook" ); 56 KGlobal::setAppName( "kaddressbook" );
42#ifndef DESKTOP_VERSION 57#ifndef DESKTOP_VERSION
43 if ( QApplication::desktop()->width() > 320 ) 58 if ( QApplication::desktop()->width() > 320 )
44 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 59 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
45 else 60 else
46 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 61 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
47#else 62#else
48 QString fileName ; 63 QString fileName ;
49 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 64 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
50 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 65 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
51 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 66 QApplication::addLibraryPath ( qApp->applicationDirPath () );
52 67
53#endif 68#endif
54 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 69 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
55 KAddressBookMain m ; 70 KAddressBookMain m ;
56//US MainWindow m; 71//US MainWindow m;
57 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 72 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
58 73
59#ifndef DESKTOP_VERSION 74#ifndef DESKTOP_VERSION
60 a.showMainWidget( &m ); 75 a.showMainWidget( &m );
61#else 76#else
62 a.setMainWidget( &m ); 77 a.setMainWidget( &m );
63 m.resize (640, 480 ); 78 m.resize (640, 480 );
64 m.show(); 79 m.show();
65#endif 80#endif
66 a.exec(); 81 a.exec();
67 82
68 } 83 }
69 qDebug("KA: Bye! "); 84 qDebug("KA: Bye! ");
70} 85}
71 86
72/* 87/*
73#include <stdlib.h> 88#include <stdlib.h>
74 89
75#include <qstring.h> 90#include <qstring.h>
76 91
77#include <kabc/stdaddressbook.h> 92#include <kabc/stdaddressbook.h>
78#include <kaboutdata.h> 93#include <kaboutdata.h>
79#include <kcmdlineargs.h> 94#include <kcmdlineargs.h>
80#include <kcrash.h> 95#include <kcrash.h>
81#include <kdebug.h> 96#include <kdebug.h>
82#include <klocale.h> 97#include <klocale.h>
83#include <kstartupinfo.h> 98#include <kstartupinfo.h>
84#include <kuniqueapplication.h> 99#include <kuniqueapplication.h>
85#include <kwin.h> 100#include <kwin.h>
86 101
87#include "kaddressbookmain.h" 102#include "kaddressbookmain.h"
88#include "kabcore.h" 103#include "kabcore.h"
89 104
90extern "C" { 105extern "C" {
91 106
92void crashHandler( int ) 107void crashHandler( int )
93{ 108{
94 KABC::StdAddressBook::handleCrash(); 109 KABC::StdAddressBook::handleCrash();
95 ::exit( 0 ); 110 ::exit( 0 );
96} 111}
97 112
98} 113}
99 114
100class KAddressBookApp : public KUniqueApplication { 115class KAddressBookApp : public KUniqueApplication {
101 public: 116 public:
102 KAddressBookApp() : mMainWin( 0 ) {} 117 KAddressBookApp() : mMainWin( 0 ) {}
103 ~KAddressBookApp() {} 118 ~KAddressBookApp() {}
104 119
105 int newInstance(); 120 int newInstance();
106 121
107 private: 122 private:
108 KAddressBookMain *mMainWin; 123 KAddressBookMain *mMainWin;
109}; 124};
110 125
111int KAddressBookApp::newInstance() 126int KAddressBookApp::newInstance()
112{ 127{
113 if ( isRestored() ) { 128 if ( isRestored() ) {
114 // There can only be one main window 129 // There can only be one main window
115 if ( KMainWindow::canBeRestored( 1 ) ) { 130 if ( KMainWindow::canBeRestored( 1 ) ) {
116 mMainWin = new KAddressBookMain; 131 mMainWin = new KAddressBookMain;
117 mMainWin->show(); 132 mMainWin->show();
118 mMainWin->restore( 1 ); 133 mMainWin->restore( 1 );
119 } 134 }
120 } else { 135 } else {
121 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 136 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();