Diffstat (limited to 'libopie2/opiecore/oapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/oapplication.cpp | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp new file mode 100644 index 0000000..a0abcc2 --- a/dev/null +++ b/libopie2/opiecore/oapplication.cpp | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
31 | #include <opie2/oapplication.h> | ||
32 | #include <opie2/oconfig.h> | ||
33 | |||
34 | OApplication* OApplication::_instance = 0; | ||
35 | |||
36 | /**************************************************************************************************/ | ||
37 | /* OApplicationPrivate | ||
38 | /**************************************************************************************************/ | ||
39 | |||
40 | class OApplicationPrivate | ||
41 | { | ||
42 | public: | ||
43 | OApplicationPrivate() {}; | ||
44 | ~OApplicationPrivate() {}; | ||
45 | }; | ||
46 | |||
47 | /**************************************************************************************************/ | ||
48 | /* OApplication | ||
49 | /**************************************************************************************************/ | ||
50 | |||
51 | |||
52 | OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) | ||
53 | :OApplicationBaseClass( argc, argv ), | ||
54 | _appname( rAppName ), | ||
55 | _config( 0 ) | ||
56 | { | ||
57 | init(); | ||
58 | } | ||
59 | |||
60 | |||
61 | OApplication::~OApplication() | ||
62 | { | ||
63 | delete d; | ||
64 | if ( _config ) | ||
65 | delete _config; | ||
66 | OApplication::_instance = 0; | ||
67 | // after deconstruction of the one-and-only application object, | ||
68 | // the construction of another object is allowed | ||
69 | } | ||
70 | |||
71 | |||
72 | OConfig* OApplication::config() | ||
73 | { | ||
74 | if ( not _config ) | ||
75 | { | ||
76 | _config = new OConfig( _appname ); | ||
77 | } | ||
78 | return _config; | ||
79 | } | ||
80 | |||
81 | |||
82 | void OApplication::init() | ||
83 | { | ||
84 | d = new OApplicationPrivate(); | ||
85 | if ( !OApplication::_instance ) | ||
86 | { | ||
87 | OApplication::_instance = this; | ||
88 | } | ||
89 | else | ||
90 | { | ||
91 | qFatal( "OApplication: Can't create more than one OApplication object. Aborting." ); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | void OApplication::setMainWidget( QWidget* widget ) | ||
96 | { | ||
97 | showMainWidget( widget ); | ||
98 | } | ||
99 | |||
100 | void OApplication::showMainWidget( QWidget* widget, bool nomax ) | ||
101 | { | ||
102 | #ifdef Q_WS_QWS | ||
103 | QPEApplication::showMainWidget( widget, nomax ); | ||
104 | #else | ||
105 | QApplication::setMainWidget( widget ); | ||
106 | widget->show(); | ||
107 | #endif | ||
108 | widget->setCaption( _appname ); | ||
109 | |||
110 | } | ||