summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/oapplication.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/oapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oapplication.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp
index d340c0e..e2f6e82 100644
--- a/libopie2/opiecore/oapplication.cpp
+++ b/libopie2/opiecore/oapplication.cpp
@@ -13,115 +13,124 @@
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include <opie2/oapplication.h> 30#include <opie2/oapplication.h>
31#include <opie2/oconfig.h> 31#include <opie2/oconfig.h>
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34#include <signal.h> 34#include <signal.h>
35#include <stdio.h> 35#include <stdio.h>
36 36
37using namespace Opie::Core;
38
39
37OApplication* OApplication::_instance = 0; 40OApplication* OApplication::_instance = 0;
38 41
39/************************************************************************************************** 42/**************************************************************************************************
40 * OApplicationPrivate 43 * OApplicationPrivate
41 **************************************************************************************************/ 44 **************************************************************************************************/
42 45
46namespace Opie {
47namespace Core {
48namespace Private {
43class OApplicationPrivate 49class OApplicationPrivate
44{ 50{
45 public: 51 public:
46 OApplicationPrivate() {}; 52 OApplicationPrivate() {};
47 ~OApplicationPrivate() {}; 53 ~OApplicationPrivate() {};
48}; 54};
55}
49 56
50/************************************************************************************************** 57/**************************************************************************************************
51 * OApplication 58 * OApplication
52 **************************************************************************************************/ 59 **************************************************************************************************/
53 60
54 61
55OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) 62OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
56 :QPEApplication( argc, argv ), 63 :QPEApplication( argc, argv ),
57 _appname( rAppName ), 64 _appname( rAppName ),
58 _config( 0 ) 65 _config( 0 )
59{ 66{
60 init(); 67 init();
61} 68}
62 69
63 70
64OApplication::~OApplication() 71OApplication::~OApplication()
65{ 72{
66 delete d; 73 delete d;
67 if ( _config ) 74 if ( _config )
68 delete _config; 75 delete _config;
69 OApplication::_instance = 0; 76 OApplication::_instance = 0;
70 // after deconstruction of the one-and-only application object, 77 // after deconstruction of the one-and-only application object,
71 // the construction of another object is allowed 78 // the construction of another object is allowed
72} 79}
73 80
74 81
75OConfig* OApplication::config() 82OConfig* OApplication::config()
76{ 83{
77 if ( !_config ) 84 if ( !_config )
78 { 85 {
79 _config = new OConfig( _appname ); 86 _config = new OConfig( _appname );
80 } 87 }
81 return _config; 88 return _config;
82} 89}
83 90
84 91
85void OApplication::init() 92void OApplication::init()
86{ 93{
87 d = new OApplicationPrivate(); 94 d = new Private::OApplicationPrivate();
88 if ( !OApplication::_instance ) 95 if ( !OApplication::_instance )
89 { 96 {
90 OApplication::_instance = this; 97 OApplication::_instance = this;
91 98
92 /* register SIGSEGV handler to give programs an option 99 /* register SIGSEGV handler to give programs an option
93 * to exit gracefully, e.g. save or close devices or files. 100 * to exit gracefully, e.g. save or close devices or files.
94 struct sigaction sa; 101 struct sigaction sa;
95 sa.sa_handler = ( void (*)(int) ) &segv_handler; 102 sa.sa_handler = ( void (*)(int) ) &segv_handler;
96 sa.sa_flags = SA_SIGINFO | SA_RESTART; 103 sa.sa_flags = SA_SIGINFO | SA_RESTART;
97 sigemptyset(&sa.sa_mask); 104 sigemptyset(&sa.sa_mask);
98 sigaction(SIGSEGV, &sa, NULL); 105 sigaction(SIGSEGV, &sa, NULL);
99 */ 106 */
100 } 107 }
101 else 108 else
102 { 109 {
103 ofatal << "OApplication: Can't create more than one OApplication object. Aborting." << oendl; 110 ofatal << "OApplication: Can't create more than one OApplication object. Aborting." << oendl;
104 //FIXME exit gracefully ? 111 //FIXME exit gracefully ?
105 ::exit( -1 ); 112 ::exit( -1 );
106 } 113 }
107} 114}
108 115
109 116
110void OApplication::showMainWidget( QWidget* widget, bool nomax ) 117void OApplication::showMainWidget( QWidget* widget, bool nomax )
111{ 118{
112 QPEApplication::showMainWidget( widget, nomax ); 119 QPEApplication::showMainWidget( widget, nomax );
113 widget->setCaption( _appname ); 120 widget->setCaption( _appname );
114} 121}
115 122
116 123
117void OApplication::setTitle( const QString& title ) const 124void OApplication::setTitle( const QString& title ) const
118{ 125{
119 if ( mainWidget() ) 126 if ( mainWidget() )
120 { 127 {
121 if ( !title.isNull() ) 128 if ( !title.isNull() )
122 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); 129 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
123 else 130 else
124 mainWidget()->setCaption( _appname ); 131 mainWidget()->setCaption( _appname );
125 } 132 }
126} 133}
127 134
135}
136}