00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <opie2/oapplication.h>
00031 #include <opie2/oconfig.h>
00032 #include <opie2/odebug.h>
00033
00034 #include <signal.h>
00035 #include <stdio.h>
00036
00037 using namespace Opie::Core;
00038
00039
00040 OApplication* OApplication::_instance = 0;
00041
00042
00043
00044
00045
00046 namespace Opie {
00047 namespace Core {
00048 namespace Internal {
00049 class OApplicationPrivate
00050 {
00051 public:
00052 OApplicationPrivate() {};
00053 ~OApplicationPrivate() {};
00054 };
00055 }
00056
00057
00058
00059
00060 OApplication::OApplication( int& argc, char** argv, Type type )
00061 :QPEApplication( argc, argv, type ),
00062 _appname( QString::null ),
00063 _config( 0 )
00064 {
00065 init();
00066 }
00067
00068 OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
00069 :QPEApplication( argc, argv ),
00070 _appname( rAppName ),
00071 _config( 0 )
00072 {
00073 init();
00074 }
00075
00076
00077 OApplication::~OApplication()
00078 {
00079 delete d;
00080 if ( _config )
00081 delete _config;
00082 OApplication::_instance = 0;
00083
00084
00085 }
00086
00087
00088 OConfig* OApplication::config()
00089 {
00090 if ( !_config )
00091 {
00092 _config = new OConfig( _appname );
00093 }
00094 return _config;
00095 }
00096
00097
00098 void OApplication::init()
00099 {
00100 d = new Internal::OApplicationPrivate();
00101 if ( !OApplication::_instance )
00102 {
00103 OApplication::_instance = this;
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 }
00114 else
00115 {
00116 ofatal << "OApplication: Can't create more than one OApplication object. Aborting." << oendl;
00117
00118 ::exit( -1 );
00119 }
00120 }
00121
00122
00123 void OApplication::showMainWidget( QWidget* widget, bool nomax )
00124 {
00125 QPEApplication::showMainWidget( widget, nomax );
00126 widget->setCaption( _appname );
00127 }
00128
00129
00130 void OApplication::setTitle( const QString& title ) const
00131 {
00132 if ( mainWidget() )
00133 {
00134 if ( !title.isNull() )
00135 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
00136 else
00137 mainWidget()->setCaption( _appname );
00138 }
00139 }
00140
00141 }
00142 }